Last active
August 29, 2015 14:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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