Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Replace single dash arrows when the typographer is enabled. (#11730)

Roman Rizzi9e25ab2e96fe
diff --git a/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js b/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js
index 3c7718eef72..c584911dcee 100644
--- a/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js
+++ b/app/assets/javascripts/discourse/tests/unit/lib/pretty-text-test.js
@@ -1566,6 +1566,8 @@ var bar = 'bar';
enabledTypographer,
"<p> \u2192 \u2190 </p>"
);
+ assert.cookedOptions("a -> b", enabledTypographer, "<p>a \u2192 b</p>");
+ assert.cookedOptions("a <- b", enabledTypographer, "<p>a \u2190 b</p>");
assert.cookedOptions("a --> b", enabledTypographer, "<p>a \u2192 b</p>");
assert.cookedOptions("-->", enabledTypographer, "<p> \u2192 </p>");
assert.cookedOptions("<--", enabledTypographer, "<p> \u2190 </p>");
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/typographer-arrows.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/typographer-arrows.js
index cccea6d47ca..b63f52f8969 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/typographer-arrows.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/typographer-arrows.js
@@ -6,7 +6,7 @@ function replaceArrows(state) {
continue;
}
- const arrowsRegexp = /-->|<--/;
+ const arrowsRegexp = /-->|<--|->|<-/;
if (arrowsRegexp.test(token.content)) {
for (let ci = 0; ci < token.children.length; ci++) {
let child = token.children[ci];
@@ -14,8 +14,8 @@ function replaceArrows(state) {
if (child.type === "text") {
if (arrowsRegexp.test(child.content)) {
child.content = child.content
- .replace(/(^|\s)-->(\s|$)/gm, "\u0020\u2192\u0020")
- .replace(/(^|\s)<--(\s|$)/gm, "\u0020\u2190\u0020");
+ .replace(/(^|\s)-{1,2}>(\s|$)/gm, "\u0020\u2192\u0020")
+ .replace(/(^|\s)<-{1,2}(\s|$)/gm, "\u0020\u2190\u0020");
}
}
}