Skip to content

Commit a173d0b

Browse files
committed
Updated spec.
1 parent cf85c76 commit a173d0b

File tree

1 file changed

+84
-25
lines changed

1 file changed

+84
-25
lines changed

test/spec.txt

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: CommonMark Spec
33
author: John MacFarlane
4-
version: 0.19
5-
date: 2015-04-27
4+
version: 0.20
5+
date: 2015-06-08
66
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
77
...
88

@@ -235,7 +235,10 @@ carriage return (`U+000D`), newline (`U+000A`), or form feed
235235
[Unicode whitespace](@unicode-whitespace) is a sequence of one
236236
or more [unicode whitespace character]s.
237237

238-
A [non-space character](@non-space-character) is anything but `U+0020`.
238+
A [space](@space) is `U+0020`.
239+
240+
A [non-space character](@non-space-character) is any character
241+
that is not a [whitespace character].
239242

240243
An [ASCII punctuation character](@ascii-punctuation-character)
241244
is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,
@@ -246,9 +249,10 @@ A [punctuation character](@punctuation-character) is an [ASCII
246249
punctuation character] or anything in
247250
the unicode classes `Pc`, `Pd`, `Pe`, `Pf`, `Pi`, `Po`, or `Ps`.
248251

249-
## Tab expansion
252+
## Preprocessing
250253

251-
Tabs in lines are expanded to spaces, with a tab stop of 4 characters:
254+
Tabs in lines are immediately expanded to [spaces][space], with a tab
255+
stop of 4 characters:
252256

253257
.
254258
→foo→baz→→bim
@@ -274,11 +278,11 @@ with the replacement character (`U+FFFD`).
274278
# Blocks and inlines
275279

276280
We can think of a document as a sequence of
277-
[blocks](@block)---structural
278-
elements like paragraphs, block quotations,
279-
lists, headers, rules, and code blocks. Blocks can contain other
280-
blocks, or they can contain [inline](@inline) content:
281-
words, spaces, links, emphasized text, images, and inline code.
281+
[blocks](@block)---structural elements like paragraphs, block
282+
quotations, lists, headers, rules, and code blocks. Some blocks (like
283+
block quotes and list items) contain other blocks; others (like
284+
headers and paragraphs) contain [inline](@inline) content---text,
285+
links, emphasized text, images, code, and so on.
282286

283287
## Precedence
284288

@@ -529,12 +533,12 @@ consists of a string of characters, parsed as inline content, between an
529533
opening sequence of 1--6 unescaped `#` characters and an optional
530534
closing sequence of any number of `#` characters. The opening sequence
531535
of `#` characters cannot be followed directly by a
532-
[non-space character].
533-
The optional closing sequence of `#`s must be preceded by a space and may be
534-
followed by spaces only. The opening `#` character may be indented 0-3
535-
spaces. The raw contents of the header are stripped of leading and
536-
trailing spaces before being parsed as inline content. The header level
537-
is equal to the number of `#` characters in the opening sequence.
536+
[non-space character]. The optional closing sequence of `#`s must be
537+
preceded by a [space] and may be followed by spaces only. The opening
538+
`#` character may be indented 0-3 spaces. The raw contents of the
539+
header are stripped of leading and trailing spaces before being parsed
540+
as inline content. The header level is equal to the number of `#`
541+
characters in the opening sequence.
538542

539543
Simple headers:
540544

@@ -562,11 +566,13 @@ More than six `#` characters is not a header:
562566
<p>####### foo</p>
563567
.
564568

565-
A space is required between the `#` characters and the header's
566-
contents. Note that many implementations currently do not require
567-
the space. However, the space was required by the [original ATX
568-
implementation](http://www.aaronsw.com/2002/atx/atx.py), and it helps
569-
prevent things like the following from being parsed as headers:
569+
At least one space is required between the `#` characters and the
570+
header's contents, unless the header is empty. Note that many
571+
implementations currently do not require the space. However, the
572+
space was required by the
573+
[original ATX implementation](http://www.aaronsw.com/2002/atx/atx.py),
574+
and it helps prevent things like the following from being parsed as
575+
headers:
570576

571577
.
572578
#5 bolt
@@ -1028,7 +1034,41 @@ paragraph.)
10281034
</code></pre>
10291035
.
10301036

1031-
The contents are literal text, and do not get parsed as Markdown:
1037+
If there is any ambiguity between an interpretation of indentation
1038+
as a code block and as indicating that material belongs to a [list
1039+
item][list items], the list item interpretation takes precedence:
1040+
1041+
.
1042+
- foo
1043+
1044+
bar
1045+
.
1046+
<ul>
1047+
<li>
1048+
<p>foo</p>
1049+
<p>bar</p>
1050+
</li>
1051+
</ul>
1052+
.
1053+
1054+
.
1055+
1. foo
1056+
1057+
- bar
1058+
.
1059+
<ol>
1060+
<li>
1061+
<p>foo</p>
1062+
<ul>
1063+
<li>bar</li>
1064+
</ul>
1065+
</li>
1066+
</ol>
1067+
.
1068+
1069+
1070+
The contents of a code block are literal text, and do not get parsed
1071+
as Markdown:
10321072

10331073
.
10341074
<a/>
@@ -2329,9 +2369,16 @@ foo</p>
23292369
</blockquote>
23302370
.
23312371

2332-
Laziness only applies to lines that are continuations of
2333-
paragraphs. Lines containing characters or indentation that indicate
2334-
block structure cannot be lazy.
2372+
Laziness only applies to lines that would have been continuations of
2373+
paragraphs had they been prepended with `>`. For example, the
2374+
`>` cannot be omitted in the second line of
2375+
2376+
``` markdown
2377+
> foo
2378+
> ---
2379+
```
2380+
2381+
without changing the meaning:
23352382

23362383
.
23372384
> foo
@@ -2343,6 +2390,15 @@ block structure cannot be lazy.
23432390
<hr />
23442391
.
23452392

2393+
Similarly, if we omit the `>` in the second line of
2394+
2395+
``` markdown
2396+
> - foo
2397+
> - bar
2398+
```
2399+
2400+
then the block quote ends after the first line:
2401+
23462402
.
23472403
> - foo
23482404
- bar
@@ -2357,6 +2413,9 @@ block structure cannot be lazy.
23572413
</ul>
23582414
.
23592415

2416+
For the same reason, we can't omit the `>` in front of
2417+
subsequent lines of an indented or fenced code block:
2418+
23602419
.
23612420
> foo
23622421
bar

0 commit comments

Comments
 (0)