Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions packages/math/texlike.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,16 @@ local mathGrammar = function (_ENV)
(P"}" + E("`}` expected"))
) / function (...)
local t = {...}
-- Remove the last mathlist if empty. This way,
-- `inner1 \\ inner2 \\` is the same as `inner1 \\ inner2`.
if not t[#t][1] or not t[#t][1][1] then table.remove(t) end
local last = t[#t]
-- Remove the last element if empty:
-- So that `inner1 \\ inner2 \\` is the same as `inner1 \\ inner2`.
if #last == 0 or (#last == 1 and #last[#last] == 0) then
-- Empty mathlist, or mathlist containing a single empty mathlist.
table.remove(t)
end
return pl.utils.unpack(t)
end

local dim2_arg_inner = Ct(V"mathlist" * (P"&" * V"mathlist")^0) /
function (t)
t.id = "mathlist"
return t
end
local dim2_arg =
Cg(P"{" *
dim2_arg_inner *
(P"\\\\" * dim2_arg_inner)^1 *
(P"}" + E("`}` expected"))
) / function (...)
local t = {...}
-- Remove the last mathlist if empty. This way,
-- `inner1 \\ inner2 \\` is the same as `inner1 \\ inner2`.
if not t[#t][1] or not t[#t][1][1] then table.remove(t) end
return pl.utils.unpack(t)
end

-- TeX uses the regular asterisk (* = U+002A) in superscripts or subscript:
-- The TeXbook exercice 18.32 (p. 179, 330) for instance.
-- Fonts usually have the asterisk raised too high, so using the Unicode
Expand Down
Loading