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 myD...
● Reads:○ Markdown (GitHub, Strict, etc.), HTML, LaTeX,Textile, reStructuredText, JSON,● Writes:○ Markdown, reStructuredTe...
● Performance vis-à-vis scripting languages● Type safety● Text.Parsec library● Hypermuscular list processing (moreabout FP...
● One possibility: functions devoted to eachtype-to-type combination○ markdownToHTML○ HTMLtoEPUB○ 12^31 possibilities○ FUC...
● Semi-stateful, non-opinionated REGEXmachine○ Accumulative — return (x:xs)○ getParserState○ modifyState● Core functions○ ...
● Neutral data types○ Pandoc = [Block]○ Block = [(Inline || Block)]○ Inline○ etc.● Reader○ Applies parsers to documents○ D...
● 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 fl...
Upcoming SlideShare
Loading in...5
×

Pandoc: the deep dive (PDXFunc presentation)

1,003

Published on

Exposing the guts of Pandoc, the marvelous Haskell-driven document conversion tool.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,003
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Pandoc: the deep dive (PDXFunc presentation)"

  1. 1. Pandoc:The Deep DiveAll that is greatstands in the storm
  2. 2. ● 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?
  3. 3. ● 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)
  4. 4. ● Performance vis-à-vis scripting languages● Type safety● Text.Parsec library● Hypermuscular list processing (moreabout FP more generally than aboutHaskell)Why Haskell?
  5. 5. ● 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
  6. 6. ● 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
  7. 7. ● 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
  8. 8. ● Readers/Markdown.hs● Writers/HTML.hs● Pandoc/Builder.hsMarkdown to HTML
  9. 9. ● 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

×