From 14a447175b46d63918215c6a4be8ab4d9d8babf5 Mon Sep 17 00:00:00 2001 From: Canapin Date: Tue, 14 Feb 2023 20:24:14 +0100 Subject: [PATCH] =?UTF-8?q?Double=20arrow=20support=20`=E2=86=94`=20(#2028?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/discourse/tests/unit/lib/pretty-text-test.js | 3 ++- .../discourse-markdown/custom-typographer-replacements.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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 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, "

a \u2192 b

"); assert.cookedOptions("-->", enabledTypographer, "

\u2192

"); assert.cookedOptions("<--", enabledTypographer, "

\u2190

"); + assert.cookedOptions("<->", enabledTypographer, "

\u2194

"); + assert.cookedOptions("<-->", enabledTypographer, "

\u2194

"); // Don't replace arrows assert.cookedOptions("", enabledTypographer, ""); @@ -1648,7 +1650,6 @@ var bar = 'bar'; enabledTypographer, "

(<–not an arrow)

" ); - assert.cookedOptions("<-->", enabledTypographer, "

<–>

"); assert.cookedOptions("asd-->", enabledTypographer, "

asd–>

"); assert.cookedOptions(" asd--> ", enabledTypographer, "

asd–>

"); assert.cookedOptions(" asd-->", enabledTypographer, "

asd–>

"); 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.js index 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, "…")