diff --git a/lib/rules_core/smartquotes.js b/lib/rules_core/smartquotes.js index 155e7a6..e96fc71 100644 --- a/lib/rules_core/smartquotes.js +++ b/lib/rules_core/smartquotes.js @@ -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; @@ -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; diff --git a/test/fixtures/markdown-it/smartquotes.txt b/test/fixtures/markdown-it/smartquotes.txt index b7a5631..fdeb883 100644 --- a/test/fixtures/markdown-it/smartquotes.txt +++ b/test/fixtures/markdown-it/smartquotes.txt @@ -144,3 +144,23 @@ The dog---"'man's' best friend" .
The dog—“‘man’s’ best friend”
. + +Should parse quotes adjacent to code block, #677: +. +"test `code`" + +"`code` test" +. +“test code
”
“code
test”
“test
”
“
test”