Use cs independent command tokens

This commit is contained in:
Marcel Krüger 2020-07-03 03:54:30 +02:00
parent f5b842c30e
commit 3d7380f76a
2 changed files with 15 additions and 4 deletions

View File

@ -34,6 +34,18 @@ local function get_outline()
return outline return outline
end end
local properties = node.direct.properties local properties = node.direct.properties
local immediateassignment = token.new(5, token.command_id'convert')
local global = token.new(0, token.command_id'prefix')
local deadcycles = token.new(8, token.command_id'set_page_property')
local zero_tok = token.create(0x30)
local relax = token.new(0, 0)
local reset_deadcycles = {
immediateassignment,
global,
deadcycles,
zero_tok,
relax,
}
token.luacmd("shipout", function() token.luacmd("shipout", function()
local pfile = get_pfile() local pfile = get_pfile()
local voff = node.new'kern' local voff = node.new'kern'
@ -50,7 +62,7 @@ token.luacmd("shipout", function()
local content = pfile:stream(nil, '', out) local content = pfile:stream(nil, '', out)
pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources<<%s%s>>%s%s>>]], parent, content, -math.ceil(list.depth/65781.76), math.ceil(list.width/65781.76), math.ceil(list.height/65781.76), resources, pdfvariable.pageresources, annots, pdfvariable.pageattr)) pfile:indirect(page, string.format([[<</Type/Page/Parent %i 0 R/Contents %i 0 R/MediaBox[0 %i %i %i]/Resources<<%s%s>>%s%s>>]], parent, content, -math.ceil(list.depth/65781.76), math.ceil(list.width/65781.76), math.ceil(list.height/65781.76), resources, pdfvariable.pageresources, annots, pdfvariable.pageattr))
node.flush_list(list) node.flush_list(list)
token.put_next(token.create'immediateassignment', token.create'global', token.create'deadcycles', token.create(0x30), token.create'relax') token.put_next(reset_deadcycles)
token.scan_token() token.scan_token()
end, 'force', 'protected') end, 'force', 'protected')

View File

@ -12,8 +12,7 @@ lua.get_functions_table()[restore_func] = function()
end end
end end
end end
local lua_call = token.command_id'lua_call' local restore_toks = {token.new(2, token.command_id'after_something') , token.new(restore_func, token.command_id'lua_call')} -- \atendofgroup FIXME: Detect mode automatically once token.primitive is fixed
local restore_toks = {token.create'atendofgroup', token.new(restore_func, lua_call)}
local put_next = token.put_next local put_next = token.put_next
local runtoks = tex.runtoks local runtoks = tex.runtoks
local function put_restore_toks() local function put_restore_toks()