Skip to content

Wrap document fragment where classes, attributes, or styles are applied#1707

Merged
k4b7 merged 4 commits intoKaTeX:masterfrom
ylemkimon:document-fragment
Oct 13, 2018
Merged

Wrap document fragment where classes, attributes, or styles are applied#1707
k4b7 merged 4 commits intoKaTeX:masterfrom
ylemkimon:document-fragment

Conversation

@ylemkimon
Copy link
Member

Fixes issues mentioned in #1618. Also a step toward #1618, separating document fragments from DOM nodes.

@codecov
Copy link

codecov bot commented Sep 8, 2018

Codecov Report

Merging #1707 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1707      +/-   ##
==========================================
+ Coverage   93.89%   93.95%   +0.06%     
==========================================
  Files          78       78              
  Lines        4585     4584       -1     
  Branches      811      809       -2     
==========================================
+ Hits         4305     4307       +2     
+ Misses        246      245       -1     
+ Partials       34       32       -2
Flag Coverage Δ
#screenshotter 88.57% <66.66%> (+0.06%) ⬆️
#test 85.38% <100%> (+0.1%) ⬆️
Impacted Files Coverage Δ
src/utils.js 93.1% <ø> (+7.38%) ⬆️
src/functions/arrow.js 87.87% <100%> (ø) ⬆️
src/buildCommon.js 98.46% <100%> (+0.02%) ⬆️
src/functions/enclose.js 100% <100%> (ø) ⬆️
src/functions/href.js 100% <100%> (ø) ⬆️
src/functions/sqrt.js 96.87% <100%> (-0.1%) ⬇️

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 3514d48...db5f669. Read the comment docs.

return value;
};

export const assertType = function<T>(val: mixed, Cls: Class<T>): T {
Copy link
Member

Choose a reason for hiding this comment

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

I was sure we were using this in more places, but I guess not.

let newOptions = options.havingStyle(style.sup());
const upperGroup = html.buildGroup(group.body, newOptions, options);
const upperGroup = buildCommon.wrapFragment(
html.buildGroup(group.body, newOptions, options), options);
Copy link
Member

Choose a reason for hiding this comment

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

Why not wrap all fragments in a span?

Copy link
Member Author

@ylemkimon ylemkimon Sep 23, 2018

Choose a reason for hiding this comment

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

@kevinbarabash The spacing would not be applied properly, (can be fixed by #1706) and the result would be more complicated. But code will become simpler and more type-safe.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks.

describe("A document fragment", function() {
it("should have paddings applied inside an extensible arrow", function() {
const markup = katex.renderToString("\\tiny\\xrightarrow\\textcolor{red}{x}");
expect(markup).toContain("x-arrow-pad");
Copy link
Member

Choose a reason for hiding this comment

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

These should maybe be snapshot tests so it's easier to see the structure of the markup.

Copy link
Member Author

@ylemkimon ylemkimon Sep 23, 2018

Choose a reason for hiding this comment

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

@kevinbarabash But the markup result is too complicated, with a lot of unnecessary parts.

Copy link
Member

@k4b7 k4b7 Oct 13, 2018

Choose a reason for hiding this comment

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

That's definitely a downside of fixtures.

Copy link
Member

@edemaine edemaine left a comment

Choose a reason for hiding this comment

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

Changes look nice: a good fix for document fragments for now.( And responses to @kevinbarabash's comments look good.) Hopefully we can make type-safe in the future by removing classes from documentFragment.

options: Options,
): HtmlDomNode {
if (group instanceof DocumentFragment) {
return makeSpan([], [group], options);
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is equivalent to

return makeSpan([], group.children, options);

? Not sure there are any advantages either way, though.

@k4b7 k4b7 merged commit a51dc4b into KaTeX:master Oct 13, 2018
@k4b7
Copy link
Member

k4b7 commented Oct 13, 2018

Thanks for the PR. Sorry for the delayed review.

@ylemkimon ylemkimon deleted the document-fragment branch March 21, 2019 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants