2018-07
Markdown is a very popular plain text markup format, but the Python community uses an alternative called reST.
Markdown usage is pretty ubiquitous; it’s used by many blogs, and sites like Reddit, GitLab, GitHub, StackOverflow, etc. The Python project uses reST, and has the Sphinx doc processing tool generate their html docs, as do many other Python-based projects.
This somewhat opinionated document (I prefer Markdown to reST) compares some syntax differences between Markdown (in particular, Pandoc’s Markdown) and reST syntax. Please note that, anywhere I say “Markdown” below, if there’s any ambiguity, I specifically mean the “Pandoc Markdown” flavor. Gruber’s original Markdown lacks a number of the modern niceties which Pandoc-Markdown tastefully provides.
To try out examples yourself:
Install Pandoc on a Debian-based distro like so: sudo apt install pandoc
. Prepare a ~/temp/foo.txt document and process it like so:
pandoc -s -o foo.html foo.txt
Install 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
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.
You can start your document in such a way as to include metadata such as title, author, and date:
Pandoc-Markdown | reST |
---|---|
|
|
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,
and my understanding is that docutils can do that as well, though I wasn’t able to get it working with docutils (version 0.8.1).
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.
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/cols. 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.
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.
Pandoc-Markdown | reST |
---|---|
|
|
Also, both markup formats support a “grid table” syntax as well.
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.
Pandoc-Markdown | reST |
---|---|
|
|
The two formats have other minor differences, including:
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 possibly-nested Pandoc-Markdown docs, I cobbled together my own tool called Rippledoc.
My 2¢: Pandoc-Markdown is easier on the eyes, easier to remember, and even easier to type.