Introduce "atom" parse node to coalesce various symbol nodes. (#1541)

This commit is contained in:
Ashish Myles
2018-08-02 07:46:40 -04:00
committed by ylemkimon
parent 30be53efe6
commit 7e97a382ec
8 changed files with 126 additions and 127 deletions

View File

@@ -45,15 +45,14 @@ defineFunction({
mathmlBuilder,
});
export const binrelClass = (arg: AnyParseNode) => {
export const binrelClass = (arg: AnyParseNode): string => {
// \binrel@ spacing varies with (bin|rel|ord) of the atom in the argument.
// (by rendering separately and with {}s before and after, and measuring
// the change in spacing). We'll do roughly the same by detecting the
// atom type directly.
const atomType = (arg.type === "ordgroup" &&
arg.value.length ? arg.value[0].type : arg.type);
if (/^(bin|rel)$/.test(atomType)) {
return "m" + atomType;
const atom = (arg.type === "ordgroup" && arg.value.length ? arg.value[0] : arg);
if (atom.type === "atom" && (atom.family === "bin" || atom.family === "rel")) {
return "m" + atom.family;
} else {
return "mord";
}