[luatex] prev field in discretionary nodes

Stephan Hennig mailing_list at arcor.de
Sat Jan 18 10:41:58 CET 2014


Hi,

below you can find a textual representation of the discretionary node
resulting from the command \discretionary{a-}{b}{c}.  Lines beginning
with a + sign contain additional information to the preceding line.

nl: <node    199 <    208 >    236 : disc 0>
nl: +pre:
nl:   <node    212 <    181 >    218 : glyph 1>
nl:   +char: a
nl:   <node    181 <    218 >    nil : glyph 1>
nl:   +char: -
nl: +post:
nl:   <node    214 <    224 >    nil : glyph 1>
nl:   +char: b
nl: +replace:
nl:   <node    216 <    230 >    nil : glyph 1>
nl:   +char: c

In this example, one can see that nodes 181, 224, 230 (first nodes in
sub-lists) do have a prev field set.  But that points neither to the
discretionary node (208) nor to any preceding node in the node list (not
shown here).

What do the first prev fields in pre, post, replace sub-lists of
discretionary nodes point to?

Best regards,
Stephan Hennig
-------------- next part --------------
local Uchar = unicode.utf8.char
local DISC = node.id('disc')
local GLYPH = node.id('glyph')

local function print_list(head, indent)
   local si = string.rep(' ', indent)
   for n in node.traverse(head) do
      luatexbase.module_log('nl', '%s%s', si, tostring(n))
      if n.id == GLYPH then
         luatexbase.module_log('nl', '%s%s %s', si, '+char:', Uchar(n.char))
         if n.components then print_list(n.components, indent+2) end
      elseif n.id == DISC then
         luatexbase.module_log('nl', '%s%s', si, '+pre:')
         print_list(n.pre, indent+2)
         luatexbase.module_log('nl', '%s%s', si, '+post:')
         print_list(n.post, indent+2)
         luatexbase.module_log('nl', '%s%s', si, '+replace:')
         print_list(n.replace, indent+2)
      end
   end
end

local function cb(head)
   print_list(head, 0)
   luatexbase.module_log('nl', '%s', '***')
   lang.hyphenate(head)
end

luatexbase.add_to_callback('hyphenate', cb, 'test_h')
-------------- next part --------------
\input luatexbase.sty
\directlua{
  dofile('disc-prev.lua')
}
\discretionary{a-}{b}{c}
\bye


More information about the luatex mailing list