Skip to content

Commit 0df93b1

Browse files
OmikhleiaDidier Willis
authored andcommitted
feat(math): Support MathML maction (basic) and mstyle (partial)
Legit MathML elements for which a naive implementation is better than nothing and paves the way to check other more important elements from the MathML test suite.
1 parent 9ce5271 commit 0df93b1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/math/typesetter.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ local function convertChildren (tree)
3434
return mboxes
3535
end
3636

37+
local function convertFirstChild (tree)
38+
-- We need to loop until the first non-nil box is found, because
39+
-- we may have blank lines in the tree.
40+
for _, n in ipairs(tree) do
41+
local box = ConvertMathML(nil, n)
42+
if box then
43+
return box
44+
end
45+
end
46+
end
47+
3748
-- convert MathML into mbox
3849
function ConvertMathML (_, content)
3950
if content == nil or content.command == nil then
@@ -159,6 +170,13 @@ function ConvertMathML (_, content)
159170
-- There's also some explanations about CSS, italic correction etc. which we ignore too.
160171
text = text:gsub("[\n\r]", " ")
161172
return b.text("string", {}, scriptType.upright, text:gsub("%s+", " "))
173+
elseif content.command == "maction" then
174+
-- MathML Core 3.6: display as mrow, ignoring all but the first child
175+
return b.stackbox("H", { convertFirstChild(content) })
176+
elseif content.command == "mstyle" then
177+
-- It's an mrow, but with some style attributes that we ignore.
178+
SU.warn("MathML mstyle is not fully supported yet")
179+
return b.stackbox("H", convertChildren(content))
162180
else
163181
SU.error("Unknown math command " .. content.command)
164182
end

0 commit comments

Comments
 (0)