Skip to content

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

@aitap

Description

@aitap

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions