PANDOC_MARKDOWN(5) | File Formats Manual | PANDOC_MARKDOWN(5) |
NAME¶
pandoc_markdown - markdown syntax for pandoc(1)DESCRIPTION¶
Pandoc understands an extended and slightly revised version of John Gruber's markdown syntax. This document explains the syntax, noting differences from standard markdown. Except where noted, these differences can be suppressed by specifying the --strict command-line option.PHILOSOPHY¶
Markdown is designed to be easy to write, and, even more importantly, easy to read:
A Markdown-formatted document should be publishable as-is, as plain text,
without looking like it's been marked up with tags or formatting instructions.
-- John Gruber
This principle has guided pandoc's decisions in finding syntax for tables,
footnotes, and other extensions.
There is, however, one respect in which pandoc's aims are different from the
original aims of markdown. Whereas markdown was originally designed with HTML
generation in mind, pandoc is designed for multiple output formats. Thus,
while pandoc allows the embedding of raw HTML, it discourages it, and provides
other, non-HTMLish ways of representing important document elements like
definition lists, tables, mathematics, and footnotes.
PARAGRAPHS¶
A paragraph is one or more lines of text followed by one or more blank line. Newlines are treated as spaces, so you can reflow your paragraphs as you like. If you need a hard line break, put two or more spaces at the end of a line, or type a backslash followed by a newline.HEADERS¶
There are two kinds of headers, Setext and atx.Setext-style headers¶
A setext-style header is a line of text "underlined" with a row of = signs (for a level one header) of - signs (for a level two header):-
A level-one header ================== A level-two header ------------------
Atx-style headers¶
An Atx-style header consists of one to six # signs and a line of text, optionally followed by any number of # signs. The number of # signs at the beginning of the line is the header level:-
## A level-two header ### A level-three header ###
-
# A level-one header with a [link](/url) and *emphasis*
-
I like several of their flavors of ice cream: #22, for example, and #5.
Header identifiers in HTML, LaTeX, and ConTeXt¶
Pandoc extension. Each header element in pandoc's HTML and ConTeXt output is given a unique identifier. This identifier is based on the text of the header. To derive the identifier from the header text,- •
- Remove all formatting, links, etc.
- •
- Remove all punctuation, except underscores, hyphens, and periods.
- •
- Replace all spaces and newlines with hyphens.
- •
- Convert all alphabetic characters to lowercase.
- •
- Remove everything up to the first letter (identifiers may not begin with a number or punctuation mark).
- •
- If nothing is left after this, use the identifier section.
Header | Identifier |
Header identifiers in HTML | header-identifiers-in-html |
Dogs?--in my house? | dogs--in-my-house |
HTML, S5, or RTF? | html-s5-or-rtf |
3. Applications | applications |
33 | section |
-
See the section on [header identifiers](#header-identifiers-in-html).
BLOCK QUOTATIONS¶
Markdown uses email conventions for quoting blocks of text. A block quotation is one or more paragraphs or other block elements (such as lists or headers), with each line preceded by a > character and a space. (The > need not start at the left margin, but it should not be indented more than three spaces.)-
> This is a block quote. This > paragraph has two lines. > > 1. This is a list inside a block quote. > 2. Second item.
-
> This is a block quote. This paragraph has two lines. > 1. This is a list inside a block quote. 2. Second item.
-
> This is a block quote. > > > A block quote within a block quote.
-
> This is a block quote. >> Nested.
VERBATIM (CODE) BLOCKS¶
Indented code blocks¶
A block of text indented four spaces (or one tab) is treated as verbatim text: that is, special characters do not trigger special formatting, and all spaces and line breaks are preserved. For example,-
if (a > 3) { moveShip(5 * gravity, DOWN); }
Delimited code blocks¶
Pandoc extension. In addition to standard indented code blocks, Pandoc supports delimited code blocks. These begin with a row of three or more tildes (~) or backticks (`) and end with a row of tildes or backticks that must be at least as long as the starting row. Everything between these lines is treated as code. No indentation is necessary:-
~~~~~~~ if (a > 3) { moveShip(5 * gravity, DOWN); } ~~~~~~~
-
~~~~~~~~~~~~~~~~ ~~~~~~~~~~ code including tildes ~~~~~~~~~~ ~~~~~~~~~~~~~~~~
-
~~~~ {#mycode .haskell .numberLines startFrom="100"} qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Otherwise, the code block above will appear as follows:
-
<pre id="mycode" class="haskell numberLines" startFrom="100"> <code> ... </code> </pre>
-
```haskell qsort [] = [] ```
-
``` {.haskell} qsort [] = [] ```
LISTS¶
Bullet lists¶
A bullet list is a list of bulleted list items. A bulleted list item begins with a bullet (*, +, or -). Here is a simple example:-
* one * two * three
-
* one * two * three
-
* here is my first list item. * and my second.
-
* here is my first list item. * and my second.
The four-space rule¶
A list item may contain multiple paragraphs and other block-level content. However, subsequent paragraphs must be preceded by a blank line and indented four spaces or a tab. The list will look better if the first paragraph is aligned with the rest:-
* First paragraph. Continued. * Second paragraph. With a code block, which must be indented eight spaces: { code }
-
* fruits + apples - macintosh - red delicious + pears + peaches * vegetables + brocolli + chard
-
+ A lazy, lazy, list item. + Another one; this looks bad but is legal. Second paragraph of second list item.
Ordered lists¶
Ordered lists work just like bulleted lists, except that the items begin with enumerators rather than bullets. In standard markdown, enumerators are decimal numbers followed by a period and a space. The numbers themselves are ignored, so there is no difference between this list:-
1. one 2. two 3. three
-
5. one 7. two 1. three
-
9) Ninth 10) Tenth 11) Eleventh i. subone ii. subtwo iii. subthree
-
(2) Two (5) Three 1. Four * Five
-
#. one #. two #. three
Definition lists¶
Pandoc extension. Pandoc supports definition lists, using a syntax inspired by PHP Markdown Extra and reStructuredText:[2]-
Term 1 : Definition 1 Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2.
-
Term 1 ~ Definition 1 Term 2 ~ Definition 2a ~ Definition 2b
Numbered example lists¶
Pandoc extension. The special list marker @ can be used for sequentially numbered examples. The first list item with a @ marker will be numbered '1', the next '2', and so on, throughout the document. The numbered examples need not occur in a single list; each new list using @ will take up where the last stopped. So, for example:-
(@) My first example will be numbered (1). (@) My second example will be numbered (2). Explanation of examples. (@) My third example will be numbered (3).
-
(@good) This is a good example. As (@good) illustrates, ...
Compact and loose lists¶
Pandoc behaves differently from Markdown.pl on some "edge cases" involving lists. Consider this source:-
+ First + Second: - Fee - Fie - Foe + Third
Ending a list¶
What if you want to put an indented code block after a list?-
- item one - item two { my code block }
-
- item one - item two <!-- end of list --> { my code block }
-
1. one 2. two 3. three <!-- --> 1. uno 2. dos 3. tres
HORIZONTAL RULES¶
A line containing a row of three or more *, -, or _ characters (optionally separated by spaces) produces a horizontal rule:-
* * * * ---------------
TABLES¶
Pandoc extension. Three kinds of tables may be used. All three kinds presuppose the use of a fixed-width font, such as Courier. Simple tables look like this:-
Right Left Center Default ------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 Table: Demonstration of simple table syntax.
- •
- If the dashed line is flush with the header text on the right side but extends beyond it on the left, the column is right-aligned.
- •
- If the dashed line is flush with the header text on the left side but extends beyond it on the right, the column is left-aligned.
- •
- If the dashed line extends beyond the header text on both sides, the column is centered.
- •
- If the dashed line is flush with the header text on both sides, the default alignment is used (in most cases, this will be left).
-
------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 ------- ------ ---------- -------
-
------------------------------------------------------------- Centered Default Right Left Header Aligned Aligned Aligned ----------- ------- --------------- ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. ------------------------------------------------------------- Table: Here's the caption. It, too, may span multiple lines.
- •
- They must begin with a row of dashes, before the header text (unless the headers are omitted).
- •
- They must end with a row of dashes, then a blank line.
- •
- The rows must be separated by blank lines.
-
----------- ------- --------------- ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. ------------------------------------------------------------- : Here's a multiline table without headers.
-
: Sample grid table. +---------------+---------------+--------------------+ | Fruit | Price | Advantages | +===============+===============+====================+ | Bananas | $1.34 | - built-in wrapper | | | | - bright color | +---------------+---------------+--------------------+ | Oranges | $2.10 | - cures scurvy | | | | - tasty | +---------------+---------------+--------------------+
TITLE BLOCK¶
Pandoc extension. If the file begins with a title block-
% title % author(s) (separated by semicolons) % date
The block may contain just a title, a title and an author, or all three elements. If you want to include an author but no title, or a title and a date but no author, you need a blank line:
-
% % Author % My title % % June 15, 2006
-
% My title on multiple lines
-
% Author One Author Two % Author One; Author Two % Author One; Author Two
Anything after this is assumed to be additional footer and header text. A single pipe character (|) should be used to separate the footer text from the header text. Thus,
-
% PANDOC(1)
-
% PANDOC(1) Pandoc User Manuals
-
% PANDOC(1) Pandoc User Manuals | Version 4.0
BACKSLASH ESCAPES¶
Except inside a code block or inline code, any punctuation or space character preceded by a backslash will be treated literally, even if it would normally indicate formatting. Thus, for example, if one writes-
*\*hello\**
-
<em>*hello*</em>
-
<strong>hello</strong>
-
\`*_{}[]()>#+-.!
SMART PUNCTUATION¶
Pandoc extension. If the --smart option is specified, pandoc will produce typographically correct output, converting straight quotes to curly quotes, --- to em-dashes, -- to en-dashes, and ... to ellipses. Nonbreaking spaces are inserted after certain abbreviations, such as "Mr." Note: if your LaTeX template uses the csquotes package, pandoc will detect automatically this and use \enquote{...} for quoted text.INLINE FORMATTING¶
Emphasis¶
To emphasize some text, surround it with *s or _, like this:-
This text is _emphasized with underscores_, and this is *emphasized with asterisks*.
-
This is **strong emphasis** and __with underscores__.
-
This is * not emphasized *, and \*neither is this\*.
-
feas*ible*, not feas*able*.
Strikeout¶
Pandoc extension. To strikeout a section of text with a horizontal line, begin and end it with ~~. Thus, for example,-
This ~~is deleted text.~~
Superscripts and subscripts¶
Pandoc extension. Superscripts may be written by surrounding the superscripted text by ^ characters; subscripts may be written by surrounding the subscripted text by ~ characters. Thus, for example,-
H~2~O is a liquid. 2^10^ is 1024.
Thus, if you want the letter P with 'a cat' in subscripts, use P~a\ cat~, not P~a cat~.
Verbatim¶
To make a short span of text verbatim, put it inside backticks:-
What is the difference between `>>=` and `>>`?
-
Here is a literal backtick `` ` ``.
-
This is a backslash followed by an asterisk: `\*`.
-
`<$>`{.haskell}
MATH¶
Pandoc extension. Anything between two $ characters will be treated as TeX math. The opening $ must have a character immediately to its right, while the closing $ must have a character immediately to its left. Thus, $20,000 and $30,000 won't parse as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won't be treated as math delimiters. TeX math will be printed in all output formats. How it is rendered depends on the output format:- Markdown, LaTeX, Org-Mode, ConTeXt
- It will appear verbatim between $ characters.
- reStructuredText
- It will be rendered using an interpreted text role :math:, as described here.
- AsciiDoc
- It will be rendered as latexmath:[...].
- Texinfo
- It will be rendered inside a @math command.
- groff man
- It will be rendered verbatim without $'s.
- MediaWiki
- It will be rendered inside <math> tags.
- Textile
- It will be rendered inside <span class="math"> tags.
- RTF, OpenDocument, ODT
- It will be rendered, if possible, using unicode characters, and will otherwise appear verbatim.
- Docbook
- If the --mathml flag is used, it will be rendered using mathml in an inlineequation or informalequation tag. Otherwise it will be rendered, if possible, using unicode characters.
- Docx
- It will be rendered using OMML math markup.
- HTML, Slidy, Slideous, DZSlides, S5, EPUB
- The way math is rendered in HTML will depend on the command-line options selected:
- 1.
- The default is to render TeX math as far as possible using unicode characters, as with RTF, DocBook, and OpenDocument output. Formulas are put inside a span with class="math", so that they may be styled differently from the surrounding text if needed.
- 2.
- If the --latexmathml option is used, TeX math will be displayed between $ or $$ characters and put in <span> tags with class LaTeX. The LaTeXMathML script will be used to render it as formulas. (This trick does not work in all browsers, but it works in Firefox. In browsers that do not support LaTeXMathML, TeX math will appear verbatim between $ characters.)
- 3.
- If the --jsmath option is used, TeX math will be put inside <span> tags (for inline math) or <div> tags (for display math) with class math. The jsMath script will be used to render it.
- 4.
- If the --mimetex option is used, the mimeTeX CGI script will be called to generate images for each TeX formula. This should work in all browsers. The --mimetex option takes an optional URL as argument. If no URL is specified, it will be assumed that the mimeTeX CGI script is at /cgi-bin/mimetex.cgi.
- 5.
- If the --gladtex option is used, TeX formulas will be enclosed in <eq> tags in the HTML output. The resulting htex file may then be processed by gladTeX, which will produce image files for each formula and an html file with links to these images. So, the procedure is:
-
pandoc -s --gladtex myfile.txt -o myfile.htex gladtex -d myfile-images myfile.htex # produces myfile.html and images in myfile-images
- 6.
- If the --webtex option is used, TeX formulas will be converted to <img> tags that link to an external script that converts formulas to images. The formula will be URL-encoded and concatenated with the URL provided. If no URL is specified, the Google Chart API will be used (http://chart.apis.google.com/chart?cht=tx&chl=).
RAW HTML¶
Markdown allows you to insert raw HTML (or DocBook) anywhere in a document (except verbatim contexts, where <, >, and & are interpreted literally). The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous, DZSlides, EPUB, Markdown, and Textile output, and suppressed in other formats. Pandoc extension. Standard markdown allows you to include HTML "blocks": blocks of HTML between balanced tags that are separated from the surrounding text with blank lines, and start and end at the left margin. Within these blocks, everything is interpreted as HTML, not markdown; so (for example), * does not signify emphasis. Pandoc behaves this way when --strict is specified; but by default, pandoc interprets material between HTML block tags as markdown. Thus, for example, Pandoc will turn-
<table> <tr> <td>*one*</td> <td>[a link](http://google.com)</td> </tr> </table>
-
<table> <tr> <td><em>one</em></td> <td><a href="http://google.com">a link</a></td> </tr> </table>
RAW TEX¶
Pandoc extension. In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be included in a document. Inline TeX commands will be preserved and passed unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use LaTeX to include BibTeX citations:-
This result was proved in \cite{jones.1967}.
-
\begin{tabular}{|l|l|}\hline Age & Frequency \\ \hline 18--25 & 15 \\ 26--35 & 33 \\ 36--45 & 22 \\ \hline \end{tabular}
Macros¶
For output formats other than LaTeX, pandoc will parse LaTeX \newcommand and \renewcommand definitions and apply the resulting macros to all LaTeX math. So, for example, the following will work in all output formats, not just LaTeX:-
\newcommand{\tuple}[1]{\langle #1 \rangle} $\tuple{a, b, c}$
LINKS¶
Markdown allows links to be specified in several ways.Automatic links¶
If you enclose a URL or email address in pointy brackets, it will become a link:-
<http://google.com> <sam@green.eggs.ham>
Inline links¶
An inline link consists of the link text in square brackets, followed by the URL in parentheses. (Optionally, the URL can be followed by a link title, in quotes.)-
This is an [inline link](/url), and here's [one with a title](http://fsf.org "click here for a good time!").
Reference links¶
An explicit reference link has two parts, the link itself and the link definition, which may occur elsewhere in the document (either before or after the link). The link consists of link text in square brackets, followed by a label in square brackets. (There can be space between the two.)The link definition must begin at the left margin or indented no more than three spaces. It consists of the bracketed label, followed by a colon and a space, followed by the URL, and optionally (after a space) a link title either in quotes or in parentheses. Here are some examples:
-
[my label 1]: /foo/bar.html "My title, optional" [my label 2]: /foo [my label 3]: http://fsf.org (The free software foundation) [my label 4]: /bar#special 'A title in single quotes'
-
[my label 5]: <http://foo.bar.baz>
-
[my label 3]: http://fsf.org "The free software foundation"
-
Here is [my link][FOO] [Foo]: /bar/baz
-
See [my website][], or [my website]. [my website]: http://foo.bar.baz
Internal links¶
To link to another section of the same document, use the automatically generated identifier (see Header identifiers in HTML, LaTeX, and ConTeXt, below). For example:-
See the [Introduction](#introduction).
-
See the [Introduction]. [Introduction]: #introduction
IMAGES¶
A link immediately preceded by a ! will be treated as an image. The link text will be used as the image's alt text:-
 ![movie reel] [movie reel]: movie.gif
Pictures with captions¶
Pandoc extension. An image occurring by itself in a paragraph will be rendered as a figure with a caption.[4] (In LaTeX, a figure environment will be used; in HTML, the image will be placed in a div with class figure, together with a caption in a p with class caption.)The image's alt text will be used as the caption.
-

-
\
FOOTNOTES¶
Pandoc extension. Pandoc's markdown allows footnotes, using the following syntax:-
Here is a footnote reference,[^1] and another.[^longnote] [^1]: Here is the footnote. [^longnote]: Here's one with multiple blocks. Subsequent paragraphs are indented to show that they belong to the previous footnote. { some.code } The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items. This paragraph won't be part of the note, because it isn't indented.
-
Here is an inline note.^[Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.]
CITATIONS¶
Pandoc extension. Pandoc can automatically generate citations and a bibliography in a number of styles (using Andrea Rossato's hs-citeproc). In order to use this feature, you will need a bibliographic database in one of the following formats:Format | File extension |
MODS | .mods |
BibTeX/BibLaTeX | .bib |
RIS | .ris |
EndNote | .enl |
EndNote XML | .xml |
ISI | .wos |
MEDLINE | .medline |
Copac | .copac |
JSON citeproc | .json |
-
Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1]. Blah blah [@doe99, pp. 33-35, 38-39 and *passim*]. Blah blah [@smith04; @doe99].
-
Smith says blah [-@smith04].
-
@smith04 says blah. @smith04 [p. 33] says blah.
-
last paragraph... # References
NOTES¶
[1]¶
The point of this rule is to ensure that normal paragraphs starting with people's initials, like-
B. Russell was an English philosopher.
-
(C) 2007 Joe Smith
-
(C\) 2007 Joe Smith
[2]¶
I have also been influenced by the suggestions of David Wheeler.[3]¶
This scheme is due to Michel Fortin, who proposed it on the Markdown discussion list.[4]¶
This feature is not yet implemented for RTF, OpenDocument, or ODT. In those formats, you'll just get an image in a paragraph by itself, with no caption.SEE ALSO¶
pandoc (1).January 27, 2012 | Pandoc |