Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: em and strong starting with special char #1832

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,13 @@ module.exports = class Lexer {
/**
* Lexing/Compiling
*/
inlineTokens(src, tokens = [], inLink = false, inRawBlock = false, prevChar = '') {
inlineTokens(src, tokens = [], inLink = false, inRawBlock = false) {
UziTech marked this conversation as resolved.
Show resolved Hide resolved
let token;

// String with links masked to avoid interference with em and strong
let maskedSrc = src;
let match;
let keepPrevChar, prevChar;

// Mask out reflinks
if (this.tokens.links) {
Expand All @@ -352,6 +353,10 @@ module.exports = class Lexer {
}

while (src) {
if (!keepPrevChar) {
prevChar = '';
}
keepPrevChar = false;
// escape
if (token = this.tokenizer.escape(src)) {
src = src.substring(token.raw.length);
Expand Down Expand Up @@ -444,6 +449,7 @@ module.exports = class Lexer {
if (token = this.tokenizer.inlineText(src, inRawBlock, smartypants)) {
src = src.substring(token.raw.length);
prevChar = token.raw.slice(-1);
keepPrevChar = true;
tokens.push(token);
continue;
}
Expand Down
15 changes: 15 additions & 0 deletions test/specs/new/em_after_inline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<p>a<br><em>@</em></p>

<p>a<em>a</em><em>a</em><em>@</em></p>

<p>a<strong>a</strong><em>a</em><em>@</em></p>

<p>a<del>a</del><em>@</em></p>

<p>a<code>a</code><em>@</em></p>

<p>a<a href="http://a.com">http://a.com</a><em>@</em></p>

<p>a<a href="a">a</a><em>@</em></p>

<p>a<a><em>@</em></p>
16 changes: 16 additions & 0 deletions test/specs/new/em_after_inline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
a\
*@*

a*a*_a_*@*

a**a**_a_*@*

a~a~*@*

a`a`*@*

a<http://a.com>*@*

a[a](a)*@*

a<a>*@*