Skip to content

Commit

Permalink
Fix smartquotes adjacent to code block
Browse files Browse the repository at this point in the history
close #677
  • Loading branch information
rlidwka committed Sep 10, 2020
1 parent b3531c8 commit 805c695
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rules_core/smartquotes.js
Expand Up @@ -60,7 +60,7 @@ function process_inlines(tokens, state) {
} else {
for (j = i - 1; j >= 0; j--) {
if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
if (tokens[j].type !== 'text') continue;
if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'

lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
break;
Expand All @@ -77,7 +77,7 @@ function process_inlines(tokens, state) {
} else {
for (j = i + 1; j < tokens.length; j++) {
if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
if (tokens[j].type !== 'text') continue;
if (!tokens[j].content) continue; // should skip all tokens except 'text', 'html_inline' or 'code_inline'

nextChar = tokens[j].content.charCodeAt(0);
break;
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/markdown-it/smartquotes.txt
Expand Up @@ -144,3 +144,23 @@ The dog---"'man's' best friend"
.
<p>The dog—“‘man’s’ best friend”</p>
.

Should parse quotes adjacent to code block, #677:
.
"test `code`"

"`code` test"
.
<p>“test <code>code</code>”</p>
<p>“<code>code</code> test”</p>
.

Should parse quotes adjacent to inline html, #677:
.
"test <br>"

"<br> test"
.
<p>“test <br>”</p>
<p>“<br> test”</p>
.

0 comments on commit 805c695

Please sign in to comment.