Skip to content

Instantly share code, notes, and snippets.

@jgm
Created December 4, 2011 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgm/1431411 to your computer and use it in GitHub Desktop.
Save jgm/1431411 to your computer and use it in GitHub Desktop.
shell for script to turn pandoc math to svg
-- math2svg.hs
-- compile with:
-- ghc --make math2svg.hs
-- run using:
-- pandoc -t json -s | ./math2svg | pandoc -f json
import Text.Pandoc
import Text.JSON.Generic
main = getContents >>= transform . decodeJSON >>= putStrLn . encodeJSON
transform :: Pandoc -> IO Pandoc
transform = bottomUpM mathToSvg
mathToSvg :: Inline -> IO Inline
mathToSvg (Math mathType x) = do
svg <- -- (CODE TO CONVERT x to SVG tag)
return (RawInline "html" svg)
mathToSvg x = return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment