Skip to content

Commit

Permalink
Merge pull request #73 from mathjax/ie-stretchy-braces
Browse files Browse the repository at this point in the history
Improve CSS for stretchy braces in IE and Edge
  • Loading branch information
dpvc committed Mar 5, 2018
2 parents cc0214c + a439df8 commit bd1d2ca
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
14 changes: 8 additions & 6 deletions mathjax3-ts/output/chtml/Wrappers/mo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,18 @@ export class CHTMLmo extends CHTMLWrapper {
'mjx-stretchy-v': {
display: 'inline-block'
},
'mjx-stretchy-v > *': {
display: 'block'
},
'mjx-stretchy-v > mjx-beg': {
display: 'block',
height: 0
},
'mjx-stretchy-v > mjx-end': {
display: 'block'
},
'mjx-stretchy-v > mjx-end > mjx-c': {
display: 'block'
},
'mjx-stretchy-v > mjx-beg > mjx-c, mjx-stretchy-v > mjx-end > mjx-c': {
'mjx-stretchy-v > * > mjx-c': {
transform: 'scale(1)', // improves Firefox positioning
'transform-origin': 'left center',
overflow: 'hidden'
},
'mjx-stretchy-v > mjx-ext': {
Expand All @@ -101,7 +102,8 @@ export class CHTMLmo extends CHTMLWrapper {
overflow: 'hidden'
},
'mjx-stretchy-v > mjx-ext > mjx-c': {
transform: 'scaleY(500) translateY(.1em)'
transform: 'scaleY(500) translateY(.1em)',
overflow: 'visible'
},
'mjx-mark': {
display: 'inline-block',
Expand Down
16 changes: 11 additions & 5 deletions mathjax3-ts/output/chtml/Wrappers/mtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export class CHTMLmtable extends CHTMLWrapper {
//
// Determine the number of columns and rows
//
this.numCols = this.childNodes.map(row => (row as CHTMLmtr).numCells).reduce((a, b) => Math.max(a, b));
this.numCols = this.childNodes.map(row => (row as CHTMLmtr).numCells)
.reduce((a, b) => Math.max(a, b), 0);
this.numRows = this.childNodes.length;
//
// Stretch the columns (rows are already taken care of in the CHTMLmtr wrapper)
Expand Down Expand Up @@ -192,12 +193,17 @@ export class CHTMLmtable extends CHTMLWrapper {
const cLines = this.getColumnAttributes('columnlines').slice(0, cMax).map(x => (x === 'none' ? 0 : .07));
const rLines = this.getColumnAttributes('rowlines').slice(0, cMax).map(x => (x === 'none' ? 0 : .07));
const a = this.font.params.axis_height;
const h = H.concat(D, rLines).reduce((a, b) => a + b) + (frame ? .14 : 0) +
rSpace.map(x => parseFloat(x)).reduce((a, b) => a + b) + 2 * parseFloat(fSpace[1]);
const h = H.concat(D, rLines).reduce((a, b) => a + b, 0)
+ (frame ? .14 : 0)
+ rSpace.map(x => parseFloat(x))
.reduce((a, b) => a + b, 0)
+ 2 * parseFloat(fSpace[1]);
bbox.h = h / 2 + a;
bbox.d = h / 2 - a;
bbox.w = W.concat(cLines).reduce((a, b) => a + b) +
cSpace.map(x => parseFloat(x)).reduce((a, b) => a + b) + 2 * parseFloat(fSpace[1]);
bbox.w = W.concat(cLines).reduce((a, b) => a + b, 0)
+ cSpace.map(x => parseFloat(x))
.reduce((a, b) => a + b, 0)
+ 2 * parseFloat(fSpace[1]);
}

/******************************************************************/
Expand Down
19 changes: 9 additions & 10 deletions mathjax3-ts/output/chtml/fonts/tex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,25 +404,24 @@ export class TeXFont extends FontData {
const Hb = this.addDelimiterVPart(styles, c, 'beg', beg);
this.addDelimiterVPart(styles, c, 'ext', ext);
const He = this.addDelimiterVPart(styles, c, 'end', end);
const css: StyleData = {};
if (mid) {
this.addDelimiterVPart(styles, c, 'mid', mid);
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] > mjx-ext'] = {height: '50%'}
const Hm = this.addDelimiterVPart(styles, c, 'mid', mid);
css.height = '50%';
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] > mjx-mid'] = {
'margin-top': this.em(-Hm/2),
'margin-bottom': this.em(-Hm/2)
};
}
const css: StyleData = {};
if (Hb) {
css['border-top-width'] = this.em0(Hb - .03);
}
if (He) {
css['border-bottom-width'] = this.em0(He - .03);
css['margin-bottom'] = this.em(-He);
if (mid) {
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] > mjx-ext:last-of-type'] = {
'margin-top': this.em(-He)
};
}
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] > mjx-end'] = {'margin-top': this.em(-He)};
}
if (Object.keys(css).length) {
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] mjx-ext'] = css;
styles['.MJX-TEX mjx-stretchy-v[c="' + c + '"] > mjx-ext'] = css;
}
}

Expand Down

0 comments on commit bd1d2ca

Please sign in to comment.