Hi all,

Someone recently asked me if it was possible to pretty print markdown in a terminal, for example to preview git commit messages and such. I'm playing around with the idea as basically stripping some formatting (I don't need # or === but I want to keep bullets or numbers for lists) and injecting in colours, bold, underlines etc. So far I have:

import Text.Pandoc

colour :: Block -> Block
colour (Header n xs) = Para $ map modHeader xs
--colour (BulletList xs) = BulletList $ map modBullet xs
colour x = x

modHeader :: Inline -> Inline
modHeader (Str xs) = Str $ "\x1b[1m\x1b[32m" ++ xs ++ "\x1b[0m"
modHeader x = x

--modBullets :: Block -> Block
--modBullets (Plain xs) = Plain $ map modBullet xs

--modBullet :: Inline -> Inline
--modBullet (Str xs) = Str $ "\x1b[1m\x1b[32m" ++ xs ++ "\x1b[0m"

main :: IO ()
main = toJsonFilter $ colour

Which just makes all headers green (I'll add in cases for different depths later). I'm having trouble with bullet lists though. I'd like to mutate them either into a single paragraph with injected newlines and dashes for bullets (and characters for colour encoding) or modify the content of each point with inline colour encoding. To execute what I have so far, I compile as toTerminal and run files through pandoc like:

pandoc -t json something.markdown | ./toTerminal | pandoc -f json -t plain

And hints or tips would be very much appreciated! If I can get the bullet lists working, I'm pretty sure I can figure the rest out. :)

Thanks,

Mark

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to pandoc-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/pandoc-discuss/-/7NiJS5t6WnAJ.
For more options, visit https://groups.google.com/groups/opt_out.