Browse Source

Update CommonMark spec to 0.26

pull/293/head
Alex Kocharin 8 years ago
parent
commit
ffd30efe99
  1. 352
      test/fixtures/commonmark/bad.txt
  2. 1512
      test/fixtures/commonmark/good.txt
  3. 528
      test/fixtures/commonmark/spec.txt

352
test/fixtures/commonmark/bad.txt

@ -0,0 +1,352 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 387
.
- foo
bar
.
<ul>
<li>
<p>foo</p>
<pre><code> bar
</code></pre>
</li>
</ul>
.
error:
<ul>
<li>
<p>foo</p>
<pre><code>bar
</code></pre>
</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 410
.
> foo
.
<blockquote>
<pre><code> foo
</code></pre>
</blockquote>
.
error:
<blockquote>
<pre><code> foo
</code></pre>
</blockquote>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 419
.
- foo
.
<ul>
<li>
<pre><code> foo
</code></pre>
</li>
</ul>
.
error:
<ul>
<li>
<pre><code>foo
</code></pre>
</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 458
.
# Foo
.
<h1>Foo</h1>
.
error:
<p># Foo</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3821
.
- foo
bar
.
<ul>
<li>
<p>foo</p>
<p>bar</p>
</li>
</ul>
.
error:
<ul>
<li>foo</li>
</ul>
<p>bar</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 3866
.
- Foo
bar
baz
.
<ul>
<li>
<p>Foo</p>
<pre><code>bar
baz
</code></pre>
</li>
</ul>
.
error:
<ul>
<li>
<p>Foo</p>
<pre><code>bar
</code></pre>
</li>
</ul>
<pre><code> baz
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4214
.
foo
*
foo
1.
.
<p>foo
*</p>
<p>foo
1.</p>
.
error:
<p>foo</p>
<ul>
<li></li>
</ul>
<p>foo</p>
<ol>
<li></li>
</ol>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4866
.
The number of windows in my house is
14. The number of doors is 6.
.
<p>The number of windows in my house is
14. The number of doors is 6.</p>
.
error:
<p>The number of windows in my house is</p>
<ol start="14">
<li>The number of doors is 6.</li>
</ol>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4890
.
- foo
- bar
- baz
.
<ul>
<li>
<p>foo</p>
</li>
<li>
<p>bar</p>
</li>
<li>
<p>baz</p>
</li>
</ul>
.
error:
<ul>
<li>
<p>foo</p>
</li>
<li>
<p>bar</p>
</li>
</ul>
<ul>
<li>baz</li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 4911
.
- foo
- bar
- baz
bim
.
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>
<p>baz</p>
<p>bim</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
.
error:
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>baz</li>
</ul>
</li>
</ul>
</li>
</ul>
<pre><code> bim
</code></pre>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 6137
.
*foo bar
*
.
<p>*foo bar
*</p>
.
error:
<p>*foo bar</p>
<ul>
<li></li>
</ul>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 6546
.
*foo**bar**baz*
.
<p><em>foo<strong>bar</strong>baz</em></p>
.
error:
<p><em>foo</em><em>bar</em><em>baz</em></p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 6585
.
*foo**bar***
.
<p><em>foo<strong>bar</strong></em></p>
.
error:
<p><em>foo</em><em>bar</em>**</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 6592
.
*foo**bar***
.
<p><em>foo<strong>bar</strong></em></p>
.
error:
<p><em>foo</em><em>bar</em>**</p>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src line: 6690
.
**foo*bar*baz**
.
<p><strong>foo<em>bar</em>baz</strong></p>
.
error:
<p><em><em>foo</em>bar</em>baz**</p>

1512
test/fixtures/commonmark/good.txt

File diff suppressed because it is too large

528
test/fixtures/commonmark/spec.txt

