Created
August 2, 2015 21:25
-
-
Save andrewalker/239bacf812e9e8db91a7 to your computer and use it in GitHub Desktop.
Draft code used to convert CV from md to pdf
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 Hakyll | |
import Text.Pandoc | |
import Text.Pandoc.PDF (makePDF) | |
import qualified Data.ByteString.Lazy as B | |
import qualified Text.Pandoc.UTF8 as UTF8 | |
main = do | |
-- -- check for latex program | |
-- mbLatex <- findExecutable "pdflatex" | |
-- when (mbLatex == Nothing) $ | |
-- err 1 $ "pdflatex not found. pdflatex is needed for pdf output." | |
file <- UTF8.readFile "cv.md" | |
let md = readMarkdown defaultHakyllReaderOptions file | |
templ <- getDefaultTemplate Nothing "latex" | |
templ' <- case templ of | |
Right t -> return t | |
Left e -> error $ show e | |
res <- makePDF "pdflatex" writeLaTeX def | |
{ | |
writerStandalone = True | |
, writerTemplate = templ' | |
, writerVariables = [("geometry", "margin=2cm")] | |
} md | |
case res of | |
Right pdf -> B.writeFile "cv.pdf" pdf | |
Left err -> B.putStrLn err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment