Skip to content

Commit

Permalink
feat(math): Support MathML mpadded and refactor TeX-like phantoms
Browse files Browse the repository at this point in the history
Nothing really complex with mpadded.. Wait some ambiguity if dimensions
are in a font-relative unit (see in-code comment), but let's move
forward anyway -- and on the same occasion, remove the non-standard
approach previously used for (La)TeX's phantom, hphantom and vphantom.
  • Loading branch information
Omikhleia authored and Didier Willis committed Oct 29, 2024
1 parent a522fda commit 4f3d8ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/math/texlike.lua
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,9 @@ compileToMathML(
% Phantom commands from TeX/LaTeX
\def{phantom}{\mphantom{#1}}
\def{hphantom}{\mphantom[special=h]{#1}}
\def{vphantom}{\mphantom[special=v]{#1}}
\def{hphantom}{\mpadded[height=0, depth=0]{\mphantom{#1}}}
\def{vphantom}{\mpadded[width=0]{\mphantom{#1}}}
%\mphantom[special=v]{#1}}}
]==],
})
)
Expand Down
4 changes: 4 additions & 0 deletions packages/math/typesetter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ function ConvertMathML (_, content)
-- It's an mrow, but with some style attributes that we ignore.
SU.warn("MathML mstyle is not fully supported yet")
return b.stackbox("H", convertChildren(content))
elseif content.command == "mpadded" then
-- MathML Core 3.3.6.1: The <mpadded> element generates an anonymous <mrow> box
-- called the "impadded inner box"
return b.padded(content.options, b.stackbox("H", convertChildren(content)))
else
SU.error("Unknown math command " .. content.command)
end
Expand Down

0 comments on commit 4f3d8ec

Please sign in to comment.