Skip to content

[R-pkg-devel] Problem with MathJax in r-release

6 messages · Deepayan Sarkar, Sebastian Meyer, Michael Dewey

#
I use the mathjaxr package to disply the formulae in my package. It has 
been working for some while including in R 4.2.2. However when I checked 
a new version of the package (metap) in r-devel I get a Note which starts

* checking HTML version of manual ... NOTE
Found the following HTML validation problems:
metap.html:553:1 (dat.metap.Rd:18): Warning: <script> anchor 
"MathJax-script" already defined

and then carries on with the same warning for each .Rd file. The 
relevant line is where it loads mathjax.

At the moment this is only a NOTE so I could either try my luck 
explaining to CRAN or change every instance of mathemtical formulae in 
every .Rd file. I am reluctant to do either of them until I understand 
what is happening. A possible clue might be in the NEWS for r-release

The HTML help system has several new features: LaTeX-like math can be 
typeset using either KaTeX or MathJax, usage and example code is 
highlighted using Prism, and for dynamic help the output of examples and 
demos can be shown within the browser if the knitr package is installed. 
These features can be disabled by setting the environment variable 
_R_HELP_ENABLE_ENHANCED_HTML_ to a false value.

So the new message might be coming from that new check.

Does anyone know what the explanation is or can offer advice aboud my 
way forward?
#
Title should read r-devel. Sorry about that.
On 17/12/2025 14:51, Michael Dewey wrote:

  
    
#
The cause of the problem is clear: If you look at the sources of

https://cran.r-project.org/web/packages/metap/refman/metap.html

you will see repeated instances of

<script id="MathJax-script" async
src="../../mathjaxr/doc/mathjax/es5/tex-chtml-full.js"></script>

which is invalid HTML.

I am not sure where this is coming from, because a recent update to
mathjaxr should have fixed this, and \mathjaxr is now supposed to
produce something different:

https://github.com/cran/mathjaxr/blob/master/man/macros/mathjax.Rd#L5

Could be that versions are still catching up, so maybe wait a few days.

Best,
-Deepayan
On Wed, 17 Dec 2025 at 20:21, Michael Dewey <lists at dewey.myzen.co.uk> wrote:
#
Am 17.12.25 um 17:13 schrieb Deepayan Sarkar:
The issue is complicated by the simultaneous use of build-stage Rd 
macros such as Rdpack's \insertAllCited. For such Rd pages, 
tools::Rd_db("metap") contains the expression of the \loadmathjax macro 
from when 'metap' was originally built (R CMD build). So it doesn't help 
to re-install the new mathjaxr version -- 'metap' also needs to be 
rebuilt with it.

	Sebastian Meyer
#
Thanks guys. I should have updated all the packages first but forgot so 
I will try that again tomorrow.

Michael
On 17/12/2025 16:57, Sebastian Meyer wrote:

  
    
2 days later
#
Updating packages did indeed fix the problem and the new version is now 
on CRAN.

Thanks again

Michael
On 17/12/2025 17:35, Michael Dewey wrote: