Repository: Khan/KaTeX
Pull request #1750 (2018-10-23 21:32:30)

Support Unicode double square brackets
This PR adds support for the Unicode characters ⟦ and ⟧. The proposed additions are not variable sized.

I tried and failed to make variable sized delimiters. I believe that new font glyphs will be necessary in order to make them variable sized.

I do not include any function names for the delimiters in this PR. I can't use names like `\ldbrack` or `\lBrack` because those are names for variable sized delimiters. There are a couple of packages that define function names for text-mode brackets, but they don't get delimiter spacing and they look remarkably out of place without that spacing.

So the PR uses only the Unicode characters. This follows the `semantic` package, which provide a non-variable sized delimiter with delimiter spacing. They render it by using a glyph from the `bbold` package. We don't have that glyph so I wrote a macro with a little negative spacing.

codecov[bot]: # [Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1750?src=pr&el=h1) Report
> Merging [#1750](https://codecov.io/gh/Khan/KaTeX/pull/1750?src=pr&el=desc) into [master](https://codecov.io/gh/Khan/KaTeX/commit/89bb37115216ccf6ec917b730168c2dfcd3f779c?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.


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

```diff
@@            Coverage Diff             @@
##           master    #1750      +/-   ##
==========================================
+ Coverage   93.99%   93.99%   +<.01%     
==========================================
  Files          78       78              
  Lines        4547     4549       +2     
  Branches      792      792              
==========================================
+ Hits         4274     4276       +2     
  Misses        242      242              
  Partials       31       31
```

| Flag | Coverage Δ | |
|---|---|---|
| #screenshotter | `88.64% <100%> (ø)` | :arrow_up: |
| #test | `85.35% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/Khan/KaTeX/pull/1750?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/macros.js](https://codecov.io/gh/Khan/KaTeX/pull/1750/diff?src=pr&el=tree#diff-c3JjL21hY3Jvcy5qcw==) | `97.13% <100%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Khan/KaTeX/pull/1750?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/1750?src=pr&el=footer). Last update [89bb371...e8bc0bc](https://codecov.io/gh/Khan/KaTeX/pull/1750?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/docs/supported.md b/docs/supported.md
index 303f6199..f6693b6b 100644
--- a/docs/supported.md
+++ b/docs/supported.md
@@ -60,7 +60,7 @@ See also [letters](#letters)
 |$\vert$ <code>&#124;</code> |$\vert$ `\vert` |$┌ ┐$ `┌ ┐`|$\ulcorner \urcorner$ `\ulcorner`<br>$~~~~$`\urcorner`  |$\Downarrow$ `\Downarrow`
 |$\Vert$ <code>&#92;&#124;</code> |$\Vert$ `\Vert` |$└ ┘$ `└ ┘`|$\llcorner \lrcorner$ `\llcorner`<br>$~~~~$`\lrcorner`  |$\Updownarrow$ `\Updownarrow`
 |$\lvert~\rvert$ `\lvert`<br>$~~~~$`\rvert`|$\lVert~\rVert$ `\lVert`<br>$~~~~~$`\rVert` |`\left.`|  `\right.` |$\backslash$ `\backslash`
-|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|
+|$\lang~\rang$ `\lang`<br>$~~~~$`\rang`|$\lt~\gt$ `\lt \gt`|$⟦~⟧$ `⟦ ⟧`|
 
 **Delimiter Sizing**
 
diff --git a/src/macros.js b/src/macros.js
index 95c429c7..d3e36bca 100644
--- a/src/macros.js
+++ b/src/macros.js
@@ -802,6 +802,18 @@ defineMacro("\\notni", "\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220C}}");
 defineMacro("\\limsup", "\\DOTSB\\mathop{\\operatorname{lim\\,sup}}\\limits");
 defineMacro("\\liminf", "\\DOTSB\\mathop{\\operatorname{lim\\,inf}}\\limits");
 
+//////////////////////////////////////////////////////////////////////
+// semantic
+
+// The semantic package renders the next two items by calling a glyph from the
+// bbold package. Those glyphs do not exist in the KaTeX fonts. Hence the macros.
+
+defineMacro("\u27e6", "\\mathopen{[\\mkern-3.2mu[}");  // blackboard bold [
+defineMacro("\u27e7", "\\mathclose{]\\mkern-3.2mu]}"); // blackboard bold ]
+
+// TODO: Create variable sized versions of the last two items. I believe that
+// will require new font glyphs.
+
 //////////////////////////////////////////////////////////////////////
 // texvc.sty
 


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index c227a37f..d415de6e 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -3216,6 +3216,7 @@ describe("Unicode", function() {
         expect("\\left\u23b0\\frac{a}{b}\\right\u23b1").toBuild();
         expect`┌x┐ └x┘`.toBuild();
         expect("\u231Cx\u231D \u231Ex\u231F").toBuild();
+        expect("\u27E6x\u27E7").toBuild();
     });
 
     it("should build some surrogate pairs", function() {