1
1
---
2
2
title: CommonMark Spec
3
3
author: John MacFarlane
4
- version: 0.19
5
- date: 2015-04-27
4
+ version: 0.20
5
+ date: 2015-06-08
6
6
license: '[CC-BY-SA 4.0](http://creativecommons.org/licenses/by-sa/4.0/)'
7
7
...
8
8
@@ -235,7 +235,10 @@ carriage return (`U+000D`), newline (`U+000A`), or form feed
235
235
[Unicode whitespace](@unicode-whitespace) is a sequence of one
236
236
or more [unicode whitespace character]s.
237
237
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].
239
242
240
243
An [ASCII punctuation character](@ascii-punctuation-character)
241
244
is `!`, `"`, `#`, `$`, `%`, `&`, `'`, `(`, `)`,
@@ -246,9 +249,10 @@ A [punctuation character](@punctuation-character) is an [ASCII
246
249
punctuation character] or anything in
247
250
the unicode classes `Pc`, `Pd`, `Pe`, `Pf`, `Pi`, `Po`, or `Ps`.
248
251
249
- ## Tab expansion
252
+ ## Preprocessing
250
253
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:
252
256
253
257
.
254
258
→foo→baz→→bim
@@ -274,11 +278,11 @@ with the replacement character (`U+FFFD`).
274
278
# Blocks and inlines
275
279
276
280
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 .
282
286
283
287
## Precedence
284
288
@@ -529,12 +533,12 @@ consists of a string of characters, parsed as inline content, between an
529
533
opening sequence of 1--6 unescaped `#` characters and an optional
530
534
closing sequence of any number of `#` characters. The opening sequence
531
535
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.
538
542
539
543
Simple headers:
540
544
@@ -562,11 +566,13 @@ More than six `#` characters is not a header:
562
566
<p>####### foo</p>
563
567
.
564
568
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:
570
576
571
577
.
572
578
#5 bolt
@@ -1028,7 +1034,41 @@ paragraph.)
1028
1034
</code></pre>
1029
1035
.
1030
1036
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:
1032
1072
1033
1073
.
1034
1074
<a/>
@@ -2329,9 +2369,16 @@ foo</p>
2329
2369
</blockquote>
2330
2370
.
2331
2371
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:
2335
2382
2336
2383
.
2337
2384
> foo
@@ -2343,6 +2390,15 @@ block structure cannot be lazy.
2343
2390
<hr />
2344
2391
.
2345
2392
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
+
2346
2402
.
2347
2403
> - foo
2348
2404
- bar
@@ -2357,6 +2413,9 @@ block structure cannot be lazy.
2357
2413
</ul>
2358
2414
.
2359
2415
2416
+ For the same reason, we can't omit the `>` in front of
2417
+ subsequent lines of an indented or fenced code block:
2418
+
2360
2419
.
2361
2420
> foo
2362
2421
bar
0 commit comments