spec.txt   spec.txt 
--- ---
title: CommonMark Spec title: CommonMark Spec
author: John MacFarlane author: John MacFarlane
version: 0.16 version: 0.17
date: 2015-01-14 date: 2015-01-24
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)' license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
... ...
# Introduction # Introduction
## What is Markdown? ## What is Markdown?
Markdown is a plain text format for writing structured documents, Markdown is a plain text format for writing structured documents,
based on conventions used for indicating formatting in email and based on conventions used for indicating formatting in email and
usenet posts. It was developed in 2004 by John Gruber, who wrote usenet posts. It was developed in 2004 by John Gruber, who wrote
skipping to change at line 3929 skipping to change at line 3929
. .
<ul> <ul>
<li>a <li>a
<ul> <ul>
<li>b</li> <li>b</li>
</ul> </ul>
</li> </li>
</ul> </ul>
. .
This list is loose, because of the blank line between the
two block elements in the list item:
.
1. ```
foo
```
bar
.
<ol>
<li>
<pre><code>foo
</code></pre>
<p>bar</p>
</li>
</ol>
.
Here the outer list is loose, the inner list tight: Here the outer list is loose, the inner list tight:
. .
* foo * foo
* bar * bar
baz baz
. .
<ul> <ul>
<li> <li>
skipping to change at line 4499 skipping to change at line 4518
run," and its rules for distinguishing left- and right-flanking runs run," and its rules for distinguishing left- and right-flanking runs
are a bit more complex than the ones given here.) are a bit more complex than the ones given here.)
The following rules define emphasis and strong emphasis: The following rules define emphasis and strong emphasis:
1. A single `*` character [can open emphasis](@can-open-emphasis) 1. A single `*` character [can open emphasis](@can-open-emphasis)
iff it is part of a [left-flanking delimiter run]. iff it is part of a [left-flanking delimiter run].
2. A single `_` character [can open emphasis] iff 2. A single `_` character [can open emphasis] iff
it is part of a [left-flanking delimiter run] it is part of a [left-flanking delimiter run]
and is not preceded by an ASCII alphanumeric character. and not part of a [right-flanking delimiter run].
3. A single `*` character [can close emphasis](@can-close-emphasis) 3. A single `*` character [can close emphasis](@can-close-emphasis)
iff it is part of a [right-flanking delimiter run]. iff it is part of a [right-flanking delimiter run].
4. A single `_` character [can close emphasis] 4. A single `_` character [can close emphasis]
iff it is part of a [right-flanking delimiter run]. iff it is part of a [right-flanking delimiter run]
and it is not followed by an ASCII alphanumeric character. and not part of a [left-flanking delimiter run].
5. A double `**` [can open strong emphasis](@can-open-strong-emphasis) 5. A double `**` [can open strong emphasis](@can-open-strong-emphasis)
iff it is part of a [left-flanking delimiter run]. iff it is part of a [left-flanking delimiter run].
6. A double `__` [can open strong emphasis] 6. A double `__` [can open strong emphasis]
iff it is part of a [left-flanking delimiter run] iff it is part of a [left-flanking delimiter run]
and is not preceded by an ASCII alphanumeric character. and not part of a [right-flanking delimiter run].
7. A double `**` [can close strong emphasis](@can-close-strong-emphasis) 7. A double `**` [can close strong emphasis](@can-close-strong-emphasis)
iff it is part of a [right-flanking delimiter run]. iff it is part of a [right-flanking delimiter run].
8. A double `__` [can close strong emphasis] 8. A double `__` [can close strong emphasis]
iff it is part of a [right-flanking delimiter run] iff it is part of a [right-flanking delimiter run]
and is not followed by an ASCII alphanumeric character. and not part of a [left-flanking delimiter run].
9. Emphasis begins with a delimiter that [can open emphasis] and ends 9. Emphasis begins with a delimiter that [can open emphasis] and ends
with a delimiter that [can close emphasis], and that uses the same with a delimiter that [can close emphasis], and that uses the same
character (`_` or `*`) as the opening delimiter. There must character (`_` or `*`) as the opening delimiter. There must
be a nonempty sequence of inlines between the open delimiter be a nonempty sequence of inlines between the open delimiter
and the closing delimiter; these form the contents of the emphasis and the closing delimiter; these form the contents of the emphasis
inline. inline.
10. Strong emphasis begins with a delimiter that 10. Strong emphasis begins with a delimiter that
[can open strong emphasis] and ends with a delimiter that [can open strong emphasis] and ends with a delimiter that
skipping to change at line 4653 skipping to change at line 4672
This is not emphasis, because the opening `_` is preceded This is not emphasis, because the opening `_` is preceded
by an alphanumeric and followed by punctuation: by an alphanumeric and followed by punctuation:
. .
a_"foo"_ a_"foo"_
. .
<p>a_&quot;foo&quot;_</p> <p>a_&quot;foo&quot;_</p>
. .
Emphasis with `_` is not allowed inside ASCII words: Emphasis with `_` is not allowed inside words:
. .
foo_bar_ foo_bar_
. .
<p>foo_bar_</p> <p>foo_bar_</p>
. .
. .
5_6_78 5_6_78
. .
<p>5_6_78</p> <p>5_6_78</p>
. .
But it is permitted inside non-ASCII words:
. .
пристаням_стремятся_ пристаням_стремятся_
. .
<p>пристаням<em>стремятся</em></p> <p>пристаням_стремятся_</p>
.
Here `_` does not generate emphasis, because the first delimiter run
is right-flanking and the second left-flanking:
.
aa_"bb"_cc
.
<p>aa_&quot;bb&quot;_cc</p>
.
Here there is no emphasis, because the delimiter runs are
both left- and right-flanking:
.
"aa"_"bb"_"cc"
.
<p>&quot;aa&quot;_&quot;bb&quot;_&quot;cc&quot;</p>
. .
Rule 3: Rule 3:
This is not emphasis, because the closing delimiter does This is not emphasis, because the closing delimiter does
not match the opening delimiter: not match the opening delimiter:
. .
_foo* _foo*
. .
skipping to change at line 4761 skipping to change at line 4796
. .
_foo_bar _foo_bar
. .
<p>_foo_bar</p> <p>_foo_bar</p>
. .
. .
_пристаням_стремятся _пристаням_стремятся
. .
<p><em>пристаням</em>стремятся</p> <p>_пристаням_стремятся</p>
. .
. .
_foo_bar_baz_ _foo_bar_baz_
. .
<p><em>foo_bar_baz</em></p> <p><em>foo_bar_baz</em></p>
. .
Rule 5: Rule 5:
skipping to change at line 4848 skipping to change at line 4883
. .
5__6__78 5__6__78
. .
<p>5__6__78</p> <p>5__6__78</p>
. .
. .
пристаням__стремятся__ пристаням__стремятся__
. .
<p>пристаням<strong>стремятся</strong></p> <p>пристаням__стремятся__</p>
. .
. .
__foo, __bar__, baz__ __foo, __bar__, baz__
. .
<p><strong>foo, <strong>bar</strong>, baz</strong></p> <p><strong>foo, <strong>bar</strong>, baz</strong></p>
. .
Rule 7: Rule 7:
skipping to change at line 4951 skipping to change at line 4986
. .
__foo__bar __foo__bar
. .
<p>__foo__bar</p> <p>__foo__bar</p>
. .
. .
__пристаням__стремятся __пристаням__стремятся
. .
<p><strong>пристаням</strong>стремятся</p> <p>__пристаням__стремятся</p>
. .
. .
__foo__bar__baz__ __foo__bar__baz__
. .
<p><strong>foo__bar__baz</strong></p> <p><strong>foo__bar__baz</strong></p>
. .
Rule 9: Rule 9:
skipping to change at line 5603 skipping to change at line 5638
The destination cannot contain line breaks, even with pointy braces: The destination cannot contain line breaks, even with pointy braces:
. .
[link](foo [link](foo
bar) bar)
. .
<p>[link](foo <p>[link](foo
bar)</p> bar)</p>
. .
.
[link](<foo
bar>)
.
<p>[link](<foo
bar>)</p>
.
One level of balanced parentheses is allowed without escaping: One level of balanced parentheses is allowed without escaping:
. .
[link]((foo)and(bar)) [link]((foo)and(bar))
. .
<p><a href="(foo)and(bar)">link</a></p> <p><a href="(foo)and(bar)">link</a></p>
. .
However, if you have parentheses within parentheses, you need to escape However, if you have parentheses within parentheses, you need to escape
or use the `<...>` form: or use the `<...>` form:
 End of changes. 13 change blocks. 
14 lines changed or deleted 57 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/