mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 12:38:39 +00:00
Rename breakOnUnsupportedCmds to throwOnError.
Also, the MathBb-chrome test changed, to what I believe is the correct result? Not sure why it looked wrong before. Test plan: - `make test` - take screenshots, see nothing changed.
This commit is contained in:
@@ -1707,43 +1707,43 @@ describe("A MathML builder", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("A parser that does not break on unsupported commands", function() {
|
||||
describe("A parser that does not throw on unsupported commands", function() {
|
||||
// The parser breaks on unsupported commands unless it is explicitly
|
||||
// told not to
|
||||
var errorColor = "#933";
|
||||
var doNotBreakSettings = new Settings({
|
||||
breakOnUnsupportedCmds: false,
|
||||
var noThrowSettings = new Settings({
|
||||
throwOnError: false,
|
||||
errorColor: errorColor
|
||||
});
|
||||
|
||||
it("should still parse on unrecognized control sequences", function() {
|
||||
expect("\\error").toParse(doNotBreakSettings);
|
||||
expect("\\error").toParse(noThrowSettings);
|
||||
});
|
||||
|
||||
describe("should allow unrecognized controls sequences anywhere, including", function() {
|
||||
it("in superscripts and subscripts", function() {
|
||||
expect("2_\\error").toBuild(doNotBreakSettings);
|
||||
expect("3^{\\error}_\\error").toBuild(doNotBreakSettings);
|
||||
expect("\\int\\nolimits^\\error_\\error").toBuild(doNotBreakSettings);
|
||||
expect("2_\\error").toBuild(noThrowSettings);
|
||||
expect("3^{\\error}_\\error").toBuild(noThrowSettings);
|
||||
expect("\\int\\nolimits^\\error_\\error").toBuild(noThrowSettings);
|
||||
});
|
||||
|
||||
it("in fractions", function() {
|
||||
expect("\\frac{345}{\\error}").toBuild(doNotBreakSettings);
|
||||
expect("\\frac\\error{\\error}").toBuild(doNotBreakSettings);
|
||||
expect("\\frac{345}{\\error}").toBuild(noThrowSettings);
|
||||
expect("\\frac\\error{\\error}").toBuild(noThrowSettings);
|
||||
});
|
||||
|
||||
it("in square roots", function() {
|
||||
expect("\\sqrt\\error").toBuild(doNotBreakSettings);
|
||||
expect("\\sqrt{234\\error}").toBuild(doNotBreakSettings);
|
||||
expect("\\sqrt\\error").toBuild(noThrowSettings);
|
||||
expect("\\sqrt{234\\error}").toBuild(noThrowSettings);
|
||||
});
|
||||
|
||||
it("in text boxes", function() {
|
||||
expect("\\text{\\error}").toBuild(doNotBreakSettings);
|
||||
expect("\\text{\\error}").toBuild(noThrowSettings);
|
||||
});
|
||||
});
|
||||
|
||||
it("should produce color nodes with a color value given by errorColor", function() {
|
||||
var parsedInput = getParsed("\\error", doNotBreakSettings);
|
||||
var parsedInput = getParsed("\\error", noThrowSettings);
|
||||
expect(parsedInput[0].type).toBe("color");
|
||||
expect(parsedInput[0].value.color).toBe(errorColor);
|
||||
});
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 11 KiB |
@@ -11,7 +11,7 @@ var fs = require("fs");
|
||||
var jsyaml = require("js-yaml");
|
||||
var querystring = require("querystring");
|
||||
|
||||
var queryKeys = ["tex", "pre", "post", "display", "doNotBreak", "errorColor"];
|
||||
var queryKeys = ["tex", "pre", "post", "display", "noThrow", "errorColor"];
|
||||
var dict = fs.readFileSync(require.resolve("./ss_data.yaml"));
|
||||
dict = jsyaml.safeLoad(dict);
|
||||
for (var key in dict) {
|
||||
|
@@ -106,7 +106,7 @@ SupSubOffsets: \displaystyle \int_{2+3}x f^{2+3}+3\lim_{2+3+4+5}f
|
||||
Text: \frac{a}{b}\text{c~ {ab} \ e}+fg
|
||||
UnsupportedCmds:
|
||||
tex: \err\,\frac\fracerr3\,2^\superr_\suberr\,\sqrt\sqrterr
|
||||
doNotBreak: 1
|
||||
noThrow: 1
|
||||
errorColor: "#dd4c4c"
|
||||
VerticalSpacing:
|
||||
pre: potato<br>blah
|
||||
|
@@ -28,7 +28,7 @@
|
||||
|
||||
var settings = {
|
||||
displayMode: !!query["display"],
|
||||
breakOnUnsupportedCmds: !query["doNotBreak"]
|
||||
throwOnError: !query["noThrow"]
|
||||
};
|
||||
if (query["errorColor"]) {
|
||||
settings.errorColor = query["errorColor"];
|
||||
|
Reference in New Issue
Block a user