Fix \nobreakspace, refactor "regular space" checking (#1200)

* Fix \nobreakspace, refactor "regular space" checking

Fix #1199 by adding \nobreakspace to the list of commands/symbols that
behave like a regular space character.  Refactor to put that list in one
place, and use an object so it checks instantly instead of sequentially.

* Copy test from #1201
This commit is contained in:
Erik Demaine
2018-03-09 19:14:42 -04:00
committed by Kevin Barabash
parent 017eb7b91d
commit abfb641d7a
4 changed files with 20 additions and 6 deletions

View File

@@ -875,6 +875,11 @@ describe("A text parser", function() {
expect(textWithEmbeddedMath).toParse();
});
it("should parse spacing functions", function() {
expect("a b\\, \\; \\! \\: ~ \\thinspace \\medspace \\quad \\ ").toBuild();
expect("\\enspace \\thickspace \\qquad \\space \\nobreakspace").toBuild();
});
it("should omit spaces after commands", function() {
expect("\\text{\\textellipsis !}")
.toParseLike("\\text{\\textellipsis!}");
@@ -2999,11 +3004,11 @@ describe("The \\mathchoice function", function() {
describe("Symbols", function() {
it("should parse \\text{\\i\\j}", () => {
expect("\\text{\\i\\j}").toParse();
expect("\\text{\\i\\j}").toBuild();
});
it("should parse spacing functions in math or text mode", () => {
expect("A\\;B\\,C\\nobreakspace \\text{A\\;B\\,C\\nobreakspace}").toParse();
expect("A\\;B\\,C\\nobreakspace \\text{A\\;B\\,C\\nobreakspace}").toBuild();
});
it("should render ligature commands like their unicode characters", () => {