Skip to content

Commit

Permalink
fix(math): Fix insertion order of MathML children
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierNicole committed Sep 14, 2022
1 parent 979c5fe commit 738e9e6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/math/texlike.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 178,19 @@ local function registerCommand (name, argTypes, fun)
commands[name] = {argTypes, fun}
end

-- Computes fun(fun(... fun(init, k1, v1), k2, v2)..., k_n, v_n), i.e. applies
-- fun on every key-value pair in the table. Keys with numeric indices are
-- processed in order. This is an important property for MathML compilation
-- below.
local function fold_pairs (fun, init, table)
local acc = init
for k,x in pairs(table) do
acc = fun(acc, k, x)
if type(k) ~= "number" then
acc = fun(acc, k, x)
end
end
for i,x in ipairs(table) do
acc = fun(acc, i, x)
end
return acc
end
Expand Down

0 comments on commit 738e9e6

Please sign in to comment.