Repository: KaTeX/KaTeX (js)

Issue:
\cal support
KaTeX supports the new-style `\mathcal{...}` but not the old-style `{\cal ...}` font format.  We should ideally support both, as we do for `\rm`/`\mathrm` etc.; see the [support table](https://katex.org/docs/supported.html#style-color-size-and-font).

This oversight was recently mentioned to me by the author of a project using KaTeX as a common issue with KaTeX where they needed to fall back to MathJax, so I think it's relevant to the real world.

Pull request description:
Add support for \cal
Fix #2115 by adding \cal to list of old-style font commands. (Surprisingly tiny change!)
Add tests for all old-style font commands.

Example with tester:
```latex
\mathcal{ABC} ABC \cal ABC \rm ABC
```
![image](https://user-images.githubusercontent.com/2218736/66523633-6161dc80-eabe-11e9-8061-a16b7f19ee84.png)


Patch:
diff --git a/docs/support_table.md b/docs/support_table.md
index 3303df98..b429c40c 100644
--- a/docs/support_table.md
+++ b/docs/support_table.md
@@ -198,7 +198,7 @@ table td {
 |Symbol/Function |  Rendered   | Source or Comment|
 |:---------------|:------------|:-----------------|
 |\C|<span style="color:firebrick;">Not supported</span>|[Deprecated](https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Deprecated_syntax)|
-|\cal|<span style="color:firebrick;">Not supported</span>|See `\mathcal`
+|\cal|$\cal AaBb123$|`\cal AaBb123`|
 |\cancel|$\cancel{5}$|`\cancel{5}`|
 |\cancelto|<span style="color:firebrick;">Not supported</span>||
 |\Cap|$\Cap$||
diff --git a/docs/supported.md b/docs/supported.md
index 74c745d5..755a8c84 100644
--- a/docs/supported.md
+++ b/docs/supported.md
@@ -538,7 +538,8 @@ For color definition, KaTeX color functions will accept the standard HTML [pred
 |$\mathsf{Ab0}$ `\mathsf{Ab0}`  |$\textmd{Ab0}$ `\textmd{Ab0}`  |$\frak{Ab0}$ `\frak{Ab0}`
 |$\textsf{Ab0}$ `\textsf{Ab0}`  |$\mathtt{Ab0}$ `\mathtt{Ab0}`  |$\mathfrak{Ab0}$ `\mathfrak{Ab0}`
 |$\sf Ab0$ `\sf Ab0`            |$\texttt{Ab0}$ `\texttt{Ab0}`  |$\mathcal{AB0}$ `\mathcal{AB0}`
-|                               |$\tt Ab0$ `\tt Ab0`            |$\mathscr{AB}$ `\mathscr{AB}`
+|                               |$\tt Ab0$ `\tt Ab0`            |$\cal AB0$ `\cal AB0`
+|                               |                               |$\mathscr{AB}$ `\mathscr{AB}`
 
 One can stack font family, font weight, and font shape by using the `\textXX` versions of the font functions. So `\textsf{\textbf{H}}` will produce $\textsf{\textbf{H}}$. The other versions do not stack, e.g., `\mathsf{\mathbf{H}}` will produce $\mathsf{\mathbf{H}}$.
 
diff --git a/src/functions/font.js b/src/functions/font.js
index 005182d2..2ba74990 100644
--- a/src/functions/font.js
+++ b/src/functions/font.js
@@ -95,7 +95,7 @@ defineFunction({
 // Old font changing functions
 defineFunction({
     type: "font",
-    names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it"],
+    names: ["\\rm", "\\sf", "\\tt", "\\bf", "\\it", "\\cal"],
     props: {
         numArgs: 0,
         allowedInText: true,


Test patch:
diff --git a/test/katex-spec.js b/test/katex-spec.js
index 2aa7b148..a418a133 100644
--- a/test/katex-spec.js
+++ b/test/katex-spec.js
@@ -1601,6 +1601,15 @@ describe("A font parser", function() {
         const built = getBuilt`a\boldsymbol{}b\boldsymbol{=}c\boldsymbol{+}d\boldsymbol{++}e\boldsymbol{xyz}f`;
         expect(built).toMatchSnapshot();
     });
+
+    it("old-style fonts work like new-style fonts", () => {
+        expect`\rm xyz`.toParseLike`\mathrm{xyz}`;
+        expect`\sf xyz`.toParseLike`\mathsf{xyz}`;
+        expect`\tt xyz`.toParseLike`\mathtt{xyz}`;
+        expect`\bf xyz`.toParseLike`\mathbf{xyz}`;
+        expect`\it xyz`.toParseLike`\mathit{xyz}`;
+        expect`\cal xyz`.toParseLike`\mathcal{xyz}`;
+    });
 });
 
 describe("A \\pmb builder", function() {