From f798bea9623277bbf89b9621cf7fb283c693fcab Mon Sep 17 00:00:00 2001
From: Alex Kocharin
Date: Thu, 12 Mar 2020 19:11:54 +0300
Subject: [PATCH] Allow opening quote after another punctuation char in
typographer
close https://github.com/markdown-it/markdown-it/issues/643
---
lib/rules_core/smartquotes.js | 10 ++++++++--
test/fixtures/markdown-it/smartquotes.txt | 7 +++++++
2 files changed, 15 insertions(+), 2 deletions(-)
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”
+.