mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Add raw
string group, move comment parsing to Parser, change URL group parser (#1711)
* Add raw string group * Move comment parsing to Parser * Use raw string group in URL group parser * Update types.js * Add multi-level nested url test
This commit is contained in:
committed by
Kevin Barabash
parent
ba8e224b8d
commit
3907545e2c
@@ -1597,6 +1597,16 @@ describe("A comment parser", function() {
|
||||
expect("% comment 1\n% comment 2\n").toParse();
|
||||
});
|
||||
|
||||
it("should parse comments between subscript and superscript", () => {
|
||||
expect("x_3 %comment\n^2").toParseLike`x_3^2`;
|
||||
});
|
||||
|
||||
it("should parse comments in size and color groups", () => {
|
||||
expect("\\kern{1 %kern\nem}").toParse();
|
||||
expect("\\kern1 %kern\nem").toParse();
|
||||
expect("\\color{#f00%red\n}").toParse();
|
||||
});
|
||||
|
||||
it("should not parse a comment without newline in strict mode", () => {
|
||||
expect`x%y`.not.toParse(strictSettings);
|
||||
expect`x%y`.toParse(nonstrictSettings);
|
||||
@@ -2527,12 +2537,6 @@ describe("href and url commands", function() {
|
||||
expect("\\url%end").toParseLike("\\url {%}end");
|
||||
});
|
||||
|
||||
it("should detect missing second argument in \\href", () => {
|
||||
expect`\href{http://example.com/}`.not.toParse();
|
||||
expect`\href%`.not.toParse();
|
||||
expect`\href %`.not.toParse();
|
||||
});
|
||||
|
||||
it("should allow spaces single-character URLs", () => {
|
||||
expect`\href %end`.toParseLike("\\href{%}end");
|
||||
expect("\\url %end").toParseLike("\\url{%}end");
|
||||
@@ -2547,7 +2551,7 @@ describe("href and url commands", function() {
|
||||
});
|
||||
|
||||
it("should allow balanced braces in url", function() {
|
||||
const url = "http://example.org/{too}";
|
||||
const url = "http://example.org/{{}t{oo}}";
|
||||
const parsed1 = getParsed(`\\href{${url}}{\\alpha}`)[0];
|
||||
expect(parsed1.href).toBe(url);
|
||||
const parsed2 = getParsed(`\\url{${url}}`)[0];
|
||||
|
Reference in New Issue
Block a user