diff options
author | Karl Berry <karl@freefriends.org> | 2011-04-22 23:36:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-04-22 23:36:31 +0000 |
commit | cd62c624e149e4c29e0e7aa29c016ae8b45cf086 (patch) | |
tree | 1279b8e45d65cd3fd93975997a8d3db844722b28 /Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua | |
parent | 2be6eaeb8090315538ca23046d0fbc8ffce6acdd (diff) |
oberdiek (22apr11)
git-svn-id: svn://tug.org/texlive/trunk@22162 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua')
-rw-r--r-- | Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua | 96 |
1 files changed, 60 insertions, 36 deletions
diff --git a/Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua b/Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua index 5638e8c1974..0f5dafdd80b 100644 --- a/Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua +++ b/Master/texmf-dist/scripts/oberdiek/oberdiek.luacolor.lua @@ -9,7 +9,7 @@ -- This is a generated file. -- -- Project: luacolor --- Version: 2011/03/29 v1.4 +-- Version: 2011/04/22 v1.5 -- -- Copyright (C) 2007, 2009-2011 by -- Heiko Oberdiek <heiko.oberdiek at googlemail.com> @@ -104,65 +104,84 @@ local attribute function setattribute(attr) attribute = attr end -function process(box) - local color = "" - local list = tex.getbox(box) - traverse(list, color) -end local LIST = 1 -local COLOR = 2 -local type = { +local LIST_LEADERS = 2 +local COLOR = 3 +local RULE = node.id("rule") +local node_types = { [node.id("hlist")] = LIST, [node.id("vlist")] = LIST, [node.id("rule")] = COLOR, [node.id("glyph")] = COLOR, [node.id("disc")] = COLOR, + [node.id("whatsit")] = { + [3] = COLOR, -- special + [8] = COLOR, -- pdf_literal + [14] = COLOR, -- pdf_refximage + }, + [node.id("glue")] = + function(n) + if n.subtype >= 100 then -- leaders + if n.leader.id == RULE then + return COLOR + else + return LIST_LEADERS + end + end + end, } -local subtype = { - [3] = COLOR, -- special - [8] = COLOR, -- pdf_literal -} +local function get_type(n) + local ret = node_types[n.id] + if type(ret) == 'table' then + ret = ret[n.subtype] + end + if type(ret) == 'function' then + ret = ret(n) + end + return ret +end local mode = 2 -- luatex.pdfliteral.direct local WHATSIT = node.id("whatsit") local SPECIAL = 3 local PDFLITERAL = 8 -function traverse(list, color) +local DRY_FALSE = 0 +local DRY_TRUE = 1 +local function traverse(list, color, dry) if not list then return color end - if type[list.id] ~= LIST then + if get_type(list) ~= LIST then texio.write_nl("!!! Error: Wrong list type: " .. node.type(list.id)) return color end local head = list.head for n in node.traverse(head) do - local type = type[n.id] - if type == LIST then - color = traverse(n, color) - elseif type == COLOR - or (type == WHATSIT - and subtype[n.subtype]) then + local t = get_type(n) + if t == LIST then + color = traverse(n, color, DRY_FALSE) + elseif t == LIST_LEADERS then + local color_after = traverse(n.leader, color, DRY_TRUE) + if color == color_after then + traverse(n.leader, color, DRY_FALSE) + else + traverse(n.leader, '', DRY_FALSE) + end + elseif t == COLOR then local v = node.has_attribute(n, attribute) if v then local newColor = map[v] if newColor ~= color then color = newColor - local newNode - if ifpdf then - newNode = node.new(WHATSIT, PDFLITERAL) - newNode.mode = mode - newNode.data = color - else - newNode = node.new(WHATSIT, SPECIAL) - newNode.data = prefix .. color - end - if head == n then - newNode.next = head - local old_prev = head.prev - head.prev = newNode - head = newNode - head.prev = old_prev - else + if dry == DRY_FALSE then + local newNode + if ifpdf then + newNode = node.new(WHATSIT, PDFLITERAL) + newNode.mode = mode + newNode.data = color + else + newNode = node.new(WHATSIT, SPECIAL) + newNode.data = prefix .. color + end head = node.insert_before(head, n, newNode) end end @@ -172,5 +191,10 @@ function traverse(list, color) list.head = head return color end +function process(box) + local color = "" + local list = tex.getbox(box) + traverse(list, color, DRY_FALSE) +end -- -- End of File `oberdiek.luacolor.lua'. |