diff --git a/src/symbols.js b/src/symbols.js index e001b867..7572aded 100644 --- a/src/symbols.js +++ b/src/symbols.js @@ -563,6 +563,16 @@ defineSymbol(math, main, spacing, null, "\\enspace"); defineSymbol(math, main, spacing, null, "\\qquad"); defineSymbol(math, main, spacing, null, "\\quad"); defineSymbol(math, main, spacing, "\u00a0", "\\space"); +defineSymbol(text, main, spacing, null, "\\!"); +defineSymbol(text, main, spacing, "\u00a0", "\\ "); +defineSymbol(text, main, spacing, "\u00a0", "~"); +defineSymbol(text, main, spacing, null, "\\,"); +defineSymbol(text, main, spacing, null, "\\:"); +defineSymbol(text, main, spacing, null, "\\;"); +defineSymbol(text, main, spacing, null, "\\enspace"); +defineSymbol(text, main, spacing, null, "\\qquad"); +defineSymbol(text, main, spacing, null, "\\quad"); +defineSymbol(text, main, spacing, "\u00a0", "\\space"); defineSymbol(math, main, punct, ",", ","); defineSymbol(math, main, punct, ";", ";"); defineSymbol(math, main, punct, ":", "\\colon"); diff --git a/test/katex-spec.js b/test/katex-spec.js index b9a55dfa..384a5e4f 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -1034,6 +1034,35 @@ describe("An overline parser", function() { }); }); +describe("An lap parser", function() { + it("should not fail on a text argument", function() { + expect("\\rlap{\\,/}{=}").toParse(); + expect("\\mathrlap{\\,/}{=}").toParse(); + expect("{=}\\llap{/\\,}").toParse(); + expect("{=}\\mathllap{/\\,}").toParse(); + expect("\\sum_{\\clap{ABCDEFG}}").toParse(); + expect("\\sum_{\\mathclap{ABCDEFG}}").toParse(); + }); + + it("should not fail if math version is used", function() { + expect("\\mathrlap{\\frac{a}{b}}{=}").toParse(); + expect("{=}\\mathllap{\\frac{a}{b}}").toParse(); + expect("\\sum_{\\mathclap{\\frac{a}{b}}}").toParse(); + }); + + it("should fail on math if AMS version is used", function() { + expect("\\rlap{\\frac{a}{b}}{=}").toNotParse(); + expect("{=}\\llap{\\frac{a}{b}}").toNotParse(); + expect("\\sum_{\\clap{\\frac{a}{b}}}").toNotParse(); + }); + + it("should produce a lap", function() { + const parse = getParsed("\\mathrlap{\\,/}")[0]; + + expect(parse.type).toEqual("lap"); + }); +}); + describe("A rule parser", function() { const emRule = "\\rule{1em}{2em}"; const exRule = "\\rule{1ex}{2em}"; @@ -2969,6 +2998,10 @@ describe("Symbols", function() { expect("\\text{\\i\\j}").toParse(); }); + it("should parse spacing functions in math or text mode", () => { + expect("A\\;B\\,C \\text{A\\;B\\,C}").toParse(); + }); + it("should render ligature commands like their unicode characters", () => { const commands = getBuilt("\\text{\\ae\\AE\\oe\\OE\\o\\O\\ss}"); const unicode = getBuilt("\\text{æÆœŒøØß}");