Double arrow support `↔` (#20288)

This commit is contained in:
Canapin 2023-02-14 20:24:14 +01:00 committed by GitHub
parent afdb4a084a
commit 14a447175b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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 arrows
assert.cookedOptions("<!-- an html comment -->", enabledTypographer, "");
@ -1648,7 +1650,6 @@ var bar = 'bar';
enabledTypographer,
"<p>(&lt;not an arrow)</p>"
);
assert.cookedOptions("<-->", enabledTypographer, "<p>&lt;&gt;</p>");
assert.cookedOptions("asd-->", enabledTypographer, "<p>asd&gt;</p>");
assert.cookedOptions(" asd--> ", enabledTypographer, "<p>asd&gt;</p>");
assert.cookedOptions(" asd-->", enabledTypographer, "<p>asd&gt;</p>");

View File

@ -5,7 +5,7 @@
// ... → … (also ?.... → ?.., !.... → !..)
// ???????? → ???, !!!!! → !!!, `,,` → `,`
// -- → &ndash;, --- → &mdash;
// --> <-- -> <- 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, "…")