Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't match type ‘[Char]’ with ‘Data.Text.Internal.Text’ #13

Open
greenorca opened this issue Dec 29, 2017 · 7 comments
Open

Comments

@greenorca
Copy link

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.

@qchenevier
Copy link

Same here.

With pandoc 2.1.1

@qchenevier
Copy link

qchenevier commented Jan 20, 2018

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'

@capn-freako
Copy link

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
+

@ply
Copy link

ply commented May 9, 2018

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]

@thirtified
Copy link

Could we get this merged, please?

@mslinn
Copy link

mslinn commented May 13, 2019

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?

artworx added a commit to artworx/pandoc-include that referenced this issue Sep 9, 2019
@capn-freako
Copy link

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants