summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/node-rul.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-01-17 18:05:46 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-01-17 18:05:46 +0100
commit0cfeab235554eeee0dddd6c3f44d3939ab490ff1 (patch)
treefed70e9a3332741e5294a01197c716dff8556506 /tex/context/base/mkiv/node-rul.lua
parent72d161c0a522fd92f32edd3588fa126c453f4a3d (diff)
downloadcontext-0cfeab235554eeee0dddd6c3f44d3939ab490ff1.tar.gz
2017-01-17 17:43:00
Diffstat (limited to 'tex/context/base/mkiv/node-rul.lua')
-rw-r--r--tex/context/base/mkiv/node-rul.lua186
1 files changed, 3 insertions, 183 deletions
diff --git a/tex/context/base/mkiv/node-rul.lua b/tex/context/base/mkiv/node-rul.lua
index 3a60ca502..76be2a5c9 100644
--- a/tex/context/base/mkiv/node-rul.lua
+++ b/tex/context/base/mkiv/node-rul.lua
@@ -17,8 +17,6 @@ if not modules then modules = { } end modules ['node-rul'] = {
-- fill s withcolor .5white ;
-- draw boundingbox s withcolor yellow;
-local floor = math.floor
-
local attributes = attributes
local nodes = nodes
local tasks = nodes.tasks
@@ -41,7 +39,6 @@ local setattr = nuts.setattr
local getfont = nuts.getfont
local getsubtype = nuts.getsubtype
local getlist = nuts.getlist
-local setlist = nuts.setlist
local flushlist = nuts.flush_list
local effective_glue = nuts.effective_glue
@@ -71,7 +68,6 @@ local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
local kern_code = nodecodes.kern
local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
local indent_code = listcodes.indent
local line_code = listcodes.line
@@ -79,12 +75,6 @@ local line_code = listcodes.line
local leftskip_code = gluecodes.leftskip
local rightskip_code = gluecodes.rightskip
local parfillskip_code = gluecodes.parfillskip
-local userskip_code = gluecodes.userskip
-local spaceskip_code = gluecodes.spaceskip
-local xspaceskip_code = gluecodes.xspaceskip
-local leader_code = gluecodes.leaders
-
-local kerning_code = kerncodes.kern
local nodepool = nuts.pool
@@ -126,181 +116,11 @@ local dimenfactor = fonts.helpers.dimenfactor
local splitdimen = number.splitdimen
local setmetatableindex = table.setmetatableindex
-local function striprange(first,last) -- todo: dir
- if first and last then -- just to be sure
- if first == last then
- return first, last
- end
- while first and first ~= last do
- local id = getid(first)
- if id == glyph_code or id == disc_code or id == dir_code or id == boundary_code then -- or id == rule_code
- break
- else
- first = getnext(first)
- end
- end
- if not first then
- return nil, nil
- elseif first == last then
- return first, last
- end
- while last and last ~= first do
- local id = getid(last)
- if id == glyph_code or id == disc_code or id == dir_code or id == boundary_code then -- or id == rule_code
- break
- else
- local prev = getprev(last) -- luatex < 0.70 has italic correction kern not prev'd
- if prev then
- last = prev
- else
- break
- end
- end
- end
- if not last then
- return nil, nil
- end
- end
- return first, last
-end
-
-nodes.striprange = striprange
-
--- todo: order and maybe other dimensions
-
--- we can use this one elsewhere too
---
--- todo: functions: word, sentence
--
--- glyph rule unset whatsit glue margin_kern kern math disc
-
--- we assume {glyphruns} and no funny extra kerning, ok, maybe we need
--- a dummy character as start and end; anyway we only collect glyphs
---
--- this one needs to take layers into account (i.e. we need a list of
--- critical attributes)
-
--- omkeren class en level -> scheelt functie call in analyze
-
--- todo: switching inside math
-
--- handlers
-
-local function processwords(attribute,data,flush,head,parent,skip) -- we have hlistdir and local dir
- local n = head
- if n then
- local f, l, a, d, i, class
- local continue, leaders, done, strip, level = false, false, false, true, -1
- while n do
- local id = getid(n)
- if id == glyph_code or id == rule_code or (id == hlist_code and getattr(n,a_runningtext) == 1) then
- local aa = getattr(n,attribute)
- if aa and aa ~= skip then
- if aa == a then
- if not f then -- ?
- f = n
- end
- l = n
- else
- -- possible extensions: when in same class then keep spanning
- local newlevel, newclass = floor(aa/1000), aa%1000
- -- strip = not continue or level == 1 -- 0
- if f then
- if class == newclass then -- and newlevel > level then
- head, done = flush(head,f,l,d,level,parent,false), true
- else
- head, done = flush(head,f,l,d,level,parent,strip), true
- end
- end
- f, l, a = n, n, aa
- level, class = newlevel, newclass
- d = data[class]
- local c = d.continue
- leaders = c == v_all
- continue = leaders or c == v_yes
- end
- else
- if f then
- head, done = flush(head,f,l,d,level,parent,strip), true
- end
- f, l, a = nil, nil, nil
- end
- if id == hlist_code then
- local list = getlist(n)
- if list then
- setlist(n,(processwords(attribute,data,flush,list,n,aa))) -- watch ()
- end
- end
- elseif id == disc_code or id == boundary_code then
- if f then
- l = n
- end
- elseif id == kern_code and getsubtype(n) == kerning_code then
- if f then
- l = n
- end
- elseif id == math_code then
- -- otherwise not consistent: a $b$ c vs a $b+c$ d etc
- -- we need a special (optional) go over math variant
- if f then
- head, done = flush(head,f,l,d,level,parent,strip), true
- f, l, a = nil, nil, nil
- end
- elseif id == hlist_code or id == vlist_code then
- if f then
- head, done = flush(head,f,l,d,level,parent,strip), true
- f, l, a = nil, nil, nil
- end
- local list = getlist(n)
- if list then
- setlist(n,(processwords(attribute,data,flush,list,n,skip))) -- watch ()
- end
- elseif id == dir_code then -- only changes in dir, we assume proper boundaries
- if f then
- l = n
- end
- elseif f then
- if continue then
- if id == penalty_code then
- l = n
- -- elseif id == kern_code then
- -- l = n
- elseif id == glue_code then
- -- catch \underbar{a} \underbar{a} (subtype test is needed)
- local subtype = getsubtype(n)
- if getattr(n,attribute) and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code or (leaders and subtype >= leader_code)) then
- l = n
- else
- head, done = flush(head,f,l,d,level,parent,strip), true
- f, l, a = nil, nil, nil
- end
- end
- else
- head, done = flush(head,f,l,d,level,parent,strip), true
- f, l, a = nil, nil, nil
- end
- end
- n = getnext(n)
- end
- if f then
- head, done = flush(head,f,l,d,level,parent,strip), true
- end
- return head, true -- todo: done
- else
- return head, false
- end
-end
-
--- nodes.processwords = processwords
-nodes.processwords = function(attribute,data,flush,head,parent) -- we have hlistdir and local dir
- head = tonut(head)
- if parent then
- parent = tonut(parent)
- end
- local head, done = processwords(attribute,data,flush,head,parent)
- return tonode(head), done
-end
+local striprange = nodes.striprange
+local processwords = nodes.processwords
+local processranges = nodes.processranges
--