Support Unicode delimiters (#1207)

* Support Unicode delimiters

This PR adds support for the Unicode versions of \lfloor, \rfloor, \lceil, \rceil, \lgroup, \rgroup, \lmoustache, \rmoustache, \ulcorner, \urcorner, \llcorner, and \lrcorner.

All the mappings agree with `unicode math`

* Change tests from Parse to Build
This commit is contained in:
Ron Kok
2018-03-13 05:21:19 -07:00
committed by Erik Demaine
parent 0d3cf000d2
commit 65b47430b5
4 changed files with 37 additions and 24 deletions

View File

@@ -229,19 +229,19 @@ const makeStackedDelim = function(
repeat = "\u23a5"; repeat = "\u23a5";
bottom = "\u23a6"; bottom = "\u23a6";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\lfloor") { } else if (delim === "\\lfloor" || delim === "\u230a") {
repeat = top = "\u23a2"; repeat = top = "\u23a2";
bottom = "\u23a3"; bottom = "\u23a3";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\lceil") { } else if (delim === "\\lceil" || delim === "\u2308") {
top = "\u23a1"; top = "\u23a1";
repeat = bottom = "\u23a2"; repeat = bottom = "\u23a2";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\rfloor") { } else if (delim === "\\rfloor" || delim === "\u230b") {
repeat = top = "\u23a5"; repeat = top = "\u23a5";
bottom = "\u23a6"; bottom = "\u23a6";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\rceil") { } else if (delim === "\\rceil" || delim === "\u2309") {
top = "\u23a4"; top = "\u23a4";
repeat = bottom = "\u23a5"; repeat = bottom = "\u23a5";
font = "Size4-Regular"; font = "Size4-Regular";
@@ -267,22 +267,22 @@ const makeStackedDelim = function(
bottom = "\u23ad"; bottom = "\u23ad";
repeat = "\u23aa"; repeat = "\u23aa";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\lgroup") { } else if (delim === "\\lgroup" || delim === "\u27ee") {
top = "\u23a7"; top = "\u23a7";
bottom = "\u23a9"; bottom = "\u23a9";
repeat = "\u23aa"; repeat = "\u23aa";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\rgroup") { } else if (delim === "\\rgroup" || delim === "\u27ef") {
top = "\u23ab"; top = "\u23ab";
bottom = "\u23ad"; bottom = "\u23ad";
repeat = "\u23aa"; repeat = "\u23aa";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\lmoustache") { } else if (delim === "\\lmoustache" || delim === "\u23b0") {
top = "\u23a7"; top = "\u23a7";
bottom = "\u23ad"; bottom = "\u23ad";
repeat = "\u23aa"; repeat = "\u23aa";
font = "Size4-Regular"; font = "Size4-Regular";
} else if (delim === "\\rmoustache") { } else if (delim === "\\rmoustache" || delim === "\u23b1") {
top = "\u23ab"; top = "\u23ab";
bottom = "\u23a9"; bottom = "\u23a9";
repeat = "\u23aa"; repeat = "\u23aa";
@@ -482,7 +482,8 @@ const makeSqrtImage = function(
const stackLargeDelimiters = [ const stackLargeDelimiters = [
"(", ")", "[", "\\lbrack", "]", "\\rbrack", "(", ")", "[", "\\lbrack", "]", "\\rbrack",
"\\{", "\\lbrace", "\\}", "\\rbrace", "\\{", "\\lbrace", "\\}", "\\rbrace",
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\lfloor", "\\rfloor", "\u230a", "\u230b",
"\\lceil", "\\rceil", "\u2308", "\u2309",
"\\surd", "\\surd",
]; ];
@@ -492,7 +493,8 @@ const stackAlwaysDelimiters = [
"\\Uparrow", "\\Downarrow", "\\Updownarrow", "\\Uparrow", "\\Downarrow", "\\Updownarrow",
"|", "\\|", "\\vert", "\\Vert", "|", "\\|", "\\vert", "\\Vert",
"\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lvert", "\\rvert", "\\lVert", "\\rVert",
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef",
"\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1",
]; ];
// and delimiters that never stack // and delimiters that never stack

View File

@@ -35,10 +35,12 @@ const delimiterSizes = {
const delimiters = [ const delimiters = [
"(", ")", "[", "\\lbrack", "]", "\\rbrack", "(", ")", "[", "\\lbrack", "]", "\\rbrack",
"\\{", "\\lbrace", "\\}", "\\rbrace", "\\{", "\\lbrace", "\\}", "\\rbrace",
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil", "\\lfloor", "\\rfloor", "\u230a", "\u230b",
"\\lceil", "\\rceil", "\u2308", "\u2309",
"<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt", "<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt",
"\\lvert", "\\rvert", "\\lVert", "\\rVert", "\\lvert", "\\rvert", "\\lVert", "\\rVert",
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache", "\\lgroup", "\\rgroup", "\u27ee", "\u27ef",
"\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1",
"/", "\\backslash", "/", "\\backslash",
"|", "\\vert", "\\|", "\\Vert", "|", "\\vert", "\\|", "\\Vert",
"\\uparrow", "\\Uparrow", "\\uparrow", "\\Uparrow",

View File

@@ -136,10 +136,10 @@ defineSymbol(text, main, textord, "\u2021", "\\ddag");
defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl"); defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl");
// Large Delimiters // Large Delimiters
defineSymbol(math, main, close, "\u23b1", "\\rmoustache"); defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true);
defineSymbol(math, main, open, "\u23b0", "\\lmoustache"); defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true);
defineSymbol(math, main, close, "\u27ef", "\\rgroup"); defineSymbol(math, main, close, "\u27ef", "\\rgroup", true);
defineSymbol(math, main, open, "\u27ee", "\\lgroup"); defineSymbol(math, main, open, "\u27ee", "\\lgroup", true);
// Binary Operators // Binary Operators
defineSymbol(math, main, bin, "\u2213", "\\mp", true); defineSymbol(math, main, bin, "\u2213", "\\mp", true);
@@ -290,10 +290,10 @@ defineSymbol(math, ams, textord, "\u03dd", "\\digamma");
defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); defineSymbol(math, ams, textord, "\u03f0", "\\varkappa");
// AMS Delimiters // AMS Delimiters
defineSymbol(math, ams, open, "\u250c", "\\ulcorner"); defineSymbol(math, ams, open, "\u250c", "\\ulcorner", true);
defineSymbol(math, ams, close, "\u2510", "\\urcorner"); defineSymbol(math, ams, close, "\u2510", "\\urcorner", true);
defineSymbol(math, ams, open, "\u2514", "\\llcorner"); defineSymbol(math, ams, open, "\u2514", "\\llcorner", true);
defineSymbol(math, ams, close, "\u2518", "\\lrcorner"); defineSymbol(math, ams, close, "\u2518", "\\lrcorner", true);
// AMS Binary Relations // AMS Binary Relations
defineSymbol(math, ams, rel, "\u2266", "\\leqq", true); defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
@@ -608,10 +608,10 @@ defineSymbol(math, main, open, "[", "\\lbrack");
defineSymbol(math, main, close, "]", "\\rbrack"); defineSymbol(math, main, close, "]", "\\rbrack");
defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc
defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc
defineSymbol(math, main, open, "\u230a", "\\lfloor"); defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
defineSymbol(math, main, close, "\u230b", "\\rfloor"); defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
defineSymbol(math, main, open, "\u2308", "\\lceil"); defineSymbol(math, main, open, "\u2308", "\\lceil", true);
defineSymbol(math, main, close, "\u2309", "\\rceil"); defineSymbol(math, main, close, "\u2309", "\\rceil", true);
defineSymbol(math, main, textord, "\\", "\\backslash"); defineSymbol(math, main, textord, "\\", "\\backslash");
defineSymbol(math, main, textord, "\u2223", "|"); defineSymbol(math, main, textord, "\u2223", "|");
defineSymbol(math, main, textord, "\u2223", "\\vert"); defineSymbol(math, main, textord, "\u2223", "\\vert");

View File

@@ -2960,6 +2960,15 @@ describe("Unicode", function() {
it("should parse binary operators", function() { it("should parse binary operators", function() {
expect("±×÷∓∔∧∨∩∪≀⊎⊓⊔⊕⊖⊗⊘⊙⊚⊛⊝⊞⊟⊠⊡⊺⊻⊼⋇⋉⋊⋋⋌⋎⋏⋒⋓⩞\u22C5").toParse(); expect("±×÷∓∔∧∨∩∪≀⊎⊓⊔⊕⊖⊗⊘⊙⊚⊛⊝⊞⊟⊠⊡⊺⊻⊼⋇⋉⋊⋋⋌⋎⋏⋒⋓⩞\u22C5").toParse();
}); });
it("should parse delimeters", function() {
expect("\\left\u230A\\frac{a}{b}\\right\u230B").toBuild();
expect("\\left\u2308\\frac{a}{b}\\right\u2308").toBuild();
expect("\\left\u27ee\\frac{a}{b}\\right\u27ef").toBuild();
expect("\\left\u27e8\\frac{a}{b}\\right\u27e9").toBuild();
expect("\\left\u23b0\\frac{a}{b}\\right\u23b1").toBuild();
expect("┌x┐ └x┘").toBuild();
});
}); });
describe("The maxSize setting", function() { describe("The maxSize setting", function() {