mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
Support Unicode Big Operators (#961)
* Support Unicode Big Operators This is the sixth in a series of PRs to give KaTeX the ability to recognize Unicode character input. This is the final PR in this series that will submit characters in bulk. After this, there come some characters whose alias or atom type was not obvious. I'll turn in PRs for them, too, but only after they are vetted. * Move constants outside of main functions * Replace ∫ with \u222b * Add backslash
This commit is contained in:
@@ -258,6 +258,13 @@ defineFunction([
|
||||
};
|
||||
});
|
||||
|
||||
const singleCharIntegrals: {[string]: string} = {
|
||||
"\u222b": "\\int",
|
||||
"\u222c": "\\iint",
|
||||
"\u222d": "\\iiint",
|
||||
"\u222e": "\\oint",
|
||||
};
|
||||
|
||||
// There are 2 flags for operators; whether they produce limits in
|
||||
// displaystyle, and whether they are symbols and should grow in
|
||||
// displaystyle. These four groups cover the four possible choices.
|
||||
@@ -297,15 +304,20 @@ defineFunction([
|
||||
|
||||
// No limits, symbols
|
||||
defineFunction([
|
||||
"\\int", "\\iint", "\\iiint", "\\oint",
|
||||
"\\int", "\\iint", "\\iiint", "\\oint", "\u222b", "\u222c",
|
||||
"\u222d", "\u222e",
|
||||
], {
|
||||
numArgs: 0,
|
||||
}, function(context) {
|
||||
let fName = context.funcName;
|
||||
if (fName.length === 1) {
|
||||
fName = singleCharIntegrals[fName];
|
||||
}
|
||||
return {
|
||||
type: "op",
|
||||
limits: false,
|
||||
symbol: true,
|
||||
body: context.funcName,
|
||||
body: fName,
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -220,22 +220,43 @@ const mathmlBuilder = (group, options) => {
|
||||
return node;
|
||||
};
|
||||
|
||||
const singleCharBigOps: {[string]: string} = {
|
||||
"\u220F": "\\prod",
|
||||
"\u2210": "\\coprod",
|
||||
"\u2211": "\\sum",
|
||||
"\u22c0": "\\bigwedge",
|
||||
"\u22c1": "\\bigvee",
|
||||
"\u22c2": "\\bigcap",
|
||||
"\u22c3": "\\bigcap",
|
||||
"\u2a00": "\\bigodot",
|
||||
"\u2a01": "\\bigoplus",
|
||||
"\u2a02": "\\bigotimes",
|
||||
"\u2a04": "\\biguplus",
|
||||
"\u2a06": "\\bigsqcup",
|
||||
};
|
||||
|
||||
defineFunction({
|
||||
type: "op",
|
||||
names: [
|
||||
"\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
|
||||
"\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
|
||||
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint",
|
||||
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint", "\u220F",
|
||||
"\u2210", "\u2211", "\u22c0", "\u22c1", "\u22c2", "\u22c3", "\u2a00",
|
||||
"\u2a01", "\u2a02", "\u2a04", "\u2a06",
|
||||
],
|
||||
props: {
|
||||
numArgs: 0,
|
||||
},
|
||||
handler: (context, args) => {
|
||||
let fName = context.funcName;
|
||||
if (fName.length === 1) {
|
||||
fName = singleCharBigOps[fName];
|
||||
}
|
||||
return {
|
||||
type: "op",
|
||||
limits: true,
|
||||
symbol: true,
|
||||
body: context.funcName,
|
||||
body: fName,
|
||||
};
|
||||
},
|
||||
htmlBuilder,
|
||||
|
@@ -2634,6 +2634,10 @@ describe("Unicode", function() {
|
||||
expect("∈∋∝∼∽≂≃≅≈≊≍≎≏≐≑≒≓≖≗≜≡≤≥≦≧≫≬≳≷≺≻≼≽≾≿").toParse();
|
||||
});
|
||||
|
||||
it("should parse big operators", function() {
|
||||
expect("∏∐∑∫∬∭∮⋀⋁⋂⋃⨀⨁⨂⨄⨆").toParse();
|
||||
});
|
||||
|
||||
it("should parse more relations", function() {
|
||||
expect("⊂⊃⊆⊇⊏⊐⊑⊒⊢⊣⊩⊪⊸⋈⋍⋐⋑⋔⋙⋛⋞⋟⌢⌣⩾⪆⪌⪕⪖⪯⪰⪷⪸⫅⫆").toParse();
|
||||
});
|
||||
|
Reference in New Issue
Block a user