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

オープン
#3,209 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
html, xml
領域
content

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
XSLT
スター
466
フォーク
251
平均マージ
4分
マージ済み PR(30日)
13

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PreTeXtBook/pretext のほかの issue

PreTeXtBook/pretext の issue をすべて見る

似ている issue

Content の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。