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

zmarkdown: upgrade rehype-katex #297

Closed
wants to merge 1 commit into from

Conversation

artragis
Copy link
Member

@artragis artragis commented Nov 14, 2018

use new version of rehype-katex

#295

@artragis
Copy link
Member Author

artragis commented Nov 14, 2018

@vhf, jI don't understand the root cause of test failure.

In fact I don't understand why we need to find viewBox and preserveAspectRation.

(sorry if you received a mail with french text).

@vhf
Copy link
Contributor

vhf commented Nov 16, 2018

@artragis Yep! It's related to this: rehypejs/rehype#2

Katex renders (used to render?) formulas as SVG with a viewBox attribute (and other camelCase attributes). Rehype doesn't handle these properly: they become e.g. view-box.

I wrote a hack based on the complete list of possible SVG attributes: https://github.com/zestedesavoir/zmarkdown/blob/1702c551a35e6490d01617a8258ebd989a0b8e53/packages/zmarkdown/utils/svg-hack.js

Assertions such as these:

expect(rendered).toContain('viewBox')
expect(rendered).toContain('preserveAspectRatio')
expect(rendered).not.toContain('view-box')
expect(rendered).not.toContain('preserve-aspect-ratio')

are making sure that viewBox isn't replaced by view-box, etc.

These tests could be failing for two reasons: either Katex changed how they render things and it's not an SVG with a viewBox attr anymore or Katex rendering is broken in our project. 🤽‍♂️ 🐃

@vhf
Copy link
Contributor

vhf commented Nov 16, 2018

Yep, this comes from rehype-katex@1.2.0 vs 1.1.1, cf. https://gist.github.com/vhf/62ddb4e6967b8ca1a05d2c18572c20cd

Here is one of these SVG parts of formula, probably a symbol that got replaced by something that doesn't need SVG:

<svg width="400em" height="0.2em" viewBox="0 0 400000 200" preserveAspectRatio="xMinYMin slice">
<path d="M0 80H400000 v40H0z M0 80H400000 v40H0z">
</path>
</svg>

Please take a look at what gets rendered and if the formula looks the same with this newer version (no symbol or fraction line missing) as what currently is rendered in production, I suggest .skipping the failing tests and adding a comment with the URL of this issue.

@vhf
Copy link
Contributor

vhf commented Nov 23, 2018

#301

@vhf vhf closed this Nov 23, 2018
@artragis artragis deleted the add_katex_0.10 branch December 19, 2020 11:20
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.

None yet

2 participants