@@ -662,6 +662,43 @@ function elements.underOver:styleChildren ()
662662 end
663663end
664664
665+ function elements .underOver :_stretchyReshapeToBase (part )
666+ -- FIXME: Big leap of faith here.
667+ -- MathML Core only mentions stretching along the inline axis in 3.4.2.2,
668+ -- i.e. under the section on <mover>, <munder>, <munderover>.
669+ -- So we are "somewhat" good here, but... the algorithm is totally unclear
670+ -- to me and seems to imply a lot of recursion and reshaping.
671+ -- The implementation below is NOT general and only works for the cases
672+ -- I checked:
673+ -- Mozilla MathML tests: braces in f19, f22
674+ -- Personal tests: vectors in d19, d22, d23
675+ -- Joe Javawaski's tests: braces in 8a, 8b
676+ -- MathML3 "complex1" torture test: Maxwell's Equations (vectors in fractions)
677+ if # part .children == 0 then
678+ local elt = part
679+ if elt .is_a (elements .text ) and elt .kind == " operator" and SU .boolean (elt .stretchy , false ) then
680+ elt :_horizStretchyReshape (self .base .width )
681+ end
682+ elseif part :is_a (elements .underOver ) then
683+ -- Big assumption here: only considering one level of stacked under/over.
684+ local hasStreched = false
685+ for _ , elt in ipairs (part .children ) do
686+ if elt .is_a (elements .text ) and elt .kind == " operator" and SU .boolean (elt .stretchy , false ) then
687+ local stretched = elt :_horizStretchyReshape (self .base .width )
688+ if stretched then
689+ hasStreched = true
690+ end
691+ end
692+ end
693+ if hasStreched then
694+ -- We need to re-calculate the shape so positions are re-calculated on each
695+ -- of its own parts.
696+ -- (Added after seeing that Mozilla test f19 was not rendering correctly.)
697+ part :shape ()
698+ end
699+ end
700+ end
701+
665702function elements .underOver :shape ()
666703 if not (self .mode == mathMode .display or self .mode == mathMode .displayCramped ) and SU .boolean (self .base .largeop , false ) then
667704 -- FIXME
@@ -684,6 +721,7 @@ function elements.underOver:shape ()
684721 self .base .relY = SILE .types .length (0 )
685722 end
686723 if self .sub then
724+ self :_stretchyReshapeToBase (self .sub )
687725 self .sub .relY = self .base .depth
688726 + SILE .types .length (
689727 math.max (
@@ -693,6 +731,7 @@ function elements.underOver:shape ()
693731 )
694732 end
695733 if self .sup then
734+ self :_stretchyReshapeToBase (self .sup )
696735 self .sup .relY = 0
697736 - self .base .height
698737 - SILE .types .length (
0 commit comments