Hi Matthew, The catch is that there's a bunch of other stuff in the `Block`. That is, the special token is some substring of `s` f :: Block -> Block f (CodeBlock _ s) = RawBlock (Format "latex") ("\\MySpecialToken{" ++ s ++ "}") f b = b and I don't want to lose that. So I can write a function f :: Block -> [Block] where each CodeBlock is expanded into a list of : `RawBlock (Format "latex")` of the kind above, and the remaining, unchanged CodeBlock But that causes problems with toJSONFilter as I can't pass in a transformation of the form [Block] -> [Block] Because there is no instance of Walkable for [Block] ... :( On Saturday, January 17, 2015 at 3:06:04 PM UTC-8, Matthew Pickering wrote: > > You can write a filter ... f :: Block -> Block and have something like > the following. > > f :: Block -> Block > f (CodeBlock _ s) = RawBlock (Format "latex") ("\\MySpecialToken{" ++ s > ++ "}") > f b = b > > Do you also plan to output to other formats? If so then "toJSONFilter" > can take a function of type "f :: Maybe Format -> Block -> Block" > where the first argument is the output format. > > Does that make sense? > > On Sat, Jan 17, 2015 at 9:05 PM, Ranjit Jhala > wrote: > > Hi, > > > > I'd like to write a filter that runs on `CodeBlock` such that each > > identifier that begins > > with (say) "$$$mytoken" gets rendered in latex not as a > > > > \NormalTok{$$$mytoken} > > > > but as > > > > \MySpecialToken{$$$mytoken} > > > > Can anyone give me a hint as to how to proceed? The stumbling block is > that > > it seems like > > the filter should "preserve" the type, so I can write a > > > > myFilter :: CodeBlock -> CodeBlock > > > > But the `CodeBlock` type only allows strings -- presumably just > replacing > > (substrings) of the form > > > > $$$mytoken > > > > with > > > > \MySpecialToken{$$$mytoken} > > > > will only cause the latter to then get "escaped" out during the final > latex > > conversion? > > > > Any pointers would be most welcome! > > > > Thanks! > > > > - Ranjit. > > > > -- > > 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...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/pandoc-discuss/5699588b-678c-4de6-96c0-6505e7fbd950%40googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > -- 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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/0d47cfc0-2a3d-4248-bd35-317dcd6a738b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.