@ -1,8 +1,8 @@
--- ---
title: CommonMark Spec title: CommonMark Spec
author: John MacFarlane author: John MacFarlane
version: 0.24 version: 0.26
date: '2015-01-12' date: '2016-07-15'
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/)'
... ...
@ -13,12 +13,90 @@ license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
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
widely used in websites. By 2014 there were dozens of ubiquitous. In the next decade, dozens of implementations were
implementations in many languages. Some of them extended basic developed in many languages. Some extended the original
Markdown syntax with conventions for footnotes, definition lists, Markdown syntax with conventions for footnotes, tables, and
tables, and other constructs, and some allowed output not just in other document elements. Some allowed Markdown documents to be
HTML but in LaTeX and many other formats. rendered in formats other than HTML. Websites like Reddit,
StackOverflow, and GitHub had millions of people using Markdown.
And Markdown started to be used beyond the web, to author books,
articles, slide shows, letters, and lecture notes.
What distinguishes Markdown from many other lightweight markup
syntaxes, which are often easier to write, is its readability.
As Gruber writes:
> The overriding design goal for Markdown's formatting syntax is
> to make it as readable as possible. The idea is that 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.
> (<http://daringfireball.net/projects/markdown/>)
The point can be illustrated by comparing a sample of
[AsciiDoc](http://www.methods.co.nz/asciidoc/) with
an equivalent sample of Markdown. Here is a sample of
AsciiDoc from the AsciiDoc manual:
```
1. List item one.
+
List item one continued with a second paragraph followed by an
Indented block.
+
.................
$ ls *.sh
$ mv *.sh ~/tmp
.................
+
List item continued with a third paragraph.
2. List item two continued with an open block.
+
--
This paragraph is part of the preceding list item.
a. This list is nested and does not require explicit item
continuation.
+
This paragraph is part of the preceding list item.
b. List item b.
This paragraph belongs to item two of the outer list.
--
```
And here is the equivalent in Markdown:
```
1. List item one.
List item one continued with a second paragraph followed by an
Indented block.
$ ls *.sh
$ mv *.sh ~/tmp
List item continued with a third paragraph.
2. List item two continued with an open block.
This paragraph is part of the preceding list item.
1. This list is nested and does not require explicit item continuation.
This paragraph is part of the preceding list item.
2. List item b.
This paragraph belongs to item two of the outer list.
```
The AsciiDoc version is, arguably, easier to write. You don't need
to worry about indentation. But the Markdown version is much easier
to read. The nesting of list items is apparent to the eye in the
source, not just in the processed document.
## Why is a spec needed? ## Why is a spec needed?
@ -258,9 +336,14 @@ the Unicode classes `Pc`, `Pd`, `Pe`, `Pf`, `Pi`, `Po`, or `Ps`.
## Tabs ## Tabs
Tabs in lines are not expanded to [spaces]. However, Tabs in lines are not expanded to [spaces]. However,
in contexts where indentation is significant for the in contexts where whitespace helps to define block structure,
document's structure, tabs behave as if they were replaced tabs behave as if they were replaced by spaces with a tab stop
by spaces with a tab stop of 4 characters. of 4 characters.
Thus, for example, a tab can be used instead of four spaces
in an indented code block. (Note, however, that internal
tabs are passed through as literal tabs, not expanded to
spaces.)
```````````````````````````````` example ```````````````````````````````` example
→foo→baz→→bim →foo→baz→→bim
@ -269,7 +352,6 @@ by spaces with a tab stop of 4 characters.
</code></pre> </code></pre>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example ```````````````````````````````` example
→foo→baz→→bim →foo→baz→→bim
. .
@ -277,7 +359,6 @@ by spaces with a tab stop of 4 characters.
</code></pre> </code></pre>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example ```````````````````````````````` example
a→a a→a
ὐ→a ὐ→a
@ -287,6 +368,9 @@ by spaces with a tab stop of 4 characters.
</code></pre> </code></pre>
```````````````````````````````` ````````````````````````````````
In the following example, a continuation paragraph of a list
item is indented with a tab; this has exactly the same effect
as indentation with four spaces would:
```````````````````````````````` example ```````````````````````````````` example
- foo - foo
@ -301,15 +385,49 @@ by spaces with a tab stop of 4 characters.
</ul> </ul>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example
- foo
→→bar
.
<ul>
<li>
<p>foo</p>
<pre><code> bar
</code></pre>
</li>
</ul>
````````````````````````````````
Normally the `>` that begins a block quote may be followed
optionally by a space, which is not considered part of the
content. In the following case `>` is followed by a tab,
which is treated as if it were expanded into spaces.
Since one of theses spaces is considered part of the
delimiter, `foo` is considered to be indented six spaces
inside the block quote context, so we get an indented
code block starting with two spaces.
```````````````````````````````` example ```````````````````````````````` example
>→foo→bar >→foo
. .
<blockquote> <blockquote>
<p>foo→bar</p> <pre><code> foo
</code></pre>
</blockquote> </blockquote>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example
-→→foo
.
<ul>
<li>
<pre><code> foo
</code></pre>
</li>
</ul>
````````````````````````````````
```````````````````````````````` example ```````````````````````````````` example
foo foo
@ -320,6 +438,35 @@ bar
</code></pre> </code></pre>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example
- foo
- bar
→ - baz
.
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>baz</li>
</ul>
</li>
</ul>
</li>
</ul>
````````````````````````````````
```````````````````````````````` example
#→Foo
.
<h1>Foo</h1>
````````````````````````````````
```````````````````````````````` example
*→*→*→
.
<hr />
````````````````````````````````
## Insecure characters ## Insecure characters
@ -658,15 +805,6 @@ headings:
```````````````````````````````` ````````````````````````````````
A tab will not work:
```````````````````````````````` example
#→foo
.
<p>#→foo</p>
````````````````````````````````
This is not a heading, because the first `#` is escaped: This is not a heading, because the first `#` is escaped:
```````````````````````````````` example ```````````````````````````````` example
@ -1204,7 +1342,7 @@ bar</p>
or use a thematic break that cannot count as a [setext heading or use a thematic break that cannot count as a [setext heading
line], such as underline], such as
```````````````````````````````` example ```````````````````````````````` example
Foo Foo
@ -1847,7 +1985,7 @@ by their start and end conditions. The block begins with a line that
meets a [start condition](@) (after up to three spaces meets a [start condition](@) (after up to three spaces
optional indentation). It ends with the first subsequent line that optional indentation). It ends with the first subsequent line that
meets a matching [end condition](@), or the last line of meets a matching [end condition](@), or the last line of
the document, if no line is encountered that meets the the document or other [container block](@), if no line is encountered that meets the
[end condition]. If the first line meets both the [start condition] [end condition]. If the first line meets both the [start condition]
and the [end condition], the block will contain just that line. and the [end condition], the block will contain just that line.
@ -2181,6 +2319,7 @@ import Text.HTML.TagSoup
main :: IO () main :: IO ()
main = print $ parseTags tags main = print $ parseTags tags
</code></pre> </code></pre>
okay
. .
<pre language="haskell"><code> <pre language="haskell"><code>
import Text.HTML.TagSoup import Text.HTML.TagSoup
@ -2188,6 +2327,7 @@ import Text.HTML.TagSoup
main :: IO () main :: IO ()
main = print $ parseTags tags main = print $ parseTags tags
</code></pre> </code></pre>
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -2199,12 +2339,14 @@ A script tag (type 1):
document.getElementById("demo").innerHTML = "Hello JavaScript!"; document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> </script>
okay
. .
<script type="text/javascript"> <script type="text/javascript">
// JavaScript example // JavaScript example
document.getElementById("demo").innerHTML = "Hello JavaScript!"; document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> </script>
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -2217,6 +2359,7 @@ h1 {color:red;}
p {color:blue;} p {color:blue;}
</style> </style>
okay
. .
<style <style
type="text/css"> type="text/css">
@ -2224,6 +2367,7 @@ h1 {color:red;}
p {color:blue;} p {color:blue;}
</style> </style>
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -2312,11 +2456,13 @@ A comment (type 2):
bar bar
baz --> baz -->
okay
. .
<!-- Foo <!-- Foo
bar bar
baz --> baz -->
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -2329,12 +2475,14 @@ A processing instruction (type 3):
echo '>'; echo '>';
?> ?>
okay
. .
<?php <?php
echo '>'; echo '>';
?> ?>
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -2362,6 +2510,7 @@ function matchwo(a,b)
} }
} }
]]> ]]>
okay
. .
<![CDATA[ <![CDATA[
function matchwo(a,b) function matchwo(a,b)
@ -2375,6 +2524,7 @@ function matchwo(a,b)
} }
} }
]]> ]]>
<p>okay</p>
```````````````````````````````` ````````````````````````````````
@ -3119,8 +3269,8 @@ Four spaces gives us a code block:
```````````````````````````````` ````````````````````````````````
The Laziness clause allows us to omit the `>` before a The Laziness clause allows us to omit the `>` before
paragraph continuation line: [paragraph continuation text]:
```````````````````````````````` example ```````````````````````````````` example
> # Foo > # Foo
@ -3226,8 +3376,8 @@ foo
```````````````````````````````` ````````````````````````````````
Note that in the following case, we have a paragraph Note that in the following case, we have a [lazy
continuation line: continuation line]:
```````````````````````````````` example ```````````````````````````````` example
> foo > foo
@ -3249,7 +3399,7 @@ To see why, note that in
the `- bar` is indented too far to start a list, and can't the `- bar` is indented too far to start a list, and can't
be an indented code block because indented code blocks cannot be an indented code block because indented code blocks cannot
interrupt paragraphs, so it is a [paragraph continuation line]. interrupt paragraphs, so it is [paragraph continuation text].
A block quote can be empty: A block quote can be empty:
@ -3478,7 +3628,7 @@ The following rules define [list items]:
1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of 1. **Basic case.** If a sequence of lines *Ls* constitute a sequence of
blocks *Bs* starting with a [non-whitespace character] and not separated blocks *Bs* starting with a [non-whitespace character] and not separated
from each other by more than one blank line, and *M* is a list from each other by more than one blank line, and *M* is a list
marker of width *W* followed by 0 < *N* < 5 spaces, then the result marker of width *W* followed by 1 ≤ *N* ≤ 4 spaces, then the result
of prepending *M* and the following spaces to the first line of of prepending *M* and the following spaces to the first line of
*Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a *Ls*, and indenting subsequent lines of *Ls* by *W + N* spaces, is a
list item with *Bs* as its contents. The type of the list item list item with *Bs* as its contents. The type of the list item
@ -3486,6 +3636,12 @@ The following rules define [list items]:
If the list item is ordered, then it is also assigned a start If the list item is ordered, then it is also assigned a start
number, based on the ordered list marker. number, based on the ordered list marker.
Exceptions: When the list item interrupts a paragraph---that
is, when it starts on a line that would otherwise count as
[paragraph continuation text]---then (a) the lines *Ls* must
not begin with a blank line, and (b) if the list item is
ordered, the start number must be 1.
For example, let *Ls* be the lines For example, let *Ls* be the lines
```````````````````````````````` example ```````````````````````````````` example
@ -3660,66 +3816,20 @@ any following content, so these are not list items:
```````````````````````````````` ````````````````````````````````
A list item may not contain blocks that are separated by more than A list item may contain blocks that are separated by more than
one blank line. Thus, two blank lines will end a list, unless the one blank line.
two blanks are contained in a [fenced code block].
```````````````````````````````` example ```````````````````````````````` example
- foo
bar
- foo - foo
bar bar
- ```
foo
bar
```
- baz
+ ```
foo
bar
```
. .
<ul> <ul>
<li> <li>
<p>foo</p> <p>foo</p>
<p>bar</p> <p>bar</p>
</li> </li>
<li>
<p>foo</p>
</li>
</ul>
<p>bar</p>
<ul>
<li>
<pre><code>foo
bar
</code></pre>
</li>
<li>
<p>baz</p>
<ul>
<li>
<pre><code>foo
bar
</code></pre>
</li>
</ul>
</li>
</ul> </ul>
```````````````````````````````` ````````````````````````````````
@ -3752,15 +3862,14 @@ A list item may contain any kind of block:
A list item that contains an indented code block will preserve A list item that contains an indented code block will preserve
empty lines within the code block verbatim, unless there are two empty lines within the code block verbatim.
or more empty lines in a row (since as described above, two
blank lines end the list):
```````````````````````````````` example ```````````````````````````````` example
- Foo - Foo
bar bar
baz baz
. .
<ul> <ul>
@ -3768,33 +3877,13 @@ blank lines end the list):
<p>Foo</p> <p>Foo</p>
<pre><code>bar <pre><code>bar
baz
</code></pre>
</li>
</ul>
````````````````````````````````
```````````````````````````````` example
- Foo
bar baz
baz
.
<ul>
<li>
<p>Foo</p>
<pre><code>bar
</code></pre> </code></pre>
</li> </li>
</ul> </ul>
<pre><code> baz
</code></pre>
```````````````````````````````` ````````````````````````````````
Note that ordered list start numbers must be nine digits or less: Note that ordered list start numbers must be nine digits or less:
```````````````````````````````` example ```````````````````````````````` example
@ -4037,6 +4126,18 @@ Here are some list items that start with a blank line but are not empty:
</ul> </ul>
```````````````````````````````` ````````````````````````````````
When the list item starts with a blank line, the number of spaces
following the list marker doesn't change the required indentation:
```````````````````````````````` example
-
foo
.
<ul>
<li>foo</li>
</ul>
````````````````````````````````
A list item can begin with at most one blank line. A list item can begin with at most one blank line.
In the following example, `foo` is not part of the list In the following example, `foo` is not part of the list
@ -4109,6 +4210,20 @@ A list may start or end with an empty list item:
</ul> </ul>
```````````````````````````````` ````````````````````````````````
However, an empty list item cannot interrupt a paragraph:
```````````````````````````````` example
foo
*
foo
1.
.
<p>foo
*</p>
<p>foo
1.</p>
````````````````````````````````
4. **Indentation.** If a sequence of lines *Ls* constitutes a list item 4. **Indentation.** If a sequence of lines *Ls* constitutes a list item
@ -4306,13 +4421,18 @@ So, in this case we need two spaces indent:
- foo - foo
- bar - bar
- baz - baz
- boo
. .
<ul> <ul>
<li>foo <li>foo
<ul> <ul>
<li>bar <li>bar
<ul> <ul>
<li>baz</li> <li>baz
<ul>
<li>boo</li>
</ul>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -4327,11 +4447,13 @@ One is not enough:
- foo - foo
- bar - bar
- baz - baz
- boo
. .
<ul> <ul>
<li>foo</li> <li>foo</li>
<li>bar</li> <li>bar</li>
<li>baz</li> <li>baz</li>
<li>boo</li>
</ul> </ul>
```````````````````````````````` ````````````````````````````````
@ -4684,28 +4806,20 @@ Foo
</ul> </ul>
```````````````````````````````` ````````````````````````````````
`Markdown.pl` does not allow this, through fear of triggering a list `Markdown.pl` does not allow this, through fear of triggering a list
via a numeral in a hard-wrapped line: via a numeral in a hard-wrapped line:
```````````````````````````````` example ```````````````````````````````` markdown
The number of windows in my house is The number of windows in my house is
14. The number of doors is 6. 14. The number of doors is 6.
.
<p>The number of windows in my house is</p>
<ol start="14">
<li>The number of doors is 6.</li>
</ol>
```````````````````````````````` ````````````````````````````````
Oddly, though, `Markdown.pl` *does* allow a blockquote to
interrupt a paragraph, even though the same considerations might
apply.
In CommonMark, we do allow lists to interrupt paragraphs, for
Oddly, `Markdown.pl` *does* allow a blockquote to interrupt a paragraph, two reasons. First, it is natural and not uncommon for people
even though the same considerations might apply. We think that the two to start lists without blank lines:
cases should be treated the same. Here are two reasons for allowing
lists to interrupt paragraphs:
First, it is natural and not uncommon for people to start lists without
blank lines:
I need to buy I need to buy
- new shoes - new shoes
@ -4739,20 +4853,40 @@ then
by itself should be a paragraph followed by a nested sublist. by itself should be a paragraph followed by a nested sublist.
Our adherence to the [principle of uniformity] Since it is well established Markdown practice to allow lists to
thus inclines us to think that there are two coherent packages: interrupt paragraphs inside list items, the [principle of
uniformity] requires us to allow this outside list items as
well. ([reStructuredText](http://docutils.sourceforge.net/rst.html)
takes a different approach, requiring blank lines before lists
even inside other list items.)
1. Require blank lines before *all* lists and blockquotes, In order to solve of unwanted lists in paragraphs with
including lists that occur as sublists inside other list items. hard-wrapped numerals, we allow only lists starting with `1` to
interrupt paragraphs. Thus,
2. Require blank lines in none of these places. ```````````````````````````````` example
The number of windows in my house is
14. The number of doors is 6.
.
<p>The number of windows in my house is
14. The number of doors is 6.</p>
````````````````````````````````
[reStructuredText](http://docutils.sourceforge.net/rst.html) takes We may still get an unintended result in cases like
the first approach, for which there is much to be said. But the second
seems more consistent with established practice with Markdown.
There can be blank lines between items, but two blank lines end ```````````````````````````````` example
a list: The number of windows in my house is
1. The number of doors is 6.
.
<p>The number of windows in my house is</p>
<ol>
<li>The number of doors is 6.</li>
</ol>
````````````````````````````````
but this rule should prevent most spurious list captures.
There can be any number of blank lines between items:
```````````````````````````````` example ```````````````````````````````` example
- foo - foo
@ -4769,36 +4903,12 @@ a list:
<li> <li>
<p>bar</p> <p>bar</p>
</li> </li>
</ul> <li>
<ul> <p>baz</p>
<li>baz</li> </li>
</ul> </ul>
```````````````````````````````` ````````````````````````````````
As illustrated above in the section on [list items],
two blank lines between blocks *within* a list item will also end a
list:
```````````````````````````````` example
- foo
bar
- baz
.
<ul>
<li>foo</li>
</ul>
<p>bar</p>
<ul>
<li>baz</li>
</ul>
````````````````````````````````
Indeed, two blank lines will end *all* containing lists:
```````````````````````````````` example ```````````````````````````````` example
- foo - foo
- bar - bar
@ -4812,26 +4922,28 @@ Indeed, two blank lines will end *all* containing lists:
<ul> <ul>
<li>bar <li>bar
<ul> <ul>
<li>baz</li> <li>
<p>baz</p>
<p>bim</p>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>
</li> </li>
</ul> </ul>
<pre><code> bim
</code></pre>
```````````````````````````````` ````````````````````````````````
Thus, two blank lines can be used to separate consecutive lists of To separate consecutive lists of the same type, or to separate a
the same type, or to separate a list from an indented code block list from an indented code block that would otherwise be parsed
that would otherwise be parsed as a subparagraph of the final list as a subparagraph of the final list item, you can insert a blank HTML
item: comment:
```````````````````````````````` example ```````````````````````````````` example
- foo - foo
- bar - bar
<!-- -->
- baz - baz
- bim - bim
@ -4840,6 +4952,7 @@ item:
<li>foo</li> <li>foo</li>
<li>bar</li> <li>bar</li>
</ul> </ul>
<!-- -->
<ul> <ul>
<li>baz</li> <li>baz</li>
<li>bim</li> <li>bim</li>
@ -4854,6 +4967,7 @@ item:
- foo - foo
<!-- -->
code code
. .
@ -4866,6 +4980,7 @@ item:
<p>foo</p> <p>foo</p>
</li> </li>
</ul> </ul>
<!-- -->
<pre><code>code <pre><code>code
</code></pre> </code></pre>
```````````````````````````````` ````````````````````````````````
@ -5812,18 +5927,22 @@ The following rules define emphasis and strong emphasis:
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. The
be a nonempty sequence of inlines between the open delimiter opening and closing delimiters must belong to separate
and the closing delimiter; these form the contents of the emphasis [delimiter runs]. If one of the delimiters can both
inline. open and close emphasis, then the sum of the lengths of the
delimiter runs containing the opening and closing delimiters
must not be a multiple of 3.
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
[can close strong emphasis], and that uses the same character [can close strong emphasis], and that uses the same character
(`_` or `*`) as the opening delimiter. (`_` or `*`) as the opening delimiter. The
There must be a nonempty sequence of inlines between the open opening and closing delimiters must belong to separate
delimiter and the closing delimiter; these form the contents of [delimiter runs]. If one of the delimiters can both open
the strong emphasis inline. and close strong emphasis, then the sum of the lengths of
the delimiter runs containing the opening and closing
delimiters must not be a multiple of 3.
11. A literal `*` character cannot occur at the beginning or end of 11. A literal `*` character cannot occur at the beginning or end of
`*`-delimited emphasis or `**`-delimited strong emphasis, unless it `*`-delimited emphasis or `**`-delimited strong emphasis, unless it
@ -5847,9 +5966,7 @@ the following principles resolve ambiguity:
so that the second begins before the first ends and ends after so that the second begins before the first ends and ends after
the first ends, the first takes precedence. Thus, for example, the first ends, the first takes precedence. Thus, for example,
`*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather `*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather
than `*foo <em>bar* baz</em>`. For the same reason, than `*foo <em>bar* baz</em>`.
`**foo*bar**` is parsed as `<em><em>foo</em>bar</em>*`
rather than `<strong>foo*bar</strong>`.
16. When there are two potential emphasis or strong emphasis spans 16. When there are two potential emphasis or strong emphasis spans
with the same closing delimiter, the shorter one (the one that with the same closing delimiter, the shorter one (the one that
@ -6022,10 +6139,8 @@ A newline also counts as whitespace:
*foo bar *foo bar
* *
. .
<p>*foo bar</p> <p>*foo bar
<ul> *</p>
<li></li>
</ul>
```````````````````````````````` ````````````````````````````````
@ -6429,18 +6544,30 @@ __foo_ bar_
<p><em>foo <strong>bar</strong> baz</em></p> <p><em>foo <strong>bar</strong> baz</em></p>
```````````````````````````````` ````````````````````````````````
But note:
```````````````````````````````` example ```````````````````````````````` example
*foo**bar**baz* *foo**bar**baz*
. .
<p><em>foo</em><em>bar</em><em>baz</em></p> <p><em>foo<strong>bar</strong>baz</em></p>
```````````````````````````````` ````````````````````````````````
Note that in the preceding case, the interpretation
``` markdown
<p><em>foo</em><em>bar<em></em>baz</em></p>
```
is precluded by the condition that a delimiter that
can both open and close (like the `*` after `foo`
cannot form emphasis if the sum of the lengths of
the delimiter runs containing the opening and
closing delimiters is a multiple of 3.
The same condition ensures that the following
cases are all strong emphasis nested inside
emphasis, even when the interior spaces are
omitted:
The difference is that in the preceding case, the internal delimiters
[can close emphasis], while in the cases with spaces, they cannot.
```````````````````````````````` example ```````````````````````````````` example
***foo** bar* ***foo** bar*
@ -6456,17 +6583,18 @@ The difference is that in the preceding case, the internal delimiters
```````````````````````````````` ````````````````````````````````
Note, however, that in the following case we get no strong
emphasis, because the opening delimiter is closed by the first
`*` before `bar`:
```````````````````````````````` example ```````````````````````````````` example
*foo**bar*** *foo**bar***
. .
<p><em>foo</em><em>bar</em>**</p> <p><em>foo<strong>bar</strong></em></p>
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example
*foo**bar***
.
<p><em>foo<strong>bar</strong></em></p>
````````````````````````````````
Indefinite levels of nesting are possible: Indefinite levels of nesting are possible:
@ -6560,18 +6688,13 @@ ____foo__ bar__
```````````````````````````````` ````````````````````````````````
But note:
```````````````````````````````` example ```````````````````````````````` example
**foo*bar*baz** **foo*bar*baz**
. .
<p><em><em>foo</em>bar</em>baz**</p> <p><strong>foo<em>bar</em>baz</strong></p>
```````````````````````````````` ````````````````````````````````
The difference is that in the preceding case, the internal delimiters
[can close emphasis], while in the cases with spaces, they cannot.
```````````````````````````````` example ```````````````````````````````` example
***foo* bar** ***foo* bar**
. .
@ -6886,13 +7009,6 @@ Rule 15:
```````````````````````````````` ````````````````````````````````
```````````````````````````````` example
**foo*bar**
.
<p><em><em>foo</em>bar</em>*</p>
````````````````````````````````
```````````````````````````````` example ```````````````````````````````` example
*foo __bar *baz bim__ bam* *foo __bar *baz bim__ bam*
. .
@ -7823,7 +7939,7 @@ consists of a [link label] that [matches] a
[link reference definition] elsewhere in the [link reference definition] elsewhere in the
document and is not followed by `[]` or a link label. document and is not followed by `[]` or a link label.
The contents of the first link label are parsed as inlines, The contents of the first link label are parsed as inlines,
which are used as the link's text. the link's URI and title which are used as the link's text. The link's URI and title
are provided by the matching link reference definition. are provided by the matching link reference definition.
Thus, `[foo]` is equivalent to `[foo][]`. Thus, `[foo]` is equivalent to `[foo][]`.
@ -8798,7 +8914,7 @@ foo
A regular line break (not in a code span or HTML tag) that is not A regular line break (not in a code span or HTML tag) that is not
preceded by two or more spaces or a backslash is parsed as a preceded by two or more spaces or a backslash is parsed as a
softbreak. (A softbreak may be rendered in HTML either as a [softbreak](@). (A softbreak may be rendered in HTML either as a
[line ending] or as a space. The result will be the same in [line ending] or as a space. The result will be the same in
browsers. In the examples here, a [line ending] will be used.) browsers. In the examples here, a [line ending] will be used.)
@ -8940,7 +9056,7 @@ This is text that can be incorporated into the last open
block (a paragraph, code block, heading, or raw HTML). block (a paragraph, code block, heading, or raw HTML).
Setext headings are formed when we see a line of a paragraph Setext headings are formed when we see a line of a paragraph
that is a setext heading line. that is a [setext heading underline].
Reference link definitions are detected when a paragraph is closed; Reference link definitions are detected when a paragraph is closed;
the accumulated text lines are parsed to see if they begin with the accumulated text lines are parsed to see if they begin with

Loading…
Cancel
Save