FEATURE: Replace single dash arrows when the typographer is enabled. (#11730)

This commit is contained in:
Roman Rizzi 2021-01-18 09:03:58 -03:00 committed by GitHub
parent d0ef952af2
commit 9e25ab2e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -1566,6 +1566,8 @@ var bar = 'bar';
enabledTypographer,
"<p> \u2192 \u2190 </p>"
);
assert.cookedOptions("a -> b", enabledTypographer, "<p>a \u2192 b</p>");
assert.cookedOptions("a <- b", enabledTypographer, "<p>a \u2190 b</p>");
assert.cookedOptions("a --> b", enabledTypographer, "<p>a \u2192 b</p>");
assert.cookedOptions("-->", enabledTypographer, "<p> \u2192 </p>");
assert.cookedOptions("<--", enabledTypographer, "<p> \u2190 </p>");

View File

@ -6,7 +6,7 @@ function replaceArrows(state) {
continue;
}
const arrowsRegexp = /-->|<--/;
const arrowsRegexp = /-->|<--|->|<-/;
if (arrowsRegexp.test(token.content)) {
for (let ci = 0; ci < token.children.length; ci++) {
let child = token.children[ci];
@ -14,8 +14,8 @@ function replaceArrows(state) {
if (child.type === "text") {
if (arrowsRegexp.test(child.content)) {
child.content = child.content
.replace(/(^|\s)-->(\s|$)/gm, "\u0020\u2192\u0020")
.replace(/(^|\s)<--(\s|$)/gm, "\u0020\u2190\u0020");
.replace(/(^|\s)-{1,2}>(\s|$)/gm, "\u0020\u2192\u0020")
.replace(/(^|\s)<-{1,2}(\s|$)/gm, "\u0020\u2190\u0020");
}
}
}