Allow all Unicode symbols in nonstrict mode (#1217)

Change symbol parsing to allow all Unicode symbols when the appropriate strict setting allows it.  By default, this allows all symbols, but the user will get (probably two) warnings about them.
This commit is contained in:
Erik Demaine
2018-05-17 11:33:01 -04:00
committed by GitHub
parent 431434258d
commit 369b5a8276
3 changed files with 34 additions and 5 deletions

View File

@@ -973,11 +973,16 @@ export default class Parser {
}
symbol = new ParseNode(symbols[this.mode][text].group,
text, this.mode, nucleus);
} else if (supportedCodepoint(text.charCodeAt(0))) {
if (this.settings.strict && this.mode === 'math') {
this.settings.reportNonstrict("unicodeTextInMathMode",
`Unicode text character "${text[0]}" used in math mode`,
nucleus);
} else if (text.charCodeAt(0) >= 0x80) { // no symbol for e.g. ^
if (this.settings.strict) {
if (!supportedCodepoint(text.charCodeAt(0))) {
this.settings.reportNonstrict("unknownSymbol",
`Unrecognized Unicode character "${text[0]}"`, nucleus);
} else if (this.mode === "math") {
this.settings.reportNonstrict("unicodeTextInMathMode",
`Unicode text character "${text[0]}" used in math mode`,
nucleus);
}
}
symbol = new ParseNode("textord", text, this.mode, nucleus);
} else {