Skip to content

Commit d33f1ae

Browse files
committed
Add support for default MathML spacing for operators not in the dictionary
1 parent 1e40b54 commit d33f1ae

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

mathjax3-ts/core/MmlTree/MmlNodes/mo.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import {PropertyList} from '../../Tree/Node.js';
2525
import {AbstractMmlTokenNode, MmlNode, AttributeList, TEXCLASS} from '../MmlNode.js';
2626
import {MmlMrow} from './mrow.js';
27-
import {OperatorList, OPTABLE, RangeDef, RANGES} from '../OperatorDictionary.js';
27+
import {OperatorList, OPTABLE, RangeDef, RANGES, MMLSPACING} from '../OperatorDictionary.js';
2828

2929
/*****************************************************************/
3030
/*
@@ -59,9 +59,10 @@ export class MmlMo extends AbstractMmlTokenNode {
5959
};
6060

6161
/*
62-
* Unicode ranges and their default TeX classes
62+
* Unicode ranges and their default TeX classes and MathML spacing
6363
*/
64-
public static RANGES: RangeDef[] = RANGES;
64+
public static RANGES = RANGES;
65+
public static MMLSPACING = MMLSPACING;
6566

6667
/*
6768
* The Operator Dictionary.
@@ -243,9 +244,9 @@ export class MmlMo extends AbstractMmlTokenNode {
243244
let range = this.getRange(mo);
244245
if (range) {
245246
this.texClass = range[2];
246-
// TODO: Fix range numbers.
247-
// this.lspace = (range[0] + 1) / 18;
248-
// this.rspace = (range[1] + 1) / 18;
247+
const spacing = (this.constructor as typeof MmlMo).MMLSPACING[range[2]];
248+
this.lspace = (spacing[0] + 1) / 18;
249+
this.rspace = (spacing[1] + 1) / 18;
249250
}
250251
}
251252
}

mathjax3-ts/core/MmlTree/OperatorDictionary.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,19 @@ export const RANGES: RangeDef[] = [
102102
[0x1D400, 0x1D7FF, TEXCLASS.ORD, 'MathAlphabets']
103103
];
104104

105+
/*
106+
* The default MathML spacing for the various TeX classes.
107+
*/
108+
export const MMLSPACING = [
109+
[0, 0], // ORD
110+
[1, 2], // OP
111+
[3, 3], // BIN
112+
[4, 4], // REL
113+
[0, 0], // OPEN
114+
[0, 0], // CLOSE
115+
[0, 3] // PUNCT
116+
];
117+
105118
/*
106119
* The operator dictionary, with sections for the three forms: prefix, postfix, and infix
107120
*/

0 commit comments

Comments
 (0)