Skip to content

Instantly share code, notes, and snippets.

@andrewalker
Created August 2, 2015 21:25
Show Gist options
  • Save andrewalker/239bacf812e9e8db91a7 to your computer and use it in GitHub Desktop.
Save andrewalker/239bacf812e9e8db91a7 to your computer and use it in GitHub Desktop.
Draft code used to convert CV from md to pdf
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