summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-03-23 09:21:12 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-03-23 09:21:12 -0700
commit660990612f513c3c3be104c7f20de7e81ba41aee (patch)
treea545b5e44fc8b6a25a047267be37891df2de3627
parent01be842b276b0049f53f720b29177a81b3d43273 (diff)
Update spec; allow internal delimiter runs to match if...
both have lengths that are multiples of 3. See commonmark/commonmark#528.
-rw-r--r--src/inlines.c3
-rw-r--r--test/spec.txt34
2 files changed, 30 insertions, 7 deletions
diff --git a/src/inlines.c b/src/inlines.c
index bab607a..6e92aff 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -642,7 +642,8 @@ static void process_emphasis(subject *subj, delimiter *stack_bottom) {
// interior closer of size 2 can't match opener of size 1
// or of size 1 can't match 2
if (!(closer->can_open || opener->can_close) ||
- ((opener->length + closer->length) % 3) != 0) {
+ closer->length % 3 == 0 ||
+ (opener->length + closer->length) % 3 != 0) {
opener_found = true;
break;
}
diff --git a/test/spec.txt b/test/spec.txt
index dc944d0..ffa0f9c 100644
--- a/test/spec.txt
+++ b/test/spec.txt
@@ -1922,9 +1922,11 @@ bar
An [info string] can be provided after the opening code fence.
-Opening and closing spaces will be stripped, and the first word, prefixed
-with `language-`, is used as the value for the `class` attribute of the
-`code` element within the enclosing `pre` element.
+Although this spec doesn't mandate any particular treatment of
+the info string, the first word is typically used to specify
+the language of the code block. In HTML output, the language is
+normally indicated by adding a class to the `code` element consisting
+of `language-` followed by the language name.
```````````````````````````````` example
```ruby
@@ -6107,7 +6109,8 @@ The following rules define emphasis and strong emphasis:
[delimiter runs]. If one of the delimiters can both
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.
+ must not be a multiple of 3 unless both lengths are
+ multiples of 3.
10. Strong emphasis begins with a delimiter that
[can open strong emphasis] and ends with a delimiter that
@@ -6117,7 +6120,8 @@ The following rules define emphasis and strong emphasis:
[delimiter runs]. If one of the delimiters can both open
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.
+ delimiters must not be a multiple of 3 unless both lengths
+ are multiples of 3.
11. A literal `*` character cannot occur at the beginning or end of
`*`-delimited emphasis or `**`-delimited strong emphasis, unless it
@@ -6736,7 +6740,8 @@ 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.
+closing delimiters is a multiple of 3 unless
+both lengths are multiples of 3.
For the same reason, we don't get two consecutive
@@ -6776,6 +6781,23 @@ omitted:
````````````````````````````````
+When the lengths of the interior closing and opening
+delimiter runs are *both* multiples of 3, though,
+they can match to create emphasis:
+
+```````````````````````````````` example
+foo***bar***baz
+.
+<p>foo<em><strong>bar</strong></em>baz</p>
+````````````````````````````````
+
+```````````````````````````````` example
+foo******bar*********baz
+.
+<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>
+````````````````````````````````
+
+
Indefinite levels of nesting are possible:
```````````````````````````````` example