diff --git a/lib/rules_core/replacements.js b/lib/rules_core/replacements.js index 5b5a157..533496f 100644 --- a/lib/rules_core/replacements.js +++ b/lib/rules_core/replacements.js @@ -68,10 +68,10 @@ function replace_rare(inlineTokens) { .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..') .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',') // em-dash - .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2') + .replace(/(^|[^-])---(?=[^-]|$)/mg, '$1\u2014') // en-dash - .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2') - .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2'); + .replace(/(^|\s)--(?=\s|$)/mg, '$1\u2013') + .replace(/(^|[^-\s])--(?=[^-\s]|$)/mg, '$1\u2013'); } } diff --git a/test/fixtures/markdown-it/tables.txt b/test/fixtures/markdown-it/tables.txt index a813375..dfd3460 100644 --- a/test/fixtures/markdown-it/tables.txt +++ b/test/fixtures/markdown-it/tables.txt @@ -168,11 +168,11 @@ bar|bar Second line should not contain symbols except "-", ":", "|" and " ": . foo|foo ----|---s +-----|-----s bar|bar .
foo|foo -—|---s +-----|-----s bar|bar
. @@ -180,11 +180,11 @@ bar|bar Second line should contain "|" symbol: . foo|foo ----:--- +-----:----- bar|bar .foo|foo -—:--- +-----:----- bar|bar
. @@ -192,11 +192,11 @@ bar|bar Second line should not have empty columns in the middle: . foo|foo ----||--- +-----||----- bar|bar .foo|foo -—||— +-----||----- bar|bar
. @@ -204,11 +204,11 @@ bar|bar Wrong alignment symbol position: . foo|foo ----|-::- +-----|-::- bar|bar .foo|foo -—|-::- +-----|-::- bar|bar
. @@ -216,11 +216,11 @@ bar|bar Title line should contain "|" symbol: . foo ----|--- +-----|----- bar|bar .foo -—|--- +-----|----- bar|bar
. diff --git a/test/fixtures/markdown-it/typographer.txt b/test/fixtures/markdown-it/typographer.txt index 0e38519..e9e2bfe 100644 --- a/test/fixtures/markdown-it/typographer.txt +++ b/test/fixtures/markdown-it/typographer.txt @@ -79,3 +79,16 @@ markdownit--awesome–markdownit – super–
markdownit–awesome
. + +regression tests for #624 +. +1---2---3 + +1--2--3 + +1 -- -- 3 +. +1—2—3
+1–2–3
+1 – – 3
+.