Skip to content

Commit 5fa0089

Browse files
author
MarkedJS bot
committed
🗜️ build [skip ci]
1 parent f9bc93b commit 5fa0089

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

lib/marked.esm.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,13 @@ var Tokenizer_1 = class Tokenizer {
592592
}
593593

594594
// Check for task list items
595-
istask = /^\[[ xX]\] /.test(item);
596-
ischecked = undefined;
597-
if (istask) {
598-
ischecked = item[1] !== ' ';
599-
item = item.replace(/^\[[ xX]\] +/, '');
595+
if (this.options.gfm) {
596+
istask = /^\[[ xX]\] /.test(item);
597+
ischecked = undefined;
598+
if (istask) {
599+
ischecked = item[1] !== ' ';
600+
item = item.replace(/^\[[ xX]\] +/, '');
601+
}
600602
}
601603

602604
list.items.push({
@@ -1657,12 +1659,13 @@ var Lexer_1 = class Lexer {
16571659
/**
16581660
* Lexing/Compiling
16591661
*/
1660-
inlineTokens(src, tokens = [], inLink = false, inRawBlock = false, prevChar = '') {
1662+
inlineTokens(src, tokens = [], inLink = false, inRawBlock = false) {
16611663
let token;
16621664

16631665
// String with links masked to avoid interference with em and strong
16641666
let maskedSrc = src;
16651667
let match;
1668+
let keepPrevChar, prevChar;
16661669

16671670
// Mask out reflinks
16681671
if (this.tokens.links) {
@@ -1681,6 +1684,10 @@ var Lexer_1 = class Lexer {
16811684
}
16821685

16831686
while (src) {
1687+
if (!keepPrevChar) {
1688+
prevChar = '';
1689+
}
1690+
keepPrevChar = false;
16841691
// escape
16851692
if (token = this.tokenizer.escape(src)) {
16861693
src = src.substring(token.raw.length);
@@ -1773,6 +1780,7 @@ var Lexer_1 = class Lexer {
17731780
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
17741781
src = src.substring(token.raw.length);
17751782
prevChar = token.raw.slice(-1);
1783+
keepPrevChar = true;
17761784
tokens.push(token);
17771785
continue;
17781786
}

lib/marked.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -685,12 +685,14 @@
685685
} // Check for task list items
686686

687687

688-
istask = /^\[[ xX]\] /.test(item);
689-
ischecked = undefined;
688+
if (this.options.gfm) {
689+
istask = /^\[[ xX]\] /.test(item);
690+
ischecked = undefined;
690691

691-
if (istask) {
692-
ischecked = item[1] !== ' ';
693-
item = item.replace(/^\[[ xX]\] +/, '');
692+
if (istask) {
693+
ischecked = item[1] !== ' ';
694+
item = item.replace(/^\[[ xX]\] +/, '');
695+
}
694696
}
695697

696698
list.items.push({
@@ -1665,7 +1667,7 @@
16651667
*/
16661668
;
16671669

1668-
_proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock, prevChar) {
1670+
_proto.inlineTokens = function inlineTokens(src, tokens, inLink, inRawBlock) {
16691671
if (tokens === void 0) {
16701672
tokens = [];
16711673
}
@@ -1678,14 +1680,11 @@
16781680
inRawBlock = false;
16791681
}
16801682

1681-
if (prevChar === void 0) {
1682-
prevChar = '';
1683-
}
1684-
16851683
var token; // String with links masked to avoid interference with em and strong
16861684

16871685
var maskedSrc = src;
1688-
var match; // Mask out reflinks
1686+
var match;
1687+
var keepPrevChar, prevChar; // Mask out reflinks
16891688

16901689
if (this.tokens.links) {
16911690
var links = Object.keys(this.tokens.links);
@@ -1705,7 +1704,12 @@
17051704
}
17061705

17071706
while (src) {
1708-
// escape
1707+
if (!keepPrevChar) {
1708+
prevChar = '';
1709+
}
1710+
1711+
keepPrevChar = false; // escape
1712+
17091713
if (token = this.tokenizer.escape(src)) {
17101714
src = src.substring(token.raw.length);
17111715
tokens.push(token);
@@ -1801,6 +1805,7 @@
18011805
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
18021806
src = src.substring(token.raw.length);
18031807
prevChar = token.raw.slice(-1);
1808+
keepPrevChar = true;
18041809
tokens.push(token);
18051810
continue;
18061811
}

0 commit comments

Comments
 (0)