Skip to content

Commit

Permalink
Track underscore bottom separately mod 3, like asterisk
Browse files Browse the repository at this point in the history
The reasoning that a failed delimiter means future delimiters will also fail
only applies if the reason they failed was not the multiple-of-three rule.
This was already implemented correctly for asterisks, but not for underscore.
  • Loading branch information
notriddle committed Oct 26, 2023
1 parent df3ea1e commit d9b65f9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ var processEmphasis = function(stack_bottom) {
var openers_bottom_index;
var odd_match = false;

for (var i = 0; i < 8; i++) {
for (var i = 0; i < 14; i++) {
openers_bottom[i] = stack_bottom;
}
// find first closer above stack_bottom:
Expand All @@ -407,10 +407,11 @@ var processEmphasis = function(stack_bottom) {
openers_bottom_index = 1;
break;
case C_UNDERSCORE:
openers_bottom_index = 2;
openers_bottom_index = 2 + (closer.can_open ? 3 : 0)
+ (closer.origdelims % 3);
break;
case C_ASTERISK:
openers_bottom_index = 3 + (closer.can_open ? 3 : 0)
openers_bottom_index = 8 + (closer.can_open ? 3 : 0)
+ (closer.origdelims % 3);
break;
}
Expand Down
29 changes: 29 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,32 @@ Link reference definitions are blocks when checking list tightness.
</li>
</ul>
````````````````````````````````

An underscore that is not part of a delimiter should not prevent another
pair of underscores from forming part of their own.
```````````````````````````````` example
__!_!__

__!x!__

**!*!**

---

_*__*_*

_*xx*_*

_*__-_-

_*xx-_-
.
<p><strong>!_!</strong></p>
<p><strong>!x!</strong></p>
<p><strong>!*!</strong></p>
<hr />
<p><em><em>__</em></em>*</p>
<p><em><em>xx</em></em>*</p>
<p><em>*__-</em>-</p>
<p><em>*xx-</em>-</p>
````````````````````````````````

0 comments on commit d9b65f9

Please sign in to comment.