Pandoc:The Deep DiveAll that is greatstands in the storm
● Universal markup converter == " the swissarmy knife of text markup formats"● ALL HASKELL● Example:pandoc -o myDoc.md myDoc.htmlpandoc -f html -t latex hackage.orgpandoc myDoc.txt -o myDoc.pdfWhat is Pandoc?
● Reads:○ Markdown (GitHub, Strict, etc.), HTML, LaTeX,Textile, reStructuredText, JSON,● Writes:○ Markdown, reStructuredText, HTML, DocbookXML, OpenDocument XML, ODT, RTF, groffman, MediaWiki markup, GNU Texinfo, LaTeX,ConTeXt, EPUB, Textile, Emacs org-mode, Slidy,S5● Extensions for LaTeX math, tables, etc.● Note to self: Pandoc in the CLIWhat is Pandoc? (pt. 2)
● Performance vis-à-vis scripting languages● Type safety● Text.Parsec library● Hypermuscular list processing (moreabout FP more generally than aboutHaskell)Why Haskell?
● One possibility: functions devoted to eachtype-to-type combination○ markdownToHTML○ HTMLtoEPUB○ 12^31 possibilities○ FUCK THAT● Vastly better possibility?Reader -->Neutral Haskell data type -->Writer -->Converted documentPossible approaches
● Semi-stateful, non-opinionated REGEXmachine○ Accumulative — return (x:xs)○ getParserState○ modifyState● Core functions○ parse■ parse parser filePath input■ parse numbers "" "a,b,2,3"○ many○ skipMany○ manyAccum● type Parser t s = Parsec t sText.Parsec
● Neutral data types○ Pandoc = [Block]○ Block = [(Inline || Block)]○ Inline○ etc.● Reader○ Applies parsers to documents○ Documents are treated as lists● Writer○ Converts neutral data type into document○ Again, documents are just structured listsBasic flow
● Readers/Markdown.hs● Writers/HTML.hs● Pandoc/Builder.hsMarkdown to HTML
● When doing big, complex things with FP,youre probably going to end up thinking interms of lists● Lists are infinitely flexible● Hard to escape state entirely○ ReaderState○ WriterState● Dont give up● Force yourself to give a presentation atPDXFuncGeneral lessons