Skip to content

Commit 6f67be5

Browse files
Omikhleiaalerque
authored andcommitted
fix(math): Empty mrow's in munderover should not affect the baseline
1 parent b6e054e commit 6f67be5

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/math/base-elements.lua‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,22 @@ function elements.underOver:__tostring ()
633633
return self._type .. "(" .. tostring(self.base) .. ", " .. tostring(self.sub) .. ", " .. tostring(self.sup) .. ")"
634634
end
635635

636+
local function isNotEmpty (element)
637+
-- The MathML test suite uses <munderover> with an empty <mrow> as sub/sup.
638+
-- I don't know why they didn't use a <munder> or <mover> instead...
639+
-- But the expectation is to behave as if the empty element was not there,
640+
-- so that height and depth are not affected by the axis height.
641+
-- See notably:
642+
-- MathML3 "complex1" torture test: Maxwell's Equations (vectors in fractions)
643+
return element and (element:is_a(elements.terminal) or #element.children > 0)
644+
end
645+
636646
function elements.underOver:_init (base, sub, sup)
637647
elements.mbox._init(self)
638648
self.atom = base.atom
639649
self.base = base
640-
self.sub = sub
641-
self.sup = sup
650+
self.sub = isNotEmpty(sub) and sub or nil
651+
self.sup = isNotEmpty(sup) and sup or nil
642652
if self.sup then
643653
table.insert(self.children, self.sup)
644654
end

0 commit comments

Comments
 (0)