mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
One strut instead of two (#1307)
* One strut instead of two As suggested in https://github.com/Khan/KaTeX/pull/1287#discussion_r187485780 the two struts were redundant; the formerly "bottom" strut suffices to implement both height and depth constraints. * Update screenshots
This commit is contained in:
@@ -641,20 +641,17 @@ function buildHTMLUnbreakable(children, options) {
|
||||
// Compute height and depth of this chunk.
|
||||
const body = makeSpan(["base"], children, options);
|
||||
|
||||
// Add struts, which ensure that the top of the HTML element falls at
|
||||
// Add strut, which ensures that the top of the HTML element falls at
|
||||
// the height of the expression, and the bottom of the HTML element
|
||||
// falls at the depth of the expression.
|
||||
const topStrut = makeSpan(["strut"]);
|
||||
const bottomStrut = makeSpan(["strut", "bottom"]);
|
||||
|
||||
topStrut.style.height = body.height + "em";
|
||||
bottomStrut.style.height = (body.height + body.depth) + "em";
|
||||
// We'd like to use `vertical-align: top` but in IE 9 this lowers the
|
||||
// baseline of the box to the bottom of this strut (instead staying in the
|
||||
// normal place) so we use an absolute value for vertical-align instead
|
||||
bottomStrut.style.verticalAlign = -body.depth + "em";
|
||||
|
||||
body.children.unshift(topStrut, bottomStrut);
|
||||
// We used to have separate top and bottom struts, where the bottom strut
|
||||
// would like to use `vertical-align: top`, but in IE 9 this lowers the
|
||||
// baseline of the box to the bottom of this strut (instead of staying in
|
||||
// the normal place) so we use an absolute value for vertical-align instead.
|
||||
const strut = makeSpan(["strut"]);
|
||||
strut.style.height = (body.height + body.depth) + "em";
|
||||
strut.style.verticalAlign = -body.depth + "em";
|
||||
body.children.unshift(strut);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user