A platform for community discussion. Free, open, simple.
Double arrow support `↔` (#20288)
Canapin14a447175b46
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.jsindex 8e6c8887e97..c633c568bb6 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@@ -1640,6 +1640,8 @@ var bar = 'bar';assert.cookedOptions("a --> b", enabledTypographer, "<p>a \u2192 b</p>");assert.cookedOptions("-->", enabledTypographer, "<p> \u2192 </p>");assert.cookedOptions("<--", enabledTypographer, "<p> \u2190 </p>");+ assert.cookedOptions("<->", enabledTypographer, "<p> \u2194 </p>");+ assert.cookedOptions("<-->", enabledTypographer, "<p> \u2194 </p>");// Don't replace arrowsassert.cookedOptions("<!-- an html comment -->", enabledTypographer, "");@@ -1648,7 +1650,6 @@ var bar = 'bar';enabledTypographer,"<p>(<–not an arrow)</p>");- assert.cookedOptions("<-->", enabledTypographer, "<p><–></p>");assert.cookedOptions("asd-->", enabledTypographer, "<p>asd–></p>");assert.cookedOptions(" asd--> ", enabledTypographer, "<p>asd–></p>");assert.cookedOptions(" asd-->", enabledTypographer, "<p>asd–></p>");diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/custom-typographer-replacements.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/custom-typographer-replacements.jsindex 5ac02093bde..6d29476d961 100644--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/custom-typographer-replacements.js+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/custom-typographer-replacements.js@@ -5,7 +5,7 @@// ... → … (also ?.... → ?.., !.... → !..)// ???????? → ???, !!!!! → !!!, `,,` → `,`// -- → –, --- → —-// --> <-- -> <- to → ← → ←+// --> <-- -> <- <-> <--> to → ← → ← ↔ ↔// (pa) (PA) → ¶//// Disabled replacements:@@ -14,7 +14,7 @@// (r) (R) → ®// (p) (P) -> §-let RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--|-->|<--|->|<-/;+let RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--|-->|<--|->|<-|<->|<-->/;let SCOPED_ABBR_RE = /\((tm|pa)\)/gi;let SCOPED_ABBR = {@@ -52,6 +52,7 @@ function replaceRare(inlineTokens) {// Custom arrows.replace(/(^|\s)-{1,2}>(\s|$)/gm, "\u0020\u2192\u0020").replace(/(^|\s)<-{1,2}(\s|$)/gm, "\u0020\u2190\u0020")+ .replace(/(^|\s)<-{1,2}>(\s|$)/gm, "\u0020\u2194\u0020")// .., ..., ....... -> …// but ?..... & !..... -> ?.. & !...replace(/\.{2,}/g, "…")