From 97da298feb94e8c404c9c734a8b5965bbcbb398e Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 25 Oct 2023 19:07:04 -0700 Subject: [PATCH] Track underscore bottom separately mod 3, like asterisk 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. --- lib/inlines.js | 7 ++++--- test/regression.txt | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib/inlines.js b/lib/inlines.js index 635a3ac2..501a251f 100644 --- a/lib/inlines.js +++ b/lib/inlines.js @@ -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: @@ -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; } diff --git a/test/regression.txt b/test/regression.txt index 678e46ad..98e98f11 100644 --- a/test/regression.txt +++ b/test/regression.txt @@ -426,3 +426,32 @@ Link reference definitions are blocks when checking list tightness. ```````````````````````````````` + +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-_- +. +

!_!

+

!x!

+

!*!

+
+

__*

+

xx*

+

*__--

+

*xx--

+````````````````````````````````