Skip to content

Instantly share code, notes, and snippets.

@lierdakil
Last active August 29, 2015 14:17
Show Gist options
  • Save lierdakil/313e3894efc82b12f82b to your computer and use it in GitHub Desktop.
Save lierdakil/313e3894efc82b12f82b to your computer and use it in GitHub Desktop.
Pandoc filter to convert svg to pdf with inkscape (useful for pdf output)
import Text.Pandoc.JSON
import Network.Mime
import Data.Text as T
import Data.ByteString.Char8 as BS
import System.Process
go :: Inline -> IO Inline
go (Image alt (src,title)) =
case BS.unpack $ defaultMimeLookup $ T.pack src of
"image/svg+xml" -> do
let newsrc=src++".pdf"
_ <- readProcess "inkscape" ["--export-pdf",newsrc,src] []
return $ Image alt (newsrc,title)
_ -> return $ Image alt (src,title)
go a = return a
main :: IO ()
main = toJSONFilter go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment