Skip to content

Commit 6609906

Browse files
committed
Update spec; allow internal delimiter runs to match if...
both have lengths that are multiples of 3. See commonmark/commonmark-spec#528.
1 parent 01be842 commit 6609906

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/inlines.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ static void process_emphasis(subject *subj, delimiter *stack_bottom) {
642642
// interior closer of size 2 can't match opener of size 1
643643
// or of size 1 can't match 2
644644
if (!(closer->can_open || opener->can_close) ||
645-
((opener->length + closer->length) % 3) != 0) {
645+
closer->length % 3 == 0 ||
646+
(opener->length + closer->length) % 3 != 0) {
646647
opener_found = true;
647648
break;
648649
}

test/spec.txt

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,9 +1922,11 @@ bar
19221922

19231923

19241924
An [info string] can be provided after the opening code fence.
1925-
Opening and closing spaces will be stripped, and the first word, prefixed
1926-
with `language-`, is used as the value for the `class` attribute of the
1927-
`code` element within the enclosing `pre` element.
1925+
Although this spec doesn't mandate any particular treatment of
1926+
the info string, the first word is typically used to specify
1927+
the language of the code block. In HTML output, the language is
1928+
normally indicated by adding a class to the `code` element consisting
1929+
of `language-` followed by the language name.
19281930

19291931
```````````````````````````````` example
19301932
```ruby
@@ -6107,7 +6109,8 @@ The following rules define emphasis and strong emphasis:
61076109
[delimiter runs]. If one of the delimiters can both
61086110
open and close emphasis, then the sum of the lengths of the
61096111
delimiter runs containing the opening and closing delimiters
6110-
must not be a multiple of 3.
6112+
must not be a multiple of 3 unless both lengths are
6113+
multiples of 3.
61116114

61126115
10. Strong emphasis begins with a delimiter that
61136116
[can open strong emphasis] and ends with a delimiter that
@@ -6117,7 +6120,8 @@ The following rules define emphasis and strong emphasis:
61176120
[delimiter runs]. If one of the delimiters can both open
61186121
and close strong emphasis, then the sum of the lengths of
61196122
the delimiter runs containing the opening and closing
6120-
delimiters must not be a multiple of 3.
6123+
delimiters must not be a multiple of 3 unless both lengths
6124+
are multiples of 3.
61216125

61226126
11. A literal `*` character cannot occur at the beginning or end of
61236127
`*`-delimited emphasis or `**`-delimited strong emphasis, unless it
@@ -6736,7 +6740,8 @@ is precluded by the condition that a delimiter that
67366740
can both open and close (like the `*` after `foo`)
67376741
cannot form emphasis if the sum of the lengths of
67386742
the delimiter runs containing the opening and
6739-
closing delimiters is a multiple of 3.
6743+
closing delimiters is a multiple of 3 unless
6744+
both lengths are multiples of 3.
67406745

67416746

67426747
For the same reason, we don't get two consecutive
@@ -6776,6 +6781,23 @@ omitted:
67766781
````````````````````````````````
67776782

67786783

6784+
When the lengths of the interior closing and opening
6785+
delimiter runs are *both* multiples of 3, though,
6786+
they can match to create emphasis:
6787+
6788+
```````````````````````````````` example
6789+
foo***bar***baz
6790+
.
6791+
<p>foo<em><strong>bar</strong></em>baz</p>
6792+
````````````````````````````````
6793+
6794+
```````````````````````````````` example
6795+
foo******bar*********baz
6796+
.
6797+
<p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p>
6798+
````````````````````````````````
6799+
6800+
67796801
Indefinite levels of nesting are possible:
67806802

67816803
```````````````````````````````` example

0 commit comments

Comments
 (0)