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

Padding over \sqrt and Paths for frac-line #1143

Merged
merged 13 commits into from
Feb 17, 2018
Merged

Padding over \sqrt and Paths for frac-line #1143

merged 13 commits into from
Feb 17, 2018

Conversation

ronkok
Copy link
Collaborator

@ronkok ronkok commented Feb 5, 2018

This replaces two earlier PRs, #1131 Change frac-line from SVG line to SVG path, and #1136 Add 0.08em padding above \sqrt line.

It was easier to create a substitute branch than it was to repair my messed up history.

This replaces two earlier PRs.
src/stretchy.js Outdated
xrightequilibrium: [["baraboveshortleftharpoon",
"rightharpoonaboveshortbar"], 1.75, 716],
xleftequilibrium: [["shortbaraboveleftharpoon",
"shortrightharpoonabovebar"], 1.75, 716],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these should've been removed. It breaks the ReactionArrows test.

src/stretchy.js Outdated
@@ -47,9 +47,6 @@ const stretchyCodePoint: {[string]: string} = {
xtwoheadrightarrow: "\u21a0",
xlongequal: "=",
xtofrom: "\u21c4",
xrightleftarrows: "\u21c4",
xrightequilibrium: "\u21cc", // Not a perfect match.
xleftequilibrium: "\u21cb", // None better available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These probably shouldn't be removed.

@ronkok
Copy link
Collaborator Author

ronkok commented Feb 5, 2018

@kevinbarabash Thank you. In my frustration, I got hasty.

@kevinbarabash
Copy link
Member

I've regenerate the screenshots in ronkok#1. It's incredible how many of our screenshots involve fractions. Many of them probably don't need fractions to test what they're testing.

@ronkok
Copy link
Collaborator Author

ronkok commented Feb 11, 2018

It's incredible how many of our screenshots involve fractions.

I know that I contributed to that. When I was testing stretchy arrows, fractions were a cheap way to test vertical alignment and vertical kerns used for clearances.

@codecov
Copy link

codecov bot commented Feb 11, 2018

Codecov Report

Merging #1143 into master will increase coverage by 0.02%.
The diff coverage is 70.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1143      +/-   ##
==========================================
+ Coverage   79.36%   79.38%   +0.02%     
==========================================
  Files          59       59              
  Lines        3862     3871       +9     
  Branches      648      648              
==========================================
+ Hits         3065     3073       +8     
- Misses        662      663       +1     
  Partials      135      135
Impacted Files Coverage Δ
src/functions/genfrac.js 58.94% <ø> (ø) ⬆️
src/svgGeometry.js 100% <100%> (ø) ⬆️
src/stretchy.js 82.02% <62.5%> (-0.2%) ⬇️
src/delimiter.js 41.76% <70.58%> (+1.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bceb7bd...3580760. Read the comment docs.

@kevinbarabash
Copy link
Member

kevinbarabash commented Feb 11, 2018

When I was testing stretchy arrows, fractions were a cheap way to test vertical alignment and vertical kerns used for clearances.

I guess you need some way to test clearance on top. It's either \frac or \sqrt.

src/delimiter.js Outdated

if (delim.type === "small") {
// Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
viewBoxHeight = 1000; // from font
viewBoxHeight = 1080; // 1000 unit glyph height + 80 unit padding.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it be good to extract some of these values into constants, e.g.

const emBoxHeight = 1000;
const delimiterPadding = 80;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

src/delimiter.js Outdated
-2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1h-12l-28-84c-16.667-52-96.667
-294.333-240-727l-212 -643 -85 170c-4-3.333-8.333-7.667-13 -13l-13-13l77-155
77-156c66 199.333 139 419.667 219 661 l218 661zM702 0H400000v40H742z`;
77-156c66 199.333 139 419.667 219 661 l218 661zM702 80H400000v40H742z`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have const delimiterPadding = 80; replace the 80 in the this string with ${delimiterPadding}... or at the very least add a component stating what the 80 is so that if people need to change the padding in the future it's easy to find all the places that need updating.

src/delimiter.js Outdated
const newOptions = options.havingBaseStyle(delim.style);
sizeMultiplier = newOptions.sizeMultiplier / options.sizeMultiplier;
spanHeight = 1 * sizeMultiplier;
spanHeight = 1.08 * sizeMultiplier;
texHeight = 1.00 * sizeMultiplier;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to extract a constant for 0.08 as well.

"viewBox": "0 0 10 10",
"preserveAspectRatio": "none",
if (className === "vertical-separator") {
path = new domTree.pathNode("vertSeparator");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thanks for updating vertical separators to be consistent with the horizontal ones.


path = new domTree.pathNode("stdHorizRule");
svgNode = new domTree.svgNode([path], {
"width": "400em",
"height": 5 * lineThickness + "em",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting that the line thickness changes for horizontal rules but not for vertical separators. Is that just a LaTeX quirk?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vertical line constant value is what I found in the code when I changed it from a span border to an SVG path. I did not go back to underlying sources to check if that was correct.

@@ -475,6 +477,8 @@
.stretchy {
width: 100%;
display: block;
position: relative;
overflow: hidden;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also b/c of a Chrome rendering issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Those two new lines are only necessary for IE. In earlier work, I had put those two lines of CSS into class hide-tail and then nested hide-tail inside a stretchy span. I found here that I could save one nesting level by writing those two new lines into stretchy. I could possibly refactor some other code and save a nesting level elsewhere, but I've got other priorities right now.

// It is in a viewBox that is 5x as tall as the line, so that the
// full line will be rendered even if the browser rounds down
// the enclosing span size.
stdHorizRule: "M0 120 V80 H400000 v40 H0 z M0 120 V80 H400000 v40 H0 z",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume all uses of 80 here for padding similar to what's in delimiter.js. Maybe we should have a constant for these so that it's easy to update if necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup.

@ronkok
Copy link
Collaborator Author

ronkok commented Feb 13, 2018

Well, I'm out of date with regard to a submodule. I tried running git submodule update --init --recursive but have gotten no relief. I'm stuck.

@kevinbarabash
Copy link
Member

@ronkok I'll check out your branch tomorrow and see if I can resolve the conflict.

@ronkok
Copy link
Collaborator Author

ronkok commented Feb 15, 2018

@kevinbarabash I am not able to view the Travis log, but I believe that I have this PR to the point where it passes all tests except screenshotter.

@kevinbarabash
Copy link
Member

@ronkok thanks for figuring out the merge. I've been slammed at work. Will try to regenerate the screenshots tonight.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks for adding in the padding constants in delimiter.js.

@kevinbarabash
Copy link
Member

Having a coverage target for patches is silly. I'm going to try to get rid of that check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants