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

Equations (and other external dependencies) in HTML help #158

Open
aitap opened this issue Nov 21, 2022 · 0 comments
Open

Equations (and other external dependencies) in HTML help #158

aitap opened this issue Nov 21, 2022 · 0 comments

Comments

@aitap
Copy link

aitap commented Nov 21, 2022

Since R-4.2.0, HTML help can now contain TeX-like equations typeset using KaTeX or MathJax, unless the _R_HELP_ENABLE_ENHANCED_HTML_ environment variable is set to a false value (documented in NEWS). Unfortunately, it's hard to bundle the dependencies required for this to happen together with the help text. Currently, repr_help_files_with_topic_generic strips everything except the page body, resulting in LaTeX source being shown for equations:

repr_html(help(dnorm))help(dnorm) rendered with latex source instead of typeset equations

As a workaround, it should be possible to either set the _R_HELP_ENABLE_ENHANCED_HTML_ environment variable to FALSE (better do it on the IRkernel side, then? feel free to transfer the issue) or pass the texmath = FALSE (anything but "katex" or "mathjax") argument to Rd2HTML in repr_html.help_files_with_topic, which will produce plain text equations from the other argument of \[d]eqn. This still won't work for packages that use the mathjaxr package.

I don't know enough about the kernel infrastructure, but I see a render_math function in IRkernel/inst/kernelspec/kernel.js. The new math has class="reqn" (undocumented), so if that's enough for the kernel to process the math, feel free to transfer the issue to IRkernel.

More generally, any external dependencies that a help page might have (e.g. \figure{}) may be broken after repr_html(). There's probably no universal solution for this. For example, it may help to start the dynamic help server and then return <iframe src="..."> links to it, but then the styling would be inconsistent with the rest of the notebook.

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

No branches or pull requests

1 participant