summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua45
1 files changed, 26 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
index 9a59891e103..1e142280fed 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/typo-drp.lua
@@ -28,11 +28,14 @@ local enableaction = tasks.enableaction
local disableaction = tasks.disableaction
local nuts = nodes.nuts
+local tonut = nuts.tonut
+local tonode = nuts.tonode
local getnext = nuts.getnext
local getprev = nuts.getprev
local getchar = nuts.getchar
local getid = nuts.getid
+local getsubtype = nuts.getsubtype
local getattr = nuts.getattr
local getwhd = nuts.getwhd
@@ -56,9 +59,8 @@ local new_kern = nodepool.kern
local insert_before = nuts.insert_before
local insert_after = nuts.insert_after
local remove_node = nuts.remove
-
-local nextnode = nuts.traversers.node
-local nextglyph = nuts.traversers.glyph
+local traverse_id = nuts.traverse_id
+local traverse = nuts.traverse
local variables = interfaces.variables
local v_default = variables.default
@@ -137,8 +139,9 @@ interfaces.implement {
-- a page so this has a low priority
actions[v_default] = function(head,setting)
+ local done = false
local id = getid(head)
- if id == localpar_code then -- and getsubtype(head) == 0
+ if id == localpar_code then
-- begin of par
local first = getnext(head)
local indent = false
@@ -170,7 +173,7 @@ actions[v_default] = function(head,setting)
-- 1 char | n chars | skip first quote | ignore punct | keep punct
--
if getattr(first,a_initial) then
- for current in nextnode, getnext(first) do
+ for current in traverse(getnext(first)) do
if getattr(current,a_initial) then
last = current
else
@@ -186,10 +189,10 @@ actions[v_default] = function(head,setting)
local next = getnext(first)
if not next then
-- don't start with a quote or so
- return head
+ return head, false
end
last = nil
- for current in nextglyph, next do
+ for current in traverse_id(glyph_code,next) do
head, first = remove_node(head,first,true)
first = current
last = first
@@ -197,21 +200,21 @@ actions[v_default] = function(head,setting)
end
if not last then
-- no following glyph or so
- return head
+ return head, false
end
else
-- keep quote etc with initial
local next = getnext(first)
if not next then
-- don't start with a quote or so
- return head
+ return head, false
end
- for current in nextglyph, next do
+ for current in traverse_id(glyph_code,next) do
last = current
break
end
if last == first then
- return head
+ return head, false
end
end
elseif kind == "pf" then
@@ -222,7 +225,8 @@ actions[v_default] = function(head,setting)
-- maybe also: get all A. B. etc
local next = getnext(first)
if next then
- for current, char in nextglyph, next do
+ for current in traverse_id(glyph_code,next) do
+ local char = getchar(current)
local kind = category(char)
if kind == "po" then
if method[v_last] then
@@ -237,7 +241,7 @@ actions[v_default] = function(head,setting)
end
end
else
- for current in nextglyph, first do
+ for current in traverse_id(glyph_code,first) do
last = current
if length <= 1 then
break
@@ -261,12 +265,12 @@ actions[v_default] = function(head,setting)
end
-- apply font
--- local g = nuts.copy(current)
+-- local g = nodes.copy(tonode(current))
-- g.subtype = 0
-- nodes.handlers.characters(g)
-- nodes.handlers.protectglyphs(g)
-- setchar(current,g.char)
--- nuts.flush_node(g)
+-- nodes.flush_node(g)
-- can be a helper
if ca and ca > 0 then
@@ -315,7 +319,7 @@ actions[v_default] = function(head,setting)
end
--
local hoffset = width + hoffset + distance + (indent and parindent or 0)
- for current in nextglyph, first do
+ for current in traverse_id(glyph_code,first) do
setoffsets(current,-hoffset,-voffset) -- no longer - height here
if current == last then
break
@@ -343,12 +347,14 @@ actions[v_default] = function(head,setting)
if indent then
insert_after(first,first,new_kern(-parindent))
end
+ done = true
end
end
- return head
+ return head, done
end
function initials.handler(head)
+ head = tonut(head)
local start = head
local attr = nil
while start do
@@ -371,8 +377,9 @@ function initials.handler(head)
if trace_initials then
report_initials("processing initials, alternative %a",alternative)
end
- return action(head,settings)
+ local head, done = action(head,settings)
+ return tonode(head), done
end
end
- return head
+ return tonode(head), false
end