Labeled alignments
This commit is contained in:
parent
b2e4824526
commit
3b692504cb
@ -4,8 +4,8 @@ local save_result = require'luamml-tex'.save_result
|
|||||||
|
|
||||||
local properties = node.get_properties_table()
|
local properties = node.get_properties_table()
|
||||||
|
|
||||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_add_box_to_row:'
|
local funcid = luatexbase.new_luafunction'__luamml_amsmath_add_box_to_row:'
|
||||||
token.set_lua('luamml_amsmath_add_box_to_row:', funcid, 'protected')
|
token.set_lua('__luamml_amsmath_add_box_to_row:', funcid, 'protected')
|
||||||
lua.get_functions_table()[funcid] = function()
|
lua.get_functions_table()[funcid] = function()
|
||||||
-- TODO: Error handling etc
|
-- TODO: Error handling etc
|
||||||
-- local box = token.scan_int()
|
-- local box = token.scan_int()
|
||||||
@ -36,8 +36,8 @@ lua.get_functions_table()[funcid] = function()
|
|||||||
table.insert(mml_row, mml)
|
table.insert(mml_row, mml)
|
||||||
end
|
end
|
||||||
|
|
||||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_finalize_row:'
|
funcid = luatexbase.new_luafunction'__luamml_amsmath_finalize_row:'
|
||||||
token.set_lua('luamml_amsmath_finalize_row:', funcid, 'protected')
|
token.set_lua('__luamml_amsmath_finalize_row:', funcid, 'protected')
|
||||||
lua.get_functions_table()[funcid] = function()
|
lua.get_functions_table()[funcid] = function()
|
||||||
-- TODO: Error handling etc
|
-- TODO: Error handling etc
|
||||||
local row_temp = tex.nest[tex.nest.ptr-1]
|
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)
|
table.insert(mml_table, mml_row)
|
||||||
end
|
end
|
||||||
|
|
||||||
local funcid = luatexbase.new_luafunction'luamml_amsmath_finalize_table:'
|
funcid = luatexbase.new_luafunction'__luamml_amsmath_finalize_table:'
|
||||||
token.set_lua('luamml_amsmath_finalize_table:', funcid)
|
token.set_lua('__luamml_amsmath_finalize_table:', funcid)
|
||||||
lua.get_functions_table()[funcid] = function()
|
lua.get_functions_table()[funcid] = function()
|
||||||
-- TODO: Error handling etc
|
-- TODO: Error handling etc
|
||||||
local props = properties[tex.lists.align_head]
|
local props = properties[tex.lists.align_head]
|
||||||
@ -78,15 +78,43 @@ lua.get_functions_table()[funcid] = function()
|
|||||||
save_result(mml_table, 0)
|
save_result(mml_table, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
funcid = luatexbase.new_luafunction'luamml_last_math_alignmark:'
|
local last_tag
|
||||||
token.set_lua('luamml_last_math_alignmark:', funcid, 'protected')
|
|
||||||
|
funcid = luatexbase.new_luafunction'__luamml_amsmath_save_tag:'
|
||||||
|
token.set_lua('__luamml_amsmath_save_tag:', funcid, 'protected')
|
||||||
lua.get_functions_table()[funcid] = function()
|
lua.get_functions_table()[funcid] = function()
|
||||||
local n = tex.nest.top.tail
|
local nest = tex.nest.top
|
||||||
n = n.nucleus or n
|
local chars = {}
|
||||||
local props = properties[n]
|
for n, id, sub in node.traverse(nest.head.next) do
|
||||||
if not props then
|
if id == node.id'glyph' then
|
||||||
props = {}
|
if sub >= 0x100 then
|
||||||
properties[n] = props
|
texio.write_nl'WARNING: Already shaped glyph detected in tag. This might lead to wrong output.'
|
||||||
|
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
|
end
|
||||||
props.mathml_table = {[0] = 'malignmark'}
|
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
|
||||||
end
|
end
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
\ifmeasuring@
|
\ifmeasuring@
|
||||||
\luamml_flag_ignore:
|
\luamml_flag_ignore:
|
||||||
\else
|
\else
|
||||||
\luamml_flag_save:
|
\luamml_flag_save:
|
||||||
\fi
|
\fi
|
||||||
$
|
$
|
||||||
}
|
}
|
||||||
\ifmeasuring@
|
\ifmeasuring@
|
||||||
\savefieldlength@
|
\savefieldlength@
|
||||||
\else
|
\else
|
||||||
\luamml_amsmath_add_box_to_row:
|
\__luamml_amsmath_add_box_to_row:
|
||||||
\fi
|
\fi
|
||||||
\set@field
|
\set@field
|
||||||
\tabskip\z@skip
|
\tabskip\z@skip
|
||||||
@ -48,7 +48,7 @@
|
|||||||
\ifmeasuring@
|
\ifmeasuring@
|
||||||
\savefieldlength@
|
\savefieldlength@
|
||||||
\else
|
\else
|
||||||
\luamml_amsmath_add_box_to_row:
|
\__luamml_amsmath_add_box_to_row:
|
||||||
\fi
|
\fi
|
||||||
\set@field
|
\set@field
|
||||||
\hfil
|
\hfil
|
||||||
@ -66,7 +66,6 @@
|
|||||||
\add@amps \maxfields@
|
\add@amps \maxfields@
|
||||||
\omit
|
\omit
|
||||||
\kern -\alignsep@
|
\kern -\alignsep@
|
||||||
\luamml_amsmath_finalize_row:
|
|
||||||
\iftag@
|
\iftag@
|
||||||
\setboxz@h {
|
\setboxz@h {
|
||||||
\@lign
|
\@lign
|
||||||
@ -74,7 +73,9 @@
|
|||||||
{ \make@display@tag }
|
{ \make@display@tag }
|
||||||
}
|
}
|
||||||
\place@tag
|
\place@tag
|
||||||
|
\__luamml_amsmath_set_tag:
|
||||||
\fi
|
\fi
|
||||||
|
\__luamml_amsmath_finalize_row:
|
||||||
\ifst@rred
|
\ifst@rred
|
||||||
\else
|
\else
|
||||||
\global \@eqnswtrue
|
\global \@eqnswtrue
|
||||||
@ -83,10 +84,19 @@
|
|||||||
\cr
|
\cr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\cs_set:Npn \maketag@@@ #1 {
|
||||||
|
\hbox {
|
||||||
|
\m@th
|
||||||
|
\normalfont
|
||||||
|
#1
|
||||||
|
\__luamml_amsmath_save_tag:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
\cs_set:Npn \endalign {
|
\cs_set:Npn \endalign {
|
||||||
\math@cr
|
\math@cr
|
||||||
\black@ \totwidth@
|
\black@ \totwidth@
|
||||||
\luamml_amsmath_finalize_table:
|
\__luamml_amsmath_finalize_table:
|
||||||
\egroup
|
\egroup
|
||||||
\ifingather@
|
\ifingather@
|
||||||
\restorealignstate@
|
\restorealignstate@
|
||||||
|
Loading…
Reference in New Issue
Block a user