Change frac-line from border to full span (#976)

* Change frac-line from border to full span

Change `frac-line`  and `vertical-separator`.  Instead of using span borders, fill entire span using a `box-shadow`.

This change will enable more dependable engagement of the `min-height` CSS.

* Fix indentation

* Fix indent again

* Change box shadow to inline SVG

* Fix lint error

* regenerate screenshots after switching to SVG for fraction bars
This commit is contained in:
Ron Kok
2017-11-24 08:41:53 -08:00
committed by Kevin Barabash
parent fd82c4fad0
commit b2698d35ec
32 changed files with 37 additions and 8 deletions

View File

@@ -475,9 +475,11 @@ groupTypes.spacing = function(group, options) {
}; };
export const makeLineSpan = function(className, options, thickness) { export const makeLineSpan = function(className, options, thickness) {
const line = makeSpan([className], [], options); // Fill the entire span instead of just a border. That way, the min-height
// value in katex.less will ensure that at least one screen pixel displays.
const line = stretchy.ruleSpan(className, options);
line.height = thickness || options.fontMetrics().defaultRuleThickness; line.height = thickness || options.fontMetrics().defaultRuleThickness;
line.style.borderBottomWidth = line.height + "em"; line.style.height = line.height + "em";
line.maxFontSize = 1.0; line.maxFontSize = 1.0;
return line; return line;
}; };

View File

@@ -6,6 +6,7 @@ import ParseError from "../ParseError";
import ParseNode from "../ParseNode"; import ParseNode from "../ParseNode";
import {calculateSize} from "../units"; import {calculateSize} from "../units";
import utils from "../utils"; import utils from "../utils";
import stretchy from "../stretchy";
import * as html from "../buildHTML"; import * as html from "../buildHTML";
import * as mml from "../buildMathML"; import * as mml from "../buildMathML";
@@ -198,9 +199,8 @@ const htmlBuilder = function(group, options) {
} }
if (colDescr.separator === "|") { if (colDescr.separator === "|") {
const separator = buildCommon.makeSpan( const separator = stretchy.ruleSpan("vertical-separator",
["vertical-separator"], options);
[]);
separator.style.height = totalHeight + "em"; separator.style.height = totalHeight + "em";
separator.style.verticalAlign = separator.style.verticalAlign =
-(totalHeight - offset) + "em"; -(totalHeight - offset) + "em";

View File

@@ -315,8 +315,22 @@ const encloseSpan = function(
return img; return img;
}; };
const ruleSpan = function(className: string, options: Options): span {
// Get a big square image. The parent span will hide the overflow.
const pathNode = new domTree.pathNode('bigRule');
const attributes = [
["width", "400em"],
["height", "400em"],
["viewBox", "0 0 400000 400000"],
["preserveAspectRatio", "xMinYMin slice"],
];
const svg = new domTree.svgNode([pathNode], attributes);
return buildCommon.makeSpan([className, "hide-tail"], [svg], options);
};
export default { export default {
encloseSpan: encloseSpan, encloseSpan: encloseSpan,
mathMLnode: mathMLnode, mathMLnode: mathMLnode,
ruleSpan: ruleSpan,
svgSpan: svgSpan, svgSpan: svgSpan,
}; };

View File

@@ -5,6 +5,10 @@
*/ */
const path: {[string]: string} = { const path: {[string]: string} = {
// bigRule provides a big square image for frac-lines, etc.
// The actual rendered rule is smaller, controlled by overflow:hidden.
bigRule: 'M0 0 h400000 v400000 h-400000z M0 0 h400000 v400000 h-400000z',
// sqrtMain path geometry is from glyph U221A in the font KaTeX Main // sqrtMain path geometry is from glyph U221A in the font KaTeX Main
sqrtMain: `M95 622c-2.667 0-7.167-2.667-13.5 sqrtMain: `M95 622c-2.667 0-7.167-2.667-13.5
-8S72 604 72 600c0-2 .333-3.333 1-4 1.333-2.667 23.833-20.667 67.5-54s -8S72 604 72 600c0-2 .333-3.333 1-4 1.333-2.667 23.833-20.667 67.5-54s

View File

@@ -297,7 +297,6 @@
.frac-line { .frac-line {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
border-bottom-style: solid;
} }
} }
@@ -428,7 +427,6 @@
.underline .underline-line { .underline .underline-line {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
border-bottom-style: solid;
} }
.sqrt { .sqrt {
@@ -546,7 +544,18 @@
.vertical-separator { .vertical-separator {
display: inline-block; display: inline-block;
margin: 0 -0.025em; margin: 0 -0.025em;
border-right: 0.05em solid black; width: 0.05em;
// Set a min-width so it will display at least one screen pixel.
@media screen {
min-width: 1px;
}
// Modify min-width for retina displays. Don't force two screen pixels.
@media screen and (-webkit-min-device-pixel-ratio: 2.0),
screen and (min-resolution: 192dpi) {
min-width: 0.5px;
}
} }
.arraycolsep { .arraycolsep {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 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: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB