diff --git a/lib/rules_core/smartquotes.js b/lib/rules_core/smartquotes.js index bff7ef7..155e7a6 100644 --- a/lib/rules_core/smartquotes.js +++ b/lib/rules_core/smartquotes.js @@ -114,8 +114,14 @@ function process_inlines(tokens, state) { } if (canOpen && canClose) { - // treat this as the middle of the word - canOpen = false; + // Replace quotes in the middle of punctuation sequence, but not + // in the middle of the words, i.e.: + // + // 1. foo " bar " baz - not replaced + // 2. foo-"-bar-"-baz - replaced + // 3. foo"bar"baz - not replaced + // + canOpen = isLastPunctChar; canClose = isNextPunctChar; } diff --git a/test/fixtures/markdown-it/smartquotes.txt b/test/fixtures/markdown-it/smartquotes.txt index 9763333..b7a5631 100644 --- a/test/fixtures/markdown-it/smartquotes.txt +++ b/test/fixtures/markdown-it/smartquotes.txt @@ -137,3 +137,10 @@ and “that”.

“this” and
“that”.

. + +Should allow quotes adjacent to other punctuation characters, #643: +. +The dog---"'man's' best friend" +. +

The dog—“‘man’s’ best friend”

+.