[Rd] Bundling MathJax

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Mon Mar 14 21:42:35 CET 2022

On Sun, 13 Mar 2022 15:25:37 +0100
Jeroen Ooms <jeroenooms using gmail.com> wrote:

> An alternative, more robust method is to render the math-to-html in R
> using the katex R package. This way no JavaScript library needs to be
> included in the html manual pages, merely a small katex css file with
> some styling, which is much lighter and safer to load in manual pages
> (and probably more feasible to bundle with R).

I do like the build-time rendering approach (I had started writing a
plotmath-style equation renderer for documentation in my R packages
with HTML and TeX support, but quickly abandoned it), but I see two
problems with adopting KaTeX in tools::Rd2HTML:

1. As far as I understand, these changes are supposed to improve
accessibility of the documentation. (PDF is beautifully typeset, but
can't be understood by screen readers as well as web pages.) MathJax
seems to have better accessibility than KaTeX. While there is a hidden
MathML block for screen readers in KaTeX output, some of them don't
pick it up: https://github.com/KaTeX/KaTeX/issues/820

2. If R-core were to adopt KaTeX, that would add a hard dependency from
Rd2HTML to the V8 JavaScript engine. I think that's unlikely to happen.

</seriously> Maybe in 20 years, when browser is the operating system
and everyone runs R compiled to JavaScript with emscripten...

Best regards,

More information about the R-devel mailing list