Skip to content

Commit

Permalink
Fix emphasis algorithm as per 0.30 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Jun 30, 2021
1 parent 0b14fa0 commit eed156e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rules_inline/balance_pairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ function processDelimiters(state, delimiters) {
if (!closer.close) continue;

// 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)) {
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;

Expand Down Expand Up @@ -87,7 +89,7 @@ function processDelimiters(state, delimiters) {
// See details here:
// 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;
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/markdown-it/commonmark_extras.txt
Original file line number Diff line number Diff line change
@@ -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
.
![&](#)
Expand Down

0 comments on commit eed156e

Please sign in to comment.