pandoc-include
pandoc-include copied to clipboard
Couldn't match type ‘[Char]’ with ‘Data.Text.Internal.Text’
Can anyone help?
cabal install pandoc-include
failed with the above error.
Above mentined cabal installation provided pandoc2.06. Piping IncludeFilter.hs (as described in the README) within my pandoc call leeds to the same error message.
Any help is highly appreciated.
Same here.
With pandoc 2.1.1
The solution I found is to stick with pandoc below version 2.
To do a clean reinstall, first get rid of all your old packages (WARNING: this will remove all you cabal packages):
rm -r ~/.ghc
Then install pandoc and all your other pandoc related packages with the constraint of keeping pandoc below version 2. In my case:
cabal install pandoc pandoc-include pandoc-citeproc --constraint 'pandoc < 2'
If you install further pandoc related packages, don't forget the flag --constraint 'pandoc < 2'
Here's a patch to master@50905129593807992b37a2af59d1ce9106234a8c
that will give a clean stack build, using the latest LTS resolver, as of today:
Once the patch below has been applied, you should get a clean build of the panda-include
executable with just:
stack setup
stack build
You'll actually find 4 new files in your bin directory, after executing the two commands above:
Davids-Air-2:pandoc-include dbanas$ ls .stack-work/install/x86_64-osx/lts-11.2/8.2.2/bin/
json2yaml pandoc pandoc-include yaml2json
And you'd, probably, be wise to copy them to whatever local .../bin/
directory you intend, as a group.
The needed patch:
diff --git a/pandoc-include.cabal b/pandoc-include.cabal
index 3469ae6..47a572b 100644
--- a/pandoc-include.cabal
+++ b/pandoc-include.cabal
@@ -36,7 +36,7 @@ Library
Executable pandoc-include
Build-Depends: base >= 4.6,
text >= 0.11,
- pandoc >= 1.13.0.0,
+ pandoc >= 1.13.0.0 && < 2.0,
pandoc-types >= 1.12.0.0,
directory
Hs-Source-Dirs: .
diff --git a/stack.yaml b/stack.yaml
new file mode 100644
index 0000000..eab9527
--- /dev/null
+++ b/stack.yaml
@@ -0,0 +1,13 @@
+resolver: lts-11.2
+packages:
+- .
+extra-deps:
+- pandoc-1.19.2.4
+- aeson-1.1.2.0
+- doctemplates-0.1.0.2
+- hslua-0.4.1
+- http-types-0.9.1
+- pandoc-types-1.17.0.5
+- skylighting-0.1.1.5
+- texmath-0.9.4.4
+
Patch for pandoc 2 API, works fine for me, but I haven't tested it properly though.
diff --git a/IncludeFilter.hs b/IncludeFilter.hs
index 6aa3387..3dc1606 100644
--- a/IncludeFilter.hs
+++ b/IncludeFilter.hs
@@ -55,6 +55,7 @@ Note: the metadata from the included source files are discarded.
import Control.Monad
import Data.List
+import Data.Text.IO (readFile)
import System.Directory
import Text.Pandoc
@@ -67,13 +68,10 @@ stripPandoc p =
Left _ -> [Null]
Right (Pandoc _ blocks) -> blocks
-ioReadMarkdown :: String -> IO(Either PandocError Pandoc)
-ioReadMarkdown content = return $! readMarkdown def content
-
getContent :: String -> IO [Block]
getContent file = do
- c <- readFile file
- p <- ioReadMarkdown c
+ c <- Data.Text.IO.readFile file
+ p <- runIO $ readMarkdown def c
return $! stripPandoc p
getProcessableFileList :: String -> IO [String]
Could we get this merged, please?
Hey folks, this is my first hour with Pandoc. Looks good so far, then I hit this speed bump. Any chance this fix could be merged sometime soon?
I had to add a little bit to @ply 's patch, above:
diff --git a/IncludeFilter.hs b/IncludeFilter.hs
index 6aa3387..da5ad6b 100644
--- a/IncludeFilter.hs
+++ b/IncludeFilter.hs
@@ -55,6 +55,8 @@ Note: the metadata from the included source files are discarded.
import Control.Monad
import Data.List
+import Data.Text (unpack)
+import Data.Text.IO (readFile)
import System.Directory
import Text.Pandoc
@@ -67,13 +69,10 @@ stripPandoc p =
Left _ -> [Null]
Right (Pandoc _ blocks) -> blocks
-ioReadMarkdown :: String -> IO(Either PandocError Pandoc)
-ioReadMarkdown content = return $! readMarkdown def content
-
getContent :: String -> IO [Block]
getContent file = do
- c <- readFile file
- p <- ioReadMarkdown c
+ c <- Data.Text.IO.readFile file
+ p <- runIO $ readMarkdown def c
return $! stripPandoc p
getProcessableFileList :: String -> IO [String]
@@ -88,8 +87,8 @@ processFiles toProcess =
doInclude :: Block -> IO [Block]
doInclude (CodeBlock (_, classes, _) list)
- | "include" `elem` classes = do
- let toProcess = getProcessableFileList list
+ | "include" `elem` (map unpack classes) = do
+ let toProcess = getProcessableFileList (unpack list)
processFiles =<< toProcess
doInclude x = return [x]