public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Bug of filter example: include.hs
@ 2022-08-09  3:45 白岩
       [not found] ` <367bff86-a70f-4bec-92a8-7bdf7df1bd6fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: 白岩 @ 2022-08-09  3:45 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 968 bytes --]

https://pandoc.org/filters.html#include-files

Does we need remove the "include" nameval from namevals.Or it will has an 
error: 

-------------------------------------------------------------------------------------------
Error producing PDF.
! Package keyval Error: include undefined.

See the keyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.61 \begin{lstlisting}[include={std.cpp}]
--------------------------------------------------------------------------------------------

OS: macOS Monterey
pandoc: 2.14.2

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/367bff86-a70f-4bec-92a8-7bdf7df1bd6fn%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1370 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug of filter example: include.hs
       [not found] ` <367bff86-a70f-4bec-92a8-7bdf7df1bd6fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-08-09 11:25   ` Jiří Wolker
  0 siblings, 0 replies; 2+ messages in thread
From: Jiří Wolker @ 2022-08-09 11:25 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Hello,

isn't that the same bug I mentioned few days ago? See this message:

>> You're right. I will fix that in the documentation (though it won't update 
>> on the website til the next release). Thank you. 
>>
>>
>>
>>> On Jul 27, 2022, at 5:14 AM, Jiří Wolker <wol...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: 
>>>
>>> Hello everyone, 
>>>
>>> I've probably found a bug in filter example that can be found in the 
>> docs (https://pandoc.org/filters.html#include-files). The original source 
>> code is: 
>>>
>>> #!/usr/bin/env runhaskell 
>>> -- includes.hs 
>>> import Text.Pandoc.JSON 
>>> import qualified Data.Text.IO as TIO 
>>> import qualified Data.Text as T 
>>>
>>> doInclude :: Block -> IO Block 
>>> doInclude cb@(CodeBlock (id, classes, namevals) contents) = 
>>> case lookup "include" namevals of 
>>> Just f -> CodeBlock (id, classes, namevals) <$> 
>>> TIO.readFile (T.unpack f) 
>>> Nothing -> return cb 
>>> doInclude x = return x 
>>>
>>> main :: IO () 
>>> main = toJSONFilter doInclude 
>>>
>>> When I tried to execute it, it fails: 
>>>
>>> …/include.hs:12:25: error: 
>>> * Couldn't match type `T.Text' with `[Char]' 
>>> Expected: [(String, T.Text)] 
>>> Actual: [(T.Text, T.Text)] 
>>> * In the second argument of `lookup', namely `namevals' 
>>> In the expression: lookup "include" namevals 
>>> In the expression: 
>>> case lookup "include" namevals of 
>>> Just f 
>>> -> CodeBlock (id, classes, namevals) <$> TIO.readFile (T.unpack f) 
>>> Nothing -> return cb 
>>> | 
>>> 12 | case lookup "include" namevals of 
>>> | ^^^^^^^^ 
>>> Error running filter …/filters/include.hs: 
>>> Filter returned error status 1 
>>>
>>> To fix the filter, I had to change the line with “case” to this: 
>>>
>>> case lookup (T.pack "include") namevals of 
>>>
>>> (i.e. call T.pack on the string literal.) 
>>>
>>> I am quite new to Haskell, correct me if I am wrong. 
>>>
>>> It is possible that this is dependent on the version of Haskell. I use 
>> runghc 9.0.2 to run the script. 
>>>
>>> P.S.: It would be nice to include few scripts in the Pandoc 
>> distribution. Ideas: includes.hs, directory listing (I write a div with 
>> special class and it produces directory listing in the text.) I will 
>> probably write the listing filter soon. It could be nice for creating 
>> directory “overview”/readme files. 
>>>
>>>
>>> Thanks. 
>>> Jiří 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>> Groups "pandoc-discuss" group. 
>>> To unsubscribe from this group and stop receiving emails from it, send 
>> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 
>>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/cada4d72-e81d-b39e-bd05-a6780b6848f5%40gmail.com. 
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/366e123d-650e-1cb4-b7b8-5c0f5a86e3f7%40gmail.com.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-09 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09  3:45 Bug of filter example: include.hs 白岩
     [not found] ` <367bff86-a70f-4bec-92a8-7bdf7df1bd6fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-08-09 11:25   ` Jiří Wolker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).