mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
Enable spacing functions in text mode (#1139)
* Enable spacing functions in text mode Spacing functions such as `\;` or `\quad` should be accepted in either math mode or text mode * Add tests * Fix tests * Fix lint error
This commit is contained in:
@@ -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");
|
||||
|
@@ -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{æÆœŒøØß}");
|
||||
|
Reference in New Issue
Block a user