Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (27 sloc) 730 Bytes
{-# LANGUAGE OverloadedStrings #-}
import Text.LaTeX
import Text.LaTeX.Base.Parser
import Data.Text (unlines)
import qualified Data.Text.IO as T
main :: IO ()
main = case parseLaTeX example of
Left err -> print err
Right l -> do
putStrLn "Printing LaTeX AST..."
print l
putStrLn "Checking that (render . parse == id)..."
let t = render l
print $ example == t
putStrLn "All done."
example :: Text
example = Data.Text.unlines
[ "\\documentclass{article}"
, "\\usepackage[utf8]{inputenc}"
, "\\author{Daniel Díaz}"
, "\\title{LaTeX parser}"
, "\\begin{document}"
, "\\maketitle"
, "This is an example of how to parse LaTeX using the"
, "\\HaTeX library."
, "\\end{document}"
Jump to Line
Something went wrong with that request. Please try again.