From 9576a982fff5b7785dc9fb45ca5040fafd4540c3 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 4 Sep 2020 11:30:11 -0500 Subject: [PATCH 1/2] fix underscore adjacent to asterisk --- src/rules.js | 8 ++++---- test/specs/new/em_strong_adjacent.html | 15 +++++++++++++++ test/specs/new/em_strong_adjacent.md | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/specs/new/em_strong_adjacent.html create mode 100644 test/specs/new/em_strong_adjacent.md diff --git a/src/rules.js b/src/rules.js index f6ef4529d2..353f172c69 100644 --- a/src/rules.js +++ b/src/rules.js @@ -172,14 +172,14 @@ const inline = { strong: { start: /^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/, // (1) returns if starts w/ punctuation middle: /^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/, - endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/, // last char can't be punct, or final * must also be followed by punct (or endline) - endUnd: /[^\s]__(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline) + endAst: /[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation_\s]|$))/, // last char can't be punct, or final * must also be followed by punct (or endline) + endUnd: /[^\s]__(?!_)(?:(?=[punctuation*\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline) }, em: { start: /^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/, // (1) returns if starts w/ punctuation middle: /^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/, - endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/, // last char can't be punct, or final * must also be followed by punct (or endline) - endUnd: /[^\s]_(?!_)(?:(?=[punctuation\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline) + endAst: /[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation_\s]|$))/, // last char can't be punct, or final * must also be followed by punct (or endline) + endUnd: /[^\s]_(?!_)(?:(?=[punctuation*\s])|$)/ // last char can't be a space, and final _ must preceed punct or \s (or endline) }, code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, diff --git a/test/specs/new/em_strong_adjacent.html b/test/specs/new/em_strong_adjacent.html new file mode 100644 index 0000000000..04ca24b89f --- /dev/null +++ b/test/specs/new/em_strong_adjacent.html @@ -0,0 +1,15 @@ +

test

+ +

test

+ +

test

+ +

test

+ +

test

+ +

test

+ +

test

+ +

test

diff --git a/test/specs/new/em_strong_adjacent.md b/test/specs/new/em_strong_adjacent.md new file mode 100644 index 0000000000..0be6ec1ac8 --- /dev/null +++ b/test/specs/new/em_strong_adjacent.md @@ -0,0 +1,15 @@ +_te_*st* + +_te_**st** + +*te*_st_ + +*te*__st__ + +__te__*st* + +__te__**st** + +**te**_st_ + +**te**__st__ From a317912f7a7cb92e51aed0829f6dcbad1c605813 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Mon, 7 Sep 2020 23:45:28 -0500 Subject: [PATCH 2/2] fix strong overlapSkip --- src/rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rules.js b/src/rules.js index 353f172c69..2951ed58fb 100644 --- a/src/rules.js +++ b/src/rules.js @@ -222,7 +222,7 @@ inline.strong.start = edit(inline.strong.start) inline.strong.middle = edit(inline.strong.middle) .replace(/punctuation/g, inline._punctuation) - .replace(/blockSkip/g, inline._blockSkip) + .replace(/overlapSkip/g, inline._overlapSkip) .getRegex(); inline.strong.endAst = edit(inline.strong.endAst, 'g')