sync with experimental
[luatex.git] / manual / luatex-nodes.tex
blobfd0b47c7290d279c80b0c73a2b5866946dffd4a0
1 % language=uk
3 \environment luatex-style
4 \environment luatex-logos
6 \startcomponent luatex-nodes
8 \startchapter[reference=nodes,title={Nodes}]
10 \section{\LUA\ node representation}
12 \TEX's nodes are represented in \LUA\ as userdata object with a variable set of
13 fields. In the following syntax tables, such the type of such a userdata object
14 is represented as \syntax {<node>}.
16 The current return value of \type {node.types()} is:
17 \startluacode
18 for id, name in table.sortedhash(node.types()) do
19 context.type(name)
20 context(" (%s), ",id)
21 end
22 context.removeunwantedspaces()
23 context.removepunctuation()
24 \stopluacode
25 . % period
27 The \type {\lastnodetype} primitive is \ETEX\ compliant. The valid range is still
28 $[-1,15]$ and glyph nodes (formerly known as char nodes) have number~0 while
29 ligature nodes are mapped to~7. That way macro packages can use the same symbolic
30 names as in traditional \ETEX. Keep in mind that these \ETEX\ node numbers are
31 different from the real internal ones and that there are more \ETEX\ node types
32 than~15.
34 You can ask for a list of fields with the \type {node.fields} (which takes an id)
35 and for valid subtypes with \type {node.subtypes} (which takes a string because
36 eventually we might support more used enumerations).
38 \subsection{Attributes}
40 The newly introduced attribute registers are non|-|trivial, because the value
41 that is attached to a node is essentially a sparse array of key|-|value pairs. It
42 is generally easiest to deal with attribute lists and attributes by using the
43 dedicated functions in the \type {node} library, but for completeness, here is
44 the low|-|level interface.
46 \subsubsection{attribute_list nodes}
48 An \type {attribute_list} item is used as a head pointer for a list of attribute
49 items. It has only one user-visible field:
51 \starttabulate[|lT|l|p|]
52 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
53 \NC next \NC node \NC pointer to the first attribute \NC \NR
54 \stoptabulate
56 \subsubsection{attribute nodes}
58 A normal node's attribute field will point to an item of type \type
59 {attribute_list}, and the \type {next} field in that item will point to the first
60 defined \quote {attribute} item, whose \type {next} will point to the second
61 \quote {attribute} item, etc.
63 \starttabulate[|lT|l|p|]
64 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
65 \NC next \NC node \NC pointer to the next attribute \NC \NR
66 \NC number \NC number \NC the attribute type id \NC \NR
67 \NC value \NC number \NC the attribute value \NC \NR
68 \stoptabulate
70 As mentioned it's better to use the official helpers rather than edit these
71 fields directly. For instance the \type {prev} field is used for other purposes
72 and there is no double linked list.
74 \subsection{Main text nodes}
76 These are the nodes that comprise actual typesetting commands. A few fields are
77 present in all nodes regardless of their type, these are:
79 \starttabulate[|lT|l|p|]
80 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
81 \NC next \NC node \NC the next node in a list, or nil \NC \NR
82 \NC id \NC number \NC the node's type (\type {id}) number \NC \NR
83 \NC subtype \NC number \NC the node \type {subtype} identifier \NC \NR
84 \stoptabulate
86 The \type {subtype} is sometimes just a stub entry. Not all nodes actually use
87 the \type {subtype}, but this way you can be sure that all nodes accept it as a
88 valid field name, and that is often handy in node list traversal. In the
89 following tables \type {next} and \type {id} are not explicitly mentioned.
91 Besides these three fields, almost all nodes also have an \type {attr} field, and
92 there is a also a field called \type {prev}. That last field is always present,
93 but only initialized on explicit request: when the function \type {node.slide()}
94 is called, it will set up the \type {prev} fields to be a backwards pointer in
95 the argument node list. By now most of \TEX's node processing makes sure that the
96 \type {prev} nodes are valid but there can be exceptions, especially when the
97 internal magic uses a leading \type {temp} nodes to temporarily store a state.
99 \subsubsection{hlist nodes}
101 \starttabulate[|lT|l|p|]
102 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
103 \NC subtype \NC number \NC \showsubtypes{list} \NC \NR
104 \NC attr \NC node \NC list of attributes \NC \NR
105 \NC width \NC number \NC the width of the box \NC \NR
106 \NC height \NC number \NC the height of the box \NC \NR
107 \NC depth \NC number \NC the depth of the box \NC \NR
108 \NC shift \NC number \NC a displacement perpendicular to the character progression direction \NC \NR
109 \NC glue_order \NC number \NC a number in the range $[0,4]$, indicating the glue order \NC \NR
110 \NC glue_set \NC number \NC the calculated glue ratio \NC \NR
111 \NC glue_sign \NC number \NC 0 = \type {normal}, 1 = \type {stretching}, 2 = \type {shrinking} \NC \NR
112 \NC head/list \NC node \NC the first node of the body of this list \NC \NR
113 \NC dir \NC string \NC the direction of this box, see~\in[dirnodes] \NC \NR
114 \stoptabulate
116 A warning: never assign a node list to the \type {head} field unless you are sure
117 its internal link structure is correct, otherwise an error may result.
119 Note: the field name \type {head} and \type {list} are both valid. Sometimes it
120 makes more sense to refer to a list by \type {head}, sometimes \type {list} makes
121 more sense.
123 \subsubsection{vlist nodes}
125 This node is similar to \type {hlist}, except that \quote {shift} is a displacement
126 perpendicular to the line progression direction, and \quote {subtype} only has
127 the values 0, 4, and~5.
129 \subsubsection{rule nodes}
131 Contrary to traditional \TEX, \LUATEX\ has more subtypes because we also use
132 rules to store reuseable objects and images. User nodes are invisible and can be
133 intercepted by a callback.
135 \starttabulate[|lT|l|p|]
136 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
137 \NC subtype \NC number \NC \showsubtypes{rule} \NC \NR
138 \NC attr \NC node \NC list of attributes \NC \NR
139 \NC width \NC number \NC the width of the rule where the special value $-1073741824$ is used for \quote {running} glue dimensions \NC \NR
140 \NC height \NC number \NC the height of the rule (can be negative) \NC \NR
141 \NC depth \NC number \NC the depth of the rule (can be negative) \NC \NR
142 \NC dir \NC string \NC the direction of this rule, see~\in[dirnodes] \NC \NR
143 \NC index \NC number \NC an optional index that can be referred to \NC \NR
144 \stoptabulate
146 \subsubsection{ins nodes}
148 \starttabulate[|lT|l|p|]
149 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
150 \NC subtype \NC number \NC the insertion class \NC \NR
151 \NC attr \NC node \NC list of attributes \NC \NR
152 \NC cost \NC number \NC the penalty associated with this insert \NC \NR
153 \NC height \NC number \NC height of the insert \NC \NR
154 \NC depth \NC number \NC depth of the insert \NC \NR
155 \NC head/list \NC node \NC the first node of the body of this insert \NC \NR
156 \stoptabulate
158 There is a set of extra fields that concern the associated glue: \type {width},
159 \type {stretch}, \type {stretch_order}, \type {shrink} and \type {shrink_order}.
160 These are all numbers.
162 A warning: never assign a node list to the \type {head} field unless you are sure
163 its internal link structure is correct, otherwise an error may be result. You can use
164 \type {list} instead (often in functions you want to use local variable swith similar
165 names and both names are equally sensible).
167 \subsubsection{mark nodes}
169 \starttabulate[|lT|l|p|]
170 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
171 \NC subtype \NC number \NC unused \NC \NR
172 \NC attr \NC node \NC list of attributes \NC \NR
173 \NC class \NC number \NC the mark class \NC \NR
174 \NC mark \NC table \NC a table representing a token list \NC \NR
175 \stoptabulate
177 \subsubsection{adjust nodes}
179 \starttabulate[|lT|l|p|]
180 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
181 \NC subtype \NC number \NC \showsubtypes{adjust} \NC \NR
182 \NC attr \NC node \NC list of attributes \NC \NR
183 \NC head/list \NC node \NC adjusted material \NC \NR
184 \stoptabulate
186 A warning: never assign a node list to the \type {head} field unless you are sure
187 its internal link structure is correct, otherwise an error may be result.
189 \subsubsection{disc nodes}
191 \starttabulate[|lT|l|p|]
192 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
193 \NC subtype \NC number \NC \showsubtypes{disc} \NC \NR
194 \NC attr \NC node \NC list of attributes \NC \NR
195 \NC pre \NC node \NC pointer to the pre|-|break text \NC \NR
196 \NC post \NC node \NC pointer to the post|-|break text \NC \NR
197 \NC replace \NC node \NC pointer to the no|-|break text \NC \NR
198 \NC penalty \NC number \NC the penalty associated with the break, normally \type {\hyphenpenalty} or \type {\exhyphenpenalty} \NC \NR
199 \stoptabulate
201 The subtype numbers~4 and~5 belong to the \quote {of-f-ice} explanation given
202 elsewhere.
204 These disc nodes are kind of special as at some point they also keep information
205 about breakpoints and nested ligatures. The \type {pre}, \type {post} and \type
206 {replace} fields at the \LUA\ end are in fact indirectly accessed and have a
207 \type {prev} pointer that is not \type {nil}. This means that when you mess
208 around with the head of these (three) lists, you also need to reassign them
209 because that will restore the proper \type {prev} pointer, so:
211 \starttyping
212 pre = d.pre
213 -- change the list starting with pre
214 d.pre = pre
215 \stoptyping
217 Otherwise you can end up with an invalid internal perception of reality and
218 \LUATEX\ might even decide to crash on you. It also means that running forward
219 over for instance \type {pre} is ok but backward you need to stop at \type {pre}.
220 And you definitely must not mess with the node that \type {prev} points to, if
221 only because it is not really an node but part of the disc data structure (so
222 freeing it again might crash \LUATEX).
224 \subsubsection{math nodes}
226 \starttabulate[|lT|l|p|]
227 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
228 \NC subtype \NC number \NC \showsubtypes{math} \NC \NR
229 \NC attr \NC node \NC list of attributes \NC \NR
230 \NC surround \NC number \NC width of the \type {\mathsurround} kern \NC \NR
231 \stoptabulate
233 There is a set of extra fields that concern the associated glue: \type {width},
234 \type {stretch}, \type {stretch_order}, \type {shrink} and \type {shrink_order}.
235 These are all numbers.
237 \subsubsection{glue nodes}
239 Skips are about the only type of data objects in traditional \TEX\ that are not a
240 simple value. The structure that represents the glue components of a skip is
241 called a \type {glue_spec}, and it has the following accessible fields:
243 \starttabulate[|lT|l|p|]
244 \NC \rmbf key \NC \bf type \NC \bf explanation \NC \NR
245 \NC width \NC number \NC the horizontal or vertical displacement \NC \NR
246 \NC stretch \NC number \NC extra (positive) displacement or stretch amount \NC \NR
247 \NC stretch_order \NC number \NC factor applied to stretch amount \NC \NR
248 \NC shrink \NC number \NC extra (negative) displacement or shrink amount\NC \NR
249 \NC shrink_order \NC number \NC factor applied to shrink amount \NC \NR
250 \stoptabulate
252 The effective width of some glue subtypes depends on the stretch or shrink needed
253 to make the encapsulating box fit its dimensions. For instance, in a paragraph
254 lines normally have glue representing spaces and these stretch of shrink to make
255 the content fit in the available space. The \type {effective_glue} function that
256 takes a glue node and a parent (hlist or vlist) returns the effective width of
257 that glue item.
259 A gluespec node is a special kind of node that is used for storing a set of glue
260 values in registers. Originally they were also used to store properties of glue
261 nodes (using a system of reference counts) but we now keep these properties in
262 the glue nodes themselves, which gives a cleaner interface to \LUA.
264 The indirect spec approach was in fact an optimization in the original \TEX\
265 code. First of all it can save quite some memory because all these spaces that
266 become glue now share the same specification (only the reference count is
267 incremented), and zero testing is also a bit faster because only the pointer has
268 to be checked (this is no longer true for engines that implement for instance
269 protrusion where we really need to ensure that zero is zero when we test for
270 bounds). Another side effect is that glue specifications are read|-|only, so in
271 the end copies need to be made when they are used from \LUA\ (each assignment to
272 a field can result in a new copy). So in the end the advantages of sharing are
273 not that high (and nowadays memory is less an issue, also given that a glue node
274 is only a few memory words larger than a spec).
276 \starttabulate[|lT|l|p|]
277 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
278 \NC subtype \NC number \NC \showsubtypes{glue} \NC \NR
279 \NC attr \NC node \NC list of attributes \NC \NR
280 \NC leader \NC node \NC pointer to a box or rule for leaders \NC \NR
281 \stoptabulate
283 In addition there are the \type {width}, \type {stretch} \type {stretch_order},
284 \type {shrink}, and \type {shrink_order} fields. Note that we use the key \type
285 {width} in both horizontal and vertical glue. This suits the \TEX\ internals well
286 so we decided to stick to that naming.
288 A regular word space also results in a \type {spaceskip} subtype (this used to be
289 a \type {userskip} with subtype zero).
291 \subsubsection{kern nodes}
293 \starttabulate[|lT|l|p|]
294 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
295 \NC subtype \NC number \NC \showsubtypes{kern} \NC \NR
296 \NC attr \NC node \NC list of attributes \NC \NR
297 \NC kern \NC number \NC fixed horizontal or vertical advance \NC \NR
298 \stoptabulate
300 \subsubsection{penalty nodes}
302 \starttabulate[|lT|l|p|]
303 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
304 \NC subtype \NC number \NC not used \NC \NR
305 \NC attr \NC node \NC list of attributes \NC \NR
306 \NC penalty \NC number \NC the penalty value \NC \NR
307 \stoptabulate
309 \subsubsection[glyphnodes]{glyph nodes}
311 \starttabulate[|lT|l|p|]
312 \NC \rmbf field \NC \rmbf type \NC \rmbf explanation \NC \NR
313 \NC subtype \NC number \NC bitfield \NC \NR
314 \NC attr \NC node \NC list of attributes \NC \NR
315 \NC char \NC number \NC the chatacter index in the font \NC \NR
316 \NC font \NC number \NC the font identifier \NC \NR
317 \NC lang \NC number \NC the language identifier \NC \NR
318 \NC left \NC number \NC the frozen \type {\lefthyphenmnin} value \NC \NR
319 \NC right \NC number \NC the frozen \type {\righthyphenmnin} value \NC \NR
320 \NC uchyph \NC boolean \NC the frozen \type {\uchyph} value \NC \NR
321 \NC components \NC node \NC pointer to ligature components \NC \NR
322 \NC xoffset \NC number \NC a virtual displacement in horizontal direction \NC \NR
323 \NC yoffset \NC number \NC a virtual displacement in vertical direction \NC \NR
324 \NC xadvance \NC number \NC an additional advance after the glyph (experimental) \NC \NR
325 \NC width \NC number \NC the (original) width of the character \NC \NR
326 \NC height \NC number \NC the (original) height of the character\NC \NR
327 \NC depth \NC number \NC the (original) depth of the character\NC \NR
328 \NC expansion_factor \NC number \NC the to be applied expansion_factor \NC \NR
329 \stoptabulate
331 The \type {width}, \type {height} and \type {depth} values are read|-|only. The
332 \type {expansion_factor} is assigned in the parbuilder and used in the backend.
334 A warning: never assign a node list to the components field unless you are sure
335 its internal link structure is correct, otherwise an error may be result. Valid
336 bits for the \type {subtype} field are:
338 \starttabulate[|c|l|]
339 \NC \rmbf bit \NC \bf meaning \NC \NR
340 \NC 0 \NC character \NC \NR
341 \NC 1 \NC ligature \NC \NR
342 \NC 2 \NC ghost \NC \NR
343 \NC 3 \NC left \NC \NR
344 \NC 4 \NC right \NC \NR
345 \stoptabulate
347 See \in {section} [charsandglyphs] for a detailed description of the \type
348 {subtype} field.
350 The \type {expansion_factor} has been introduced as part of the separation
351 between font- and backend. It is the result of extensive experiments with a more
352 efficient implementation of expansion. Early versions of \LUATEX\ already
353 replaced multiple instances of fonts in the backend by scaling but contrary to
354 \PDFTEX\ in \LUATEX\ we now also got rid of font copies in the frontend and
355 replaced them by expansion factors that travel with glyph nodes. Apart from a
356 cleaner approach this is also a step towards a better separation between front-
357 and backend.
359 The \type {is_char} function checks if a node is a glyph node with a subtype still
360 less than 256. This function can be used to determine if applying font logic to a
361 glyph node makes sense. The value \type {nil} gets returned when the node is not
362 a glyph, a character number is returned if the node is still tagged as character
363 and \type {false} gets returned otherwise. When nil is returned, the id is also
364 returned. The \type {is_glyph} variant doesn't check for a subtype being less
365 than 256, so it returns either the character value or nil plus the id. These
366 helpers are not always faster than separate calls but they sometimes permit
367 making more readable tests.
369 \subsubsection{boundary nodes}
371 \starttabulate[|lT|l|p|]
372 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
373 \NC subtype \NC number \NC \showsubtypes{boundary} \NC \NR
374 \NC attr \NC node \NC list of attributes \NC \NR
375 \NC value \NC number \NC values 0--255 are reserved \NC \NR
376 \stoptabulate
378 This node relates to the \type {\noboundary}, \type {\boundary}, \type
379 {\protrusionboundary} and \type {\wordboundary} primitives.
381 \subsubsection{local_par nodes}
383 \starttabulate[|lT|l|p|]
384 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
385 \NC attr \NC node \NC list of attributes \NC \NR
386 \NC pen_inter \NC number \NC local interline penalty (from \type {\localinterlinepenalty}) \NC \NR
387 \NC pen_broken \NC number \NC local broken penalty (from \type {\localbrokenpenalty}) \NC \NR
388 \NC dir \NC string \NC the direction of this par. see~\in [dirnodes] \NC \NR
389 \NC box_left \NC node \NC the \type {\localleftbox} \NC \NR
390 \NC box_left_width \NC number \NC width of the \type {\localleftbox} \NC \NR
391 \NC box_right \NC node \NC the \type {\localrightbox} \NC \NR
392 \NC box_right_width \NC number \NC width of the \type {\localrightbox} \NC \NR
393 \stoptabulate
395 A warning: never assign a node list to the \type {box_left} or \type {box_right}
396 field unless you are sure its internal link structure is correct, otherwise an
397 error may be result.
399 \subsubsection[dirnodes]{dir nodes}
401 \starttabulate[|lT|l|p|]
402 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
403 \NC attr \NC node \NC list of attributes \NC \NR
404 \NC dir \NC string \NC the direction (but see below) \NC \NR
405 \NC level \NC number \NC nesting level of this direction whatsit \NC \NR
406 \stoptabulate
408 A note on \type {dir} strings. Direction specifiers are three|-|letter
409 combinations of \type {T}, \type {B}, \type {R}, and \type {L}.
411 These are built up out of three separate items:
413 \startitemize[packed]
414 \startitem
415 the first is the direction of the \quote{top} of paragraphs.
416 \stopitem
417 \startitem
418 the second is the direction of the \quote{start} of lines.
419 \stopitem
420 \startitem
421 the third is the direction of the \quote{top} of glyphs.
422 \stopitem
423 \stopitemize
425 However, only four combinations are accepted: \type {TLT}, \type {TRT}, \type
426 {RTT}, and \type {LTL}.
428 Inside actual \type {dir} whatsit nodes, the representation of \type {dir} is not
429 a three-letter but a four|-|letter combination. The first character in this case
430 is always either \type {+} or \type {-}, indicating whether the value is pushed
431 or popped from the direction stack.
433 \subsubsection{margin_kern nodes}
435 \starttabulate[|lT|l|p|]
436 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
437 \NC subtype \NC number \NC \showsubtypes{margin_kern} \NC \NR
438 \NC attr \NC node \NC list of attributes \NC \NR
439 \NC width \NC number \NC the advance of the kern \NC \NR
440 \NC glyph \NC node \NC the glyph to be used \NC \NR
441 \stoptabulate
443 \subsection{Math nodes}
445 These are the so||called \quote {noad}s and the nodes that are specifically
446 associated with math processing. Most of these nodes contain subnodes so that the
447 list of possible fields is actually quite small. First, the subnodes:
449 \subsubsection{Math kernel subnodes}
451 Many object fields in math mode are either simple characters in a specific family
452 or math lists or node lists. There are four associated subnodes that represent
453 these cases (in the following node descriptions these are indicated by the word
454 \type {<kernel>}).
456 The \type {next} and \type {prev} fields for these subnodes are unused.
458 \subsubsubsection{math_char and math_text_char subnodes}
460 \starttabulate[|lT|l|p|]
461 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
462 \NC attr \NC node \NC list of attributes \NC \NR
463 \NC char \NC number \NC the character index \NC \NR
464 \NC fam \NC number \NC the family number \NC \NR
465 \stoptabulate
467 The \type {math_char} is the simplest subnode field, it contains the character
468 and family for a single glyph object. The \type {math_text_char} is a special
469 case that you will not normally encounter, it arises temporarily during math list
470 conversion (its sole function is to suppress a following italic correction).
472 \subsubsubsection{sub_box and sub_mlist subnodes}
474 \starttabulate[|lT|l|p|]
475 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
476 \NC attr \NC node \NC list of attributes \NC \NR
477 \NC head/list \NC node \NC list of nodes \NC \NR
478 \stoptabulate
480 These two subnode types are used for subsidiary list items. For \type {sub_box},
481 the \type {head} points to a \quote {normal} vbox or hbox. For \type {sub_mlist},
482 the \type {head} points to a math list that is yet to be converted.
484 A warning: never assign a node list to the \type {head} field unless you are sure
485 its internal link structure is correct, otherwise an error may be result.
487 \subsubsection{Math delimiter subnode}
489 There is a fifth subnode type that is used exclusively for delimiter fields. As
490 before, the \type {next} and \type {prev} fields are unused.
492 \subsubsubsection{delim subnodes}
494 \starttabulate[|lT|l|p|]
495 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
496 \NC attr \NC node \NC list of attributes \NC \NR
497 \NC small_char \NC number \NC character index of base character \NC \NR
498 \NC small_fam \NC number \NC family number of base character \NC \NR
499 \NC large_char \NC number \NC character index of next larger character \NC \NR
500 \NC large_fam \NC number \NC family number of next larger character \NC \NR
501 \stoptabulate
503 The fields \type {large_char} and \type {large_fam} can be zero, in that case the
504 font that is sed for the \type {small_fam} is expected to provide the large
505 version as an extension to the \type {small_char}.
507 \subsubsection{Math core nodes}
509 First, there are the objects (the \TEX book calls then \quote {atoms}) that are
510 associated with the simple math objects: ord, op, bin, rel, open, close, punct,
511 inner, over, under, vcent. These all have the same fields, and they are combined
512 into a single node type with separate subtypes for differentiation.
514 \subsubsubsection{simple nodes}
516 \starttabulate[|lT|l|p|]
517 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
518 \NC subtype \NC number \NC \showsubtypes{noad} \NC \NR
519 \NC attr \NC node \NC list of attributes \NC \NR
520 \NC nucleus \NC kernel node \NC base \NC \NR
521 \NC sub \NC kernel node \NC subscript \NC \NR
522 \NC sup \NC kernel node \NC superscript \NC \NR
523 \stoptabulate
525 \subsubsubsection{accent nodes}
527 \starttabulate[|lT|l|p|]
528 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
529 \NC subtype \NC number \NC \showsubtypes{accent} \NC \NR
530 \NC nucleus \NC kernel node \NC base \NC \NR
531 \NC sub \NC kernel node \NC subscript \NC \NR
532 \NC sup \NC kernel node \NC superscript \NC \NR
533 \NC accent \NC kernel node \NC top accent \NC \NR
534 \NC bot_accent \NC kernel node \NC bottom accent \NC \NR
535 \NC fraction \NC number \NC larger step criterium (divided by 1000) \NC \NR
536 \stoptabulate
538 \subsubsubsection{style nodes}
540 \starttabulate[|lT|l|p|]
541 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
542 \NC style \NC string \NC contains the style \NC \NR
543 \stoptabulate
545 There are eight possibilities for the string value: one of \quote {display},
546 \quote {text}, \quote {script}, or \quote {scriptscript}. Each of these can have
547 a trailing \type {'} to signify \quote {cramped} styles.
549 \subsubsubsection{choice nodes}
551 \starttabulate[|lT|l|p|]
552 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
553 \NC attr \NC node \NC list of attributes \NC \NR
554 \NC display \NC node \NC list of display size alternatives \NC \NR
555 \NC text \NC node \NC list of text size alternatives \NC \NR
556 \NC script \NC node \NC list of scriptsize alternatives \NC \NR
557 \NC scriptscript \NC node \NC list of scriptscriptsize alternatives \NC \NR
558 \stoptabulate
560 Warning: never assign a node list to the \type {display}, \type {text}, \type
561 {script}, or \type {scriptscript} field unless you are sure its internal link
562 structure is correct, otherwise an error may be result.
564 \subsubsubsection{radical nodes}
566 \starttabulate[|lT|l|p|]
567 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
568 \NC subtype \NC number \NC \showsubtypes{radical} \NC \NR
569 \NC attr \NC node \NC list of attributes \NC \NR
570 \NC nucleus \NC kernel node \NC base \NC \NR
571 \NC sub \NC kernel node \NC subscript \NC \NR
572 \NC sup \NC kernel node \NC superscript \NC \NR
573 \NC left \NC delimiter node \NC \NC \NR
574 \NC degree \NC kernel node \NC only set by \type {\Uroot} \NC \NR
575 \NC width \NC number \NC required width \NC \NR
576 \NC options \NC number \NC bitset of rendering options \NC \NR
577 \stoptabulate
579 Warning: never assign a node list to the \type {nucleus}, \type {sub}, \type
580 {sup}, \type {left}, or \type {degree} field unless you are sure its internal
581 link structure is correct, otherwise an error may be result.
583 \subsubsubsection{fraction nodes}
585 \starttabulate[|lT|l|p|]
586 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
587 \NC attr \NC node \NC list of attributes \NC \NR
588 \NC width \NC number \NC (optional) width of the fraction \NC \NR
589 \NC num \NC kernel node \NC numerator \NC \NR
590 \NC denom \NC kernel node \NC denominator \NC \NR
591 \NC left \NC delimiter node \NC left side symbol \NC \NR
592 \NC right \NC delimiter node \NC right side symbol \NC \NR
593 \NC middle \NC delimiter node \NC middle symbol \NC \NR
594 \NC options \NC number \NC bitset of rendering options \NC \NR
595 \stoptabulate
597 Warning: never assign a node list to the \type {num}, or \type {denom} field
598 unless you are sure its internal link structure is correct, otherwise an error
599 may be result.
601 \subsubsubsection{fence nodes}
603 \starttabulate[|lT|l|p|]
604 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
605 \NC subtype \NC number \NC \showsubtypes{fence} \NC \NR
606 \NC attr \NC node \NC list of attributes \NC \NR
607 \NC delim \NC delimiter node \NC delimiter specification \NC \NR
608 \NC italic \NC number \NC italic correction \NC \NR
609 \NC height \NC number \NC required height \NC \NR
610 \NC depth \NC number \NC required depth \NC \NR
611 \NC options \NC number \NC bitset of rendering options \NC \NR
612 \NC class \NC number \NC spacing related class \NC \NR
613 \stoptabulate
615 Warning: some of these fields are used by the renderer and might get adapted in
616 the process.
618 \subsection{whatsit nodes}
620 Whatsit nodes come in many subtypes that you can ask for by running
621 \type {node.whatsits()}:
622 \startluacode
623 for id, name in table.sortedpairs(node.whatsits()) do
624 context.type(name)
625 context(" (%s), ",id)
627 context.removeunwantedspaces()
628 context.removepunctuation()
629 \stopluacode
630 . % period
632 \subsubsection{front|-|end whatsits}
634 \subsubsubsection{open whatsits}
636 \starttabulate[|lT|l|p|]
637 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
638 \NC attr \NC node \NC list of attributes \NC \NR
639 \NC stream \NC number \NC \TEX's stream id number \NC \NR
640 \NC name \NC string \NC file name \NC \NR
641 \NC ext \NC string \NC file extension \NC \NR
642 \NC area \NC string \NC file area (this may become obsolete) \NC \NR
643 \stoptabulate
645 \subsubsubsection{write whatsits}
647 \starttabulate[|lT|l|p|]
648 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
649 \NC attr \NC node \NC list of attributes \NC \NR
650 \NC stream \NC number \NC \TEX's stream id number \NC \NR
651 \NC data \NC table \NC a table representing the token list to be written \NC \NR
652 \stoptabulate
654 \subsubsubsection{close whatsits}
656 \starttabulate[|lT|l|p|]
657 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
658 \NC attr \NC node \NC list of attributes \NC \NR
659 \NC stream \NC number \NC \TEX's stream id number \NC \NR
660 \stoptabulate
662 \subsubsubsection{user_defined whatsits}
664 User|-|defined whatsit nodes can only be created and handled from \LUA\ code. In
665 effect, they are an extension to the extension mechanism. The \LUATEX\ engine
666 will simply step over such whatsits without ever looking at the contents.
668 \starttabulate[|lT|l|p|]
669 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
670 \NC attr \NC node \NC list of attributes \NC \NR
671 \NC user_id \NC number \NC id number \NC \NR
672 \NC type \NC number \NC type of the value \NC \NR
673 \NC value \NC number \NC a \LUA\ number \NC \NR
674 \NC \NC node \NC a node list \NC \NR
675 \NC \NC string \NC a \LUA\ string \NC \NR
676 \NC \NC table \NC a \LUA\ table \NC \NR
677 \stoptabulate
679 The \type {type} can have one of six distinct values. The number is the \ASCII\
680 value if the first character if the type name (so you can use string.byte("l")
681 instead of \type {108}).
683 \starttabulate[|lT|lT|p|]
684 \NC \rmbf value \NC \bf meaning \NC \bf explanation \NC \NR
685 \NC 97 \NC a \NC list of attributes (a node list) \NC \NR
686 \NC 100 \NC d \NC a \LUA\ number \NC \NR
687 \NC 108 \NC l \NC a \LUA\ value (table, number, boolean, etc) \NC \NR
688 \NC 110 \NC n \NC a node list \NC \NR
689 \NC 115 \NC s \NC a \LUA\ string \NC \NR
690 \NC 116 \NC t \NC a \LUA\ token list in \LUA\ table form (a list of triplets) \NC \NR
691 \stoptabulate
693 \subsubsubsection{save_pos whatsits}
695 \starttabulate[|lT|l|p|]
696 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
697 \NC attr \NC node \NC list of attributes \NC \NR
698 \stoptabulate
700 \subsubsubsection{late_lua whatsits}
702 \starttabulate[|lT|l|p|]
703 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
704 \NC attr \NC node \NC list of attributes \NC \NR
705 \NC data \NC string \NC data to execute \NC \NR
706 \NC string \NC string \NC data to execute \NC \NR
707 \NC name \NC string \NC the name to use for \LUA\ error reporting \NC \NR
708 \stoptabulate
710 The difference between \type {data} and \type {string} is that on assignment, the
711 \type {data} field is converted to a token list, cf. use as \type {\latelua}. The
712 \type {string} version is treated as a literal string.
714 \subsubsection{\DVI\ backend whatsits}
716 \subsubsection{special whatsits}
718 \starttabulate[|lT|l|p|]
719 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
720 \NC attr \NC node \NC list of attributes \NC \NR
721 \NC data \NC string \NC the \type {\special} information \NC \NR
722 \stoptabulate
724 \subsubsection{\PDF\ backend whatsits}
726 \subsubsubsection{pdf_literal whatsits}
728 \starttabulate[|lT|l|p|]
729 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
730 \NC attr \NC node \NC list of attributes \NC \NR
731 \NC mode \NC number \NC the \quote {mode} setting of this literal \NC \NR
732 \NC data \NC string \NC the \type {\pdfliteral} information \NC \NR
733 \stoptabulate
735 Possible mode values are:
737 \starttabulate[|lT|p|]
738 \NC \rmbf value \NC \rmbf \PDFTEX\ keyword \NC \NR
739 \NC 0 \NC setorigin \NC \NR
740 \NC 1 \NC page \NC \NR
741 \NC 2 \NC direct \NC \NR
742 \stoptabulate
744 \subsubsubsection{pdf_refobj whatsits}
746 \starttabulate[|lT|l|p|]
747 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
748 \NC attr \NC node \NC list of attributes \NC \NR
749 \NC objnum \NC number \NC the referenced \PDF\ object number \NC \NR
750 \stoptabulate
752 \subsubsubsection{pdf_annot whatsits}
754 \starttabulate[|lT|l|p|]
755 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
756 \NC attr \NC node \NC list of attributes \NC \NR
757 \NC width \NC number \NC the width (not used in calculations) \NC \NR
758 \NC height \NC number \NC the height (not used in calculations) \NC \NR
759 \NC depth \NC number \NC the depth (not used in calculations) \NC \NR
760 \NC objnum \NC number \NC the referenced \PDF\ object number \NC \NR
761 \NC data \NC string \NC the annotation data \NC \NR
762 \stoptabulate
764 \subsubsubsection{pdf_start_link whatsits}
766 \starttabulate[|lT|l|p|]
767 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
768 \NC attr \NC node \NC list of attributes \NC \NR
769 \NC width \NC number \NC the width (not used in calculations) \NC \NR
770 \NC height \NC number \NC the height (not used in calculations) \NC \NR
771 \NC depth \NC number \NC the depth (not used in calculations) \NC \NR
772 \NC objnum \NC number \NC the referenced \PDF\ object number \NC \NR
773 \NC link_attr \NC table \NC the link attribute token list \NC \NR
774 \NC action \NC node \NC the action to perform \NC \NR
775 \stoptabulate
777 \subsubsubsection{pdf_end_link whatsits}
779 \starttabulate[|lT|l|p|]
780 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
781 \NC attr \NC node \NC \NC \NR
782 \stoptabulate
784 \subsubsubsection{pdf_dest whatsits}
786 \starttabulate[|lT|l|p|]
787 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
788 \NC attr \NC node \NC list of attributes \NC \NR
789 \NC width \NC number \NC the width (not used in calculations) \NC \NR
790 \NC height \NC number \NC the height (not used in calculations) \NC \NR
791 \NC depth \NC number \NC the depth (not used in calculations) \NC \NR
792 \NC named_id \NC number \NC is the \type {dest_id} a string value? \NC \NR
793 \NC dest_id \NC number \NC the destination id \NC \NR
794 \NC \NC string \NC the destination name \NC \NR
795 \NC dest_type \NC number \NC type of destination \NC \NR
796 \NC xyz_zoom \NC number \NC the zoom factor (times 1000) \NC \NR
797 \NC objnum \NC number \NC the \PDF\ object number \NC \NR
798 \stoptabulate
800 \subsubsubsection{pdf_action whatsits}
802 These are a special kind of item that only appears inside \PDF\ start link
803 objects.
805 \starttabulate[|lT|l|p|]
806 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
807 \NC action_type \NC number \NC the kind of action involved \NC \NR
808 \NC action_id \NC number or string \NC token list reference or string \NC \NR
809 \NC named_id \NC number \NC the index of the destination \NC \NR
810 \NC file \NC string \NC the target filename \NC \NR
811 \NC new_window \NC number \NC the window state of the target \NC \NR
812 \NC data \NC string \NC the name of the destination \NC \NR
813 \stoptabulate
815 Valid action types are:
817 \starttabulate[|lT|lT|]
818 \NC 0 \NC page \NC \NR
819 \NC 1 \NC goto \NC \NR
820 \NC 2 \NC thread \NC \NR
821 \NC 3 \NC user \NC \NR
822 \stoptabulate
824 Valid window types are:
826 \starttabulate[|lT|lT|]
827 \NC 0 \NC notset \NC \NR
828 \NC 1 \NC new \NC \NR
829 \NC 2 \NC nonew \NC \NR
830 \stoptabulate
832 \subsubsubsection{pdf_thread whatsits}
834 \starttabulate[|lT|l|p|]
835 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
836 \NC attr \NC node \NC list of attributes \NC \NR
837 \NC width \NC number \NC the width (not used in calculations) \NC \NR
838 \NC height \NC number \NC the height (not used in calculations) \NC \NR
839 \NC depth \NC number \NC the depth (not used in calculations) \NC \NR
840 \NC named_id \NC number \NC is \type {tread_id} a string value? \NC \NR
841 \NC tread_id \NC number \NC the thread id \NC \NR
842 \NC \NC string \NC the thread name \NC \NR
843 \NC thread_attr \NC number \NC extra thread information \NC \NR
844 \stoptabulate
846 \subsubsubsection{pdf_start_thread whatsits}
848 \starttabulate[|lT|l|p|]
849 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
850 \NC attr \NC node \NC list of attributes \NC \NR
851 \NC width \NC number \NC the width (not used in calculations) \NC \NR
852 \NC height \NC number \NC the height (not used in calculations) \NC \NR
853 \NC depth \NC number \NC the depth (not used in calculations) \NC \NR
854 \NC named_id \NC number \NC is \type {tread_id} a string value? \NC \NR
855 \NC tread_id \NC number \NC the thread id \NC \NR
856 \NC \NC string \NC the thread name \NC \NR
857 \NC thread_attr \NC number \NC extra thread information \NC \NR
858 \stoptabulate
860 \subsubsubsection{pdf_end_thread whatsits}
862 \starttabulate[|lT|l|p|]
863 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
864 \NC attr \NC node \NC \NC \NR
865 \stoptabulate
867 \subsubsubsection{pdf_colorstack whatsits}
869 \starttabulate[|lT|l|p|]
870 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
871 \NC attr \NC node \NC list of attributes \NC \NR
872 \NC stack \NC number \NC colorstack id number \NC \NR
873 \NC command \NC number \NC command to execute \NC \NR
874 \NC data \NC string \NC data \NC \NR
875 \stoptabulate
877 \subsubsubsection{pdf_setmatrix whatsits}
879 \starttabulate[|lT|l|p|]
880 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
881 \NC attr \NC node \NC list of attributes \NC \NR
882 \NC data \NC string \NC data \NC \NR
883 \stoptabulate
885 \subsubsubsection{pdf_save whatsits}
887 \starttabulate[|lT|l|p|]
888 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
889 \NC attr \NC node \NC list of attributes \NC \NR
890 \stoptabulate
892 \subsubsubsection{pdf_restore whatsits}
894 \starttabulate[|lT|l|p|]
895 \NC \rmbf field \NC \bf type \NC \bf explanation \NC \NR
896 \NC attr \NC node \NC list of attributes \NC \NR
897 \stoptabulate
899 \section{The \type {node} library}
901 The \type {node} library contains functions that facilitate dealing with (lists
902 of) nodes and their values. They allow you to create, alter, copy, delete, and
903 insert \LUATEX\ node objects, the core objects within the typesetter.
905 \LUATEX\ nodes are represented in \LUA\ as userdata with the metadata type
906 \type {luatex.node}. The various parts within a node can be accessed using
907 named fields.
909 Each node has at least the three fields \type {next}, \type {id}, and \type
910 {subtype}:
912 \startitemize[intro]
914 \startitem
915 The \type {next} field returns the userdata object for the next node in a
916 linked list of nodes, or \type {nil}, if there is no next node.
917 \stopitem
919 \startitem
920 The \type {id} indicates \TEX's \quote{node type}. The field \type {id} has a
921 numeric value for efficiency reasons, but some of the library functions also
922 accept a string value instead of \type {id}.
923 \stopitem
925 \startitem
926 The \type {subtype} is another number. It often gives further information
927 about a node of a particular \type {id}, but it is most important when
928 dealing with \quote {whatsits}, because they are differentiated solely based
929 on their \type {subtype}.
930 \stopitem
932 \stopitemize
934 The other available fields depend on the \type {id} (and for \quote {whatsits},
935 the \type {subtype}) of the node. Further details on the various fields and their
936 meanings are given in~\in{chapter}[nodes].
938 Support for \type {unset} (alignment) nodes is partial: they can be queried and
939 modified from \LUA\ code, but not created.
941 Nodes can be compared to each other, but: you are actually comparing indices into
942 the node memory. This means that equality tests can only be trusted under very
943 limited conditions. It will not work correctly in any situation where one of the
944 two nodes has been freed and|/|or reallocated: in that case, there will be false
945 positives.
947 At the moment, memory management of nodes should still be done explicitly by the
948 user. Nodes are not \quote {seen} by the \LUA\ garbage collector, so you have to
949 call the node freeing functions yourself when you are no longer in need of a node
950 (list). Nodes form linked lists without reference counting, so you have to be
951 careful that when control returns back to \LUATEX\ itself, you have not deleted
952 nodes that are still referenced from a \type {next} pointer elsewhere, and that
953 you did not create nodes that are referenced more than once.
955 There are statistics available with regards to the allocated node memory, which
956 can be handy for tracing.
958 \subsection{Node handling functions}
960 \subsubsection{\type {node.is_node}}
962 \startfunctioncall
963 <boolean> t =
964 node.is_node(<any> item)
965 \stopfunctioncall
967 This function returns true if the argument is a userdata object of
968 type \type {<node>}.
970 \subsubsection{\type {node.types}}
972 \startfunctioncall
973 <table> t =
974 node.types()
975 \stopfunctioncall
977 This function returns an array that maps node id numbers to node type strings,
978 providing an overview of the possible top|-|level \type {id} types.
980 \subsubsection{\type {node.whatsits}}
982 \startfunctioncall
983 <table> t =
984 node.whatsits()
985 \stopfunctioncall
987 \TEX's \quote{whatsits} all have the same \type {id}. The various subtypes are
988 defined by their \type {subtype} fields. The function is much like \type
989 {node.types}, except that it provides an array of \type {subtype} mappings.
991 \subsubsection{\type {node.id}}
993 \startfunctioncall
994 <number> id =
995 node.id(<string> type)
996 \stopfunctioncall
998 This converts a single type name to its internal numeric representation.
1000 \subsubsection{\type {node.subtype}}
1002 \startfunctioncall
1003 <number> subtype =
1004 node.subtype(<string> type)
1005 \stopfunctioncall
1007 This converts a single whatsit name to its internal numeric representation (\type
1008 {subtype}).
1010 \subsubsection{\type {node.type}}
1012 \startfunctioncall
1013 <string> type =
1014 node.type(<any> n)
1015 \stopfunctioncall
1017 In the argument is a number, then this function converts an internal numeric
1018 representation to an external string representation. Otherwise, it will return
1019 the string \type {node} if the object represents a node, and \type {nil}
1020 otherwise.
1022 \subsubsection{\type {node.fields}}
1024 \startfunctioncall
1025 <table> t =
1026 node.fields(<number> id)
1027 <table> t =
1028 node.fields(<number> id, <number> subtype)
1029 \stopfunctioncall
1031 This function returns an array of valid field names for a particular type of
1032 node. If you want to get the valid fields for a \quote {whatsit}, you have to
1033 supply the second argument also. In other cases, any given second argument will
1034 be silently ignored.
1036 This function accepts string \type {id} and \type {subtype} values as well.
1038 \subsubsection{\type {node.has_field}}
1040 \startfunctioncall
1041 <boolean> t =
1042 node.has_field(<node> n, <string> field)
1043 \stopfunctioncall
1045 This function returns a boolean that is only true if \type {n} is
1046 actually a node, and it has the field.
1048 \subsubsection{\type {node.new}}
1050 \startfunctioncall
1051 <node> n =
1052 node.new(<number> id)
1053 <node> n =
1054 node.new(<number> id, <number> subtype)
1055 \stopfunctioncall
1057 Creates a new node. All of the new node's fields are initialized to either zero
1058 or \type {nil} except for \type {id} and \type {subtype} (if supplied). If you
1059 want to create a new whatsit, then the second argument is required, otherwise it
1060 need not be present. As with all node functions, this function creates a node on
1061 the \TEX\ level.
1063 This function accepts string \type {id} and \type {subtype} values as well.
1065 \subsubsection{\type {node.free} and \type {node.flush_node}}
1067 \startfunctioncall
1068 <node> next =
1069 node.free(<node> n)
1070 flush_node(<node> n)
1071 \stopfunctioncall
1073 Removes the node \type {n} from \TEX's memory. Be careful: no checks are done on
1074 whether this node is still pointed to from a register or some \type {next} field:
1075 it is up to you to make sure that the internal data structures remain correct.
1077 The \type {free} function returns the next field of the freed node, while the
1078 \type {flush_node} alternative returns nothing.
1080 \subsubsection{\type {node.flush_list}}
1082 \startfunctioncall
1083 node.flush_list(<node> n)
1084 \stopfunctioncall
1086 Removes the node list \type {n} and the complete node list following \type {n}
1087 from \TEX's memory. Be careful: no checks are done on whether any of these nodes
1088 is still pointed to from a register or some \type {next} field: it is up to you
1089 to make sure that the internal data structures remain correct.
1091 \subsubsection{\type {node.copy}}
1093 \startfunctioncall
1094 <node> m =
1095 node.copy(<node> n)
1096 \stopfunctioncall
1098 Creates a deep copy of node \type {n}, including all nested lists as in the case
1099 of a hlist or vlist node. Only the \type {next} field is not copied.
1101 \subsubsection{\type {node.copy_list}}
1103 \startfunctioncall
1104 <node> m =
1105 node.copy_list(<node> n)
1106 <node> m =
1107 node.copy_list(<node> n, <node> m)
1108 \stopfunctioncall
1110 Creates a deep copy of the node list that starts at \type {n}. If \type {m} is
1111 also given, the copy stops just before node \type {m}.
1113 Note that you cannot copy attribute lists this way, specialized functions for
1114 dealing with attribute lists will be provided later but are not there yet.
1115 However, there is normally no need to copy attribute lists as when you do
1116 assignments to the \type {attr} field or make changes to specific attributes, the
1117 needed copying and freeing takes place automatically.
1119 \subsubsection{\type {node.next}}
1121 \startfunctioncall
1122 <node> m =
1123 node.next(<node> n)
1124 \stopfunctioncall
1126 Returns the node following this node, or \type {nil} if there is no such node.
1128 \subsubsection{\type {node.prev}}
1130 \startfunctioncall
1131 <node> m =
1132 node.prev(<node> n)
1133 \stopfunctioncall
1135 Returns the node preceding this node, or \type {nil} if there is no such node.
1137 \subsubsection{\type {node.current_attr}}
1139 \startfunctioncall
1140 <node> m =
1141 node.current_attr()
1142 \stopfunctioncall
1144 Returns the currently active list of attributes, if there is one.
1146 The intended usage of \type {current_attr} is as follows:
1148 \starttyping
1149 local x1 = node.new("glyph")
1150 x1.attr = node.current_attr()
1151 local x2 = node.new("glyph")
1152 x2.attr = node.current_attr()
1153 \stoptyping
1157 \starttyping
1158 local x1 = node.new("glyph")
1159 local x2 = node.new("glyph")
1160 local ca = node.current_attr()
1161 x1.attr = ca
1162 x2.attr = ca
1163 \stoptyping
1165 The attribute lists are ref counted and the assignment takes care of incrementing
1166 the refcount. You cannot expect the value \type {ca} to be valid any more when
1167 you assign attributes (using \type {tex.setattribute}) or when control has been
1168 passed back to \TEX.
1170 Note: this function is somewhat experimental, and it returns the {\it actual}
1171 attribute list, not a copy thereof. Therefore, changing any of the attributes in
1172 the list will change these values for all nodes that have the current attribute
1173 list assigned to them.
1175 \subsubsection{\type {node.hpack}}
1177 \startfunctioncall
1178 <node> h, <number> b =
1179 node.hpack(<node> n)
1180 <node> h, <number> b =
1181 node.hpack(<node> n, <number> w, <string> info)
1182 <node> h, <number> b =
1183 node.hpack(<node> n, <number> w, <string> info, <string> dir)
1184 \stopfunctioncall
1186 This function creates a new hlist by packaging the list that begins at node \type
1187 {n} into a horizontal box. With only a single argument, this box is created using
1188 the natural width of its components. In the three argument form, \type {info}
1189 must be either \type {additional} or \type {exactly}, and \type {w} is the
1190 additional (\type {\hbox spread}) or exact (\type {\hbox to}) width to be used. The
1191 second return value is the badness of the generated box.
1193 Caveat: at this moment, there can be unexpected side|-|effects to this function,
1194 like updating some of the \type {\marks} and \type {\inserts}. Also note that the
1195 content of \type {h} is the original node list \type {n}: if you call \type
1196 {node.free(h)} you will also free the node list itself, unless you explicitly set
1197 the \type {list} field to \type {nil} beforehand. And in a similar way, calling
1198 \type {node.free(n)} will invalidate \type {h} as well!
1200 \subsubsection{\type {node.vpack}}
1202 \startfunctioncall
1203 <node> h, <number> b =
1204 node.vpack(<node> n)
1205 <node> h, <number> b =
1206 node.vpack(<node> n, <number> w, <string> info)
1207 <node> h, <number> b =
1208 node.vpack(<node> n, <number> w, <string> info, <string> dir)
1209 \stopfunctioncall
1211 This function creates a new vlist by packaging the list that begins at node \type
1212 {n} into a vertical box. With only a single argument, this box is created using
1213 the natural height of its components. In the three argument form, \type {info}
1214 must be either \type {additional} or \type {exactly}, and \type {w} is the
1215 additional (\type {\vbox spread}) or exact (\type {\vbox to}) height to be used.
1217 The second return value is the badness of the generated box.
1219 See the description of \type {node.hpack()} for a few memory allocation caveats.
1221 \subsubsection{\type {node.dimensions}, \type {node.rangedimensions}}
1223 \startfunctioncall
1224 <number> w, <number> h, <number> d =
1225 node.dimensions(<node> n)
1226 <number> w, <number> h, <number> d =
1227 node.dimensions(<node> n, <string> dir)
1228 <number> w, <number> h, <number> d =
1229 node.dimensions(<node> n, <node> t)
1230 <number> w, <number> h, <number> d =
1231 node.dimensions(<node> n, <node> t, <string> dir)
1232 \stopfunctioncall
1234 This function calculates the natural in|-|line dimensions of the node list starting
1235 at node \type {n} and terminating just before node \type {t} (or the end of the
1236 list, if there is no second argument). The return values are scaled points. An
1237 alternative format that starts with glue parameters as the first three arguments
1238 is also possible:
1240 \startfunctioncall
1241 <number> w, <number> h, <number> d =
1242 node.dimensions(<number> glue_set, <number> glue_sign, <number> glue_order,
1243 <node> n)
1244 <number> w, <number> h, <number> d =
1245 node.dimensions(<number> glue_set, <number> glue_sign, <number> glue_order,
1246 <node> n, <string> dir)
1247 <number> w, <number> h, <number> d =
1248 node.dimensions(<number> glue_set, <number> glue_sign, <number> glue_order,
1249 <node> n, <node> t)
1250 <number> w, <number> h, <number> d =
1251 node.dimensions(<number> glue_set, <number> glue_sign, <number> glue_order,
1252 <node> n, <node> t, <string> dir)
1253 \stopfunctioncall
1255 This calling method takes glue settings into account and is especially useful for
1256 finding the actual width of a sublist of nodes that are already boxed, for
1257 example in code like this, which prints the width of the space in between the
1258 \type {a} and \type {b} as it would be if \type {\box0} was used as-is:
1260 \starttyping
1261 \setbox0 = \hbox to 20pt {a b}
1263 \directlua{print (node.dimensions(
1264 tex.box[0].glue_set,
1265 tex.box[0].glue_sign,
1266 tex.box[0].glue_order,
1267 tex.box[0].head.next,
1268 node.tail(tex.box[0].head)
1269 )) }
1270 \stoptyping
1272 You need to keep in mind that this is one of the few places in \TEX\ where floats
1273 are used, which means that you can get small differences in rounding when you
1274 compare the width reported by \type {hpack} with \type {dimensions}.
1276 The second alternative saves a few lookups and can be more convenient in some
1277 cases:
1279 \startfunctioncall
1280 <number> w, <number> h, <number> d =
1281 node.rangedimensions(<node> parent, <node> first)
1282 <number> w, <number> h, <number> d =
1283 node.rangedimensions(<node> parent, <node> first, <node> last)
1284 \stopfunctioncall
1286 \subsubsection{\type {node.mlist_to_hlist}}
1288 \startfunctioncall
1289 <node> h =
1290 node.mlist_to_hlist(<node> n, <string> display_type, <boolean> penalties)
1291 \stopfunctioncall
1293 This runs the internal mlist to hlist conversion, converting the math list in
1294 \type {n} into the horizontal list \type {h}. The interface is exactly the same
1295 as for the callback \type {mlist_to_hlist}.
1297 \subsubsection{\type {node.slide}}
1299 \startfunctioncall
1300 <node> m =
1301 node.slide(<node> n)
1302 \stopfunctioncall
1304 Returns the last node of the node list that starts at \type {n}. As a
1305 side|-|effect, it also creates a reverse chain of \type {prev} pointers between
1306 nodes.
1308 \subsubsection{\type {node.tail}}
1310 \startfunctioncall
1311 <node> m =
1312 node.tail(<node> n)
1313 \stopfunctioncall
1315 Returns the last node of the node list that starts at \type {n}.
1317 \subsubsection{\type {node.length}}
1319 \startfunctioncall
1320 <number> i =
1321 node.length(<node> n)
1322 <number> i =
1323 node.length(<node> n, <node> m)
1324 \stopfunctioncall
1326 Returns the number of nodes contained in the node list that starts at \type {n}.
1327 If \type {m} is also supplied it stops at \type {m} instead of at the end of the
1328 list. The node \type {m} is not counted.
1330 \subsubsection{\type {node.count}}
1332 \startfunctioncall
1333 <number> i =
1334 node.count(<number> id, <node> n)
1335 <number> i =
1336 node.count(<number> id, <node> n, <node> m)
1337 \stopfunctioncall
1339 Returns the number of nodes contained in the node list that starts at \type {n}
1340 that have a matching \type {id} field. If \type {m} is also supplied, counting
1341 stops at \type {m} instead of at the end of the list. The node \type {m} is not
1342 counted.
1344 This function also accept string \type {id}'s.
1346 \subsubsection{\type {node.traverse}}
1348 \startfunctioncall
1349 <node> t =
1350 node.traverse(<node> n)
1351 \stopfunctioncall
1353 This is a \LUA\ iterator that loops over the node list that starts at \type {n}.
1354 Typically code looks like this:
1356 \starttyping
1357 for n in node.traverse(head) do
1360 \stoptyping
1362 is functionally equivalent to:
1364 \starttyping
1366 local n
1367 local function f (head,var)
1368 local t
1369 if var == nil then
1370 t = head
1371 else
1372 t = var.next
1374 return t
1376 while true do
1377 n = f (head, n)
1378 if n == nil then break end
1382 \stoptyping
1384 It should be clear from the definition of the function \type {f} that even though
1385 it is possible to add or remove nodes from the node list while traversing, you
1386 have to take great care to make sure all the \type {next} (and \type {prev})
1387 pointers remain valid.
1389 If the above is unclear to you, see the section \quote {For Statement} in the
1390 \LUA\ Reference Manual.
1392 \subsubsection{\type {node.traverse_id}}
1394 \startfunctioncall
1395 <node> t =
1396 node.traverse_id(<number> id, <node> n)
1397 \stopfunctioncall
1399 This is an iterator that loops over all the nodes in the list that starts at
1400 \type {n} that have a matching \type {id} field.
1402 See the previous section for details. The change is in the local function \type
1403 {f}, which now does an extra while loop checking against the upvalue \type {id}:
1405 \starttyping
1406 local function f(head,var)
1407 local t
1408 if var == nil then
1409 t = head
1410 else
1411 t = var.next
1413 while not t.id == id do
1414 t = t.next
1416 return t
1418 \stoptyping
1420 \subsubsection{\type {node.traverse_char}}
1422 This iterators loops over the glyph nodes in a list. Only nodes with a subtype
1423 less than 256 are seen.
1425 \startfunctioncall
1426 <node> n =
1427 node.traverse_char(<node> n)
1428 \stopfunctioncall
1430 \subsubsection{\type {node.has_glyph}}
1432 This function returns the first glyph or disc node in the given list:
1434 \startfunctioncall
1435 <node> n =
1436 node.has_glyph(<node> n)
1437 \stopfunctioncall
1439 \subsubsection{\type {node.end_of_math}}
1441 \startfunctioncall
1442 <node> t =
1443 node.end_of_math(<node> start)
1444 \stopfunctioncall
1446 Looks for and returns the next \type {math_node} following the \type {start}. If
1447 the given node is a math endnode this helper return that node, else it follows
1448 the list and return the next math endnote. If no such node is found nil is
1449 returned.
1451 \subsubsection{\type {node.remove}}
1453 \startfunctioncall
1454 <node> head, current =
1455 node.remove(<node> head, <node> current)
1456 \stopfunctioncall
1458 This function removes the node \type {current} from the list following \type
1459 {head}. It is your responsibility to make sure it is really part of that list.
1460 The return values are the new \type {head} and \type {current} nodes. The
1461 returned \type {current} is the node following the \type {current} in the calling
1462 argument, and is only passed back as a convenience (or \type {nil}, if there is
1463 no such node). The returned \type {head} is more important, because if the
1464 function is called with \type {current} equal to \type {head}, it will be
1465 changed.
1467 \subsubsection{\type {node.insert_before}}
1469 \startfunctioncall
1470 <node> head, new =
1471 node.insert_before(<node> head, <node> current, <node> new)
1472 \stopfunctioncall
1474 This function inserts the node \type {new} before \type {current} into the list
1475 following \type {head}. It is your responsibility to make sure that \type
1476 {current} is really part of that list. The return values are the (potentially
1477 mutated) \type {head} and the node \type {new}, set up to be part of the list
1478 (with correct \type {next} field). If \type {head} is initially \type {nil}, it
1479 will become \type {new}.
1481 \subsubsection{\type {node.insert_after}}
1483 \startfunctioncall
1484 <node> head, new =
1485 node.insert_after(<node> head, <node> current, <node> new)
1486 \stopfunctioncall
1488 This function inserts the node \type {new} after \type {current} into the list
1489 following \type {head}. It is your responsibility to make sure that \type
1490 {current} is really part of that list. The return values are the \type {head} and
1491 the node \type {new}, set up to be part of the list (with correct \type {next}
1492 field). If \type {head} is initially \type {nil}, it will become \type {new}.
1494 \subsubsection{\type {node.first_glyph}}
1496 \startfunctioncall
1497 <node> n =
1498 node.first_glyph(<node> n)
1499 <node> n =
1500 node.first_glyph(<node> n, <node> m)
1501 \stopfunctioncall
1503 Returns the first node in the list starting at \type {n} that is a glyph node
1504 with a subtype indicating it is a glyph, or \type {nil}. If \type {m} is given,
1505 processing stops at (but including) that node, otherwise processing stops at the
1506 end of the list.
1508 \subsubsection{\type {node.ligaturing}}
1510 \startfunctioncall
1511 <node> h, <node> t, <boolean> success =
1512 node.ligaturing(<node> n)
1513 <node> h, <node> t, <boolean> success =
1514 node.ligaturing(<node> n, <node> m)
1515 \stopfunctioncall
1517 Apply \TEX-style ligaturing to the specified nodelist. The tail node \type {m} is
1518 optional. The two returned nodes \type {h} and \type {t} are the new head and
1519 tail (both \type {n} and \type {m} can change into a new ligature).
1521 \subsubsection{\type {node.kerning}}
1523 \startfunctioncall
1524 <node> h, <node> t, <boolean> success =
1525 node.kerning(<node> n)
1526 <node> h, <node> t, <boolean> success =
1527 node.kerning(<node> n, <node> m)
1528 \stopfunctioncall
1530 Apply \TEX|-|style kerning to the specified node list. The tail node \type {m} is
1531 optional. The two returned nodes \type {h} and \type {t} are the head and tail
1532 (either one of these can be an inserted kern node, because special kernings with
1533 word boundaries are possible).
1535 \subsubsection{\type {node.unprotect_glyphs}}
1537 \startfunctioncall
1538 node.unprotect_glyphs(<node> n)
1539 \stopfunctioncall
1541 Subtracts 256 from all glyph node subtypes. This and the next function are
1542 helpers to convert from \type {characters} to \type {glyphs} during node
1543 processing.
1545 \subsubsection{\type {node.protect_glyphs} and \type {node.protect_glyph}}
1547 \startfunctioncall
1548 node.protect_glyphs(<node> n)
1549 \stopfunctioncall
1551 Adds 256 to all glyph node subtypes in the node list starting at \type {n},
1552 except that if the value is 1, it adds only 255. The special handling of 1 means
1553 that \type {characters} will become \type {glyphs} after subtraction of 256. A
1554 single character can be marked by the singular call.
1556 \subsubsection{\type {node.last_node}}
1558 \startfunctioncall
1559 <node> n =
1560 node.last_node()
1561 \stopfunctioncall
1563 This function pops the last node from \TEX's \quote{current list}. It returns
1564 that node, or \type {nil} if the current list is empty.
1566 \subsubsection{\type {node.write}}
1568 \startfunctioncall
1569 node.write(<node> n)
1570 \stopfunctioncall
1572 This is an experimental function that will append a node list to \TEX's \quote
1573 {current list} The node list is not deep|-|copied! There is no error checking
1574 either!
1576 \subsubsection{\type {node.protrusion_skippable}}
1578 \startfunctioncall
1579 <boolean> skippable =
1580 node.protrusion_skippable(<node> n)
1581 \stopfunctioncall
1583 Returns \type {true} if, for the purpose of line boundary discovery when
1584 character protrusion is active, this node can be skipped.
1586 \subsection{Glue handling}
1588 \subsubsection{\type {node.setglue}}
1590 You can set the properties of a glue in one go. If you pass no values, the glue
1591 will become a zero glue.
1593 \startfunctioncall
1594 node.setglue(<node> n)
1595 node.setglue(<node> n,width,stretch,shrink,stretch_order,shrink_order)
1596 \stopfunctioncall
1598 When you pass values, only arguments that are numbers
1599 are assigned so
1601 \starttyping
1602 node.setglue(n,655360,false,65536)
1603 \stoptyping
1605 will only adapt the width and shrink.
1607 \subsubsection{\type {node.getglue}}
1609 The next call will return 5 values (or northing when no glue is passed).
1611 \startfunctioncall
1612 <integer> width, <integer> stretch, <integer> shrink, <integer> stretch_order,
1613 <integer> shrink_order = node.getglue(<node> n)
1614 \stopfunctioncall
1616 \subsubsection{\type {node.is_zero_glue}}
1618 This function returns \type {true} when the width, stretch and shrink properties
1619 are zero.
1621 \startfunctioncall
1622 <boolean> isglue =
1623 node.is_zero_glue(<node> n)
1624 \stopfunctioncall
1626 \subsection{Attribute handling}
1628 Attributes appear as linked list of userdata objects in the \type {attr} field of
1629 individual nodes. They can be handled individually, but it is much safer and more
1630 efficient to use the dedicated functions associated with them.
1632 \subsubsection{\type {node.has_attribute}}
1634 \startfunctioncall
1635 <number> v =
1636 node.has_attribute(<node> n, <number> id)
1637 <number> v =
1638 node.has_attribute(<node> n, <number> id, <number> val)
1639 \stopfunctioncall
1641 Tests if a node has the attribute with number \type {id} set. If \type {val} is
1642 also supplied, also tests if the value matches \type {val}. It returns the value,
1643 or, if no match is found, \type {nil}.
1645 \subsubsection{\type {node.get_attribute}}
1647 \startfunctioncall
1648 <number> v =
1649 node.get_attribute(<node> n, <number> id)
1650 \stopfunctioncall
1652 Tests if a node has an attribute with number \type {id} set. It returns the
1653 value, or, if no match is found, \type {nil}.
1655 \subsubsection{\type {node.find_attribute}}
1657 \startfunctioncall
1658 <number> v, <node> n =
1659 node.find_attribute(<node> n, <number> id)
1660 \stopfunctioncall
1662 Finds the first node that has attribute with number \type {id} set. It returns
1663 the value and the node if there is a match and otherwise nothing.
1665 \subsubsection{\type {node.set_attribute}}
1667 \startfunctioncall
1668 node.set_attribute(<node> n, <number> id, <number> val)
1669 \stopfunctioncall
1671 Sets the attribute with number \type {id} to the value \type {val}. Duplicate
1672 assignments are ignored. {\em [needs explanation]}
1674 \subsubsection{\type {node.unset_attribute}}
1676 \startfunctioncall
1677 <number> v =
1678 node.unset_attribute(<node> n, <number> id)
1679 <number> v =
1680 node.unset_attribute(<node> n, <number> id, <number> val)
1681 \stopfunctioncall
1683 Unsets the attribute with number \type {id}. If \type {val} is also supplied, it
1684 will only perform this operation if the value matches \type {val}. Missing
1685 attributes or attribute|-|value pairs are ignored.
1687 If the attribute was actually deleted, returns its old value. Otherwise, returns
1688 \type {nil}.
1690 \subsubsection{\type {node.slide}}
1692 This helper makes sure that the node lists is double linked and returns the found
1693 tail node.
1695 \startfunctioncall
1696 <node> tail =
1697 node.slide(<node> n)
1698 \stopfunctioncall
1700 \subsubsection{\type {node.check_discretionary} and \type {node.check_discretionaries}}
1702 When you fool around with disc nodes you need to be aware of the fact that they
1703 have a special internal data structure. As long as you reassign the fields when
1704 you have extended the lists it's ok because then the tail pointers get updated,
1705 but when you add to list without reassigning you might end up in troubles when
1706 the linebreak routien kicks in. You can call this function to check the list for
1707 issues with disc nodes.
1709 \startfunctioncall
1710 node.check_discretionary(<node> n)
1711 node.check_discretionaries(<node> head)
1712 \stopfunctioncall
1714 The plural variant runs over all disc nodes in a list, the singular variant
1715 checks one node only (it also checks if the node is a disc node).
1717 \subsubsection{\type {node.family_font}}
1719 When you pass it a proper family identifier the next helper will return the font
1720 currently associated with it. You can normally also access the font with the normal
1721 font field or getter because it will resolve the family automatically for noads.
1723 \startfunctioncall
1724 <integer> id =
1725 node.family_font(<integer> fam)
1726 \stopfunctioncall
1728 \section{Two access models}
1730 Deep down in \TEX\ a node has a number which is an numeric entry in a memory
1731 table. In fact, this model, where \TEX\ manages memory is real fast and one of
1732 the reasons why plugging in callbacks that operate on nodes is quite fast too.
1733 Each node gets a number that is in fact an index in the memory table and that
1734 number often gets reported when you print node related information.
1736 There are two access models, a robust one using a so called user data object that
1737 provides a virtual interface to the internal nodes, and a more direct access which
1738 uses the node numbers directly. The first model provide key based access while
1739 the second always accesses fields via functions:
1741 \starttyping
1742 nodeobject.char
1743 getfield(nodenumber,"char")
1744 \stoptyping
1746 If you use the direct model, even if you know that you deal with numbers, you
1747 should not depend on that property but treat it an abstraction just like
1748 traditional nodes. In fact, the fact that we use a simple basic datatype has the
1749 penalty that less checking can be done, but less checking is also the reason why
1750 it's somewhat faster. An important aspect is that one cannot mix both methods,
1751 but you can cast both models. So, multiplying a node number makes no sense.
1753 So our advice is: use the indexed (table) approach when possible and investigate
1754 the direct one when speed might be an real issue. For that reason we also provide
1755 the \type {get*} and \type {set*} functions in the top level node namespace.
1756 There is a limited set of getters. When implementing this direct approach the
1757 regular index by key variant was also optimized, so direct access only makes
1758 sense when we're accessing nodes millions of times (which happens in some font
1759 processing for instance).
1761 We're talking mostly of getters because setters are less important. Documents
1762 have not that many content related nodes and setting many thousands of properties
1763 is hardly a burden contrary to millions of consultations.
1765 Normally you will access nodes like this:
1767 \starttyping
1768 local next = current.next
1769 if next then
1770 -- do something
1772 \stoptyping
1774 Here \type {next} is not a real field, but a virtual one. Accessing it results in
1775 a metatable method being called. In practice it boils down to looking up the node
1776 type and based on the node type checking for the field name. In a worst case you
1777 have a node type that sits at the end of the lookup list and a field that is last
1778 in the lookup chain. However, in successive versions of \LUATEX\ these lookups
1779 have been optimized and the most frequently accessed nodes and fields have a
1780 higher priority.
1782 Because in practice the \type {next} accessor results in a function call, there
1783 is some overhead involved. The next code does the same and performs a tiny bit
1784 faster (but not that much because it is still a function call but one that knows
1785 what to look up).
1787 \starttyping
1788 local next = node.next(current)
1789 if next then
1790 -- do something
1792 \stoptyping
1794 If performance matters you can use an function instead:
1796 \starttabulate[|T|p|]
1797 \NC getnext \NC parsing nodelist always involves this one \NC \NR
1798 \NC getprev \NC used less but is logical companion to \type {getnext} \NC \NR
1799 \NC getboth \NC returns the next and prev pointer of a node \NC \NR
1800 \NC getid \NC consulted a lot \NC \NR
1801 \NC getsubtype \NC consulted less but also a topper \NC \NR
1802 \NC getfont \NC used a lot in \OPENTYPE\ handling (glyph nodes are consulted a lot) \NC \NR
1803 \NC getchar \NC idem and also in other places \NC \NR
1804 \NC getdisc \NC returns the \type {pre}, \type {post} and \type {replace} fields and
1805 optionally when true is passed also the tail fields. \NC \NR
1806 \NC getlist \NC we often parse nested lists so this is a convenient one too
1807 (only works for hlist and vlist!) \NC \NR
1808 \NC getleader \NC comparable to list, seldom used in \TEX\ (but needs frequent consulting
1809 like lists; leaders could have been made a dedicated node type) \NC \NR
1810 \NC getfield \NC generic getter, sufficient for the rest (other field names are
1811 often shared so a specific getter makes no sense then) \NC \NR
1812 \NC getbox \NC gets the given box (a list node) \NC \NR
1813 \stoptabulate
1815 The direct variants also have setters, where the discretionary setter takes three
1816 (optional) arguments plus an optional fourth indicating the subtype. An additional
1817 setter is \type {setlink} which will link two nodes.
1819 It doesn't make sense to add getters for all fields, also because some are not
1820 unique to one node type. Profiling demonstrated that these fields can get
1821 accesses way more times than other fields. Even in complex documents, many node
1822 and fields types never get seen, or seen only a few times. Most functions in the
1823 \type {node} namespace have a companion in \type {node.direct}, but of course not
1824 the ones that don't deal with nodes themselves. The following table summarized
1825 this:
1827 % \startcolumns[balance=yes]
1829 \def\yes{$+$} \def\nop{$-$}
1831 \starttabulate[|T|c|c|]
1833 \NC \bf function \NC \bf node \NC \bf direct \NC \NR
1835 \NC \type {check_discretionaries}\NC \yes \NC \yes \NC \NR
1836 \NC \type {copy_list} \NC \yes \NC \yes \NC \NR
1837 \NC \type {copy} \NC \yes \NC \yes \NC \NR
1838 \NC \type {count} \NC \yes \NC \yes \NC \NR
1839 \NC \type {current_attr} \NC \yes \NC \yes \NC \NR
1840 \NC \type {dimensions} \NC \yes \NC \yes \NC \NR
1841 \NC \type {rangedimensions} \NC \yes \NC \yes \NC \NR
1842 %NC \type {do_ligature_n} \NC \yes \NC \yes \NC \NR % was never documented and experimental
1843 \NC \type {effective_glue} \NC \yes \NC \yes \NC \NR
1844 \NC \type {end_of_math} \NC \yes \NC \yes \NC \NR
1845 \NC \type {family_font} \NC \yes \NC \nop \NC \NR
1846 \NC \type {fields} \NC \yes \NC \nop \NC \NR
1847 \NC \type {find_attribute} \NC \yes \NC \yes \NC \NR
1848 \NC \type {first_glyph} \NC \yes \NC \yes \NC \NR
1849 \NC \type {flush_list} \NC \yes \NC \yes \NC \NR
1850 \NC \type {flush_node} \NC \yes \NC \yes \NC \NR
1851 \NC \type {free} \NC \yes \NC \yes \NC \NR
1852 \NC \type {get_attribute} \NC \yes \NC \yes \NC \NR
1853 \NC \type {getboth} \NC \yes \NC \yes \NC \NR
1854 \NC \type {getbox} \NC \nop \NC \yes \NC \NR
1855 \NC \type {getchar} \NC \yes \NC \yes \NC \NR
1856 \NC \type {getdisc} \NC \yes \NC \yes \NC \NR
1857 \NC \type {getfield} \NC \yes \NC \yes \NC \NR
1858 \NC \type {getfont} \NC \yes \NC \yes \NC \NR
1859 \NC \type {getglue} \NC \yes \NC \yes \NC \NR
1860 \NC \type {getid} \NC \yes \NC \yes \NC \NR
1861 \NC \type {getleader} \NC \yes \NC \yes \NC \NR
1862 \NC \type {getlist} \NC \yes \NC \yes \NC \NR
1863 \NC \type {getnext} \NC \yes \NC \yes \NC \NR
1864 \NC \type {getprev} \NC \yes \NC \yes \NC \NR
1865 \NC \type {getsubtype} \NC \yes \NC \yes \NC \NR
1866 \NC \type {has_attribute} \NC \yes \NC \yes \NC \NR
1867 \NC \type {has_field} \NC \yes \NC \yes \NC \NR
1868 \NC \type {has_glyph} \NC \yes \NC \yes \NC \NR
1869 \NC \type {hpack} \NC \yes \NC \yes \NC \NR
1870 \NC \type {id} \NC \yes \NC \nop \NC \NR
1871 \NC \type {insert_after} \NC \yes \NC \yes \NC \NR
1872 \NC \type {insert_before} \NC \yes \NC \yes \NC \NR
1873 \NC \type {is_char} \NC \yes \NC \yes \NC \NR
1874 \NC \type {is_direct} \NC \nop \NC \yes \NC \NR
1875 \NC \type {is_glue_zero} \NC \yes \NC \yes \NC \NR
1876 \NC \type {is_glyph} \NC \yes \NC \yes \NC \NR
1877 \NC \type {is_node} \NC \yes \NC \yes \NC \NR
1878 \NC \type {kerning} \NC \yes \NC \yes \NC \NR
1879 \NC \type {last_node} \NC \yes \NC \yes \NC \NR
1880 \NC \type {length} \NC \yes \NC \yes \NC \NR
1881 \NC \type {ligaturing} \NC \yes \NC \yes \NC \NR
1882 \NC \type {mlist_to_hlist} \NC \yes \NC \nop \NC \NR
1883 \NC \type {new} \NC \yes \NC \yes \NC \NR
1884 \NC \type {next} \NC \yes \NC \nop \NC \NR
1885 \NC \type {prev} \NC \yes \NC \nop \NC \NR
1886 \NC \type {protect_glyphs} \NC \yes \NC \yes \NC \NR
1887 \NC \type {protect_glyph} \NC \yes \NC \yes \NC \NR
1888 \NC \type {protrusion_skippable} \NC \yes \NC \yes \NC \NR
1889 \NC \type {remove} \NC \yes \NC \yes \NC \NR
1890 \NC \type {set_attribute} \NC \yes \NC \yes \NC \NR
1891 \NC \type {setboth} \NC \yes \NC \yes \NC \NR
1892 \NC \type {setbox} \NC \nop \NC \yes \NC \NR
1893 \NC \type {setchar} \NC \yes \NC \yes \NC \NR
1894 \NC \type {setdisc} \NC \yes \NC \yes \NC \NR
1895 \NC \type {setfield} \NC \yes \NC \yes \NC \NR
1896 \NC \type {setglue} \NC \yes \NC \yes \NC \NR
1897 \NC \type {setlink} \NC \yes \NC \yes \NC \NR
1898 \NC \type {setnext} \NC \yes \NC \yes \NC \NR
1899 \NC \type {setprev} \NC \yes \NC \yes \NC \NR
1900 \NC \type {slide} \NC \yes \NC \yes \NC \NR
1901 \NC \type {subtypes} \NC \yes \NC \nop \NC \NR
1902 \NC \type {subtype} \NC \yes \NC \nop \NC \NR
1903 \NC \type {tail} \NC \yes \NC \yes \NC \NR
1904 \NC \type {todirect} \NC \yes \NC \yes \NC \NR
1905 \NC \type {tonode} \NC \yes \NC \yes \NC \NR
1906 \NC \type {tostring} \NC \yes \NC \yes \NC \NR
1907 \NC \type {traverse_char} \NC \yes \NC \yes \NC \NR
1908 \NC \type {traverse_id} \NC \yes \NC \yes \NC \NR
1909 \NC \type {traverse} \NC \yes \NC \yes \NC \NR
1910 \NC \type {types} \NC \yes \NC \nop \NC \NR
1911 \NC \type {type} \NC \yes \NC \nop \NC \NR
1912 \NC \type {unprotect_glyphs} \NC \yes \NC \yes \NC \NR
1913 \NC \type {unset_attribute} \NC \yes \NC \yes \NC \NR
1914 \NC \type {usedlist} \NC \yes \NC \yes \NC \NR
1915 \NC \type {vpack} \NC \yes \NC \yes \NC \NR
1916 \NC \type {whatsitsubtypes} \NC \yes \NC \nop \NC \NR
1917 \NC \type {whatsits} \NC \yes \NC \nop \NC \NR
1918 \NC \type {write} \NC \yes \NC \yes \NC \NR
1919 \stoptabulate
1921 % \stopcolumns
1923 The \type {node.next} and \type {node.prev} functions will stay but for
1924 consistency there are variants called \type {getnext} and \type {getprev}. We had
1925 to use \type {get} because \type {node.id} and \type {node.subtype} are already
1926 taken for providing meta information about nodes. Note: The getters do only basic
1927 checking for valid keys. You should just stick to the keys mentioned in the
1928 sections that describe node properties.
1930 Some nodes have indirect references. For instance a math character refers to a
1931 family instead of a font. In that case we provide a virtual font field as
1932 accessor. So, \type {getfont} and \type {.font} can be used on them. The same is
1933 true for the \type {width}, \type {height} and \type {depth} of glue nodes. These
1934 actually access the spec node properties, and here we can set as well as get the
1935 values.
1937 \stopchapter
1939 \stopcomponent