spec.txt   spec.txt 
--- ---
title: CommonMark Spec title: CommonMark Spec
author: author:
- John MacFarlane - John MacFarlane
version: 0.12 version: 0.13
date: 2014-11-10 date: 2014-12-10
... ...
# 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
the first Markdown-to-HTML converter in perl, and it soon became the first Markdown-to-HTML converter in perl, and it soon became
skipping to change at line 173 skipping to change at line 173
a document that renders one way on one system (say, a github wiki) a document that renders one way on one system (say, a github wiki)
renders differently on another (say, converting to docbook using renders differently on another (say, converting to docbook using
pandoc). To make matters worse, because nothing in Markdown counts pandoc). To make matters worse, because nothing in Markdown counts
as a "syntax error," the divergence often isn't discovered right away. as a "syntax error," the divergence often isn't discovered right away.
## About this document ## About this document
This document attempts to specify Markdown syntax unambiguously. This document attempts to specify Markdown syntax unambiguously.
It contains many examples with side-by-side Markdown and It contains many examples with side-by-side Markdown and
HTML. These are intended to double as conformance tests. An HTML. These are intended to double as conformance tests. An
accompanying script `runtests.pl` can be used to run the tests accompanying script `spec_tests.py` can be used to run the tests
against any Markdown program: against any Markdown program:
perl runtests.pl spec.txt PROGRAM python test/spec_tests.py --spec spec.txt --program PROGRAM
Since this document describes how Markdown is to be parsed into Since this document describes how Markdown is to be parsed into
an abstract syntax tree, it would have made sense to use an abstract an abstract syntax tree, it would have made sense to use an abstract
representation of the syntax tree instead of HTML. But HTML is capable representation of the syntax tree instead of HTML. But HTML is capable
of representing the structural distinctions we need to make, and the of representing the structural distinctions we need to make, and the
choice of HTML for the tests makes it possible to run the tests against choice of HTML for the tests makes it possible to run the tests against
an implementation without writing an abstract syntax tree renderer. an implementation without writing an abstract syntax tree renderer.
This document is generated from a text file, `spec.txt`, written This document is generated from a text file, `spec.txt`, written
in Markdown with a small extension for the side-by-side tests. in Markdown with a small extension for the side-by-side tests.
skipping to change at line 226 skipping to change at line 226
<pre><code>a a <pre><code>a a
ὐ a ὐ a
</code></pre> </code></pre>
. .
Line endings are replaced by newline characters (LF). Line endings are replaced by newline characters (LF).
A line containing no characters, or a line containing only spaces (after A line containing no characters, or a line containing only spaces (after
tab expansion), is called a [blank line](@blank-line). tab expansion), is called a [blank line](@blank-line).
For security reasons, a conforming parser must strip or replace the
Unicode character `U+0000`.
# Blocks and inlines # Blocks and inlines
We can think of a document as a sequence of We can think of a document as a sequence of
[blocks](@block)---structural [blocks](@block)---structural
elements like paragraphs, block quotations, elements like paragraphs, block quotations,
lists, headers, rules, and code blocks. Blocks can contain other lists, headers, rules, and code blocks. Blocks can contain other
blocks, or they can contain [inline](@inline) content: blocks, or they can contain [inline](@inline) content:
words, spaces, links, emphasized text, images, and inline code. words, spaces, links, emphasized text, images, and inline code.
## Precedence ## Precedence
skipping to change at line 471 skipping to change at line 474
. .
If you want a horizontal rule in a list item, use a different bullet: If you want a horizontal rule in a list item, use a different bullet:
. .
- Foo - Foo
- * * * - * * *
. .
<ul> <ul>
<li>Foo</li> <li>Foo</li>
<li><hr /></li> <li>
<hr />
</li>
</ul> </ul>
. .
## ATX headers ## ATX headers
An [ATX header](@atx-header) An [ATX header](@atx-header)
consists of a string of characters, parsed as inline content, between an consists of a string of characters, parsed as inline content, between an
opening sequence of 1--6 unescaped `#` characters and an optional opening sequence of 1--6 unescaped `#` characters and an optional
closing sequence of any number of `#` characters. The opening sequence closing sequence of any number of `#` characters. The opening sequence
of `#` characters cannot be followed directly by a nonspace character. of `#` characters cannot be followed directly by a nonspace character.
skipping to change at line 2516 skipping to change at line 2521
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
> A block quote. > A block quote.
. .
<ol> <ol>
<li><p>A paragraph <li>
<p>A paragraph
with two lines.</p> with two lines.</p>
<pre><code>indented code <pre><code>indented code
</code></pre> </code></pre>
<blockquote> <blockquote>
<p>A block quote.</p> <p>A block quote.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
The most important thing to notice is that the position of The most important thing to notice is that the position of
the text after the list marker determines how much indentation the text after the list marker determines how much indentation
is needed in subsequent blocks in the list item. If the list is needed in subsequent blocks in the list item. If the list
marker takes up two spaces, and there are three spaces between marker takes up two spaces, and there are three spaces between
the list marker and the next nonspace character, then blocks the list marker and the next nonspace character, then blocks
must be indented five spaces in order to fall under the list must be indented five spaces in order to fall under the list
item. item.
skipping to change at line 2554 skipping to change at line 2561
</ul> </ul>
<p>two</p> <p>two</p>
. .
. .
- one - one
two two
. .
<ul> <ul>
<li><p>one</p> <li>
<p>two</p></li> <p>one</p>
<p>two</p>
</li>
</ul> </ul>
. .
. .
- one - one
two two
. .
<ul> <ul>
<li>one</li> <li>one</li>
skipping to change at line 2577 skipping to change at line 2586
<pre><code> two <pre><code> two
</code></pre> </code></pre>
. .
. .
- one - one
two two
. .
<ul> <ul>
<li><p>one</p> <li>
<p>two</p></li> <p>one</p>
<p>two</p>
</li>
</ul> </ul>
. .
It is tempting to think of this in terms of columns: the continuation It is tempting to think of this in terms of columns: the continuation
blocks must be indented at least to the column of the first nonspace blocks must be indented at least to the column of the first nonspace
character after the list marker. However, that is not quite right. character after the list marker. However, that is not quite right.
The spaces after the list marker determine how much relative indentation The spaces after the list marker determine how much relative indentation
is needed. Which column this indentation reaches will depend on is needed. Which column this indentation reaches will depend on
how the list item is embedded in other constructions, as shown by how the list item is embedded in other constructions, as shown by
this example: this example:
. .
> > 1. one > > 1. one
>> >>
>> two >> two
. .
<blockquote> <blockquote>
<blockquote> <blockquote>
<ol> <ol>
<li><p>one</p> <li>
<p>two</p></li> <p>one</p>
<p>two</p>
</li>
</ol> </ol>
</blockquote> </blockquote>
</blockquote> </blockquote>
. .
Here `two` occurs in the same column as the list marker `1.`, Here `two` occurs in the same column as the list marker `1.`,
but is actually contained in the list item, because there is but is actually contained in the list item, because there is
sufficent indentation after the last containing blockquote marker. sufficent indentation after the last containing blockquote marker.
The converse is also possible. In the following example, the word `two` The converse is also possible. In the following example, the word `two`
skipping to change at line 2649 skipping to change at line 2662
bar bar
- ``` - ```
foo foo
bar bar
``` ```
. .
<ul> <ul>
<li><p>foo</p> <li>
<p>bar</p></li> <p>foo</p>
<li><p>foo</p></li> <p>bar</p>
</li>
<li>
<p>foo</p>
</li>
</ul> </ul>
<p>bar</p> <p>bar</p>
<ul> <ul>
<li><pre><code>foo <li>
<pre><code>foo
bar bar
</code></pre></li> </code></pre>
</li>
</ul> </ul>
. .
A list item may contain any kind of block: A list item may contain any kind of block:
. .
1. foo 1. foo
``` ```
bar bar
``` ```
baz baz
> bam > bam
. .
<ol> <ol>
<li><p>foo</p> <li>
<p>foo</p>
<pre><code>bar <pre><code>bar
</code></pre> </code></pre>
<p>baz</p> <p>baz</p>
<blockquote> <blockquote>
<p>bam</p> <p>bam</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
2. **Item starting with indented code.** If a sequence of lines *Ls* 2. **Item starting with indented code.** If a sequence of lines *Ls*
constitute a sequence of blocks *Bs* starting with an indented code constitute a sequence of blocks *Bs* starting with an indented code
block and not separated from each other by more than one blank line, block and not separated from each other by more than one blank line,
and *M* is a list marker *M* of width *W* followed by and *M* is a list marker *M* of width *W* followed by
one space, then the result of prepending *M* and the following one space, then the result of prepending *M* and the following
space to the first line of *Ls*, and indenting subsequent lines of space to the first line of *Ls*, and indenting subsequent lines of
*Ls* by *W + 1* spaces, is a list item with *Bs* as its contents. *Ls* by *W + 1* spaces, is a list item with *Bs* as its contents.
skipping to change at line 2708 skipping to change at line 2729
An indented code block will have to be indented four spaces beyond An indented code block will have to be indented four spaces beyond
the edge of the region where text will be included in the list item. the edge of the region where text will be included in the list item.
In the following case that is 6 spaces: In the following case that is 6 spaces:
. .
- foo - foo
bar bar
. .
<ul> <ul>
<li><p>foo</p> <li>
<p>foo</p>
<pre><code>bar <pre><code>bar
</code></pre></li> </code></pre>
</li>
</ul> </ul>
. .
And in this case it is 11 spaces: And in this case it is 11 spaces:
. .
10. foo 10. foo
bar bar
. .
<ol start="10"> <ol start="10">
<li><p>foo</p> <li>
<p>foo</p>
<pre><code>bar <pre><code>bar
</code></pre></li> </code></pre>
</li>
</ol> </ol>
. .
If the *first* block in the list item is an indented code block, If the *first* block in the list item is an indented code block,
then by rule #2, the contents must be indented *one* space after the then by rule #2, the contents must be indented *one* space after the
list marker: list marker:
. .
indented code indented code
skipping to change at line 2754 skipping to change at line 2779
. .
. .
1. indented code 1. indented code
paragraph paragraph
more code more code
. .
<ol> <ol>
<li><pre><code>indented code <li>
<pre><code>indented code
</code></pre> </code></pre>
<p>paragraph</p> <p>paragraph</p>
<pre><code>more code <pre><code>more code
</code></pre></li> </code></pre>
</li>
</ol> </ol>
. .
Note that an additional space indent is interpreted as space Note that an additional space indent is interpreted as space
inside the code block: inside the code block:
. .
1. indented code 1. indented code
paragraph paragraph
more code more code
. .
<ol> <ol>
<li><pre><code> indented code <li>
<pre><code> indented code
</code></pre> </code></pre>
<p>paragraph</p> <p>paragraph</p>
<pre><code>more code <pre><code>more code
</code></pre></li> </code></pre>
</li>
</ol> </ol>
. .
Note that rules #1 and #2 only apply to two cases: (a) cases Note that rules #1 and #2 only apply to two cases: (a) cases
in which the lines to be included in a list item begin with a nonspace in which the lines to be included in a list item begin with a nonspace
character, and (b) cases in which they begin with an indented code character, and (b) cases in which they begin with an indented code
block. In a case like the following, where the first block begins with block. In a case like the following, where the first block begins with
a three-space indent, the rules do not allow us to form a list item by a three-space indent, the rules do not allow us to form a list item by
indenting the whole thing and prepending a list marker: indenting the whole thing and prepending a list marker:
skipping to change at line 2819 skipping to change at line 2848
with 1-3 spaces indent, the indentation can always be removed without with 1-3 spaces indent, the indentation can always be removed without
a change in interpretation, allowing rule #1 to be applied. So, in a change in interpretation, allowing rule #1 to be applied. So, in
the above case: the above case:
. .
- foo - foo
bar bar
. .
<ul> <ul>
<li><p>foo</p> <li>
<p>bar</p></li> <p>foo</p>
<p>bar</p>
</li>
</ul> </ul>
. .
3. **Indentation.** If a sequence of lines *Ls* constitutes a list item 3. **Indentation.** If a sequence of lines *Ls* constitutes a list item
according to rule #1 or #2, then the result of indenting each line according to rule #1 or #2, then the result of indenting each line
of *L* by 1-3 spaces (the same for each line) also constitutes a of *L* by 1-3 spaces (the same for each line) also constitutes a
list item with the same contents and attributes. If a line is list item with the same contents and attributes. If a line is
empty, then it need not be indented. empty, then it need not be indented.
Indented one space: Indented one space:
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
> A block quote. > A block quote.
. .
<ol> <ol>
<li><p>A paragraph <li>
<p>A paragraph
with two lines.</p> with two lines.</p>
<pre><code>indented code <pre><code>indented code
</code></pre> </code></pre>
<blockquote> <blockquote>
<p>A block quote.</p> <p>A block quote.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
Indented two spaces: Indented two spaces:
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
> A block quote. > A block quote.
. .
<ol> <ol>
<li><p>A paragraph <li>
<p>A paragraph
with two lines.</p> with two lines.</p>
<pre><code>indented code <pre><code>indented code
</code></pre> </code></pre>
<blockquote> <blockquote>
<p>A block quote.</p> <p>A block quote.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
Indented three spaces: Indented three spaces:
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
> A block quote. > A block quote.
. .
<ol> <ol>
<li><p>A paragraph <li>
<p>A paragraph
with two lines.</p> with two lines.</p>
<pre><code>indented code <pre><code>indented code
</code></pre> </code></pre>
<blockquote> <blockquote>
<p>A block quote.</p> <p>A block quote.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
Four spaces indent gives a code block: Four spaces indent gives a code block:
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
skipping to change at line 2933 skipping to change at line 2970
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
indented code indented code
> A block quote. > A block quote.
. .
<ol> <ol>
<li><p>A paragraph <li>
<p>A paragraph
with two lines.</p> with two lines.</p>
<pre><code>indented code <pre><code>indented code
</code></pre> </code></pre>
<blockquote> <blockquote>
<p>A block quote.</p> <p>A block quote.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
. .
Indentation can be partially deleted: Indentation can be partially deleted:
. .
1. A paragraph 1. A paragraph
with two lines. with two lines.
. .
<ol> <ol>
skipping to change at line 2963 skipping to change at line 3002
. .
These examples show how laziness can work in nested structures: These examples show how laziness can work in nested structures:
. .
> 1. > Blockquote > 1. > Blockquote
continued here. continued here.
. .
<blockquote> <blockquote>
<ol> <ol>
<li><blockquote> <li>
<blockquote>
<p>Blockquote <p>Blockquote
continued here.</p> continued here.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
</blockquote> </blockquote>
. .
. .
> 1. > Blockquote > 1. > Blockquote
> continued here. > continued here.
. .
<blockquote> <blockquote>
<ol> <ol>
<li><blockquote> <li>
<blockquote>
<p>Blockquote <p>Blockquote
continued here.</p> continued here.</p>
</blockquote></li> </blockquote>
</li>
</ol> </ol>
</blockquote> </blockquote>
. .
5. **That's all.** Nothing that is not counted as a list item by rules 5. **That's all.** Nothing that is not counted as a list item by rules
#1--4 counts as a [list item](#list-item). #1--4 counts as a [list item](#list-item).
The rules for sublists follow from the general rules above. A sublist The rules for sublists follow from the general rules above. A sublist
must be indented the same number of spaces a paragraph would need to be must be indented the same number of spaces a paragraph would need to be
in order to be included in the list item. in order to be included in the list item.
skipping to change at line 3005 skipping to change at line 3048
- foo - foo
- bar - bar
- baz - baz
. .
<ul> <ul>
<li>foo <li>foo
<ul> <ul>
<li>bar <li>bar
<ul> <ul>
<li>baz</li> <li>baz</li>
</ul></li> </ul>
</ul></li> </li>
</ul>
</li>
</ul> </ul>
. .
One is not enough: One is not enough:
. .
- foo - foo
- bar - bar
- baz - baz
. .
skipping to change at line 3034 skipping to change at line 3079
Here we need four, because the list marker is wider: Here we need four, because the list marker is wider:
. .
10) foo 10) foo
- bar - bar
. .
<ol start="10"> <ol start="10">
<li>foo <li>foo
<ul> <ul>
<li>bar</li> <li>bar</li>
</ul></li> </ul>
</li>
</ol> </ol>
. .
Three is not enough: Three is not enough:
. .
10) foo 10) foo
- bar - bar
. .
<ol start="10"> <ol start="10">
skipping to change at line 3058 skipping to change at line 3104
<li>bar</li> <li>bar</li>
</ul> </ul>
. .
A list may be the first block in a list item: A list may be the first block in a list item:
. .
- - foo - - foo
. .
<ul> <ul>
<li><ul> <li>
<ul>
<li>foo</li> <li>foo</li>
</ul></li> </ul>
</li>
</ul> </ul>
. .
. .
1. - 2. foo 1. - 2. foo
. .
<ol> <ol>
<li><ul> <li>
<li><ol start="2"> <ul>
<li>
<ol start="2">
<li>foo</li> <li>foo</li>
</ol></li> </ol>
</ul></li> </li>
</ul>
</li>
</ol> </ol>
. .
A list item may be empty: A list item may be empty:
. .
- foo - foo
- -
- bar - bar
. .
skipping to change at line 3107 skipping to change at line 3159
A list item can contain a header: A list item can contain a header:
. .
- # Foo - # Foo
- Bar - Bar
--- ---
baz baz
. .
<ul> <ul>
<li><h1>Foo</h1></li> <li>
<li><h2>Bar</h2> <h1>Foo</h1>
<p>baz</p></li> </li>
<li>
<h2>Bar</h2>
baz</li>
</ul> </ul>
. .
### Motivation ### Motivation
John Gruber's Markdown spec says the following about list items: John Gruber's Markdown spec says the following about list items:
1. "List markers typically start at the left margin, but may be indented 1. "List markers typically start at the left margin, but may be indented
by up to three spaces. List markers must be followed by one or more by up to three spaces. List markers must be followed by one or more
spaces or a tab." spaces or a tab."
skipping to change at line 3204 skipping to change at line 3259
<p>bar</p> <p>bar</p>
<ul> <ul>
<li>baz</li> <li>baz</li>
</ul> </ul>
``` ```
as the four-space rule demands, rather than a single list, as the four-space rule demands, rather than a single list,
``` html ``` html
<ul> <ul>
<li><p>foo</p> <li>
<p>foo</p>
<p>bar</p> <p>bar</p>
<ul> <ul>
<li>baz</li> <li>baz</li>
</ul></li> </ul>
</li>
</ul> </ul>
``` ```
The choice of four spaces is arbitrary. It can be learned, but it is The choice of four spaces is arbitrary. It can be learned, but it is
not likely to be guessed, and it trips up beginners regularly. not likely to be guessed, and it trips up beginners regularly.
Would it help to adopt a two-space rule? The problem is that such Would it help to adopt a two-space rule? The problem is that such
a rule, together with the rule allowing 1--3 spaces indentation of the a rule, together with the rule allowing 1--3 spaces indentation of the
initial list marker, allows text that is indented *less than* the initial list marker, allows text that is indented *less than* the
original list marker to be included in the list item. For example, original list marker to be included in the list item. For example,
skipping to change at line 3231 skipping to change at line 3288
``` markdown ``` markdown
- one - one
two two
``` ```
as a single list item, with `two` a continuation paragraph: as a single list item, with `two` a continuation paragraph:
``` html ``` html
<ul> <ul>
<li><p>one</p> <li>
<p>two</p></li> <p>one</p>
<p>two</p>
</li>
</ul> </ul>
``` ```
and similarly and similarly
``` markdown ``` markdown
> - one > - one
> >
> two > two
``` ```
as as
``` html ``` html
<blockquote> <blockquote>
<ul> <ul>
<li><p>one</p> <li>
<p>two</p></li> <p>one</p>
<p>two</p>
</li>
</ul> </ul>
</blockquote> </blockquote>
``` ```
This is extremely unintuitive. This is extremely unintuitive.
Rather than requiring a fixed indent from the margin, we could require Rather than requiring a fixed indent from the margin, we could require
a fixed indent (say, two spaces, or even one space) from the list marker (which a fixed indent (say, two spaces, or even one space) from the list marker (which
may itself be indented). This proposal would remove the last anomaly may itself be indented). This proposal would remove the last anomaly
discussed. Unlike the spec presented above, it would count the following discussed. Unlike the spec presented above, it would count the following
skipping to change at line 3447 skipping to change at line 3508
a list: a list:
. .
- foo - foo
- bar - bar
- baz - baz
. .
<ul> <ul>
<li><p>foo</p></li> <li>
<li><p>bar</p></li> <p>foo</p>
</li>
<li>
<p>bar</p>
</li>
</ul> </ul>
<ul> <ul>
<li>baz</li> <li>baz</li>
</ul> </ul>
. .
As illustrated above in the section on [list items](#list-item), As illustrated above in the section on [list items](#list-item),
two blank lines between blocks *within* a list item will also end a two blank lines between blocks *within* a list item will also end a
list: list:
skipping to change at line 3489 skipping to change at line 3554
- baz - baz
bim bim
. .
<ul> <ul>
<li>foo <li>foo
<ul> <ul>
<li>bar <li>bar
<ul> <ul>
<li>baz</li> <li>baz</li>
</ul></li> </ul>
</ul></li> </li>
</ul>
</li>
</ul> </ul>
<pre><code> bim <pre><code> bim
</code></pre> </code></pre>
. .
Thus, two blank lines can be used to separate consecutive lists of Thus, two blank lines can be used to separate consecutive lists of
the same type, or to separate a list from an indented code block the same type, or to separate a list from an indented code block
that would otherwise be parsed as a subparagraph of the final list that would otherwise be parsed as a subparagraph of the final list
item: item:
skipping to change at line 3528 skipping to change at line 3595
. .
- foo - foo
notcode notcode
- foo - foo
code code
. .
<ul> <ul>
<li><p>foo</p> <li>
<p>notcode</p></li> <p>foo</p>
<li><p>foo</p></li> <p>notcode</p>
</li>
<li>
<p>foo</p>
</li>
</ul> </ul>
<pre><code>code <pre><code>code
</code></pre> </code></pre>
. .
List items need not be indented to the same level. The following List items need not be indented to the same level. The following
list items will be treated as items at the same list level, list items will be treated as items at the same list level,
since none is indented enough to belong to the previous list since none is indented enough to belong to the previous list
item: item:
skipping to change at line 3571 skipping to change at line 3642
This is a loose list, because there is a blank line between This is a loose list, because there is a blank line between
two of the list items: two of the list items:
. .
- a - a
- b - b
- c - c
. .
<ul> <ul>
<li><p>a</p></li> <li>
<li><p>b</p></li> <p>a</p>
<li><p>c</p></li> </li>
<li>
<p>b</p>
</li>
<li>
<p>c</p>
</li>
</ul> </ul>
. .
So is this, with a empty second item: So is this, with a empty second item:
. .
* a * a
* *
* c * c
. .
<ul> <ul>
<li><p>a</p></li> <li>
<p>a</p>
</li>
<li></li> <li></li>
<li><p>c</p></li> <li>
<p>c</p>
</li>
</ul> </ul>
. .
These are loose lists, even though there is no space between the items, These are loose lists, even though there is no space between the items,
because one of the items directly contains two block-level elements because one of the items directly contains two block-level elements
with a blank line between them: with a blank line between them:
. .
- a - a
- b - b
c c
- d - d
. .
<ul> <ul>
<li><p>a</p></li> <li>
<li><p>b</p> <p>a</p>
<p>c</p></li> </li>
<li><p>d</p></li> <li>
<p>b</p>
<p>c</p>
</li>
<li>
<p>d</p>
</li>
</ul> </ul>
. .
. .
- a - a
- b - b
[ref]: /url [ref]: /url
- d - d
. .
<ul> <ul>
<li><p>a</p></li> <li>
<li><p>b</p></li> <p>a</p>
<li><p>d</p></li> </li>
<li>
<p>b</p>
</li>
<li>
<p>d</p>
</li>
</ul> </ul>
. .
This is a tight list, because the blank lines are in a code block: This is a tight list, because the blank lines are in a code block:
. .
- a - a
- ``` - ```
b b
``` ```
- c - c
. .
<ul> <ul>
<li>a</li> <li>a</li>
<li><pre><code>b <li>
<pre><code>b
</code></pre></li> </code></pre>
</li>
<li>c</li> <li>c</li>
</ul> </ul>
. .
This is a tight list, because the blank line is between two This is a tight list, because the blank line is between two
paragraphs of a sublist. So the sublist is loose while paragraphs of a sublist. So the sublist is loose while
the outer list is tight: the outer list is tight:
. .
- a - a
- b - b
c c
- d - d
. .
<ul> <ul>
<li>a <li>a
<ul> <ul>
<li><p>b</p> <li>
<p>c</p></li> <p>b</p>
</ul></li> <p>c</p>
</li>
</ul>
</li>
<li>d</li> <li>d</li>
</ul> </ul>
. .
This is a tight list, because the blank line is inside the This is a tight list, because the blank line is inside the
block quote: block quote:
. .
* a * a
> b > b
> >
* c * c
. .
<ul> <ul>
<li>a <li>a
<blockquote> <blockquote>
<p>b</p> <p>b</p>
</blockquote></li> </blockquote>
</li>
<li>c</li> <li>c</li>
</ul> </ul>
. .
This list is tight, because the consecutive block elements This list is tight, because the consecutive block elements
are not separated by blank lines: are not separated by blank lines:
. .
- a - a
> b > b
skipping to change at line 3700 skipping to change at line 3799
c c
``` ```
- d - d
. .
<ul> <ul>
<li>a <li>a
<blockquote> <blockquote>
<p>b</p> <p>b</p>
</blockquote> </blockquote>
<pre><code>c <pre><code>c
</code></pre></li> </code></pre>
</li>
<li>d</li> <li>d</li>
</ul> </ul>
. .
A single-paragraph list is tight: A single-paragraph list is tight:
. .
- a - a
. .
<ul> <ul>
skipping to change at line 3723 skipping to change at line 3823
. .
. .
- a - a
- b - b
. .
<ul> <ul>
<li>a <li>a
<ul> <ul>
<li>b</li> <li>b</li>
</ul></li> </ul>
</li>
</ul> </ul>
. .
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><p>foo</p> <li>
<p>foo</p>
<ul> <ul>
<li>bar</li> <li>bar</li>
</ul> </ul>
<p>baz</p></li> <p>baz</p>
</li>
</ul> </ul>
. .
. .
- a - a
- b - b
- c - c
- d - d
- e - e
- f - f
. .
<ul> <ul>
<li><p>a</p> <li>
<p>a</p>
<ul> <ul>
<li>b</li> <li>b</li>
<li>c</li> <li>c</li>
</ul></li> </ul>
<li><p>d</p> </li>
<li>
<p>d</p>
<ul> <ul>
<li>e</li> <li>e</li>
<li>f</li> <li>f</li>
</ul></li> </ul>
</li>
</ul> </ul>
. .
# Inlines # Inlines
Inlines are parsed sequentially from the beginning of the character Inlines are parsed sequentially from the beginning of the character
stream to the end (left to right, in left-to-right languages). stream to the end (left to right, in left-to-right languages).
Thus, for example, in Thus, for example, in
. .
skipping to change at line 5766 skipping to change at line 5873
The link labels are case-insensitive: The link labels are case-insensitive:
. .
[Foo] [Foo]
[foo]: /url "title" [foo]: /url "title"
. .
<p><a href="/url" title="title">Foo</a></p> <p><a href="/url" title="title">Foo</a></p>
. .
A space after the link text should be preserved:
.
[foo] bar
[foo]: /url
.
<p><a href="/url">foo</a> bar</p>
.
If you just want bracketed text, you can backslash-escape the If you just want bracketed text, you can backslash-escape the
opening bracket to avoid links: opening bracket to avoid links:
. .
\[foo] \[foo]
[foo]: /url "title" [foo]: /url "title"
. .
<p>[foo]</p> <p>[foo]</p>
. .
skipping to change at line 6600 skipping to change at line 6717
<p>foo <p>foo
baz</p> baz</p>
. .
A conforming parser may render a soft line break in HTML either as a A conforming parser may render a soft line break in HTML either as a
line break or as a space. line break or as a space.
A renderer may also provide an option to render soft line breaks A renderer may also provide an option to render soft line breaks
as hard line breaks. as hard line breaks.
## Strings ## Textual content
Any characters not given an interpretation by the above rules will Any characters not given an interpretation by the above rules will
be parsed as string content. be parsed as plain textual content.
. .
hello $.;'there hello $.;'there
. .
<p>hello $.;'there</p> <p>hello $.;'there</p>
. .
. .
Foo χρῆν Foo χρῆν
. .
 End of changes. 69 change blocks. 
95 lines changed or deleted 212 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/