mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-07 04:08:43 +00:00
unicodeTextInMathMode setting (#1117)
* unicodeTextInMathMode setting * When `unicodeTextInMathMode` is `true`, accented letters from `unicodeSymbols.js`, and CJK and other supported languages, get added support in math mode (as requested in #895). * When `unicodeTextInMathMode` is `false, all of these stop working in math mode, and are only supported in text mode (matching XeTeX behavior). Note that this is a backwards incompatibility with some 0.9.0 alpha/betas. * Fix handling of Unicode characters ð, Å, å * Fix double handling of ð (math maps to \eth, not special Unicode character) * Remove Åå special math handling, thanks to #1125 * Forbid extraLatin when unicodeTextInMathMode is false
This commit is contained in:
committed by
Kevin Barabash
parent
7de91f73eb
commit
aed1c1e564
@@ -2864,7 +2864,8 @@ describe("Unicode accents", function() {
|
||||
"\\tilde n" +
|
||||
"\\grave o\\acute o\\hat o\\tilde o\\ddot o" +
|
||||
"\\grave u\\acute u\\hat u\\ddot u" +
|
||||
"\\acute y\\ddot y");
|
||||
"\\acute y\\ddot y",
|
||||
{unicodeTextInMathMode: true});
|
||||
});
|
||||
|
||||
it("should parse Latin-1 letters in text mode", function() {
|
||||
@@ -2894,18 +2895,21 @@ describe("Unicode accents", function() {
|
||||
});
|
||||
|
||||
it("should parse combining characters", function() {
|
||||
expect("A\u0301C\u0301").toParseLike("Á\\acute C");
|
||||
expect("A\u0301C\u0301").toParseLike("Á\\acute C",
|
||||
{unicodeTextInMathMode: true});
|
||||
expect("\\text{A\u0301C\u0301}").toParseLike("\\text{Á\\'C}");
|
||||
});
|
||||
|
||||
it("should parse multi-accented characters", function() {
|
||||
expect("ấā́ắ\\text{ấā́ắ}").toParse();
|
||||
expect("ấā́ắ\\text{ấā́ắ}").toParse({unicodeTextInMathMode: true});
|
||||
// Doesn't parse quite the same as
|
||||
// "\\text{\\'{\\^a}\\'{\\=a}\\'{\\u a}}" because of the ordgroups.
|
||||
});
|
||||
|
||||
it("should parse accented i's and j's", function() {
|
||||
expect("íȷ́").toParseLike("\\acute ı\\acute ȷ");
|
||||
expect("íȷ́").toParseLike("\\acute ı\\acute ȷ",
|
||||
{unicodeTextInMathMode: true});
|
||||
expect("ấā́ắ\\text{ấā́ắ}").toParse({unicodeTextInMathMode: true});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3009,6 +3013,29 @@ describe("Symbols", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("unicodeTextInMathMode setting", function() {
|
||||
it("should allow unicode text when true", () => {
|
||||
expect("é").toParse({unicodeTextInMathMode: true});
|
||||
expect("試").toParse({unicodeTextInMathMode: true});
|
||||
});
|
||||
|
||||
it("should forbid unicode text when false", () => {
|
||||
expect("é").toNotParse({unicodeTextInMathMode: false});
|
||||
expect("試").toNotParse({unicodeTextInMathMode: false});
|
||||
});
|
||||
|
||||
it("should forbid unicode text when default", () => {
|
||||
expect("é").toNotParse();
|
||||
expect("試").toNotParse();
|
||||
});
|
||||
|
||||
it("should always allow unicode text in text mode", () => {
|
||||
expect("\\text{é試}").toParse({unicodeTextInMathMode: false});
|
||||
expect("\\text{é試}").toParse({unicodeTextInMathMode: true});
|
||||
expect("\\text{é試}").toParse();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Internal __* interface", function() {
|
||||
const latex = "\\sum_{k = 0}^{\\infty} x^k";
|
||||
const rendered = katex.renderToString(latex);
|
||||
|
Reference in New Issue
Block a user