`_
in a few respects. Except where noted, these differences can be
suppressed by specifying the ``--strict`` command-line option.
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\**
one will get
::
*hello*
instead of
::
hello
This rule is easier to remember than standard markdown's rule,
which allows only the following characters to be
backslash-escaped:
::
\`*_{}[]()>#+-.!
A backslash-escaped space is parsed as a nonbreaking space. It will
appear in TeX output as '``~``' and in HTML and XML as
'``\ ``' or '``\ ``'.
A backslash-escaped newline (i.e. a backslash occurring at the end
of a line) is parsed as a hard line break. It will appear in TeX
output as '``\\``' and in HTML as '``
``'. This is a nice
alternative to markdown's "invisible" way of indicating hard line
breaks using two trailing spaces on a line.
Subscripts and superscripts
---------------------------
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.
If the superscripted or subscripted text contains spaces, these
spaces must be escaped with backslashes. (This is to prevent
accidental superscripting and subscripting through the ordinary use
of ``~`` and ``^``.) Thus, if you want the letter P with 'a cat' in
subscripts, use ``P~a\ cat~``, not ``P~a cat~``.
Strikeout
---------
To strikeout a section of text with a horizontal line, begin and
end it with ``~~``. Thus, for example,
::
This ~~is deleted text.~~
Nested Lists
------------
Pandoc behaves differently from standard markdown on some "edge
cases" involving lists. Consider this source:
::
1. First
2. Second:
- Fee
- Fie
- Foe
3. Third
Pandoc transforms this into a "compact list" (with no ```` tags
around "First", "Second", or "Third"), while markdown puts ``
``
tags around "Second" and "Third" (but not "First"), because of the
blank space around "Third". Pandoc follows a simple rule: if the
text is followed by a blank line, it is treated as a paragraph.
Since "Second" is followed by a list, and not a blank line, it
isn't treated as a paragraph. The fact that the list is followed by
a blank line is irrelevant. (Note: Pandoc works this way even when
the ``--strict`` option is specified. This behavior is consistent
with the official markdown syntax description, even though it is
different from that of ``Markdown.pl``.)
Ordered Lists
-------------
Unlike standard markdown, Pandoc allows ordered list items to be
marked with uppercase and lowercase letters and roman numerals, in
addition to arabic numerals. (This behavior can be turned off using
the ``--strict`` option.) List markers may be enclosed in
parentheses or followed by a single right-parentheses or period.
They must be separated from the text that follows by at least one
space, and, if the list marker is a capital letter with a period,
by at least two spaces. [2]_
Pandoc also pays attention to the type of list marker used, and to
the starting number, and both of these are preserved where possible
in the output format. Thus, the following yields a list with
numbers followed by a single parenthesis, starting with 9, and a
sublist with lowercase roman numerals:
::
9) Ninth
10) Tenth
11) Eleventh
i. subone
ii. subtwo
iii. subthree
Note that Pandoc pays attention only to the *starting* marker in a
list. So, the following yields a list numbered sequentially
starting from 2:
::
(2) Two
(5) Three
1. Four
* Five
If default list markers are desired, use '``#.``':
::
#. one
#. two
#. three
Definition lists
----------------
Pandoc supports definition lists, using a syntax inspired by
`PHP Markdown Extra `_
and
`reStructuredText `_: [3]_
::
Term 1
: Definition 1
Term 2 with *inline markup*
: Definition 2
{ some code, part of Definition 2 }
Third paragraph of definition 2.
Each term must fit on one line, which may optionally be followed by
a blank line, and must be followed by one or more definitions. A
definition begins with a colon or tilde, which may be indented one
or two spaces. A term may have multiple definitions, and each
definition may consist of one or more block elements (paragraph,
code block, list, etc.), each indented four spaces or one tab
stop.
If you leave space after the definition (as in the example above),
the blocks of the definitions will be considered paragraphs. In
some output formats, this will mean greater spacing between
term/definition pairs. For a compact definition list, do not leave
space between the definition and the next term:
::
Term 1
~ Definition 1
Term 2
~ Definition 2a
~ Definition 2b
Reference links
---------------
Pandoc allows implicit reference links with just a single set of
brackets. So, the following links are equivalent:
::
1. Here's my [link]
2. Here's my [link][]
[link]: linky.com
(Note: Pandoc works this way even if ``--strict`` is specified,
because ``Markdown.pl`` 1.0.2b7 allows single-bracket links.)
Footnotes
---------
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.
The identifiers in footnote references may not contain spaces,
tabs, or newlines. These identifiers are used only to correlate the
footnote reference with the note itself; in the output, footnotes
will be numbered sequentially.
The footnotes themselves need not be placed at the end of the
document. They may appear anywhere except inside other block
elements (lists, block quotes, tables, etc.).
Inline footnotes are also allowed (though, unlike regular notes,
they cannot contain multiple paragraphs). The syntax is as
follows:
::
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.]
Inline and regular footnotes may be mixed freely.
Tables
------
Two kinds of tables may be used. Both 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.
The headers and table rows must each fit on one line. Column
alignments are determined by the position of the header text
relative to the dashed line below it: [4]_
- 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).
The table must end with a blank line, or a line of dashes followed
by a blank line. A caption may optionally be provided (as
illustrated in the example above). A caption is a paragraph
beginning with the string ``Table:``, which will be stripped off.
The column headers may be omitted, provided a dashed line is used
to end the table. For example:
::
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
------- ------ ---------- -------
When headers are omitted, column alignments are determined on the
basis of the first line of the table body. So, in the tables above,
the columns would be right, left, center, and right aligned,
respectively.
Multiline tables allow headers and table rows to span multiple
lines of text. Here is an example:
::
-------------------------------------------------------------
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.
These work like simple tables, but with the following differences:
- 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.
In multiline tables, the table parser pays attention to the widths
of the columns, and the writers try to reproduce these relative
widths in the output. So, if you find that one of the columns is
too narrow in the output, try widening it in the markdown source.
Headers may be omitted in multiline tables as well as simple
tables:
::
----------- ------- --------------- -------------------------
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 a multiline table without headers.
It is possible for a multiline table to have just one row, but the
row should be followed by a blank line (and then the row of dashes
that ends the table), or the table may be interpreted as a simple
table.
Delimited Code blocks
---------------------
In addition to standard indented code blocks, Pandoc supports
*delimited* code blocks. These begin with a row of three or more
tildes (``~``) and end with a row of tildes that must be at least
as long as the starting row. Everything between the tilde-lines is
treated as code. No indentation is necessary:
::
~~~~~~~
{code here}
~~~~~~~
Like regular code blocks, delimited code blocks must be separated
from surrounding text by blank lines.
If the code itself contains a row of tildes, just use a longer row
of tildes at the start and end:
::
~~~~~~~~~~~~~~~~
~~~~~~~~~~
code including tildes
~~~~~~~~~~
~~~~~~~~~~~~~~~~
Optionally, you may specify the language of the code block using
this syntax:
::
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.haskell .numberLines}
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some output formats can use this information to do syntax
highlighting. Currently, the only output format that uses this
information is HTML.
If pandoc has been compiled with syntax highlighting support, then
the code block above will appear highlighted, with numbered lines.
(To see which languages are supported, do ``pandoc --version``.)
If pandoc has not been compiled with syntax highlighting support,
the code block above will appear as follows:
::
...
Images with captions
--------------------
An image occurring by itself in a paragraph will be rendered as a
figure with a caption. [5]_ (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.
::

If you just want a regular inline image, just make sure it is not
the only thing in the paragraph. One way to do this is to insert a
nonbreaking space after the image:
::
\
Title blocks
------------
If the file begins with a title block
::
% title
% author(s) (separated by semicolons)
% date
it will be parsed as bibliographic information, not regular text.
(It will be used, for example, in the title of standalone LaTeX or
HTML output.) 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
The title may occupy multiple lines, but continuation lines must
begin with leading space, thus:
::
% My title
on multiple lines
If a document has multiple authors, the authors may be put on
separate lines with leading space, or separated by semicolons, or
both. So, all of the following are equivalent:
::
% Author One
Author Two
% Author One; Author Two
% Author One;
Author Two
The date must fit on one line.
All three metadata fields may contain standard inline formatting
(italics, links, footnotes, etc.).
Title blocks will always be parsed, but they will affect the output
only when the ``--standalone`` (``-s``) option is chosen. In HTML
output, titles will appear twice: once in the document head -- this
is the title that will appear at the top of the window in a browser
-- and once at the beginning of the document body. The title in the
document head can have an optional prefix attached
(``--title-prefix`` or ``-T`` option). The title in the body
appears as an H1 element with class "title", so it can be
suppressed or reformatted with CSS. If a title prefix is specified
with ``-T`` and no title block appears in the document, the title
prefix will be used by itself as the HTML title.
The man page writer extracts a title, man page section number, and
other header and footer information from the title line. The title
is assumed to be the first word on the title line, which may
optionally end with a (single-digit) section number in parentheses.
(There should be no space between the title and the parentheses.)
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)
will yield a man page with the title ``PANDOC`` and section 1.
::
% PANDOC(1) Pandoc User Manuals
will also have "Pandoc User Manuals" in the footer.
::
% PANDOC(1) Pandoc User Manuals | Version 4.0
will also have "Version 4.0" in the header.
Markdown in HTML blocks
-----------------------
While standard markdown leaves HTML blocks exactly as they are,
Pandoc treats text between HTML tags as markdown. Thus, for
example, Pandoc will turn
::
| *one* |
[a link](http://google.com) |
into
::
whereas ``Markdown.pl`` will preserve it as is.
There is one exception to this rule: text between ```` tags is not interpreted as markdown.
This departure from standard markdown should make it easier to mix
markdown with HTML block elements. For example, one can surround a
block of markdown text with ```` tags without preventing it
from being interpreted as markdown.
Header identifiers in HTML
--------------------------
Each header element in pandoc's HTML 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``.
Thus, for example,
+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
| 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`` |
+--------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
These rules should, in most cases, allow one to determine the
identifier from the header text. The exception is when several
headers have the same text; in this case, the first will get an
identifier as described above; the second will get the same
identifier with ``-1`` appended; the third with ``-2``; and so on.
These identifiers are used to provide link targets in the table of
contents generated by the ``--toc|--table-of-contents`` option.
They also make it easy to provide links from one section of a
document to another. A link to this section, for example, might
look like this:
::
See the section on [header identifiers](#header-identifiers-in-html).
Note, however, that this method of providing links to sections
works only in HTML.
Blank lines before headers and blockquotes
------------------------------------------
Standard markdown syntax does not require a blank line before a
header or blockquote. Pandoc does require this (except, of course,
at the beginning of the document). The reason for the requirement
is that it is all too easy for a ``>`` or ``#`` to end up at the
beginning of a line by accident (perhaps through line wrapping).
Consider, for example:
::
I like several of their flavors of ice cream: #22, for example, and
#5.
Math
----
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. In Markdown,
reStructuredText, LaTeX, and ConTeXt output, it will appear
verbatim between $ characters.
In reStructuredText output, it will be rendered using an
interpreted text role ``:math:``, as described
`here `_.
In Texinfo output, it will be rendered inside a ``@math`` command.
In groff man output, it will be rendered verbatim without $'s.
In MediaWiki output, it will be rendered inside ``