Pandoc and Markdown in 5 Minutes
Lightning Talk @ Open Source Open Mic
Dirk Eddelbuettel
26 October 2017
OSOM Oct 2017 1/17
Outline
OSOM Oct 2017 2/17
Plan for today
• Pandoc• Markdoc• Text processing
OSOM Oct 2017 3/17
Pandoc
OSOM Oct 2017 4/17
Pandoc in a nutshell
• The Swiss army knife for text conversion
• From anything to anything
• Rather widely used
• Well documented, many options
• Written in Haskell (!!) by head of UCBerkeley philosophy dept (!!)
• Very scriptable in the Unix tradition;extensible via pandoc-filters
Source: Pandoc website
OSOM Oct 2017 5/17
Markdown
OSOM Oct 2017 6/17
Key Points
• Invented by John Gruber of Daring Fireball
• Very widely used as an easy markup language
• It is everywhere now (GitHub, StackOverflow, …)
• Might get standardised (commonmark, GitHub-flavored, …)
• Fits with Pandoc like peanut butter and jelly
OSOM Oct 2017 7/17
Example
OSOM Oct 2017 8/17
Integration
OSOM Oct 2017 9/17
RMarkdown
• Integration with R via rmarkdown package• Extensive documentation by RStudio• Integration with R (and Python, SQL, …) code chunks• Dynamic and computable documents that auto-update
OSOM Oct 2017 10/17
RMarkdown
OSOM Oct 2017 11/17
Demo
OSOM Oct 2017 12/17
Our ‘Template’
OSOM Oct 2017 13/17
Our ‘Deployment’
#!/bin/sh
for i in 1 2 3; dormdfile=”demo${i}.Rmd”pdffile=”demo${i}.pdf”echo ${rmdfile}cp -vax demo.Rmd ${rmdfile}Rscript -e 'rmarkdown::render(”'${rmdfile}'”)'test -f ${pdffile} && xdg-open ${pdffile}
done
OSOM Oct 2017 14/17
Result
OSOM Oct 2017 15/17
Summary
Pandoc
• rocks as very versatile to/from anything converter• highly scriptable, widely available
Markdown
• has won the markup languages fight• is literally everywhere, dialects exists though
RMarkdown
• highly customizable• highly expressive
OSOM Oct 2017 16/17
Contact
Websitehttp://dirk.eddelbuettel.com
Twitter@eddelbuettel
GitHubeddelbuettel
OSOM Oct 2017 17/17