-
Notifications
You must be signed in to change notification settings - Fork 336
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
Should it be easier to not load MathJax/to tweak the version? #1966
Comments
I think ideally we be able to specify a |
Are there that many differences between mathjax versions? |
I think it's mostly just faster: https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html |
So why do more than updating mathjax in pkgdown? That seems like it would be easier? |
It's still very heavy and only used by a handful of packages, we prefer to make it opt-in for rOpenSci. But we can make this work by shipping a custom |
There are two commits from an abandoned PR branch that might be helpful when updating MathJax to v3: 39f001e and 63af614 The |
FYI Yes version 3.0 has completely different configuration than version 2.0. For example, the MathJax configuration java-script that you use to turn on equation numbers is completely different between the two versions. |
Should we switch from mathjax to mathml? It looks like it's well supported by all major browsers (https://caniuse.com/mathml), and it would eliminate an external dependency. (We could default to mathml, but still allow folks to switch back to the previous mathjax approach if mathml didn't work for them) |
I mathjax is needed to convert latex to mathml? If you want something in R, |
Is there some reason not to use pandoc's mathml conversion? https://pandoc.org/MANUAL.html#math-rendering-in-html |
@Bisaloo looks like maybe you have some experience with this? |
I guess it would absolutely make sense to use Pandoc for this. If we rely on Pandoc for the conversion, why not give users the choice to opt in to While the future appears to belong to MathML, browser support is still somewhat rudimentary compared to KaTeX/MathJax. See Pandoc's math demo pages (in your preferred browser) for a rendering quality comparison: Another nice browser math engine comparison site: https://mk12.github.io/web-math-demo/ |
The main reason not to expose more math rendering options is that it's potentially a bunch of work that few people would benefit from. |
No sorry, I don't know enough to help with this |
Looks like we'll need to use some basic markdown file with a custom template (see below) in order to extract the version of mathjax that pandoc uses. If we're doing that, then it does probably make sense to support at least katex, since we'd need to do the same thing. We could capture this info in a similar way to <html>
<head>
$for(css)$
<link rel="stylesheet" href="$css$" type="text/css" />
$endfor$
$for(header-includes)$
$header-includes$
$endfor$
$if(math)$
$if(mathjax)$
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
$endif$
$math$
$endif$
</head>
</html> |
Depending on whether we further pursue #2249, we could just leverage But I'm not sure whether it's worth to determine the mathjax/katex asset versions used by Pandoc defaults dynamically at pkgdown site build-time in the first place. Instead we could also just hardcode the (currently) latest versions in |
@salim-b ah yeah, that's a good strategy. We can code up the approach I outline above, and then use it once per release to update the external assets yaml. |
@hadley We could do that. Or we could just define the latest asset versions in |
@salim-b I like the idea of keeping in sync with pandoc as that gives one fewer difference from rmarkdown etc. |
Next Pandoc release will use the latest KaTeX CDN asset: jgm/pandoc#9707 Update: Pandoc v3.2 just got released incl. mentioned PR |
Post #2263, also need to apply to |
@salim-b I think you're beginning to convince me — it does seem overwrought to go through all this work just to capture two urls that don't change very often. Where should the math-rendering option go in template:
math-rendering: katex We'd default to mathml since that minimises dependencies and most sites don't use that much math; and sites that do want better rendering can use |
Yep,
I think that is sensible. 👍 |
At the moment to not have MathJax or to load a different version one needs to override the head.html template.
Should it be easier to not include MathJax? E.g. providing an opt-out.
From looking at https://github.com/r-lib/pkgdown/blob/main/inst/BS5/templates/head.html, I see no other element that's loaded everywhere but not useful everywhere.
I know this was discussed following #1566 but without the aspect that one can't choose another version.
Cc @jeroen
The text was updated successfully, but these errors were encountered: