summaryrefslogtreecommitdiff
path: root/spec.txt
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-10-31 22:10:45 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-10-31 22:10:45 -0700
commit601908591b553b87901bb1122ff4e29d1decd6b1 (patch)
treea69ad063e0e5d0db8b5d99b6389a202188a8f3de /spec.txt
parentb14ece9e725175f98011dda8749d046d25b2f2bb (diff)
parent45ca1bc3867a48c75a6c464cf2420e25a8ef74c6 (diff)
Merge branch 'master' into cmake
Diffstat (limited to 'spec.txt')
-rw-r--r--spec.txt96
1 files changed, 78 insertions, 18 deletions
diff --git a/spec.txt b/spec.txt
index 12ec482..1bbd287 100644
--- a/spec.txt
+++ b/spec.txt
@@ -2,8 +2,8 @@
title: CommonMark Spec
author:
- John MacFarlane
-version: 0.5
-date: 2014-10-25
+version: 0.7
+date: 2014-10-28
...
# Introduction
@@ -479,11 +479,11 @@ consists of a string of characters, parsed as inline content, between an
opening sequence of 1--6 unescaped `#` characters and an optional
closing sequence of any number of `#` characters. The opening sequence
of `#` characters cannot be followed directly by a nonspace character.
-The closing `#` characters may be followed by spaces only. The opening
-`#` character may be indented 0-3 spaces. The raw contents of the
-header are stripped of leading and trailing spaces before being parsed
-as inline content. The header level is equal to the number of `#`
-characters in the opening sequence.
+The optional closing sequence of `#`s must be preceded by a space and may be
+followed by spaces only. The opening `#` character may be indented 0-3
+spaces. The raw contents of the header are stripped of leading and
+trailing spaces before being parsed as inline content. The header level
+is equal to the number of `#` characters in the opening sequence.
Simple headers:
@@ -614,16 +614,24 @@ header:
<h3>foo ### b</h3>
.
+The closing sequence must be preceded by a space:
+
+.
+# foo#
+.
+<h1>foo#</h1>
+.
+
Backslash-escaped `#` characters do not count as part
of the closing sequence:
.
### foo \###
-## foo \#\##
+## foo #\##
# foo \#
.
-<h3>foo #</h3>
-<h2>foo ##</h2>
+<h3>foo ###</h3>
+<h2>foo ###</h2>
<h1>foo #</h1>
.
@@ -1301,6 +1309,40 @@ aaa
</code></pre>
.
+Closing fences may be indented by 0-3 spaces, and their indentation
+need not match that of the opening fence:
+
+.
+```
+aaa
+ ```
+.
+<pre><code>aaa
+</code></pre>
+.
+
+.
+ ```
+aaa
+ ```
+.
+<pre><code>aaa
+</code></pre>
+.
+
+This is not a closing fence, because it is indented 4 spaces:
+
+.
+```
+aaa
+ ```
+.
+<pre><code>aaa
+ ```
+</code></pre>
+.
+
+
Code fences (opening and closing) cannot contain internal spaces:
.
@@ -4286,15 +4328,21 @@ the following principles resolve ambiguity:
12. An interpretation `<strong><em>...</em></strong>` is always
preferred to `<em><strong>..</strong></em>`.
-13. Earlier closings are preferred to later closings. Thus,
- when two potential emphasis or strong emphasis spans overlap,
- the first takes precedence: for example, `*foo _bar* baz_`
- is parsed as `<em>foo _bar</em> baz_` rather than
- `*foo <em>bar* baz</em>`. For the same reason,
+13. When two potential emphasis or strong emphasis spans overlap,
+ so that the second begins before the first ends and ends after
+ the first ends, the first is preferred. Thus, for example,
+ `*foo _bar* baz_` is parsed as `<em>foo _bar</em> baz_` rather
+ than `*foo <em>bar* baz</em>`. For the same reason,
`**foo*bar**` is parsed as `<em><em>foo</em>bar</em>*`
rather than `<strong>foo*bar</strong>`.
-14. Inline code spans, links, images, and HTML tags group more tightly
+14. When there are two potential emphasis or strong emphasis spans
+ with the same closing delimiter, the shorter one (the one that
+ opens later) is preferred. Thus, for example,
+ `**foo **bar baz**` is parsed as `**foo <strong>bar baz</strong>`
+ rather than `<strong>foo **bar baz</strong>`.
+
+15. Inline code spans, links, images, and HTML tags group more tightly
than emphasis. So, when there is a choice between an interpretation
that contains one of these elements and one that does not, the
former always wins. Thus, for example, `*[foo*](bar)` is
@@ -4928,6 +4976,20 @@ The following cases illustrate rule 13:
The following cases illustrate rule 14:
.
+**foo **bar baz**
+.
+<p>**foo <strong>bar baz</strong></p>
+.
+
+.
+*foo *bar baz*
+.
+<p>*foo <em>bar baz</em></p>
+.
+
+The following cases illustrate rule 15:
+
+.
*[foo*](bar)
.
<p>*<a href="bar">foo*</a></p>
@@ -6440,5 +6502,3 @@ an `emph`.
The document can be rendered as HTML, or in any other format, given
an appropriate renderer.
-
-