Skip to content

Commit

Permalink
Update spec; allow internal delimiter runs to match if...
Browse files Browse the repository at this point in the history
both have lengths that are multiples of 3.

See commonmark/commonmark-spec#528.
  • Loading branch information
jgm committed Mar 23, 2019
1 parent 01be842 commit 6609906
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
34 changes: 28 additions & 6 deletions test/spec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6609906

Please sign in to comment.