Pandoc Markdown and ReST Compared
2013-01
Two popular plain text markup formats are Markdown and reST. Markdown usage is pretty ubiquitous; it’s used by many blogs, sites like reddit and github, etc. The Python project uses reST, and has the Sphinx doc processing tool generate their html docs, as do lots of other Python-based projects.
This somewhat opinionated document (I prefer Markdown to reST) compares some syntax differences between Markdown — in particular, Pandoc’s Markdown (v1.10.0.5) — and reST syntax. Please note that, anywhere I say “Markdown” below, if there’s any ambiguity, I specifically mean “Pandoc Markdown”. Gruber’s original Markdown lacks a number of the modern niceties which Pandoc-Markdown provides.
To try out examples yourself:
Install Pandoc on a Debian-based distro like so:
sudo apt-get install pandoc. Prepare a ~/temp/foo.txt document and process it like so:pandoc -s -o foo.html foo.txtInstall docutils on a Debian-based distro like so:
sudo apt-get install python-docutils. Prepare a ~/temp/foo.rst document and process it like so:rst2html foo.rst foo.html
Headings
| Pandoc-Markdown | reST |
|---|---|
|
|
The characters chosen to underline the reST H3 and H4 headings are mostly arbitrary; different people use different ones. When working on large documents, personally I prefer Markdown style — it’s easier to visually discern the main sections and subsections without getting distracted by lower subsections.
Markdown allows you to use “# H1 #” and “## H2 ##” (and even just “# H1” & “## H2”), but I find those somewhat less readable than what’s shown above.
Title Block
You can start your document in such a way as to include metadata such as title, author, and date:
| Pandoc-Markdown | reST |
|---|---|
|
|
Italic, Bold, Code
| Pandoc-Markdown | reST |
|---|---|
|
|
ReST requires two backticks around inline code, which gets tiresome to type. It also requires a double colon (either ending the preceding paragraph, or else as shown above) for code blocks.
With Pandoc-markdown delimited blocks, you can use the triple-tilde or the triple-backtick. Since delimited blocks don’t need to be indented, they can save time when copying/pasting code from source files to documents.
Pandoc can do syntax highlighting of code blocks,
for i in range(10):
print "hi", i
and my understanding is that docutils can do that as well, though I haven’t been able to get it working with docutils (version 0.8.1).
Links
| Pandoc-Markdown | reST |
|---|---|
|
|
Personally, I regularly forget the reST link syntax.
Also, reST automatically converts things that look like urls to links (see the last line above), but it’s smart about not including trailing punctuation in the linked-to url (at least, for the cases I tried). That said, bare urls with trailing punctuation look a bit weird to me. Regardless, I prefer the Markdown style of always putting angle brackets around urls so that (A) they stand out better, and (B) there’s no ambiguity about what’s included in the url.
Lists
| Pandoc-Markdown | reST |
|---|---|
|
|
I think a major win for Pandoc-Markdown here is that, when dealing with any kind of list, list content (not the marker, but the text itself) can always start in at a multiple of 4 spaces. Code is the same, but with no list marker. It’s simple and consistent, is easy to remember, looks good, and makes formatting deeply nested lists easy.
Blockquote
| Pandoc-Markdown | reST |
|---|---|
|
|
With reST, the blockquote content looks to me like it might be a code block — I have to check if there’s a preceeding double-colon to be sure.
Tables
| Pandoc-Markdown | reST |
|---|---|
|
|
Also, both markup formats support a “grid table” syntax as well.
Misc
| Pandoc-Markdown | reST |
|---|---|
|
|
It’s nice that reST has its own comment syntax, though I can’t say that it stands out very much from the rest of the document’s content.
reST supports autonumbering of footnotes, if you’d prefer to just write them with a number sign (like autonumbered enumerated lists).
For details on reST’s raw html directive, see the reST docs.
Field Lists
| Pandoc-Markdown | reST |
|---|---|
|
|
Conclusion
The two formats have other minor differences, including:
- with Pandoc-markdown you can force a newline by ending a line with a backslash (note that both reST and Pandoc-Markdown support line blocks).
- reST has “option lists” for listing options and args you might pass to a command-line program.
And of course there’s other sundry differences between them that you can read about in their respective documentation pages. In this article, I’m trying to sum up the major differences that you’ll notice when using them on a regular basis.
For multi-chapter documents, ReST has Sphinx. For processing multi-chapter Pandoc-Markdown docs, I cobbled together my own tool called Gouda (and for processing a nested jumble of notes, Rippledoc).
My 2¢: Pandoc-Markdown is easier on the eyes, easier to remember, and easier to type.