From 4dd0e2cdca4f4ad4999a83e9ac275f1aa8643bce Mon Sep 17 00:00:00 2001 From: ylemkimon Date: Thu, 25 Oct 2018 11:04:00 +0900 Subject: [PATCH] Add \> (#1752) * Add \> * Update snapshot --- docs/support_table.md | 1 + docs/supported.md | 23 ++++++++++++----------- src/macros.js | 4 +++- test/__snapshots__/mathml-spec.js.snap | 5 ++++- test/katex-spec.js | 2 +- test/mathml-spec.js | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/docs/support_table.md b/docs/support_table.md index e7a26ed3..928adba9 100644 --- a/docs/support_table.md +++ b/docs/support_table.md @@ -44,6 +44,7 @@ table td { |<|$<$|| |\\=|$\text{\={a}}$|\text{\\={a}}| | >|$>$|| +|\\>|$a\>\>{b}$|`a\>\>{b}`| |\[|$[$|| |\]|$]$|| |{|${a}$|`{a}`| diff --git a/docs/supported.md b/docs/supported.md index f6693b6b..2d69441c 100644 --- a/docs/supported.md +++ b/docs/supported.md @@ -233,17 +233,18 @@ KaTeX also supports `\llap`, `\rlap`, and `\clap`, but they will take only text, |:----------------|:-------------------|:---------------------|:--------------------------------------| | `\,` | ³∕₁₈ em space | `\kern{distance}` | space, width = *distance* | `\thinspace` | ³∕₁₈ em space | `\mkern{distance}` | space, width = *distance* -| `\:` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance* -| `\medspace` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance* -| `\;` | ⁵∕₁₈ em space | `\hspace{distance}` | space, width = *distance* -| `\thickspace` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance* -| `\enspace` | ½ em space | `\phantom{content}` | space the width and height of content -| `\quad` | 1 em space | `\hphantom{content}` | space the width of content -| `\qquad` | 2 em space | `\vphantom{content}` | a strut the height of content -| `~` | non-breaking space | `\!` | – ³∕₁₈ em space -| `\` | space | `\negthinspace` | – ³∕₁₈ em space -| `\nobreakspace` | non-breaking space | `\negmedspace` | – ⁴∕₁₈ em space -| `\space` | space | `\negthickspace` | – ⁵∕₁₈ em space +| `\>` | ⁴∕₁₈ em space | `\mskip{distance}` | space, width = *distance* +| `\:` | ⁴∕₁₈ em space | `\hskip{distance}` | space, width = *distance* +| `\medspace` | ⁴∕₁₈ em space | `\hspace{distance}` | space, width = *distance* +| `\;` | ⁵∕₁₈ em space | `\hspace*{distance}` | space, width = *distance* +| `\thickspace` | ⁵∕₁₈ em space | `\phantom{content}` | space the width and height of content +| `\enspace` | ½ em space | `\hphantom{content}` | space the width of content +| `\quad` | 1 em space | `\vphantom{content}` | a strut the height of content +| `\qquad` | 2 em space | `\!` | – ³∕₁₈ em space +| `~` | non-breaking space | `\negthinspace` | – ³∕₁₈ em space +| `\` | space | `\negmedspace` | – ⁴∕₁₈ em space +| `\nobreakspace` | non-breaking space | `\negthickspace` | – ⁵∕₁₈ em space +| `\space` | space | diff --git a/src/macros.js b/src/macros.js index d3e36bca..0db4271b 100644 --- a/src/macros.js +++ b/src/macros.js @@ -605,8 +605,10 @@ defineMacro("\\tmspace", "\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"); defineMacro("\\,", "\\tmspace+{3mu}{.1667em}"); // \let\thinspace\, defineMacro("\\thinspace", "\\,"); +// \def\>{\mskip\medmuskip} // \renewcommand{\:}{\tmspace+\medmuskip{.2222em}} -// TODO: math mode should use \medmuskip = 4mu plus 2mu minus 4mu +// TODO: \> and math mode of \: should use \medmuskip = 4mu plus 2mu minus 4mu +defineMacro("\\>", "\\mskip{4mu}"); defineMacro("\\:", "\\tmspace+{4mu}{.2222em}"); // \let\medspace\: defineMacro("\\medspace", "\\:"); diff --git a/test/__snapshots__/mathml-spec.js.snap b/test/__snapshots__/mathml-spec.js.snap index 25b923ba..3ed5593b 100644 --- a/test/__snapshots__/mathml-spec.js.snap +++ b/test/__snapshots__/mathml-spec.js.snap @@ -713,6 +713,9 @@ exports[`A MathML builder special spaces render specially 1`] = ` + +   +    @@ -757,7 +760,7 @@ exports[`A MathML builder special spaces render specially 1`] = ` - \\,\\thinspace\\:\\medspace\\;\\thickspace\\!\\negthinspace\\negmedspace\\negthickspace\\mkern1mu\\mkern3mu\\mkern4mu\\mkern5mu\\mkern-1mu\\mkern-3mu\\mkern-4mu\\mkern-5mu + \\,\\thinspace\\:\\>\\medspace\\;\\thickspace\\!\\negthinspace\\negmedspace\\negthickspace\\mkern1mu\\mkern3mu\\mkern4mu\\mkern5mu\\mkern-1mu\\mkern-3mu\\mkern-4mu\\mkern-5mu diff --git a/test/katex-spec.js b/test/katex-spec.js index d415de6e..f15c50a3 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -752,7 +752,7 @@ describe("A text parser", function() { }); it("should parse spacing functions", function() { - expect`a b\, \; \! \: ~ \thinspace \medspace \quad \ `.toBuild(); + expect`a b\, \; \! \: \> ~ \thinspace \medspace \quad \ `.toBuild(); expect`\enspace \thickspace \qquad \space \nobreakspace`.toBuild(); }); diff --git a/test/mathml-spec.js b/test/mathml-spec.js index f862feba..b44db6b4 100644 --- a/test/mathml-spec.js +++ b/test/mathml-spec.js @@ -109,7 +109,7 @@ describe("A MathML builder", function() { }); it('special spaces render specially', function() { expect(getMathML( - "\\,\\thinspace\\:\\medspace\\;\\thickspace" + + "\\,\\thinspace\\:\\>\\medspace\\;\\thickspace" + "\\!\\negthinspace\\negmedspace\\negthickspace" + "\\mkern1mu\\mkern3mu\\mkern4mu\\mkern5mu" + "\\mkern-1mu\\mkern-3mu\\mkern-4mu\\mkern-5mu")).toMatchSnapshot();