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 86e2fd72d75..995d96cef96 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 @@ -1625,6 +1625,7 @@ var bar = 'bar'; "
!!! ??? ,
" ); assert.cookedOptions("(tm) (TM)", enabledTypographer, "™ ™
"); + assert.cookedOptions("(pa) (PA)", enabledTypographer, "¶ ¶
"); }); test("default typhographic replacements - dashes", function (assert) { 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 220e75fe275..5ac02093bde 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 @@ -6,6 +6,7 @@ // ???????? → ???, !!!!! → !!!, `,,` → `,` // -- → –, --- → — // --> <-- -> <- to → ← → ← +// (pa) (PA) → ¶ // // Disabled replacements: // @@ -14,7 +15,16 @@ // (p) (P) -> § let RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--|-->|<--|->|<-/; -let SCOPED_ABBR_RE = /\((tm)\)/gi; + +let SCOPED_ABBR_RE = /\((tm|pa)\)/gi; +let SCOPED_ABBR = { + pa: "¶", + tm: "™", +}; + +function replaceFn(match, name) { + return SCOPED_ABBR[name.toLowerCase()]; +} function replaceScoped(inlineTokens) { let i, token; @@ -22,9 +32,7 @@ function replaceScoped(inlineTokens) { for (i = inlineTokens.length - 1; i >= 0; i--) { token = inlineTokens[i]; if (token.type === "text") { - token.content = token.content.replace(SCOPED_ABBR_RE, () => { - return "™"; - }); + token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn); } } }