Skip to content

Content MathML read through ctop.xsl; amssymb symbols in LaTeX - #13

Merged
simonebortolin merged 16 commits into
mainfrom
claude/content-mathml
Nov 9, 2026
Merged

simonebortolin merged 16 commits into
mainfrom
claude/content-mathml

Conversation

@simonebortolin

Copy link
Copy Markdown
Owner

Content MathML (apply, ci, cn...) outside the annotations is rewritten as presentation MathML by David Carlisle's ctop.xsl (MIT), keeping the presentation MathML around it. White space between elements and around the text of ci/cn is removed first, and the limits ctop leaves empty after. ctop.xsl is fixed for nested mi in bvar, x^{} in partialdiff without a degree, an unprefixed mo, a bare log and ∫ as mi. The 40 equations of ctop's test page are the corpus of the new tests.

From the table of entities.xsl (XSLT MathML Library): about 70 amssymb symbols written as commands, 15 commands the LaTeX reader did not know (\square, \surd, \triangleq, \S...), and □ and √ written as \square and \surd in standard LaTeX instead of \□ and \√.

simonebortolin and others added 7 commits November 8, 2026 15:01
Content MathML (apply, ci, cn...) outside the annotations is rewritten as
presentation MathML by David Carlisle's ctop.xsl (MIT), keeping the
presentation MathML around it. White space between elements and around
the text of ci/cn is removed first, and the limits ctop leaves empty
after. ctop.xsl is fixed for nested mi in bvar, x^{} in partialdiff
without a degree, an unprefixed mo, a bare log and ∫ as mi. The 40
equations of ctop's test page are the corpus of the new tests.

From the table of entities.xsl (XSLT MathML Library): about 70 amssymb
symbols written as commands, 15 commands the LaTeX reader did not know
(\square, \surd, \triangleq, \S...), and □ and √ written as \square and
\surd in standard LaTeX instead of \□ and \√.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… \underbrace

\mathop of one symbol is a group, to which \limits attaches its scripts
(munderover(x, 0, 1)); \overbrace and \underbrace with both scripts are, as
for TeX, operators with limits: \underset{x}{\overset{a}{\overbrace{3}}}.
The latex2mathml cases issue-125-4-limits, overbrace-c and underbrace-c pass.

[no-new-version]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…does

\begin{name}{arguments}...\end{name} becomes the begin code with its #1...
(the first argument optional with a default), the body and the end code,
before the other passes; the definitions go to the macros, where later
conversions find them. ## in a macro body is # in math mode, which TeX
rejects: newcommand-escaped-hash is no LaTeX.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…acdf3

# Conflicts:
#	tests/SharpEquations.Tests/LaTeX/Latex2MathMLCorpusTests.cs
…sts to any branch

Stacked pull requests (based on another PR's branch rather than main) ran no
workflow at all, since every pull_request trigger was filtered to main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s out of NotInWordLaTeX

[no-new-version]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The groups of NotInWordLaTeX taken from main, without the seven cases the
reader now reads (\tt, \Bbb, \mathop, the arrows of mathtools), and \Box
renamed once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonebortolin
simonebortolin added this pull request to stack #15 November 8, 2026 14:32
simonebortolin and others added 2 commits November 9, 2026 19:14
Conflicts resolved by keeping both sides: the NOTICE and tests/data/README.md
entries of ctop.xsl and of the latex2mathml and mml2tex corpora, and the union
of the symbols the LaTeX reader rewrites. The standard writer escapes a
structure operator as main does ({\surd}), so \surd reads as {\surd}, a
symbol, and the tests expect main's writer (a{\surd}b, \sum\limits in an
inline munderover).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
\ce{...} and \pu{...} are rewritten as plain LaTeX before the LaTeX is read
(Internal/LaTeX/Mhchem.cs): upright elements with counts and charges as
scripts, mass and atomic numbers as prescripts, reaction arrows with their
labels, bonds (\bond, - = #), states, hydrate dots, precipitates and gases.
The rules of \ce follow mhchem.go of treeblood (MIT, Copyright (c) 2024
Wyatt Sheffield), rewritten to write LaTeX instead of MathML.

Fixes the UnicodeMath preprocessing of a prescripted base with scripts of its
own (^0_(-1) n^-): its scripts were preprocessed twice, and an operator in
them came out as "[object Object]".

Test data: the 76 chemistry cases of treeblood's test/TESTCASES.yaml
(tests/data/latex/treeblood-mhchem.json), all read with Strict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonebortolin and others added 7 commits November 9, 2026 19:20
The standard LaTeX writer wrote \geqslant, \leqslant, \therefore, \coloneqq,
\dblcolon, \ngtr and \lozenge, which the reader did not know. The reader now
falls back to LaTeXSymbols for the commands UnicodeMath has no control word
for, or another one (\succeq is ⪰, ≽ in UnicodeMath), so the two tables
cannot drift. \oslash is escaped (⊘ builds a fraction in UnicodeMath) and
\mid outside brackets too (∣ is a separator only in brackets).

A test writes every character of LaTeXSymbols to LaTeX and reads it back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tex-symbols-readback-e290e7

LaTeX reader reads every command the writer writes
…chem

mhchem: \ce and \pu in the LaTeX reader
…reads

Since main reads a script without a base as one on an empty base ({^3H} is
{}^3 H, as in TeX), the prescripts mhchem wrote at the start of a group
were read as scripts of an empty base. The reader reads \prescript of
mathtools as UnicodeMath prescripts, and mhchem writes them with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio98rJkziNnwWW9T1Mn
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Pre-release removed now that this PR is closed.

@simonebortolin
simonebortolin merged commit 5abcf9d into main Nov 9, 2026
17 checks passed
@simonebortolin
simonebortolin deleted the claude/content-mathml branch November 9, 2026 19:24
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

Successfully merging this pull request may close these issues.

2 participants