-
Notifications
You must be signed in to change notification settings - Fork 2
/
nodetree-doc.tex
1444 lines (1090 loc) · 31.6 KB
/
nodetree-doc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!TEX program = lualatex
\documentclass{ltxdoc}
\usepackage{paralist,fontspec,microtype}
\usepackage[
colorlinks=true,
linkcolor=red,
filecolor=red,
urlcolor=red,
]{hyperref}
\usepackage{nodetree-embed}
\mdfsetup{
innerleftmargin=0.2em,
innerrightmargin=0.2em,
}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
% Improve ltxdoc's `|...|` feature by allowing breaks.
\usepackage{fvextra}
\fvset{breaklines=true,breakbefore=.-_}
\AtBeginDocument{\DefineShortVerb{\|}}
% We use 'pmboxdraw' to draw box elements in minted environments.
% https://tex.stackexchange.com/questions/281368/print-box-drawing-characters-with-pdflatex/355403#355403
\usepackage{pmboxdraw}
\begingroup
\def\DeclareUnicodeCharacter#1{%
\begingroup
\lccode`\~="#1\relax
\lowercase{\endgroup
\global\catcode`~=\active
\gdef~%
}%
}%
\input{pmboxdrawenc.dfu}%
\endgroup
% https://tex.stackexchange.com/questions/108127/block-element-characters-pmboxdraw-are-shown-too-wide-in-verbatim-and-verbatim
\pmboxdrawsetup{
Block/box={\texttt{0}},
}
\usepackage{minted}
\usemintedstyle{colorful}
\BeforeBeginEnvironment{minted}{\begin{mdframed}[backgroundcolor=gray!3]}
\AfterEndEnvironment{minted}{\end{mdframed}}
\setminted{
breaklines=true,
fontsize=\footnotesize,
}
\setmintedinline{
fontsize=auto
}
\def\TmpLuaCodeInline#1{\texttt{\scantokens{\catcode`\_=12\relax#1}}}
\def\TmpSecRef#1{(\rightarrow\ \ref{#1})}
\def\TmpPageSecRef#1{
Page
\pageref{#1},
Section
\ref{#1}
}
\newcommand{\TmpExample}[2]{
\begin{NodetreeEmbedView}[fontsize=#2]
\input{examples/#1.nttex}
\end{NodetreeEmbedView}
}
\newcommand{\TmpVerbExample}[2]{
\VerbatimInput[firstline=4]{examples/#1.tex}
\TmpExample{#1}{#2}
}
\newcommand\TmpMacroName[1]{%
\texorpdfstring{\cs{#1}}{\textbackslash #1}%
}
\DefineVerbatimEnvironment{code}{Verbatim}
{
frame=single,
fontsize=\footnotesize,
}
\newcommand{\TmpLuaFunction}[1]{
\marginpar{%
\raggedleft%
\MacroFont%
\texttt{%
\scantokens{\catcode`\_=12\relax#1}%
}%
}%
}
\begin{document}
\providecommand*{\url}{\texttt}
\GetFileInfo{nodetree.dtx}
\title{The \textsf{nodetree} package}
\author{%
Josef Friedrich\\%
\url{[email protected]}\\%
\href{https://github.com/Josef-Friedrich/nodetree}{github.com/Josef-Friedrich/nodetree}\\%
with contributions by Werner Lemberg
}
\date{v2.4.0 from 2024/09/17}
\maketitle
\begin{NodetreeEmbedEnv}
nodetree
\end{NodetreeEmbedEnv}
\newpage
\tableofcontents
\newpage
%-----------------------------------------------------------------------
% Abstract
%-----------------------------------------------------------------------
\section{Abstract}
|nodetree| is a Lua\TeX{} development package for both plain \TeX{}
and \LaTeX{} that visualizes the structure of node lists while
compiling with the \TeX{} engine. It uses a visual representation of
node lists similar to the UNIX |tree| command’s output for folder
trees. The processed document isn’t changed.
The tree view can be emitted to the console, to a log file, or as a
\LaTeX{} input file. Its appearance is highly customizable; multiple
color and B/W themes together with various levels of verbosity are
provided.
Node lists are the main building blocks of the \TeX{} engine, which
Lua\TeX{} allows to inspect and modify. |nodetree| is inspired by a
\href{https://gist.github.com/pgundlach/556247} {gist from Patrick
Gundlach}.
%-----------------------------------------------------------------------
% Usage
%-----------------------------------------------------------------------
\section{Usage}
The package |nodetree| has four usage scenarios.
It can be used as a standalone Lua module, as a plain Lua\TeX{}, a
Lua\LaTeX{} package or as package to embed nodetree views in a
Lua\LaTeX{} document.
%-----------------------------------------------------------------------
%
%-----------------------------------------------------------------------
\newpage
\subsection{As a plain Lua\TeX{} package}
Run |luatex luatex-test.tex| for example to list the nodes using
Lua\TeX{}.
\begin{minted}{latex}
\input{nodetree.tex}
\NodetreeRegisterCallback{postline}
Lorem ipsum dolor.
\bye
\end{minted}
\subsubsection{Available macros}
\def\TmpTabularMacrosPlainTeX{
\cmd{\NodetreeRegisterCallback}\marg{callbacks} &
\TmpPageSecRef{sec:cmd:nodetree-register-callback} \\
\cmd{\NodetreeUnregisterCallback}\marg{callbacks} &
\TmpPageSecRef{sec:cmd:nodetree-unregister-callback} \\
\cmd{\NodetreeSetOption}\oarg{option}\marg{value} &
\TmpPageSecRef{sec:cmd:nodetree-set-option} \\
\cmd{\NodetreeResetOption}\marg{option} &
\TmpPageSecRef{sec:cmd:nodetree-reset-option} \\
\cmd{\NodetreeReset} &
\TmpPageSecRef{sec:cmd:nodetree-reset} \\
}
\begin{tabular}{ll}
\textbf{Macro name} &
\textbf{Reference} \\
\TmpTabularMacrosPlainTeX
\end{tabular}
\subsubsection{Available options}
\def\TmpTabularOptionsBase{\scantextokens{
|callback| &
\TmpPageSecRef{sec:option:callback} \\
|verbosity| &
\TmpPageSecRef{sec:option:verbosity} \\
|color| &
\TmpPageSecRef{sec:option:color} \\
|unit| &
\TmpPageSecRef{sec:option:unit} \\
|decimalplaces| &
\TmpPageSecRef{sec:option:decimalplaces} \\
}}
\begin{tabular}{ll}
\textbf{Option name} &
\textbf{Reference} \\
\TmpTabularOptionsBase
|channel| &
\TmpPageSecRef{sec:option:channel} \\
\end{tabular}
%-----------------------------------------------------------------------
%
%-----------------------------------------------------------------------
\newpage
\subsection{As a Lua\LaTeX{} package}
Run |lualatex lualatex-test.tex| to show a node tree using
Lua\LaTeX{}. In Lua\LaTeX{} you can omit a call to
|\NodetreeRegisterCallback{postline}|, since |\usepackage{nodetree}|
registers the |post_linebreak_filter| by default. Use
|\NodetreeUnregisterCallback{postline}| if you don’t want to debug the
|post_linebreak_filter|.
\begin{minted}{latex}
\documentclass{article}
\usepackage{nodetree}
\begin{document}
Lorem ipsum dolor.
\end{document}
\end{minted}
\subsubsection{Available macros}
\begin{tabular}{ll}
\textbf{Macro name} &
\textbf{Reference} \\
\TmpTabularMacrosPlainTeX
\cmd{\NodetreeSet}\marg{kv-options} &
\TmpPageSecRef{sec:cmd:nodetree-set} \\
\end{tabular}
\subsubsection{Available options}
\begin{tabular}{ll}
\textbf{Option name} &
\textbf{Reference} \\
\TmpTabularOptionsBase
|channel| &
\TmpPageSecRef{sec:option:channel} \\
\end{tabular}
%-----------------------------------------------------------------------
%
%-----------------------------------------------------------------------
\newpage
\subsection{As a Lua module}
Import the Lua module of the package inside
\mintinline{latex}{\directlua{}}
with this command:
\mintinline{lua}{local nodetree = require('nodetree')}.
Then use the Lua function
\mintinline{lua}{nodetree.print(head, options)}
to debug nodes inside your Lua code.
\begin{minted}{lua}
local nodetree = require('nodetree')
local rule1 = node.new('rule')
rule1.width = 20 * 65536
rule1.height = 10 * 65536
rule1.depth = 10 * 65536
nodetree.print(vbox)
\end{minted}
\noindent
The function \mintinline{lua}{nodetree.print()} takes as a second
argument a Lua table to configure the output.
\begin{minted}{lua}
nodetree.print(vbox, { verbosity = 2, unit = 'cm' })
\end{minted}
\noindent
These are the default options:
\begin{minted}{lua}
options = {
callback = 'post_linebreak_filter',
channel = 'term',
color = 'colored',
decimalplaces = 2,
unit = 'pt',
verbosity = 0,
firstline = 1,
lastline = -1,
}
\end{minted}
Options |firstline| and |lastline| only have an effect on function
\mintinline{lua}{nodetree.input(filename)}, which is used to implement
\cmd{\NodetreeEmbedInput} \TmpSecRef{sec:cmd:nodetree-embed-input}.
The following code snippet demonstrates the usage in Lua\TeX{}.
|head| is the current node.
\begin{minted}{latex}
\directlua{
local nodetree = require('nodetree')
local test = function (head)
nodetree.print(head)
end
callback.register('post_linebreak_filter', test)
}
Lorem ipsum dolor.
\bye
\end{minted}
\noindent
This example illustrates how the function has to be applied in
Lua\LaTeX{}.
\begin{minted}{latex}
\documentclass{article}
\usepackage{nodetree}
\begin{document}
\directlua{
local nodetree = require('nodetree')
local test = function (head)
nodetree.print(head)
end
luatexbase.add_to_callback('post_linebreak_filter', test, 'test')
}
Lorem ipsum dolor.
\end{document}
\end{minted}
%-----------------------------------------------------------------------
%
%-----------------------------------------------------------------------
\newpage
\subsection{The package \texttt{nodetree-embed}}
The single purpose of this auxiliary package is to provide a view
similar to a terminal (console) output.
This view mimics the output
of |nodetree| in a terminal.
The view can be embedded in a Lua\LaTeX{} file. You have to
compile documents using this embedded view with the option
|--shell-escape|.
The main environment of this package is |NodetreeEmbed|.
Markup
inside this environment is written into a temporary \LaTeX{} file.
This file is compiled in the background by |latexmk| and the
|nodetree| output is embedded into this view.
The following list shows each intermediate step:
\begin{enumerate}
\item |jobname.tex|
\begin{minted}{latex}
\begin{NodetreeEmbedEnv}
nodetree
\end{NodetreeEmbedEnv}
\end{minted}
\item |_nodetree-jobname/1.tex|
\begin{minted}{latex}
%!TEX program = lualatex
\documentclass{article}
\usepackage{nodetree}
\NodetreeSetOption[channel]{tex}
\NodetreeSetOption[verbosity]{0}
\NodetreeSetOption[unit]{pt}
\NodetreeSetOption[decimalplaces]{2}
\NodetreeUnregisterCallback{post_linebreak_filter}
\NodetreeRegisterCallback{post_linebreak_filter}
\begin{document}
nodetree
\end{document}
\end{minted}
\item |_nodetree-jobname/1.nttex|: This temporary Lua\LaTeX{} file is
compiled using |latexmk| and embedded in the environment |NodetreeEmbed|
(the trailing |\| character indicates line continuation).
\begin{minted}{latex}
Callback: \textcolor{NTEred}{post\_linebreak\_filter}\par
------------------------------------------\par
\mbox{├─\textcolor{NTEmagentabright}{GLUE}\hspace{0.5em}(baselineskip)\
\textcolor{NTEyellow}{wd} 5.06\textcolor{NTEwhite}{pt}}\par
...
\end{minted}
\item Finally the result:
\begin{NodetreeEmbedEnv}
nodetree
\end{NodetreeEmbedEnv}
\end{enumerate}
\subsubsection{Available macros}
\begin{tabular}{ll}
\textbf{Macro name} &
\textbf{Reference} \\
\TmpTabularMacrosPlainTeX
\cmd{\NodetreeSet}\marg{kv-options} &
\TmpPageSecRef{sec:cmd:nodetree-set} \\
\cmd{\NodetreeEmbedCmd}\oarg{kv-options}\marg{tex-markup} &
\TmpPageSecRef{sec:cmd:nodetree-embed-cmd} \\
\cmd{\NodetreeEmbedInput}\oarg{kv-options}\marg{nttex-file} &
\TmpPageSecRef{sec:cmd:nodetree-embed-input} \\
\end{tabular}
\subsubsection{Available environment}
\begin{tabular}{ll}
\textbf{Environment name} &
\textbf{Reference} \\
|\begin{NodetreeEmbedEnv}|\oarg{kv-options} & % |\end{NodetreeEmbedEnv}|
\TmpPageSecRef{sec:env:nodetree-embed-env} \\
\end{tabular}
\subsubsection{Available options}
\begin{tabular}{ll}
\textbf{Option name} &
\textbf{Reference} \\
\TmpTabularOptionsBase
|theme| &
\TmpPageSecRef{sec:option:theme} \\
|thememode| &
\TmpPageSecRef{sec:option:thememode} \\
|font| &
\TmpPageSecRef{sec:option:font} \\
|fontsize| &
\TmpPageSecRef{sec:option:fontsize} \\
|firstline| &
\TmpPageSecRef{sec:option:firstlastline} \\
|lastline| &
\TmpPageSecRef{sec:option:firstlastline} \\
\end{tabular}
%-----------------------------------------------------------------------
% Macros
%-----------------------------------------------------------------------
\newpage
\section{Macros}
%%
% \NodetreeRegisterCallback
%%
\subsection{\TmpMacroName{NodetreeRegisterCallback}}
\label{sec:cmd:nodetree-register-callback}
\DescribeMacro{\NodetreeRegisterCallback}
\cmd{\NodetreeRegisterCallback}\marg{callbacks}: Globally register
\marg{callbacks}, which is a comma-separated list of callback aliases
\TmpSecRef{sec:option:callback}.
%%
% \NodetreeUnregisterCallback
%%
\subsection{\TmpMacroName{NodetreeUnregisterCallback}}
\label{sec:cmd:nodetree-unregister-callback}
\DescribeMacro{\NodetreeUnregisterCallback}
\cmd{\NodetreeUnregisterCallback}\marg{callbacks}: Globally unregister
\marg{callbacks}, which is a separated list of callback aliases
\TmpSecRef{sec:option:callback}.
%%
% \NodetreeSetOption
%%
\subsection{\TmpMacroName{NodetreeSetOption}}
\label{sec:cmd:nodetree-set-option}
\DescribeMacro{\NodetreeSetOption}
\cmd{\NodetreeSetOption}\oarg{option}\marg{value}: Globally set a
single \oarg{option} to \marg{value} \TmpSecRef{sec:options}.
%%
% \NodetreeResetOption
%%
\subsection{\TmpMacroName{NodetreeResetOption}}
\label{sec:cmd:nodetree-reset-option}
\DescribeMacro{\NodetreeResetOption}
\cmd{\NodetreeResetOption}\marg{option}: Globally reset a single
\marg{option} to its default value \TmpSecRef{sec:options}.
%%
% \NodetreeSet
%%
\subsection{\TmpMacroName{NodetreeSet}}
\label{sec:cmd:nodetree-set}
\DescribeMacro{\NodetreeSet}
\cmd{\NodetreeSet}\marg{kv-options}: Globally set multiple options at
once. It can only be used along with Lua\LaTeX{}. \marg{kv-options}
are key-value pairs.
\begin{code}
\NodetreeSet{color=no,callbacks={hpack,vpack},verbosity=2}
\end{code}
%%
% \NodetreeReset
%%
\subsection{\TmpMacroName{NodetreeReset}}
\label{sec:cmd:nodetree-reset}
\DescribeMacro{\NodetreeReset}
\cmd{\NodetreeReset}: Globally reset multiple options to their default
values.
%%
%
%%
\subsection{\TmpMacroName{NodetreeEmbedCmd}}
\label{sec:cmd:nodetree-embed-cmd}
\DescribeMacro{\NodetreeEmbedCmd}
\cmd{\NodetreeEmbedCmd}\oarg{kv-options}\marg{tex-markup}:
Main macro (cmd) to evaluate some \TeX{} markup and generate a
node tree from it. See environment version
\TmpSecRef{sec:cmd:nodetree-embed-cmd}. Uses |xparse|'s |+v| option to
grab the verbatim content. \marg{kv-options} are key-value pairs and
set locally only.
Only available in package |nodetree-embed|; you need option
|--shell-escape|.
%%
% \NodetreeEmbedInput
%%
\subsection{\TmpMacroName{NodetreeEmbedInput}}
\label{sec:cmd:nodetree-embed-input}
\DescribeMacro{\NodetreeEmbedInput}
\cmd{\NodetreeEmbedInput}\oarg{kv-options}\marg{nttex-file}: The path or
file name of the |*.nttex| file without the extension.
\marg{kv-options} are key-value pairs and set locally only.
Only available in package |nodetree-embed|. This command works without
option |--shell-escape|.
%-----------------------------------------------------------------------
% Environments
%-----------------------------------------------------------------------
\newpage
\section{Environments}
\subsection{\texttt{NodetreeEmbedEnv}}
\label{sec:env:nodetree-embed-env}
\DescribeEnv{NodetreeEmbedEnv}
|\begin{NodetreeEmbedEnv}|\oarg{kv-options}\\
\dots{} \textit{\TeX{} markup for evaluation} \dots\\
|\end{NodetreeEmbedEnv}|
Main environment (env) to evaluate some \TeX{} markup and generate a
node tree from it. See command version
\TmpSecRef{sec:cmd:nodetree-embed-cmd}. Uses the \cmd{\detokenize}
command to grab the verbatim content. \marg{kv-options} are key-value
pairs and set locally only.
Only available in package |nodetree-embed|; you need option
|--shell-escape|.
%-----------------------------------------------------------------------
% Options
%-----------------------------------------------------------------------
\newpage
\section{Options}
\label{sec:options}
%%
% callback
%%
\subsection{Option \texttt{callback}}
\label{sec:option:callback}
The option |callback| is the most important setting of the package. It
is possible to specify an alias to select the callback. Take a look at
the overview of callbacks (\rightarrow{} Figure~\ref{fig:callback}).
|nodetree| supports all node-related callbacks as listed in the
Lua\TeX{} reference manual.
These macros process callback options:
\begin{quote}
\cmd{\NodetreeRegisterCallback}\marg{callbacks}\\
\cmd{\NodetreeUnregisterCallback}\marg{callbacks}\\
\cmd{\NodetreeSet}\marg{callback=<callbacks>}\\
\cmd{\usepackage}\oarg{callback=<callbacks>}\marg{nodetree}
\end{quote}
The |nodetree| package can watch the node tree before and after the
functions of a callback are executed: It is possible to prepend and/or
append a colon (|:|) to indicate the desired watchpoint position,
which defaults to 'before' if no colon is used.
Use commas to specify multiple callbacks; trailing and leading
whitespace is ignored. For example, this call
\begin{code}
\NodetreeRegisterCallback{:preline, line, :postline:}
\end{code}
\noindent
watches the node tree before the |preline| callback functions, before
the |line| callback functions, and before and after the |postline|
callback functions. In case there are no callback functions
registered for one of the |hyphenate|, |kerning|, |ligaturing|, and
|mlist_to_hlist| callbacks, Lua\TeX{} executes some internal code
instead. It thus makes sense to watch the node tree before and after
these (empty) callbacks even in this case.
Wrap your callback aliases in curly braces for the macro
|\NodetreeSet|. Note that no whitespace between |=| and |{| is
allowed.
\begin{code}
\NodetreeSet{callback={:preline, line, :postline:}}
\end{code}
The same applies for the macro |\usepackage|:
\begin{code}
\usepackage{callback={:preline, line, :postline:}}
\end{code}
The callbacks in Figure~\ref{fig:callback} are listed in the same
order as in the Lua\TeX{} reference manual. Note that the |ligaturing|
and |kerning| callbacks only have an effect on ligatures and kernings,
respectively, if the |luaotfload| package (which is the default for
Lua\LaTeX{}, and an optional package for Lua\TeX{}) handles the
affected font with |mode=base| (see the
\href{http://mirrors.ctan.org/macros/luatex/generic/luaotfload/luaotfload-latex.pdf}
{documentation} for more details).
%%
% Tabular callbacks
%%
\newcommand{\TmpCallbackRow}[3]{
\TmpLuaCodeInline{#1} & \TmpLuaCodeInline{#2} & \TmpLuaCodeInline{\footnotesize#3} \\
}
\begin{figure}
\begin{tabular}{lll}
\textbf{Callback} & \textbf{Alias} & \textbf{Alias (longer)} \\
\TmpCallbackRow{contribute_filter}
{contribute}
{contributefilter}
\TmpCallbackRow{buildpage_filter}
{buildfilter} %
{buildpagefilter}
% new
\TmpCallbackRow{build_page_insert}
{buildinsert}
{buildpageinsert}
\TmpCallbackRow{pre_linebreak_filter}
{preline}
{prelinebreakfilter}
\TmpCallbackRow{linebreak_filter}
{line}
{linebreakfilter}
\TmpCallbackRow{append_to_vlist_filter}
{append}
{appendtovlistfilter}
\TmpCallbackRow{post_linebreak_filter}
{postline}
{postlinebreakfilter}
\TmpCallbackRow{hpack_filter}
{hpack}
{hpackfilter}
\TmpCallbackRow{vpack_filter}
{vpack}
{vpackfilter}
\TmpCallbackRow{hpack_quality}
{hpackq}
{hpackquality}
\TmpCallbackRow{vpack_quality}
{vpackq}
{vpackquality}
\TmpCallbackRow{process_rule}
{process}
{processrule}
\TmpCallbackRow{pre_output_filter}
{preout}
{preoutputfilter}
\TmpCallbackRow{hyphenate}
{hyph}
{}
\TmpCallbackRow{ligaturing}
{liga}
{}
\TmpCallbackRow{kerning}
{kern}
{}
\TmpCallbackRow{insert_local_par}
{insert}
{insertlocalpar}
\TmpCallbackRow{mlist_to_hlist}
{mhlist}
{mlisttohlist}
\end{tabular}
\caption{The callback aliases}
\label{fig:callback}
\end{figure}
%%
% channel
%%
\subsection{Option \texttt{channel}}
\label{sec:option:channel}
You can select the debug output channel with this option. The default
value for the option |channel| is |term|, which displays the node tree in
the current terminal. Specify |log| and the package creates a log file
named |<jobname>.ntlog|. Specify |tex| and a log file named
|<jobname>.nttex| is created. |nt...| stands for |nodetree|.
|<jobname>| is the basename of your file you want to debug. The debug
channel is only useful for the auxiliary package |nodetree-embed|. Paste
the markup in the environment |NodetreeEmbedView| and you get a
terminal-like view in your document.
%%
% verbosity
%
\subsection{Option \texttt{verbosity}}
\label{sec:option:verbosity}
Higher integer values result in a more verbose output. The default value
for this option is~|0|. At the moment verbosity levels |0| to~|3| are
implemented.
\def\TmpExampleVerbosity#1{
\subsubsection{Example: \texttt{verbosity=#1}}
\begin{NodetreeEmbedEnv}[verbosity=#1,callback=pre_linebreak_filter,
fontsize=\fontsize{5.5}{6.6}\selectfont]
.
\end{NodetreeEmbedEnv}
}
\TmpExampleVerbosity{0}
\TmpExampleVerbosity{1}
\TmpExampleVerbosity{2}
\TmpExampleVerbosity{3}
%%
% color
%%
\subsection{Option \texttt{color}}
\label{sec:option:color}
The default option for |color| is |colored|. Use any other string (for
example |none| or |no|) to disable the colored terminal output of the
package.
\begin{code}
\usepackage[color=no]{nodetree}
\end{code}
%%
% unit
%%
\subsection{Option \texttt{unit}}
\label{sec:option:unit}
The option |unit| sets the length unit to display all length values of
the nodes. The default option for |unit| is |pt|. See figures
\ref{fig:fixed-units} and~\ref{fig:relative-units} for possible values.
\begin{figure}
\begin{tabular}{lp{10cm}}
\textbf{Unit} &
\textbf{Description} \\
pt &
Point 1/72.27 inch. The conversion to metric units, to two decimal
places, is 1 point = 2.85 mm = 28.45 cm. \\
pc &
Pica, 12 pt \\
in &
Inch, 72.27 pt \\
bp &
Big point, 1/72 inch. This length is the definition of a point in
PostScript and many desktop publishing systems. \\
cm &
Centimeter \\
mm &
Millimeter \\
dd &
Didot point, 1.07 pt \\
cc &
Cicero, 12 dd \\
sp &
Scaled point, 1/65536 pt \\
\end{tabular}
\caption{Fixed units}
\label{fig:fixed-units}
\end{figure}
\begin{figure}
\begin{tabular}{lp{10cm}}
\textbf{Unit} &
\textbf{Description} \\
ex &
x-height of the current font \\
em &
Width of the capital letter M \\
\end{tabular}
\caption{Relative units}
\label{fig:relative-units}
\end{figure}
\def\TmpExampleUnit#1{
\subsubsection{Example: \texttt{unit=#1}}
\begin{NodetreeEmbedEnv}[unit=#1,callback=pre_linebreak_filter]
Lorem.
\end{NodetreeEmbedEnv}
}
\TmpExampleUnit{pt}
\TmpExampleUnit{sp}
\TmpExampleUnit{cm}
%%
% decimalplaces
%%
\subsection{Option \texttt{decimalplaces}}
\label{sec:option:decimalplaces}
The options |decimalplaces| sets the number of decimal places for some
node fields. If |decimalplaces| is set to |0| only integer values are shown.
\begin{code}
\NodetreeSetOption[decimalplaces]{4}
\end{code}
\def\TmpExampleDecimalplaces#1{
\subsubsection{Example: \texttt{decimalplaces=#1}}
\begin{NodetreeEmbedEnv}[unit=cc,decimalplaces=#1,callback=pre_linebreak_filter]
Lorem.
\end{NodetreeEmbedEnv}
}
\TmpExampleDecimalplaces{0}
\TmpExampleDecimalplaces{2}
\TmpExampleDecimalplaces{5}
%%
% theme and thememode
%%
\def\TmpExampleTheme#1#2{
\subsubsection{Example: \texttt{theme=#1} \texttt{thememode=#2}}
\begin{NodetreeEmbedEnv}[callback=pre_linebreak_filter,theme=#1,thememode=#2,fontsize=\small]
.
\end{NodetreeEmbedEnv}
}
\subsection{Option \texttt{theme} and \texttt{thememode}}
\label{sec:option:theme}
\label{sec:option:thememode}
% bw
\TmpExampleTheme{bwdark}{dark}
\TmpExampleTheme{bwlight}{light}
% monokaisoda
\TmpExampleTheme{monokaisoda}{dark}
\TmpExampleTheme{monokaisoda}{light}
%%
% font
%%
\subsection{Option \texttt{font}}
\label{sec:option:font}
\NodetreeSet{fontsize=\footnotesize}
\def\TmpExampleFont#1{
\subsubsection{Example: \texttt{font=\{#1\}}}
\begin{NodetreeEmbedEnv}[font={#1}]
.
\end{NodetreeEmbedEnv}
}
|nodetree-embed| passes the option |font| down to the
command |\setmonofont{}| of the |fontspec| package. The used font
should be monospaced and have some box drawing glyphs (see
table~\ref{fig:unicode}).
\TmpExampleFont{Liberation Mono}
\TmpExampleFont{Ubuntu Mono}
%%
% fontsize
%%