EPUB: every numbered display fails EPUBCheck 5.3.0 because MathJax's SVG carries `data-mjx-viewBox`

Abierto
#3,209 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
html, xml
Área
content

Línea de trabajo

Start with the EPUB assembly step where the SVG from the math representations file is pasted into the XHTML, and reproduce with -c doc -f epub-svg on a document with one numbered display, then run epubcheck. The fix is to move data-mjx-viewBox back to viewBox on the svg element and drop the data attribute, which MathJax's runtime would otherwise do. Done means epubcheck 5.3.0 reports no HTM_061 errors and the static SVG keeps its viewBox.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

An epub-svg build of an article with 40 numbered displays fails EPUBCheck 5.3.0 with
40 errors, one per numbered display, all the same:

ERROR(HTM_061): .../EPUB/xhtml/section-infinitely-many-zeros.xhtml(53,13582):
"data-mjx-viewBox" is not a valid custom data attribute (it must have at least one
character after the hyphen, be XML-compatible, and not contain ASCII uppercase letters).

An article with mathematics but no numbered display validates clean. Inline
mathematics and unnumbered displays are not affected.

The attribute comes from MathJax itself, not from PreTeXt's driver script, and the
name violates HTML's rule for custom data attributes. So this is partly ours to
absorb in the EPUB assembly and partly something to raise with the MathJax people.

What MathJax does

@mathjax/src 4.1.3, output/svg.js, createRoot: when a display's bounding box has
a percentage width (pwidth), which a tagged equation always has so that the number
can sit at the margin, the SVG is given width="100%", its real viewBox is copied into
data-mjx-viewBox, and the viewBox attribute is removed. The browser-side runtime
restores the viewBox from that stash when it lays the display out. In an EPUB there is
no runtime, so the SVG is left with a data-mjx-viewBox that nothing reads and, as a
side effect, with no viewBox at all.

The element as it appears in the XHTML:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
     style="vertical-align: -0.566ex; min-width: 36.166ex;" width="100%" height="2.262ex"
     role="img" data-mjx-viewBox="0 -750 15985.2 1000"
     aria-labelledby="equation-polynomial-growth-bound-title"
     aria-describedby="equation-polynomial-growth-bound-desc">

Reproduce

Any document with a numbered display, for example

<md number="yes" xml:id="equation-growth-bound">\log(\lvert f(z) \rvert) \lt \mathcal{N} \log(\lvert z \rvert).</md>

built with -c doc -f epub-svg, then

java -jar epubcheck-5.3.0/epubcheck.jar <file>.epub

One HTM_061 per numbered display. Counted against the article in question: 40
numbered displays, 40 errors, and the same 40 data-mjx-viewBox attributes in the XHTML.

A note on the validator

This is reported by the latest EPUBCheck, 5.3.0 (2025-09-01), validating against
EPUB 3.3. Older releases do not report it.

Proposed fix

In the EPUB assembly, at the point where the SVG from the math representations file is
pasted into the XHTML: restore viewBox from data-mjx-viewBox and drop the data
attribute. That both satisfies the validator and gives the static SVG back the
viewBox MathJax would have restored at runtime. Merely lowercasing the name would
satisfy the validator but leave the SVG without its viewBox.

And maybe we need to talk to the MathJax folks: a data-* attribute name with an
uppercase letter is invalid in any HTML or XHTML document, runtime or not, so the stash
would be better named data-mjx-viewbox, or restored before serialization when the
output is not going to a live page.

Environment

PreTeXt master at 59cd06c1 (2026-09-03); pretext/pretext -c doc -f epub-svg with a
publication file; MathJax @mathjax/src 4.1.3 and speech-rule-engine 5.0.0-rc.4 under
node 24.3.0; EPUBCheck 5.3.0.

Claude Fable 5.1, acting as a coding assistant for Rob Beezer

Lenguaje dominante
XSLT
Estrellas
466
Forks
251
Merge medio
4 min
PR fusionados (30 d)
13

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PreTeXtBook/pretext

Todos los issues de PreTeXtBook/pretext

Issues similares

Más issues de Content

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.