Skip to content

Commit

Permalink
fixup! fix(math): Paired open/close atoms shall be forced in a mrow i…
Browse files Browse the repository at this point in the history
…n TeX-like math
  • Loading branch information
Omikhleia authored and Didier Willis committed Oct 27, 2024
1 parent 94948d2 commit a522fda
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/math/texlike.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ local compileToStr = function (argEnv, mathlist)
end

local function isOperatorKind (tree, typeOfAtom, typeOfSymbol)
if not tree then
return false -- safeguard
end
if tree.command ~= "mo" then
return false
end
Expand Down Expand Up @@ -363,6 +366,22 @@ local function compileToMathML_aux (_, arg_env, tree)
if #stack > 0 then
children = table.remove(stack)
end
elseif (child.command == "msubsup" or child.command == "msub" or child.command == "msup")
and isCloseOperator(child[1]) -- child[1] is the base
then
if #stack > 0 then
-- Special case for closing operator with sub/superscript:
-- (....)^i must be interpreted as {(....)}^i, not as (...{)}^i
-- Push the closing operator into the mrow
table.insert(children, child[1])
-- Move the mrow into the msubsup, replacing the closing operator
child[1] = children
-- And insert the msubsup into the parent
children = table.remove(stack)
children[#children] = child
else
table.insert(children, child)
end
else
table.insert(children, child)
end
Expand Down

0 comments on commit a522fda

Please sign in to comment.