Skip to content

Commit 8e975dd

Browse files
committed
Make constants for indent attribute names and for 100%, as per Volker's review
1 parent 08db0ac commit 8e975dd

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

mathjax3-ts/core/MmlTree/MmlNode.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ const TEXSPACE = [
6767
[ 1, -1, 2, 3, 1, 0, 1, 1] // INNER
6868
];
6969

70+
/*
71+
* Attributes used to determine indentation and shifting
72+
*/
73+
export const indentAttributes = [
74+
'indentalign', 'indentalignfirst',
75+
'indentshift', 'indentshiftfirst'
76+
];
77+
7078

7179
/*****************************************************************/
7280
/*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
import {PropertyList, Node} from '../../Tree/Node.js';
25-
import {MmlNode, AbstractMmlNode, AttributeList, TEXCLASS} from '../MmlNode.js';
25+
import {MmlNode, AbstractMmlNode, AttributeList, TEXCLASS, indentAttributes} from '../MmlNode.js';
2626
import {split} from '../../../util/string.js';
2727

2828
/*****************************************************************/
@@ -79,7 +79,7 @@ export class MmlMtable extends AbstractMmlNode {
7979
// Force inheritance of shift and align values (since they are needed to output tables with labels)
8080
// but make sure they are not given explicitly on the <mtable> tag.
8181
//
82-
for (const name of ['indentalign', 'indentalignfirst', 'indentshift', 'indentshiftfirst']) {
82+
for (const name of indentAttributes) {
8383
if (attributes[name]) {
8484
this.attributes.setInherited(name, attributes[name][1]);
8585
}

mathjax3-ts/output/chtml/BBox.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export type BBoxData = {
5252
*/
5353

5454
export class BBox {
55+
/*
56+
* Constant for pwidth of full width box
57+
*/
58+
public static fullWidth = '100%';
59+
5560
/*
5661
* These are the data stored for a bounding box
5762
*/

mathjax3-ts/output/chtml/Wrapper.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import {AbstractWrapper} from '../../core/Tree/Wrapper.js';
2525
import {Node, PropertyList} from '../../core/Tree/Node.js';
26-
import {MmlNode, TextNode, AbstractMmlNode, AttributeList} from '../../core/MmlTree/MmlNode.js';
26+
import {MmlNode, TextNode, AbstractMmlNode, AttributeList, indentAttributes} from '../../core/MmlTree/MmlNode.js';
2727
import {Property} from '../../core/Tree/Node.js';
2828
import {OptionList} from '../../util/Options.js';
2929
import {unicodeChars} from '../../util/string.js';
@@ -279,7 +279,7 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
279279
this.childNodes = node.childNodes.map((child: Node) => {
280280
const wrapped = this.wrap(child as MmlNode);
281281
if (wrapped.bbox.pwidth) {
282-
this.bbox.pwidth = '100%';
282+
this.bbox.pwidth = BBox.fullWidth;
283283
}
284284
return wrapped;
285285
});
@@ -622,7 +622,7 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
622622
*/
623623
protected handlePWidth() {
624624
if (this.bbox.pwidth) {
625-
if (this.bbox.pwidth === '100%') {
625+
if (this.bbox.pwidth === BBox.fullWidth) {
626626
this.adaptor.setAttribute(this.chtml, 'width', 'full');
627627
} else {
628628
this.adaptor.setStyle(this.chtml, 'width', this.bbox.pwidth);
@@ -683,8 +683,7 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
683683
*/
684684
protected getAlignShift() {
685685
let {indentalign, indentshift, indentalignfirst, indentshiftfirst} =
686-
this.node.attributes.getList('indentalign', 'indentshift',
687-
'indentalignfirst', 'indentshiftfirst') as StringMap;
686+
this.node.attributes.getList(...indentAttributes) as StringMap;
688687
if (indentalignfirst !== 'indentalign') {
689688
indentalign = indentalignfirst;
690689
}
@@ -702,7 +701,7 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
702701
}
703702

704703
/*
705-
* @param{N} chtml The HTML node whose indenting is to be adjusted
704+
* @param{N} chtml The HTML node whose indentation is to be adjusted
706705
* @param{string} align The alignment for the node
707706
* @param{number} shift The indent (positive or negative) for the node
708707
*/

mathjax3-ts/output/chtml/Wrappers/mrow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class CHTMLmrow<N, T, D> extends CHTMLWrapper<N, T, D> {
4848
this.stretchChildren();
4949
for (const child of this.childNodes) {
5050
if (child.bbox.pwidth) {
51-
this.bbox.pwidth = '100%';
51+
this.bbox.pwidth = BBox.fullWidth;
5252
break;
5353
}
5454
}

mathjax3-ts/output/chtml/Wrappers/mtable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export class CHTMLmtable<N, T, D> extends CHTMLWrapper<N, T, D> {
181181
protected getPercentageWidth() {
182182
for (const row of this.childNodes) {
183183
if (row.node.isKind('mlabeledtr')) {
184-
this.bbox.pwidth = '100%';
184+
this.bbox.pwidth = BBox.fullWidth;
185185
return;
186186
}
187187
}

0 commit comments

Comments
 (0)