Repository: Khan/KaTeX
Pull request #1207 (2018-03-12 02:04:43)

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`

codecov[bot]: # [Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=h1) Report
> Merging [#1207](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=desc) into [master](https://codecov.io/gh/Khan/KaTeX/commit/75b55a63b152159aef84e29d49c91bde89e9023c?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `60%`.


[![Impacted file tree graph](https://codecov.io/gh/Khan/KaTeX/pull/1207/graphs/tree.svg?src=pr&token=vfDnj2P77o&height=150&width=650)](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1207   +/-   ##
=======================================
  Coverage   79.66%   79.66%           
=======================================
  Files          59       59           
  Lines        3884     3884           
  Branches      654      654           
=======================================
  Hits         3094     3094           
  Misses        657      657           
  Partials      133      133
```


| [Impacted Files](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/functions/delimsizing.js](https://codecov.io/gh/Khan/KaTeX/pull/1207/diff?src=pr&el=tree#diff-c3JjL2Z1bmN0aW9ucy9kZWxpbXNpemluZy5qcw==) | `65.85% <ø> (ø)` | :arrow_up: |
| [src/delimiter.js](https://codecov.io/gh/Khan/KaTeX/pull/1207/diff?src=pr&el=tree#diff-c3JjL2RlbGltaXRlci5qcw==) | `42.2% <0%> (ø)` | :arrow_up: |
| [src/symbols.js](https://codecov.io/gh/Khan/KaTeX/pull/1207/diff?src=pr&el=tree#diff-c3JjL3N5bWJvbHMuanM=) | `100% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=footer). Last update [75b55a6...62925a6](https://codecov.io/gh/Khan/KaTeX/pull/1207?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

ronkok: And to refresh some visual confirmation:

![delimiters](https://user-images.githubusercontent.com/16403058/37262862-a45eb2c4-2562-11e8-95d7-d38da64c7378.PNG)

ronkok: @edemaine  Tests are revised `toBuild`. Should be good to go.

Patch:
diff --git a/src/delimiter.js b/src/delimiter.js
index f389e5cf..82cdac5e 100644
--- a/src/delimiter.js
+++ b/src/delimiter.js
@@ -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
diff --git a/src/functions/delimsizing.js b/src/functions/delimsizing.js
index 603640b6..da66bc30 100644
--- a/src/functions/delimsizing.js
+++ b/src/functions/delimsizing.js
@@ -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",
diff --git a/src/symbols.js b/src/symbols.js
index 0e03847a..2bf1f3cb 100644
--- a/src/symbols.js
+++ b/src/symbols.js
@@ -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");


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index 31aada64..3abde22b 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -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() {