mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
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:
@@ -229,19 +229,19 @@ const makeStackedDelim = function(
|
||||
repeat = "\u23a5";
|
||||
bottom = "\u23a6";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\lfloor") {
|
||||
} else if (delim === "\\lfloor" || delim === "\u230a") {
|
||||
repeat = top = "\u23a2";
|
||||
bottom = "\u23a3";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\lceil") {
|
||||
} else if (delim === "\\lceil" || delim === "\u2308") {
|
||||
top = "\u23a1";
|
||||
repeat = bottom = "\u23a2";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\rfloor") {
|
||||
} else if (delim === "\\rfloor" || delim === "\u230b") {
|
||||
repeat = top = "\u23a5";
|
||||
bottom = "\u23a6";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\rceil") {
|
||||
} else if (delim === "\\rceil" || delim === "\u2309") {
|
||||
top = "\u23a4";
|
||||
repeat = bottom = "\u23a5";
|
||||
font = "Size4-Regular";
|
||||
@@ -267,22 +267,22 @@ const makeStackedDelim = function(
|
||||
bottom = "\u23ad";
|
||||
repeat = "\u23aa";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\lgroup") {
|
||||
} else if (delim === "\\lgroup" || delim === "\u27ee") {
|
||||
top = "\u23a7";
|
||||
bottom = "\u23a9";
|
||||
repeat = "\u23aa";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\rgroup") {
|
||||
} else if (delim === "\\rgroup" || delim === "\u27ef") {
|
||||
top = "\u23ab";
|
||||
bottom = "\u23ad";
|
||||
repeat = "\u23aa";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\lmoustache") {
|
||||
} else if (delim === "\\lmoustache" || delim === "\u23b0") {
|
||||
top = "\u23a7";
|
||||
bottom = "\u23ad";
|
||||
repeat = "\u23aa";
|
||||
font = "Size4-Regular";
|
||||
} else if (delim === "\\rmoustache") {
|
||||
} else if (delim === "\\rmoustache" || delim === "\u23b1") {
|
||||
top = "\u23ab";
|
||||
bottom = "\u23a9";
|
||||
repeat = "\u23aa";
|
||||
@@ -482,7 +482,8 @@ const makeSqrtImage = function(
|
||||
const stackLargeDelimiters = [
|
||||
"(", ")", "[", "\\lbrack", "]", "\\rbrack",
|
||||
"\\{", "\\lbrace", "\\}", "\\rbrace",
|
||||
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
|
||||
"\\lfloor", "\\rfloor", "\u230a", "\u230b",
|
||||
"\\lceil", "\\rceil", "\u2308", "\u2309",
|
||||
"\\surd",
|
||||
];
|
||||
|
||||
@@ -492,7 +493,8 @@ const stackAlwaysDelimiters = [
|
||||
"\\Uparrow", "\\Downarrow", "\\Updownarrow",
|
||||
"|", "\\|", "\\vert", "\\Vert",
|
||||
"\\lvert", "\\rvert", "\\lVert", "\\rVert",
|
||||
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache",
|
||||
"\\lgroup", "\\rgroup", "\u27ee", "\u27ef",
|
||||
"\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1",
|
||||
];
|
||||
|
||||
// and delimiters that never stack
|
||||
|
@@ -35,10 +35,12 @@ const delimiterSizes = {
|
||||
const delimiters = [
|
||||
"(", ")", "[", "\\lbrack", "]", "\\rbrack",
|
||||
"\\{", "\\lbrace", "\\}", "\\rbrace",
|
||||
"\\lfloor", "\\rfloor", "\\lceil", "\\rceil",
|
||||
"\\lfloor", "\\rfloor", "\u230a", "\u230b",
|
||||
"\\lceil", "\\rceil", "\u2308", "\u2309",
|
||||
"<", ">", "\\langle", "\u27e8", "\\rangle", "\u27e9", "\\lt", "\\gt",
|
||||
"\\lvert", "\\rvert", "\\lVert", "\\rVert",
|
||||
"\\lgroup", "\\rgroup", "\\lmoustache", "\\rmoustache",
|
||||
"\\lgroup", "\\rgroup", "\u27ee", "\u27ef",
|
||||
"\\lmoustache", "\\rmoustache", "\u23b0", "\u23b1",
|
||||
"/", "\\backslash",
|
||||
"|", "\\vert", "\\|", "\\Vert",
|
||||
"\\uparrow", "\\Uparrow",
|
||||
|
@@ -136,10 +136,10 @@ defineSymbol(text, main, textord, "\u2021", "\\ddag");
|
||||
defineSymbol(text, main, textord, "\u2020", "\\textdaggerdbl");
|
||||
|
||||
// Large Delimiters
|
||||
defineSymbol(math, main, close, "\u23b1", "\\rmoustache");
|
||||
defineSymbol(math, main, open, "\u23b0", "\\lmoustache");
|
||||
defineSymbol(math, main, close, "\u27ef", "\\rgroup");
|
||||
defineSymbol(math, main, open, "\u27ee", "\\lgroup");
|
||||
defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true);
|
||||
defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true);
|
||||
defineSymbol(math, main, close, "\u27ef", "\\rgroup", true);
|
||||
defineSymbol(math, main, open, "\u27ee", "\\lgroup", true);
|
||||
|
||||
// Binary Operators
|
||||
defineSymbol(math, main, bin, "\u2213", "\\mp", true);
|
||||
@@ -290,10 +290,10 @@ defineSymbol(math, ams, textord, "\u03dd", "\\digamma");
|
||||
defineSymbol(math, ams, textord, "\u03f0", "\\varkappa");
|
||||
|
||||
// AMS Delimiters
|
||||
defineSymbol(math, ams, open, "\u250c", "\\ulcorner");
|
||||
defineSymbol(math, ams, close, "\u2510", "\\urcorner");
|
||||
defineSymbol(math, ams, open, "\u2514", "\\llcorner");
|
||||
defineSymbol(math, ams, close, "\u2518", "\\lrcorner");
|
||||
defineSymbol(math, ams, open, "\u250c", "\\ulcorner", true);
|
||||
defineSymbol(math, ams, close, "\u2510", "\\urcorner", true);
|
||||
defineSymbol(math, ams, open, "\u2514", "\\llcorner", true);
|
||||
defineSymbol(math, ams, close, "\u2518", "\\lrcorner", true);
|
||||
|
||||
// AMS Binary Relations
|
||||
defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
|
||||
@@ -608,10 +608,10 @@ defineSymbol(math, main, open, "[", "\\lbrack");
|
||||
defineSymbol(math, main, close, "]", "\\rbrack");
|
||||
defineSymbol(text, main, textord, "<", "\\textless"); // in T1 fontenc
|
||||
defineSymbol(text, main, textord, ">", "\\textgreater"); // in T1 fontenc
|
||||
defineSymbol(math, main, open, "\u230a", "\\lfloor");
|
||||
defineSymbol(math, main, close, "\u230b", "\\rfloor");
|
||||
defineSymbol(math, main, open, "\u2308", "\\lceil");
|
||||
defineSymbol(math, main, close, "\u2309", "\\rceil");
|
||||
defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
|
||||
defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
|
||||
defineSymbol(math, main, open, "\u2308", "\\lceil", true);
|
||||
defineSymbol(math, main, close, "\u2309", "\\rceil", true);
|
||||
defineSymbol(math, main, textord, "\\", "\\backslash");
|
||||
defineSymbol(math, main, textord, "\u2223", "|");
|
||||
defineSymbol(math, main, textord, "\u2223", "\\vert");
|
||||
|
@@ -2960,6 +2960,15 @@ describe("Unicode", function() {
|
||||
it("should parse binary operators", function() {
|
||||
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() {
|
||||
|
Reference in New Issue
Block a user