Compare commits
No commits in common. "3b692504cb2205dae7afcd9c836fb475835f0caa" and "372e43e16571dc80d55e20f3fcfebf635eb01fd7" have entirely different histories.
3b692504cb
...
372e43e165
@ -4,8 +4,8 @@ local save_result = require'luamml-tex'.save_result
|
||||
|
||||
local properties = node.get_properties_table()
|
||||
|
||||
local funcid = luatexbase.new_luafunction'__luamml_amsmath_add_box_to_row:'
|
||||
token.set_lua('__luamml_amsmath_add_box_to_row:', funcid, 'protected')
|
||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_add_box_to_row:'
|
||||
token.set_lua('luamml_amsmath_add_box_to_row:', funcid, 'protected')
|
||||
lua.get_functions_table()[funcid] = function()
|
||||
-- TODO: Error handling etc
|
||||
-- local box = token.scan_int()
|
||||
@ -36,8 +36,8 @@ lua.get_functions_table()[funcid] = function()
|
||||
table.insert(mml_row, mml)
|
||||
end
|
||||
|
||||
funcid = luatexbase.new_luafunction'__luamml_amsmath_finalize_row:'
|
||||
token.set_lua('__luamml_amsmath_finalize_row:', funcid, 'protected')
|
||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_finalize_row:'
|
||||
token.set_lua('luamml_amsmath_finalize_row:', funcid, 'protected')
|
||||
lua.get_functions_table()[funcid] = function()
|
||||
-- TODO: Error handling etc
|
||||
local row_temp = tex.nest[tex.nest.ptr-1]
|
||||
@ -59,8 +59,8 @@ lua.get_functions_table()[funcid] = function()
|
||||
table.insert(mml_table, mml_row)
|
||||
end
|
||||
|
||||
funcid = luatexbase.new_luafunction'__luamml_amsmath_finalize_table:'
|
||||
token.set_lua('__luamml_amsmath_finalize_table:', funcid)
|
||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_finalize_table:'
|
||||
token.set_lua('luamml_amsmath_finalize_table:', funcid)
|
||||
lua.get_functions_table()[funcid] = function()
|
||||
-- TODO: Error handling etc
|
||||
local props = properties[tex.lists.align_head]
|
||||
@ -70,51 +70,19 @@ lua.get_functions_table()[funcid] = function()
|
||||
if not mml_table then return end
|
||||
local columns = node.count(node.id'align_record', tex.lists.align_head)//2
|
||||
mml_table.columnalign = string.rep('right left', columns, ' ')
|
||||
local spacing = {}
|
||||
for n in node.traverse_id(node.id'glue', tex.lists.align_head) do
|
||||
spacing[#spacing+1] = n.width == 0 and '0' or '.8em'
|
||||
end
|
||||
mml_table.columnspacing = table.concat(spacing, ' ', 2, #spacing-2)
|
||||
mml_table.columnspacing = string.rep('0', columns, ' 0.8em ') -- FIXME: 0.3em is a hack needed since MathML doesn't add spacing for our empty mrow
|
||||
save_result(mml_table, 0)
|
||||
end
|
||||
|
||||
local last_tag
|
||||
|
||||
funcid = luatexbase.new_luafunction'__luamml_amsmath_save_tag:'
|
||||
token.set_lua('__luamml_amsmath_save_tag:', funcid, 'protected')
|
||||
funcid = luatexbase.new_luafunction'luamml_last_math_alignmark:'
|
||||
token.set_lua('luamml_last_math_alignmark:', funcid, 'protected')
|
||||
lua.get_functions_table()[funcid] = function()
|
||||
local nest = tex.nest.top
|
||||
local chars = {}
|
||||
for n, id, sub in node.traverse(nest.head.next) do
|
||||
if id == node.id'glyph' then
|
||||
if sub >= 0x100 then
|
||||
texio.write_nl'WARNING: Already shaped glyph detected in tag. This might lead to wrong output.'
|
||||
local n = tex.nest.top.tail
|
||||
n = n.nucleus or n
|
||||
local props = properties[n]
|
||||
if not props then
|
||||
props = {}
|
||||
properties[n] = props
|
||||
end
|
||||
chars[#chars+1] = n.char
|
||||
elseif id == node.id'glue' then
|
||||
chars[#chars+1] = 0x20
|
||||
elseif id == node.id'kern' then
|
||||
else
|
||||
print(n)
|
||||
texio.write_nl'WARNING: Unsupported node in tag dropped'
|
||||
end
|
||||
end
|
||||
last_tag = utf8.char(table.unpack(chars))
|
||||
end
|
||||
|
||||
funcid = luatexbase.new_luafunction'__luamml_amsmath_set_tag:'
|
||||
token.set_lua('__luamml_amsmath_set_tag:', funcid, 'protected')
|
||||
lua.get_functions_table()[funcid] = function()
|
||||
if not last_tag then
|
||||
texio.write_nl'WARNING: Tag extraction failed'
|
||||
return
|
||||
end
|
||||
local row_temp = tex.nest[tex.nest.ptr-1]
|
||||
local props = properties[row_temp]
|
||||
if not props then return end
|
||||
if not props.mathml_row then return end
|
||||
mml_row = props.mathml_row
|
||||
mml_row[0] = 'mlabeledtr'
|
||||
table.insert(mml_row, 1, {[0] = 'mtd', {[0] = 'mtext', last_tag}})
|
||||
last_tag = nil
|
||||
props.mathml_table = {[0] = 'malignmark'}
|
||||
end
|
||||
|
@ -24,7 +24,7 @@
|
||||
\ifmeasuring@
|
||||
\savefieldlength@
|
||||
\else
|
||||
\__luamml_amsmath_add_box_to_row:
|
||||
\luamml_amsmath_add_box_to_row:
|
||||
\fi
|
||||
\set@field
|
||||
\tabskip\z@skip
|
||||
@ -48,7 +48,7 @@
|
||||
\ifmeasuring@
|
||||
\savefieldlength@
|
||||
\else
|
||||
\__luamml_amsmath_add_box_to_row:
|
||||
\luamml_amsmath_add_box_to_row:
|
||||
\fi
|
||||
\set@field
|
||||
\hfil
|
||||
@ -66,6 +66,7 @@
|
||||
\add@amps \maxfields@
|
||||
\omit
|
||||
\kern -\alignsep@
|
||||
\luamml_amsmath_finalize_row:
|
||||
\iftag@
|
||||
\setboxz@h {
|
||||
\@lign
|
||||
@ -73,9 +74,7 @@
|
||||
{ \make@display@tag }
|
||||
}
|
||||
\place@tag
|
||||
\__luamml_amsmath_set_tag:
|
||||
\fi
|
||||
\__luamml_amsmath_finalize_row:
|
||||
\ifst@rred
|
||||
\else
|
||||
\global \@eqnswtrue
|
||||
@ -84,19 +83,10 @@
|
||||
\cr
|
||||
}
|
||||
|
||||
\cs_set:Npn \maketag@@@ #1 {
|
||||
\hbox {
|
||||
\m@th
|
||||
\normalfont
|
||||
#1
|
||||
\__luamml_amsmath_save_tag:
|
||||
}
|
||||
}
|
||||
|
||||
\cs_set:Npn \endalign {
|
||||
\math@cr
|
||||
\black@ \totwidth@
|
||||
\__luamml_amsmath_finalize_table:
|
||||
\luamml_amsmath_finalize_table:
|
||||
\egroup
|
||||
\ifingather@
|
||||
\restorealignstate@
|
||||
|
Loading…
Reference in New Issue
Block a user