mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-11 14:08:42 +00:00
lexer: Remove match-at
dependency, use RegExp (#1447)
* lexer: Remove `match-at` dependency, use RegExp * chore(package): update flow-bin to version 0.75.0 * Fix flow error * Remove unused flow libs * Minor fix * Throw an error when `RegExp.exec` jumps
This commit is contained in:
@@ -27,7 +27,9 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = `
|
||||
"end": 37,
|
||||
"lexer": {
|
||||
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
|
||||
"pos": 56
|
||||
"tokenRegex": {
|
||||
"lastIndex": 56
|
||||
}
|
||||
},
|
||||
"start": 36
|
||||
},
|
||||
@@ -56,7 +58,9 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = `
|
||||
"end": 39,
|
||||
"lexer": {
|
||||
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
|
||||
"pos": 56
|
||||
"tokenRegex": {
|
||||
"lastIndex": 56
|
||||
}
|
||||
},
|
||||
"start": 38
|
||||
},
|
||||
@@ -87,7 +91,9 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = `
|
||||
"end": 42,
|
||||
"lexer": {
|
||||
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
|
||||
"pos": 56
|
||||
"tokenRegex": {
|
||||
"lastIndex": 56
|
||||
}
|
||||
},
|
||||
"start": 41
|
||||
},
|
||||
@@ -116,7 +122,9 @@ exports[`A begin/end parser should grab \\arraystretch 1`] = `
|
||||
"end": 44,
|
||||
"lexer": {
|
||||
"input": "\\\\def\\\\arraystretch{1.5}\\\\begin{matrix}a&b\\\\\\\\c&d\\\\end{matrix}",
|
||||
"pos": 56
|
||||
"tokenRegex": {
|
||||
"lastIndex": 56
|
||||
}
|
||||
},
|
||||
"start": 43
|
||||
},
|
||||
|
@@ -285,9 +285,9 @@ describe("Lexer:", function() {
|
||||
|
||||
describe("#_innerLex", function() {
|
||||
it("rejects lone surrogate char", function() {
|
||||
expect("\udcba").toFailWithParseError(
|
||||
expect("\udcba ").toFailWithParseError(
|
||||
"Unexpected character: '\udcba' at position 1:" +
|
||||
" \udcba\u0332");
|
||||
" \udcba\u0332 ");
|
||||
});
|
||||
it("rejects lone backslash at end of input", function() {
|
||||
expect("\\").toFailWithParseError(
|
||||
|
@@ -23,9 +23,17 @@ const typeFirstCompare = (a, b) => {
|
||||
}
|
||||
};
|
||||
|
||||
const regExpReplacer = (key, value) => {
|
||||
return value instanceof RegExp ? {lastIndex: value.lastIndex} : value;
|
||||
};
|
||||
|
||||
const serializer = {
|
||||
print(val) {
|
||||
return stringify(val, {cmp: typeFirstCompare, space: ' '});
|
||||
return stringify(val, {
|
||||
cmp: typeFirstCompare,
|
||||
space: ' ',
|
||||
replacer: regExpReplacer,
|
||||
});
|
||||
},
|
||||
test(val) {
|
||||
// Leave strings (e.g. XML) to other serializers
|
||||
|
Reference in New Issue
Block a user