Repository navigation
rehype-mathjax: fix SVG output with global font cache - #123
Open
mkantautas wants to merge 1 commit into
Open
mkantautas wants to merge 1 commit into
mkantautas wants to merge 1 commit into
Conversation
Member
|
Thanks for the write-up. Did you hit this in a project? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initial checklist
Description of changes
With
rehype-mathjax/svgandsvg: {fontCache: 'global'}, the glyphs of all math are missing from the output:With a global font cache, each glyph is a
<use>that points into one shared<defs>.MathJax returns that cache from
pageElements()and adds it to<body>when it typesets a page itself.rehype-mathjaxonly added the style sheet, so in browsers the math shows up blank: only rules, such as fraction bars, are drawn.This adds a
pageElementsstep next tostyleSheet.The hidden
<svg>is appended to<body>, or to the end of the tree for fragments.CHTML,
fontCache: 'local'(the default), and'none'have no page elements, so their output does not change.The two new fixtures (a fragment and a complete document) fail without the change.
Rendered in Chromium 149 and Firefox 151, none of the 21 glyphs of a
remark-mathexample are drawn before the change, and all 21 after.npm testpasses with Node 18.20.8 and dev-dependencies fromnpm install --before=2025-02-21.With current dependencies, the existing
rehype-katextest “should handle errors, supporterrorColor” also fails onmain(newervfile-messagefields), as in the CI run of #122.