From f0aa78e1a1f6f680ec9a037a8c57ec8e39fbf5e1 Mon Sep 17 00:00:00 2001 From: Brano Date: Sat, 2 Nov 2019 09:59:01 +0100 Subject: [PATCH] Fixes left single quote identification (#22) --- docs/CHANGELOG.md | 2 ++ src/lib/punctuation/single-quotes.js | 5 ++++- src/test/punctuation/single-quotes.test.js | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e784f62..36c9a11 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,8 @@ * mm x mm → mm⎵×⎵mm (abbreviations) * Marciano x Clay → Marciano⎵×⎵Clay (words) +### Fixes +* Fixes left single quote identification ([Issue #22](https://github.com/surfinzap/typopo/issues/22)) ## 2.3.1 // 2019-10-25 ### Fixes diff --git a/src/lib/punctuation/single-quotes.js b/src/lib/punctuation/single-quotes.js index 5725582..aa523f5 100644 --- a/src/lib/punctuation/single-quotes.js +++ b/src/lib/punctuation/single-quotes.js @@ -59,7 +59,10 @@ export function fixSingleQuotesPrimesAndApostrophes(string, locale) { string = string.replace(re, function($0, $1, $2, $3){ // identify {{typopo__left-single-quote--adept}} - let pattern = "([" + locale.spaces + "])(" + locale.singleQuoteAdepts + "|,)(["+ locale.allChars +"])"; + let pattern = + "([" + locale.spaces + locale.emDash + locale.enDash + "])" + + "(" + locale.singleQuoteAdepts + "|,)" + + "(["+ locale.allChars +"])"; let re = new RegExp(pattern, "g"); $2 = $2.replace(re, "$1{{typopo__left-single-quote--adept}}$3"); diff --git a/src/test/punctuation/single-quotes.test.js b/src/test/punctuation/single-quotes.test.js index 10cad75..939f664 100644 --- a/src/test/punctuation/single-quotes.test.js +++ b/src/test/punctuation/single-quotes.test.js @@ -14,6 +14,8 @@ describe('Single quotes in default language (en-us)\n', () => { "He said: “What about ‘name’ and ‘other name’?”", "He said: “What about 'Localhost 3000', is that good?”": "He said: “What about ‘Localhost 3000’, is that good?”", + "And I ask you: “What’s the idea behind this—how do you call it—'one size fits all' approach?”": + "And I ask you: “What’s the idea behind this—how do you call it—‘one size fits all’ approach?”", /* Mixing quotes and primes, left for single quotes */ "12' 45″": "12′ 45″",