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("a --> b", enabledTypographer, "<p>a \u2192 b</p>");
assert.cookedOptions("-->", enabledTypographer, "<p> \u2192 </p>"); assert.cookedOptions("-->", enabledTypographer, "<p> \u2192 </p>");
assert.cookedOptions("<--", enabledTypographer, "<p> \u2190 </p>"); assert.cookedOptions("<--", enabledTypographer, "<p> \u2190 </p>");
assert.cookedOptions("<->", enabledTypographer, "<p> \u2194 </p>");
assert.cookedOptions("<-->", enabledTypographer, "<p> \u2194 </p>");
// Don't replace arrows // Don't replace arrows
assert.cookedOptions("<!-- an html comment -->", enabledTypographer, ""); assert.cookedOptions("<!-- an html comment -->", enabledTypographer, "");
@ -1648,7 +1650,6 @@ var bar = 'bar';
enabledTypographer, enabledTypographer,
"<p>(&lt;not an arrow)</p>" "<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>"); 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 ?.... → ?.., !.... → !..) // ... → … (also ?.... → ?.., !.... → !..)
// ???????? → ???, !!!!! → !!!, `,,` → `,` // ???????? → ???, !!!!! → !!!, `,,` → `,`
// -- → &ndash;, --- → &mdash; // -- → &ndash;, --- → &mdash;
// --> <-- -> <- to → ← → ← // --> <-- -> <- <-> <--> to → ← → ← ↔ ↔
// (pa) (PA) → ¶ // (pa) (PA) → ¶
// //
// Disabled replacements: // Disabled replacements:
@ -14,7 +14,7 @@
// (r) (R) → ® // (r) (R) → ®
// (p) (P) -> § // (p) (P) -> §
let RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--|-->|<--|->|<-/; let RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--|-->|<--|->|<-|<->|<-->/;
let SCOPED_ABBR_RE = /\((tm|pa)\)/gi; let SCOPED_ABBR_RE = /\((tm|pa)\)/gi;
let SCOPED_ABBR = { let SCOPED_ABBR = {
@ -52,6 +52,7 @@ function replaceRare(inlineTokens) {
// Custom arrows // Custom arrows
.replace(/(^|\s)-{1,2}>(\s|$)/gm, "\u0020\u2192\u0020") .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\u2190\u0020")
.replace(/(^|\s)<-{1,2}>(\s|$)/gm, "\u0020\u2194\u0020")
// .., ..., ....... -> … // .., ..., ....... -> …
// but ?..... & !..... -> ?.. & !.. // but ?..... & !..... -> ?.. & !..
.replace(/\.{2,}/g, "…") .replace(/\.{2,}/g, "…")