Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to handle smallmatrix properly #582

Merged
merged 1 commit into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ts/core/MmlTree/MmlNodes/mtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class MmlMtable extends AbstractMmlNode {
* Extra properties for this node
*/
public properties = {
useHeight: 1
useHeight: true
};

/**
Expand Down Expand Up @@ -116,6 +116,7 @@ export class MmlMtable extends AbstractMmlNode {
.appendChild(child);
}
}
level = this.getProperty('scriptlevel') as number || level;
display = !!(this.attributes.getExplicit('displaystyle') || this.attributes.getDefault('displaystyle'));
attributes = this.addInheritedAttributes(attributes, {
columnalign: this.attributes.get('columnalign'),
Expand Down
2 changes: 2 additions & 0 deletions ts/core/MmlTree/SerializedMmlVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ export class SerializedMmlVisitor extends MmlVisitor {
}
setclass && this.setDataAttribute(data, 'texclass', texclass < 0 ? 'NONE' : TEXCLASSNAMES[texclass]);
}
node.getProperty('scriptlevel') && node.getProperty('useHeight') === false &&
this.setDataAttribute(data, 'smallmatrix', 'true');
return data;
}

Expand Down
3 changes: 3 additions & 0 deletions ts/input/mathml/MathMLCompile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ export class MathMLCompile<N, T, D> {
} else if (name === 'data-mjx-variant') {
mml.attributes.set('mathvariant', value);
ignoreVariant = true;
} else if (name === 'data-mjx-smallmatrix') {
mml.setProperty('scriptlevel', 1);
mml.setProperty('useHeight', false);
}
} else if (name !== 'class') {
let val = value.toLowerCase();
Expand Down
7 changes: 3 additions & 4 deletions ts/input/tex/base/BaseItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,9 @@ export class ArrayItem extends BaseItem {
const scriptlevel = this.arraydef['scriptlevel'];
delete this.arraydef['scriptlevel'];
let mml = this.create('node', 'mtable', this.table, this.arraydef);
if (scriptlevel) {
mml.setProperty('scriptlevel', scriptlevel);
}
if (this.frame.length === 4) {
// @test Enclosed frame solid, Enclosed frame dashed
NodeUtil.setAttribute(mml, 'frame', this.dashed ? 'dashed' : 'solid');
Expand All @@ -866,10 +869,6 @@ export class ArrayItem extends BaseItem {
NodeUtil.setAttribute(mml, 'padding', 0);
}
}
if (scriptlevel) {
// @test Subarray, Small Matrix
mml = this.create('node', 'mstyle', [mml], {scriptlevel: scriptlevel});
}
if (this.getProperty('open') || this.getProperty('close')) {
// @test Cross Product Formula
mml = ParseUtil.fenced(this.factory.configuration,
Expand Down
3 changes: 3 additions & 0 deletions ts/output/chtml/Wrappers/mtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ CommonMtableMixin<CHTMLmtd<any, any, any>, CHTMLmtr<any, any, any>, CHTMLConstru
'position': 'relative',
'box-sizing': 'border-box'
},
'mjx-mstyle[size="s"] mjx-mtable': {
'vertical-align': '.354em'
},
'mjx-labels': {
position: 'absolute',
left: 0,
Expand Down
7 changes: 5 additions & 2 deletions ts/output/chtml/Wrappers/mtd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ CommonMtdMixin<CHTMLConstructor<any, any, any>>(CHTMLWrapper) {
this.adaptor.setStyle(this.chtml, 'textAlign', calign);
}
//
// Include a strut to force minimum height and depth
// If we are using minimum row heights,
// Include a strut to force minimum height and depth
//
this.adaptor.append(this.chtml, this.html('mjx-tstrut'));
if (this.parent.parent.node.getProperty('useHeight')) {
this.adaptor.append(this.chtml, this.html('mjx-tstrut'));
}
}

}
4 changes: 3 additions & 1 deletion ts/output/common/Wrappers/mrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export function CommonMrowMixin<T extends WrapperConstructor>(Base: T): MrowCons
for (const child of this.childNodes) {
const noStretch = (child.stretch.dir === DIRECTION.None);
if (all || noStretch) {
const {h, d} = child.getBBox(noStretch);
let {h, d, rscale} = child.getBBox(noStretch);
h *= rscale;
d *= rscale;
if (h > H) H = h;
if (d > D) D = d;
}
Expand Down
12 changes: 10 additions & 2 deletions ts/output/common/Wrappers/mtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,16 @@ export function CommonMtableMixin<
*/
public updateHDW(cell: C, i: number, j: number, H: number[], D: number[], W: number[] = null) {
let {h, d, w} = cell.getBBox();
if (h < .75) h = .75;
if (d < .25) d = .25;
const scale = cell.parent.bbox.rscale;
if (cell.parent.bbox.rscale !== 1) {
h *= scale;
d *= scale;
w *= scale;
}
if (this.node.getProperty('useHeight')) {
if (h < .75) h = .75;
if (d < .25) d = .25;
}
if (h > H[j]) H[j] = h;
if (d > D[j]) D[j] = d;
if (W && w > W[i]) W[i] = w;
Expand Down