Browse Source

Fix emphasis algorithm as per 0.30 spec

https://github.com/commonmark/cmark/issues/383
pull/799/head
Alex Kocharin 4 years ago
parent
commit
eed156e9cd
  1. 10
      lib/rules_inline/balance_pairs.js
  2. 7
      test/fixtures/markdown-it/commonmark_extras.txt

10
lib/rules_inline/balance_pairs.js

@ -21,12 +21,14 @@ function processDelimiters(state, delimiters) {
if (!closer.close) continue; if (!closer.close) continue;
// Previously calculated lower bounds (previous fails) // Previously calculated lower bounds (previous fails)
// for each marker and each delimiter length modulo 3. // for each marker, each delimiter length modulo 3,
// and for whether this closer can be an opener;
// https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
if (!openersBottom.hasOwnProperty(closer.marker)) { if (!openersBottom.hasOwnProperty(closer.marker)) {
openersBottom[closer.marker] = [ -1, -1, -1 ]; openersBottom[closer.marker] = [ -1, -1, -1, -1, -1, -1 ];
} }
minOpenerIdx = openersBottom[closer.marker][closer.length % 3]; minOpenerIdx = openersBottom[closer.marker][(closer.open ? 3 : 0) + (closer.length % 3)];
openerIdx = closerIdx - closer.jump - 1; openerIdx = closerIdx - closer.jump - 1;
@ -87,7 +89,7 @@ function processDelimiters(state, delimiters) {
// See details here: // See details here:
// https://github.com/commonmark/cmark/issues/178#issuecomment-270417442 // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
// //
openersBottom[closer.marker][(closer.length || 0) % 3] = newMinOpenerIdx; openersBottom[closer.marker][(closer.open ? 3 : 0) + ((closer.length || 0) % 3)] = newMinOpenerIdx;
} }
} }
} }

7
test/fixtures/markdown-it/commonmark_extras.txt

@ -1,3 +1,10 @@
Issue commonmark/cmark#383:
.
*****Hello*world****
.
<p>**<em><strong>Hello<em>world</em></strong></em></p>
.
Issue #246. Double escaping in ALT Issue #246. Double escaping in ALT
. .
![&](#) ![&](#)

Loading…
Cancel
Save