summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/latex/contrib/animate/ChangeLog4
-rw-r--r--macros/latex/contrib/animate/README.md6
-rw-r--r--macros/latex/contrib/animate/animate.pdfbin3887704 -> 3887825 bytes
-rw-r--r--macros/latex/contrib/animate/animate.sty4
-rw-r--r--macros/latex/contrib/animate/animate.tex6
-rw-r--r--macros/latex/contrib/biblatex-contrib/biblatex-vancouver/LICENSE674
-rw-r--r--macros/latex/contrib/biblatex-contrib/biblatex-vancouver/README62
-rw-r--r--macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.bbx125
-rw-r--r--macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.cbx25
-rw-r--r--macros/luatex/generic/nodetree/README.md63
-rw-r--r--macros/luatex/generic/nodetree/nodetree.dtx2007
-rw-r--r--macros/luatex/generic/nodetree/nodetree.ins10
-rw-r--r--macros/luatex/generic/nodetree/nodetree.lua1547
-rw-r--r--macros/luatex/generic/nodetree/nodetree.pdfbin396294 -> 357181 bytes
14 files changed, 2745 insertions, 1788 deletions
diff --git a/macros/latex/contrib/animate/ChangeLog b/macros/latex/contrib/animate/ChangeLog
index 820f6bb3a3..10ca7c56f0 100644
--- a/macros/latex/contrib/animate/ChangeLog
+++ b/macros/latex/contrib/animate/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-29
+ * fix: `autoplay' option non-functional in combination with `poster=last';
+ missing mention of KDE Okular in the list of supported PDF viewers
+
2020-05-07
* fix: control button issue (dvisvgm)
diff --git a/macros/latex/contrib/animate/README.md b/macros/latex/contrib/animate/README.md
index e9af5c9f3b..3d76e4ab20 100644
--- a/macros/latex/contrib/animate/README.md
+++ b/macros/latex/contrib/animate/README.md
@@ -10,11 +10,11 @@ This package provides an interface to create portable, JavaScript driven PDF and
It supports the usual PDF making workflows, i. e. pdfLaTeX, LaTeX ⇒ `dvips` ⇒ `ps2pdf` (Ghostscript)/Distiller, (Xe)LaTeX ⇒ `(x)dvipdfmx`, LuaLaTeX, and LaTeX ⇒ `dvisvgm` for SVG.
-The resulting PDF with animations can be viewed in Acrobat Reader (except on mobile devices), in PDF-XChange and in Foxit Reader. Animated SVG are self-contained files that can be embedded into HTML using the `<object>` tag or opened directly in a Web browser, such as Firefox or Chromium.
+The resulting PDF with animations can be viewed in Acrobat Reader (except on mobile devices), KDE Okular, PDF-XChange and Foxit Reader. Animated SVG are self-contained files that can be embedded into HTML using the `<object>` tag or opened directly in a Web browser, such as Firefox or Chromium.
Note, this file only gives a summary of usage and available package and command options. Please refer to the documentation [`animate.pdf`](animate.pdf) for details and examples.
-*Keywords:* include portable PDF animation SVG animation animated PDF animated SVG dvisvgm html TeX4ht web animating embed animated graphics LaTeX pdfLaTeX LuaLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Acrobat Reader PDF-XChange Foxit Reader Firefox Chrome Chromium
+*Keywords:* include portable PDF animation SVG animation animated PDF animated SVG dvisvgm html TeX4ht web animating embed animated graphics LaTeX pdfLaTeX LuaLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Acrobat Reader KDE Okular PDF-XChange Foxit Reader Firefox Chrome Chromium
## Usage
@@ -96,7 +96,7 @@ Recent versions of
- Ghostscript or Adobe Distiller
- dvipdfmx
- dvisvgm
-- PDF: Acrobat Reader, PDF-XChange, Foxit Reader
+- PDF: Acrobat Reader, KDE Okular, PDF-XChange, Foxit Reader
- SVG: Blink-based web browsers (Chromium, Chrome, Opera, ...) or Firefox
## Installation
diff --git a/macros/latex/contrib/animate/animate.pdf b/macros/latex/contrib/animate/animate.pdf
index e936974244..9fcccf84fa 100644
--- a/macros/latex/contrib/animate/animate.pdf
+++ b/macros/latex/contrib/animate/animate.pdf
Binary files differ
diff --git a/macros/latex/contrib/animate/animate.sty b/macros/latex/contrib/animate/animate.sty
index 679dad68f3..64d1291144 100644
--- a/macros/latex/contrib/animate/animate.sty
+++ b/macros/latex/contrib/animate/animate.sty
@@ -13,7 +13,7 @@
\NeedsTeXFormat{LaTeX2e}
-\def\@anim@version{2020/05/07}
+\def\@anim@version{2020/05/29}
\ProvidesPackage{animate}
[\@anim@version\space PDF & SVG animations from files and inline graphics]
@@ -4159,7 +4159,7 @@
\if@anim@autoresume
if(a#1_isPaused){$%
\fi
- if(a#1_playsRight){a#1_playRight();}else{a#1_playLeft();}$%
+ if(a#1_playsRight){a#1_playFwd();}else{a#1_playBwd();}$%
\if@anim@autoresume%
}$%
\fi%
diff --git a/macros/latex/contrib/animate/animate.tex b/macros/latex/contrib/animate/animate.tex
index 34f8d2de67..82979a475d 100644
--- a/macros/latex/contrib/animate/animate.tex
+++ b/macros/latex/contrib/animate/animate.tex
@@ -61,7 +61,7 @@
% \makeatother
%\fi
-\def\keywords{include portable PDF animation SVG animation animated PDF animated SVG dvisvgm html TeX4ht web animating embed animated graphics LaTeX pdfLaTeX LuaLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Acrobat Reader PDF-XChange Foxit Reader Firefox Chrome Chromium}
+\def\keywords{include portable PDF animation SVG animation animated PDF animated SVG dvisvgm html TeX4ht web animating embed animated graphics LaTeX pdfLaTeX LuaLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Acrobat Reader KDE Okular PDF-XChange Foxit Reader Firefox Chrome Chromium}
\hypersetup{
pdftitle={The animate Package},
pdfsubject={Documentation},
@@ -114,7 +114,7 @@ This package provides an interface for creating PDF and SVG files with animated
Package `animate' supports the usual workflows for making PDF, i.\,e. pdf\LaTeX{}, Lua\-\LaTeX{}, \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller and \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+. For animated SVG, it supports the \verb+dvisvgm+ driver. The DVI/XDV used as input for \verb+dvisvgm+ can be generated with \LaTeX{}, Lua\LaTeX{} (in DVI mode with command `\verb+dvilualatex+') and \XeLaTeX{} (with option `\verb+--no-pdf+').
-PDF files with animations can be viewed in Acrobat Reader (except on mobile devices), PDF-XChange and Foxit Reader.
+PDF files with animations can be viewed in Acrobat Reader (except on mobile devices), KDE Okular, PDF-XChange and Foxit Reader.
Animated SVG produced by means of \LaTeX{} and \verb+dvisvgm+ are self-sufficient files that can be embedded into HTML using the \verb+<object>+ tag or opened directly in a Web browser, such as Chromium or Firefox. Also, presentations, such as `beamer'-class documents, with embedded animations can be exported to SVG instead of PDF and viewed in a Web browser. SVG-capable Web browsers are standard on many platforms and operating systems and thus make SVG a very portable file format. A \LaTeX{} package for embedding video and audio into SVG is also available\cite{media4svg}.
@@ -131,7 +131,7 @@ The user interacts with the animation through optional animation controls or usi
\item \verb+dvipdfmx+ for DVI to PDF conversion
\item dvipdfmx, version $\ge 20190503$, for DVI to PDF conversion
\item \verb+dvisvgm+ for DVI to SVG conversion (also requires Ghostscript)
-\item PDF: Acrobat Reader, PDF-XChange, Foxit Reader
+\item PDF: Acrobat Reader, KDE Okular, PDF-XChange, Foxit Reader
\item SVG: Chromium-based browsers for best performance
\end{trivlist}
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/LICENSE b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/LICENSE
new file mode 100644
index 0000000000..94a9ed024d
--- /dev/null
+++ b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/README b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/README
new file mode 100644
index 0000000000..bcc28f5bb9
--- /dev/null
+++ b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/README
@@ -0,0 +1,62 @@
+ BibLaTex Vancouver
+ ==================
+
+This package provides the Vancouver reference style for BibLateX. It is based on
+the numeric style and requires biber.
+
+Downloading
+-----------
+
+Latest release of BibLaTeX Vancouver can be downloaded from
+http://code.agnibho.com/biblatex-vancouver/
+
+
+Installation
+------------
+
+Install the package to your local texmf directory. The local texmf directory can
+be found by running 'kpsewhich -var-value TEXMFHOME' in the commandline.
+
+For example if your local texmf directory is '~/texmf', then copy the
+'biblatex-vancouver' folder to '~/texmf/tex/latex/'.
+
+Usage
+-----
+
+BibLaTex Vancouver can be included in your LaTex document as a style argument.
+
+Example:
+ \usepackage[backend=biber,style=vancouver]{biblatex}
+
+Acknowledgment
+--------------
+
+Some part of the code has been adapted from the biblatex-nejm package.
+
+Licensing
+---------
+
+Copyright (c) 2020 Agnibho Mondal
+All rights reserved
+
+This file is part of BibLaTex Vancouver.
+
+BibLaTex Vancouver is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation, either version 3 of the License, or (at your option) any
+later version.
+
+BibLaTex Vancouver is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+details.
+
+You should have received a copy of the GNU General Public License along with
+BibLaTex Vancouver. If not, see <http://www.gnu.org/licenses/>.
+
+Contact
+--------
+
+Agnibho Mondal
+contact@agnibho.com
+www.agnibho.com
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.bbx
new file mode 100644
index 0000000000..a20c39a86e
--- /dev/null
+++ b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.bbx
@@ -0,0 +1,125 @@
+% Copyright (c) 2020 Agnibho Mondal
+% All rights reserved
+%
+% This file is part of BibLaTex Vancouver.
+%
+% BibLaTex Vancouver is free software: you can redistribute it and/or modify it
+% under the terms of the GNU General Public License as published by the Free
+% Software Foundation, either version 3 of the License, or (at your option) any
+% later version.
+%
+% BibLaTex Vancouver is distributed in the hope that it will be useful, but
+% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+% details.
+%
+% You should have received a copy of the GNU General Public License along with
+% BibLaTex Vancouver. If not, see <http://www.gnu.org/licenses/>.
+%
+% Agnibho Mondal
+% contact@agnibho.com
+% www.agnibho.com
+
+\ProvidesFile{vancouver.bbx}[2020/05/20 v0.1 biblatex vancouver]
+
+\RequireBiber[2]
+\RequireBibliographyStyle{numeric}
+
+\RequirePackage{ifthen}
+
+% Set default bibliography options
+\ExecuteBibliographyOptions{
+ sorting=none,
+ giveninits=true,
+ terseinits=true,
+ isbn=false,
+ maxbibnames=99
+}
+
+% Remove unwanted punctuations
+\renewcommand*{\revsdnamepunct}{}
+\renewcommand*{\finentrypunct}{}
+\renewcommand*{\bibpagespunct}{}
+
+% Remove 'in:' string
+\renewbibmacro{in:}{}
+
+% Provide three letter month names
+\newcommand*{\shortmonth}[1]{
+ \ifthenelse{\NOT\equal{#1}{}}{
+ \ifcase#1\relax
+ \or Jan
+ \or Feb
+ \or Mar
+ \or Apr
+ \or May
+ \or Jun
+ \or Jul
+ \or Aug
+ \or Sep
+ \or Oct
+ \or Nov
+ \or Dec
+ \fi
+ }
+}
+
+% Family name first
+\DeclareNameAlias{default}{family-given}
+
+% Remove unwanted formatting
+\DeclareFieldFormat*{title}{#1}
+\DeclareFieldFormat*{journaltitle}{#1}
+\DeclareFieldFormat*{labelnumberwidth}{#1\adddot}
+\DeclareFieldFormat*{pages}{:\mkcomprange{#1}}
+\DeclareFieldFormat*{url}{Available from: \url{#1}}
+\DeclareFieldFormat*[article]{issue}{(#1)}
+\DeclareFieldFormat*{date}{
+ \thefield{year}%
+ \shortmonth{\thefield{month}}\addspace
+ \thefield{day}\isdot
+}
+\DeclareFieldFormat*{urldate}{
+ {[}Accessed on:
+ \thefield{urlyear}%
+ \shortmonth{\thefield{urlmonth}}\addspace
+ \thefield{urlday}{]}
+}
+
+% Some string replacements
+\DeclareSourcemap{
+ \maps[datatype=bibtex]{
+ \map[overwrite=true]{
+ \step[fieldsource=journaltitle, match=\regexp{(\.)}, replace={}]
+ \step[fieldsource=journaltitle, match=\regexp{($)}, replace={.}]
+ }
+ }
+}
+
+% Code adapted from biblatex-nejm package
+
+\renewbibmacro*{volume+number+eid}{
+ \printfield{volume}%
+ \printfield{issue}%
+ \printfield{eid}%
+}
+
+%Order year;volume:page
+\renewbibmacro*{issue+date}{
+ \setunit*{\addspace}%
+ \usebibmacro{date}%
+ \newunit%
+}
+
+\renewbibmacro*{journal+issuetitle}{
+ \usebibmacro{journal}%
+ \iffieldundef{series}
+ {}
+ {\newunit
+ \printfield{series}}%
+ \setunit*{\addspace}%
+ \usebibmacro{issue+date}%
+ \setunit*{\addsemicolon\addspace}%
+ \usebibmacro{volume+number+eid}%
+ \usebibmacro{issue}%
+\newunit}
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.cbx
new file mode 100644
index 0000000000..63ea070960
--- /dev/null
+++ b/macros/latex/contrib/biblatex-contrib/biblatex-vancouver/vancouver.cbx
@@ -0,0 +1,25 @@
+% Copyright (c) 2020 Agnibho Mondal
+% All rights reserved
+%
+% This file is part of BibLaTex Vancouver.
+%
+% BibLaTex Vancouver is free software: you can redistribute it and/or modify it
+% under the terms of the GNU General Public License as published by the Free
+% Software Foundation, either version 3 of the License, or (at your option) any
+% later version.
+%
+% BibLaTex Vancouver is distributed in the hope that it will be useful, but
+% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+% details.
+%
+% You should have received a copy of the GNU General Public License along with
+% BibLaTex Vancouver. If not, see <http://www.gnu.org/licenses/>.
+%
+% Agnibho Mondal
+% contact@agnibho.com
+% www.agnibho.com
+
+\ProvidesFile{vancouver.bbx}[2020/05/20 v0.1 biblatex vancouver]
+
+\RequireCitationStyle{numeric}
diff --git a/macros/luatex/generic/nodetree/README.md b/macros/luatex/generic/nodetree/README.md
index 2b92a67fa2..7f21098f11 100644
--- a/macros/luatex/generic/nodetree/README.md
+++ b/macros/luatex/generic/nodetree/README.md
@@ -1,4 +1,3 @@
-
![nodetree](https://raw.githubusercontent.com/Josef-Friedrich/nodetree/master/graphics/packagename.png)
# Abstract
@@ -19,7 +18,7 @@ terminal to generate the document.
# License
-Copyright (C) 2016 by Josef Friedrich <josef@friedrich.rocks>
+Copyright (C) 2016-2020 by Josef Friedrich <josef@friedrich.rocks>
------------------------------------------------------------------------
This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3 of this license
@@ -102,3 +101,63 @@ Office
![nodetree](https://raw.githubusercontent.com/Josef-Friedrich/nodetree/master/graphics/ligatures.png)
+# Development
+
+First delete the stable version installed by TeX Live. Because the
+package `nodetree` belongs to the collection `collection-latexextra`, the
+option `--force` must be used to delete the package.
+
+ tlmgr remove --force nodetree
+
+## Deploying a new version
+
+Update the version number in the file `nodetree.dtx` on this locations:
+
+### In the markup for the file `nodetree.sty` (approximately at the line number 30)
+
+ %<*package>
+ [2016/07/18 v1.2 Visualize node lists in a tree view]
+ %<*package>
+
+### In the markup for the file `nodetree-embed.sty` (approximately at the line number 220)
+
+ %<*package>
+ [2016/07/18 v1.2 Visualize node lists in a tree view]
+ %<*package>
+
+### In the markup for the package documentation (approximately at the line number 50)
+
+Add a changes entry:
+
+```latex
+\changes{v1.2}{2020/05/20}{...}
+```
+
+### In documentation (documentation.tex) (approximately at the line number 70)
+
+```latex
+\date{v2.0 from 2020/05/29}
+```
+
+### In the file `nodetree.lua` (approximately at the line number 20)
+
+```lua
+if not modules then modules = { } end modules ['nodetree'] = {
+ version = '1.2'
+}
+```
+
+### Update the copyright year:
+
+```
+sed -i 's/(C) 2016-2020/(C) 2016-2021/g' nodetree.ins
+sed -i 's/(C) 2016-2020/(C) 2016-2021/g' nodetree.dtx
+```
+
+### Command line tasks:
+
+```
+git tag -a v1.4
+make
+make ctan
+```
diff --git a/macros/luatex/generic/nodetree/nodetree.dtx b/macros/luatex/generic/nodetree/nodetree.dtx
index 24416e17ce..5b18176843 100644
--- a/macros/luatex/generic/nodetree/nodetree.dtx
+++ b/macros/luatex/generic/nodetree/nodetree.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2016 by Josef Friedrich <josef@friedrich.rocks>
+% Copyright (C) 2016-2020 by Josef Friedrich <josef@friedrich.rocks>
% ----------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3 of this license
@@ -28,648 +28,8 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{nodetree}
%<*package>
- [2016/07/18 v1.2 Visualize node lists in a tree view]
+ [2020/05/29 v2.0 Visualize node lists in a tree view]
%</package>
-%<*driver>
-\documentclass{ltxdoc}
-\usepackage{paralist,fontspec,graphicx,fancyvrb}
-\usepackage[
- colorlinks=true,
- linkcolor=red,
- filecolor=red,
- urlcolor=red,
-]{hyperref}
-%\usepackage{nodetree}
-\EnableCrossrefs
-\CodelineIndex
-\RecordChanges
-
-\setmonofont{DejaVu Sans Mono}
-
-\def\nodetreelua#1{\texttt{\scantokens{\catcode`\_=12\relax#1}}}
-
-\def\secref#1{(\rightarrow\ \ref{#1})}
-
-\newcommand{\tmpgraphics}[1]{
- \noindent
- \includegraphics[scale=0.4]{graphics/#1}
-}
-
-\DefineVerbatimEnvironment{code}{Verbatim}
-{
- frame=single,
- fontsize=\footnotesize,
-}
-
-\begin{document}
-
-\providecommand*{\url}{\texttt}
-\GetFileInfo{nodetree.dtx}
-\title{The \textsf{nodetree} package}
-\author{%
- Josef Friedrich\\%
- \url{josef@friedrich.rocks}\\%
- \href{https://github.com/Josef-Friedrich/nodetree}{github.com/Josef-Friedrich/nodetree}%
-}
-\date{\fileversion~from \filedate}
-
-\maketitle
-
-\noindent
-\includegraphics[width=\linewidth]{graphics/packagename}
-
-\newpage
-
-\tableofcontents
-
-\newpage
-
-%-----------------------------------------------------------------------
-% Abstract
-%-----------------------------------------------------------------------
-
-\section{Abstract}
-
-|nodetree| is a development package that visualizes the structure of
-node lists. |nodetree| shows its debug informations in the consoles’
-output when you compile a Lua\TeX{} file. It uses a similar visual
-representation for node lists as the UNIX |tree| command uses for a
-folder structure.
-
-Node lists are the main building blocks of each document generated by
-the \TeX{} engine \emph{Lua\TeX}. The package |nodetree| doesn‘t change
-the rendered document. The tree view can only be seen when using a
-terminal to generate the document.
-
-|nodetree| is inspired by a
-\href{https://gist.github.com/pgundlach/556247}
-{gist from Patrick Gundlach}.
-
-%-----------------------------------------------------------------------
-% Usage
-%-----------------------------------------------------------------------
-
-\section{Usage}
-
-The package |nodetree| can be used both with Lua\TeX{} and Lua\LaTeX{}.
-You have to use both engines in a text console. Run for example
-|luatex luatex-test.tex| to list the nodes using Lua\TeX{}.
-
-\begin{code}
-\input{nodetree.tex}
-\nodetreeregister{postline}
-
-Lorem ipsum dolor.
-\bye
-\end{code}
-
-Or run |lualatex lualatex-test.tex| to show a node tree using
-Lua\LaTeX{}. In Lua\LaTeX{} you can omit |\nodetreeregister{postline}|.
-|\usepackage{nodetree}| registers automatically the
-|post_linebreak_filter|. If you don’t want debug the
-|post_linebreak_filter| use |\nodetreeunregister{postline}|.
-
-\begin{code}
-\documentclass{article}
-\usepackage{nodetree}
-
-\begin{document}
-Lorem ipsum dolor.
-\end{document}
-\end{code}
-
-%%
-% inside Lua code
-%%
-
-\subsection{Debug nodes inside Lua code}
-
-Use the Lua function |nodetree.analyze(head)| to debug nodes inside your
-Lua code. The following code snippet demonstrates the usage in Lua\TeX{}.
-|head| is the current node.
-
-\begin{code}
-\input{nodetree.tex}
-
-\directlua{
- local test = function (head)
- nodetree.analyze(head)
- end
- callback.register('post_linebreak_filter', test)
-}
-
-Lorem ipsum dolor.
-\bye
-\end{code}
-
-This example illustrates how the function has to be applied in
-Lua\LaTeX{}.
-
-\begin{code}
-\documentclass{article}
-\usepackage{nodetree}
-
-\begin{document}
-
-\directlua{
- local test = function (head)
- nodetree.analyze(head)
- end
- luatexbase.add_to_callback('post_linebreak_filter', test, 'test')
-}
-
-Lorem ipsum dolor.
-\end{document}
-\end{code}
-
-%-----------------------------------------------------------------------
-% Macros
-%-----------------------------------------------------------------------
-
-\section{Macros}
-
-%%
-% \nodetreeregister
-%%
-
-\subsection{\cmd{\nodetreeregister}}
-
-\DescribeMacro{\nodetreeregister}
-\cmd{\nodetreeregister}\marg{callbacks}: The argument \marg{callbacks}
-takes a comma separated list of callback aliases as described in
-\secref{sec:option-callback}.
-
-%%
-% \nodetreeunregister
-%%
-
-\subsection{\cmd{\nodetreeunregister}}
-
-\DescribeMacro{\nodetreeunregister}
-\cmd{\nodetreeunregister}\marg{callbacks}: The argument \marg{callbacks}
-takes a comma separated list of callback aliases as described in
-\secref{sec:option-callback}.
-
-%%
-% \nodetreeoption
-%%
-
-\subsection{\cmd{\nodetreeoption}}
-
-\DescribeMacro{\nodetreeoption}
-\cmd{\nodetreeoption}\oarg{option}\marg{value}: \secref{sec:options}
-This macro sets the option \oarg{option} to the value \marg{value}.
-
-%%
-% \nodetreeset
-%%
-
-\subsection{\cmd{\nodetreeset}}
-
-\DescribeMacro{\nodetreeset}
-\cmd{\nodetreeset}\marg{kv-options}:
-This macro can only be used in Lua\LaTeX{}. \marg{kv-options} are key
-value pairs.
-
-\begin{code}
-\nodetreeset{color=no,callbacks={hpack,vpack},verbosity=2}
-\end{code}
-
-%-----------------------------------------------------------------------
-% Options
-%-----------------------------------------------------------------------
-
-\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. You
-have to specify one alias to select the |callback|. Because of the
-underscores the callback name contains it can not set by its technical
-name (\rightarrow{} Figure \ref{fig:callback}).
-
-This macros process callback options:
-\cmd{\nodetreeregister}\marg{callbacks},
-\cmd{\nodetreeunregister}\marg{callbacks},
-\cmd{\nodetreeset}\marg{callback=<callbacks>} and
-\cmd{\usepackage}\oarg{callback=<callbacks>}\marg{nodetree}.
-
-Use commas to specify mulitple callbacks. Avoid using whitespaces:
-
-\begin{code}
-\nodetreeregister{preline,line,postline}
-\end{code}
-
-Wrap your callback aliases in curly braces for the macro |\nodetreeset|:
-
-\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}
-
-%%
-% Tabular callbacks
-%%
-
-\newcommand{\nodetreecallback}[3]{
- \nodetreelua{#1} & \nodetreelua{#2} & \nodetreelua{#3} \\
-}
-
-\begin{figure}
-
-\noindent
-\begin{tabular}{lll}
-\textbf{Alias (short)} & \textbf{Alias (longer)} & \textbf{Callback} \\
-\nodetreecallback{contribute}{contributefilter}{contribute_filter}
-\nodetreecallback{buildpage}{buildpagefilter}{buildpage_filter}
-\nodetreecallback{preline}{prelinebreakfilter}{pre_linebreak_filter}
-\nodetreecallback{line}{linebreakfilter}{linebreak_filter}
-\nodetreecallback{append}{appendtovlistfilter}{append_to_vlist_filter}
-\nodetreecallback{postline}{postlinebreakfilter}{post_linebreak_filter}
-\nodetreecallback{hpack}{hpackfilter}{hpack_filter}
-\nodetreecallback{vpack}{vpackfilter}{vpack_filter}
-\nodetreecallback{hpackq}{hpackquality}{hpack_quality}
-\nodetreecallback{vpackq}{vpackquality}{vpack_quality}
-\nodetreecallback{process}{processrule}{process_rule}
-\nodetreecallback{preout}{preoutputfilter}{pre_output_filter}
-\nodetreecallback{hyph}{hyphenate}{hyphenate}
-\nodetreecallback{liga}{ligaturing}{ligaturing}
-\nodetreecallback{kern}{kerning}{kerning}
-\nodetreecallback{insert}{insertlocalpar}{insert_local_par}
-\nodetreecallback{mhlist}{mlisttohlist}{mlist_to_hlist}
-\end{tabular}
-
-\caption{The callback aliases}
-\label{fig:callback}
-\end{figure}
-
-%%
-% verbosity
-%%
-
-\subsection{Option \texttt{verbosity}}
-
-Higher integer values result in a more verbose output. The default value
-for this options is |1|. At the moment only verbosity level |2| is
-implemented.
-
-%%
-% color
-%%
-
-\subsection{Option \texttt{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}}
-
-The option |unit| sets the length unit to display all length values of
-the nodes. The default option for |unit| is |pt|. See figure
-\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}
-
-%%
-% decimalplaces
-%%
-
-\subsection{Option \texttt{decimalplaces}}
-
-The options |decimalplaces| sets the number of decimal places for some
-node fields.
-
-\begin{code}
-\nodetreeoption[decimalplaces]{4}
-\end{code}
-
-gets
-
-\begin{code}
-├─GLYPH char: "a"; width: 5pt; height: 4.3055pt;
-\end{code}
-
-If |decimalplaces| is set to |0| only integer values are shown.
-
-\begin{code}
-├─GLYPH char: "a"; width: 5pt; height: 4pt;
-\end{code}
-
-%-----------------------------------------------------------------------
-% Visual tree structure
-%-----------------------------------------------------------------------
-
-\section{Visual tree structure}
-
-%%
-% Two different connections
-%%
-
-\subsection{Two different connections}
-
-Nodes in Lua\TeX{} are connected. The |nodetree| package distinguishs
-between the |list| and |field| connections.
-
-\begin{itemize}
- \item |list|: Nodes, which are double connected by |next| and
- |previous| fields.
- \item |field|: Connections to nodes by other fields than |next| and
- |previous| fields, e. g. |head|, |pre|.
-\end{itemize}
-
-%%
-% Unicode characters
-%%
-
-\subsection{Unicode characters to show the tree view}
-
-\renewcommand{\arraystretch}{1.5}
-
-The package |nodetree| uses the unicode box drawing symbols. Your
-default terminal font should contain this characters to obtain the tree
-view. Eight box drawing characters are necessary.
-
-\noindent
-\begin{tabular}{lcl}
-\textbf{Code} & \textbf{Character} & \textbf{Name} \\
-U+2500 & |─| & BOX DRAWINGS LIGHT HORIZONTAL \\
-U+2502 & |│| & BOX DRAWINGS LIGHT VERTICAL \\
-U+2514 & |└| & BOX DRAWINGS LIGHT UP AND RIGHT \\
-U+251C & |├| & BOX DRAWINGS LIGHT VERTICAL AND RIGHT \\
-U+2550 & |═| & BOX DRAWINGS DOUBLE HORIZONTAL \\
-U+2551 & |║| & BOX DRAWINGS DOUBLE VERTICAL \\
-U+255A & |╚| & BOX DRAWINGS DOUBLE UP AND RIGHT \\
-U+2560 & |╠| & BOX DRAWINGS DOUBLE VERTICAL AND RIGHT \\
-\end{tabular}
-
-For |list| connections \emph{light} characters are shown.
-
-\begin{code}
-│ │
-│ ├─list1
-│ └─list2
-└─list3
-\end{code}
-
-|field| connections are visialized by \emph{Double} characters.
-
-\begin{code}
-║ ║
-║ ╠═field1
-║ ╚═field2
-╚═field3
-\end{code}
-
-%-----------------------------------------------------------------------
-% Examples
-%-----------------------------------------------------------------------
-
-\newpage
-
-\section{Examples}
-
-%%
-% packagename
-%%
-
-\subsection{The node list of the package name}
-
-\begin{code}
-\documentclass{article}
-\usepackage{nodetree}
-\begin{document}
-nodetree
-\end{document}
-\end{code}
-
-\tmpgraphics{packagename}
-
-%%
-% math
-%%
-
-\newpage
-
-\subsection{The node list of a mathematical formula}
-
-\begin{code}
-\documentclass{article}
-\usepackage[callback={mhlist}]{nodetree}
-\begin{document}
-\[\left(a\right)\left[\frac{b}{a}\right]=a\,\]
-\end{document}
-\end{code}
-
-\tmpgraphics{math}
-
-%%
-% ligatures
-%%
-
-\newpage
-
-\subsection{The node list of the word \emph{Office}}
-
-The characters \emph{ffi} are deeply nested in a discretionary node.
-
-\begin{code}
-\documentclass{article}
-\usepackage{nodetree}
-\begin{document}
-Office
-\end{document}
-\end{code}
-
-\tmpgraphics{ligatures}
-
-%-----------------------------------------------------------------------
-% Index
-%-----------------------------------------------------------------------
-
- \DocInput{nodetree.dtx}
- \pagebreak
- \PrintChanges
- \pagebreak
- \PrintIndex
-\end{document}
-%</driver>
-%<*readme>
-
-![nodetree](https://raw.githubusercontent.com/Josef-Friedrich/nodetree/master/graphics/packagename.png)
-
-# Abstract
-
-`nodetree` is a development package that visualizes the structure of
-node lists. `nodetree` shows its debug informations in the consoles’
-output when you compile a LuaTeX file. It uses a similar visual
-representation for node lists as the UNIX `tree` command uses for a
-folder structure.
-
-Node lists are the main building blocks of each document generated by
-the TeX engine LuaTeX. The package `nodetree` doesn‘t change
-the rendered document. The tree view can only be seen when using a
-terminal to generate the document.
-
-`nodetree` is inspired by a
-[gist from Patrick Gundlach](https://gist.github.com/pgundlach/556247).
-
-# License
-
-Copyright (C) 2016 by Josef Friedrich <josef@friedrich.rocks>
-------------------------------------------------------------------------
-This work may be distributed and/or modified under the conditions of
-the LaTeX Project Public License, either version 1.3 of this license
-or (at your option) any later version. The latest version of this
-license is in:
-
- http://www.latex-project.org/lppl.txt
-
-and version 1.3 or later is part of all distributions of LaTeX
-version 2005/12/01 or later.
-
-# CTAN
-
-Since July 2016 the cloze package is included in the Comprehensive TeX
-Archive Network (CTAN).
-
-* TeX archive: http://mirror.ctan.org/tex-archive/macros/luatex/generic/nodetree
-* Package page: http://www.ctan.org/pkg/nodetree
-
-# Repository
-
-https://github.com/Josef-Friedrich/nodetree
-
-# Installation
-
-Get source:
-
- git clone git@github.com:Josef-Friedrich/nodetree.git
- cd nodetree
-
-Compile:
-
- make
-
-or manually:
-
- luatex nodetree.ins
- lualatex nodetree.dtx
- makeindex -s gglo.ist -o nodetree.gls nodetree.glo
- makeindex -s gind.ist -o nodetree.ind nodetree.idx
- lualatex nodetree.dtx
-
-# Examples
-
-## The node list of the package name
-
-```latex
-\documentclass{article}
-\usepackage{nodetree}
-\begin{document}
-nodetree
-\end{document}
-```
-
-![nodetree](graphics/packagename.png)
-
-## The node list of a mathematical formula
-
-```latex
-\documentclass{article}
-\usepackage[callback={mhlist}]{nodetree}
-\begin{document}
-\[\left(a\right)\left[\frac{b}{a}\right]=a\,\]
-\end{document}
-```
-
-![nodetree](https://raw.githubusercontent.com/Josef-Friedrich/nodetree/master/graphics/math.png)
-
-## The node list of the word 'Office'
-
-The characters 'ffi' are deeply nested in a discretionary node.
-
-```latex
-\documentclass{article}
-\usepackage{nodetree}
-\begin{document}
-Office
-\end{document}
-```
-
-![nodetree](https://raw.githubusercontent.com/Josef-Friedrich/nodetree/master/graphics/ligatures.png)
-
-%</readme>
% \fi
%
% \CheckSum{0}
@@ -695,6 +55,16 @@ Office
% \changes{v1.0}{2016/07/07}{Inital release}
% \changes{v1.1}{2016/07/13}{Fix the registration of same callbacks}
% \changes{v1.2}{2016/07/18}{Fix difference between README.md in the upload and that from nodetree.dtx}
+% \changes{v2.0}{2020/05/29}{
+% * Switch from lowercase macro names to PascalCase names for better readability.
+% * The Lua code is no longer developed inside the DTX file, instead in a separate file named nodetree.lua.
+% * Add a sub package named nodetree-embed.sty for embedding nodetree views into a \LaTeX{} document.
+% * Add support for new node subtype names.
+% * Add support for a new Lua\TeX{} node callback.
+% * Add support for node properties.
+% * Less verbose representation of node attributes.
+% * Minor tree output adjustments.
+% }
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\directlua}
%
@@ -716,40 +86,68 @@ Office
% \begin{macrocode}
\directlua{
nodetree = require('nodetree')
- nodetree.set_option('engine', 'luatex')
- nodetree.set_default_options()
}
% \end{macrocode}
%
-% \begin{macro}{\nodetreeoption}
+% \begin{macro}{\NodetreeSetOption}
% \begin{macrocode}
-\def\nodetreeoption[#1]#2{
+\def\NodetreeSetOption[#1]#2{
\directlua{
nodetree.set_option('#1', '#2')
}
}
+\let\nodetreeoption\NodetreeSetOption
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NodetreeResetOption}
+% \begin{macrocode}
+\def\NodetreeResetOption#1{
+ \NodetreeSetOption[#1]{%
+ \directlua{
+ tex.print(nodetree.get_default_option('#1'))
+ }%
+ }%
+}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\nodetreeregister}
+% \begin{macro}{\NodetreeReset}
% \begin{macrocode}
-\def\nodetreeregister#1{
+\def\NodetreeReset{
+ \NodetreeResetOption{callback}
+ \NodetreeResetOption{channel}
+ \NodetreeResetOption{color}
+ \NodetreeResetOption{decimalplaces}
+ \NodetreeResetOption{engine}
+ \NodetreeResetOption{unit}
+ \NodetreeResetOption{verbosity}
+}
+\let\nodetreereset\NodetreeReset
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NodetreeRegisterCallback}
+% \begin{macrocode}
+\def\NodetreeRegisterCallback#1{
\directlua{
nodetree.set_option('callback', '#1')
nodetree.register_callbacks()
}
}
+\let\nodetreeregister\NodetreeRegisterCallback
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\nodetreeunregister}
+% \begin{macro}{\NodetreeUnregisterCallback}
% \begin{macrocode}
-\def\nodetreeunregister#1{
+\def\NodetreeUnregisterCallback#1{
\directlua{
nodetree.set_option('callback', '#1')
nodetree.unregister_callbacks()
}
}
+\let\nodetreeunregister\NodetreeUnregisterCallback
% \end{macrocode}
% \end{macro}
%
@@ -765,9 +163,6 @@ Office
%
% \begin{macrocode}
\input{nodetree}
-\directlua{
- nodetree.set_option('engine', 'lualatex')
-}
% \end{macrocode}
%
% \begin{macrocode}
@@ -777,1233 +172,303 @@ Office
% \begin{macrocode}
\SetupKeyvalOptions{
family=NT,
- prefix=NT@
+ prefix=NTK@
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[term]{channel}
-\define@key{NT}{channel}[]{\nodetreeoption[channel]{#1}}
+\define@key{NT}{channel}[]{\NodetreeSetOption[channel]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[postlinebreak]{callback}
-\define@key{NT}{callback}[]{\nodetreeoption[callback]{#1}}
+\define@key{NT}{callback}[]{\NodetreeSetOption[callback]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[1]{verbosity}
-\define@key{NT}{verbosity}[]{\nodetreeoption[verbosity]{#1}}
+\define@key{NT}{verbosity}[]{\NodetreeSetOption[verbosity]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[colored]{color}
-\define@key{NT}{color}[]{\nodetreeoption[color]{#1}}
+\define@key{NT}{color}[]{\NodetreeSetOption[color]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[1]{unit}
-\define@key{NT}{unit}[]{\nodetreeoption[unit]{#1}}
+\define@key{NT}{unit}[]{\NodetreeSetOption[unit]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareStringOption[1]{decimalplaces}
-\define@key{NT}{decimalplaces}[]{\nodetreeoption[decimalplaces]{#1}}
+\define@key{NT}{decimalplaces}[]{\NodetreeSetOption[decimalplaces]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-\ProcessKeyvalOptions*
+\ProcessKeyvalOptions{NT}
\directlua{
- nodetree.set_default_options()
nodetree.register_callbacks()
}
% \end{macrocode}
%
-% \begin{macro}{\nodetreeset}
+% \begin{macro}{\NodetreeSet}
% \begin{macrocode}
-\newcommand{\nodetreeset}[1]{\setkeys{nodetree}{#1}}
+\newcommand{\NodetreeSet}[1]{%
+ \setkeys{NT}{#1}%
+}
+\let\nodetreeset\NodetreeSet
% \end{macrocode}
% \end{macro}
%
% \iffalse
%</package>
-%<*luamain>
+%<*packageembed>
% \fi
-%
-% \makeatletter
-% \c@CodelineNo 0 \relax
-% \makeatother
-%
-% \subsection{The file \tt{nodetree.lua}}
-%
-% \begin{macrocode}
-local nodex = {}
-% \end{macrocode}
-%
-% \begin{macrocode}
-local tpl = {}
-% \end{macrocode}
-%
-% \begin{macrocode}
-local tree = {}
-% \end{macrocode}
-%
-% Nodes in Lua\TeX{} are connected. The nodetree view distinguishs
-% between the |list| and |field| connections.
-%
-% \begin{itemize}
-% \item |list|: Nodes, which are double connected by |next| and
-% |previous| fields.
-% \item |field|: Connections to nodes by other fields than |next| and
-% |previous| fields, e. g. |head|, |pre|.
-% \end{itemize}
-%
-% The lua table named |tree.state| holds state values for the current
-% tree item.
-%
-% \begin{code}
-% tree.state:
-% - 1:
-% - list: continue
-% - field: stop
-% - 2:
-% - list: continue
-% - field: stop
-% \end{code}
-% \begin{macrocode}
-tree.state = {}
-% \end{macrocode}
-%
-% \begin{macrocode}
-local callbacks = {}
-% \end{macrocode}
-%
-% \begin{macrocode}
-local base = {}
-% \end{macrocode}
-%
-% \begin{macrocode}
-local options = {}
-% \end{macrocode}
-%
-% \subsubsection{nodex --- Extend the node library}
-%
-% Get the node id form, e. g.:
-% \begin{code}
-% <node nil < 172 > nil : hlist 2>
-% \end{code}
-% \begin{macrocode}
-function nodex.node_id(n)
- return string.gsub(tostring(n), '^<node%s+%S+%s+<%s+(%d+).*', '%1')
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function nodex.subtype(n)
- local typ = node.type(n.id)
- local subtypes = {
-% \end{macrocode}
-% \paragraph{hlist (0)}
-% \begin{macrocode}
- hlist = {
- [0] = 'unknown',
- [1] = 'line',
- [2] = 'box',
- [3] = 'indent',
- [4] = 'alignment',
- [5] = 'cell',
- [6] = 'equation',
- [7] = 'equationnumber',
- },
-% \end{macrocode}
-% \paragraph{vlist (1)}
-% \begin{macrocode}
- vlist = {
- [0] = 'unknown',
- [4] = 'alignment',
- [5] = 'cell',
- },
-% \end{macrocode}
-% \paragraph{rule (2)}
-% \begin{macrocode}
- rule = {
- [0] = 'unknown',
- [1] = 'box',
- [2] = 'image',
- [3] = 'empty',
- [4] = 'user',
- },
-% \end{macrocode}
-%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item ins (3)
-% \item mark (4)
-% \end{compactitem}
-% \begin{macrocode}
-% \end{macrocode}
-% \paragraph{adjust (5)}
-% \begin{macrocode}
- adjust = {
- [0] = 'normal',
- [1] = 'pre',
- },
-% \end{macrocode}
-% \paragraph{boundary (6)}
-% \begin{macrocode}
- boundary = {
- [0] = 'cancel',
- [1] = 'user',
- [2] = 'protrusion',
- [3] = 'word',
- },
-% \end{macrocode}
-% \paragraph{disc (7)}
-% \begin{macrocode}
- disc = {
- [0] = 'discretionary',
- [1] = 'explicit',
- [2] = 'automatic',
- [3] = 'regular',
- [4] = 'first',
- [5] = 'second',
- },
-% \end{macrocode}
-%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item whatsit (8)
-% \item local\_par (9)
-% \item dir (10)
-% \end{compactitem}
-%
-% \paragraph{math (11)}
-% \begin{macrocode}
- math = {
- [0] = 'beginmath',
- [1] = 'endmath',
- },
-% \end{macrocode}
-% \paragraph{glue (12)}
-% \begin{macrocode}
- glue = {
- [0] = 'userskip',
- [1] = 'lineskip',
- [2] = 'baselineskip',
- [3] = 'parskip',
- [4] = 'abovedisplayskip',
- [5] = 'belowdisplayskip',
- [6] = 'abovedisplayshortskip',
- [7] = 'belowdisplayshortskip',
- [8] = 'leftskip',
- [9] = 'rightskip',
- [10] = 'topskip',
- [11] = 'splittopskip',
- [12] = 'tabskip',
- [13] = 'spaceskip',
- [14] = 'xspaceskip',
- [15] = 'parfillskip',
- [16] = 'mathskip',
- [17] = 'thinmuskip',
- [18] = 'medmuskip',
- [19] = 'thickmuskip',
- [98] = 'conditionalmathskip',
- [99] = 'muglue',
- [100] = 'leaders',
- [101] = 'cleaders',
- [102] = 'xleaders',
- [103] = 'gleaders',
- },
-% \end{macrocode}
-% \paragraph{kern (13)}
-% \begin{macrocode}
- kern = {
- [0] = 'fontkern',
- [1] = 'userkern',
- [2] = 'accentkern',
- [3] = 'italiccorrection',
- },
-% \end{macrocode}
-%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item penalty (14)
-% \item unset (15)
-% \item style (16)
-% \item choice (17)
-% \end{compactitem}
-%
-% \paragraph{noad (18)}
% \begin{macrocode}
- noad = {
- [0] = 'ord',
- [1] = 'opdisplaylimits',
- [2] = 'oplimits',
- [3] = 'opnolimits',
- [4] = 'bin',
- [5] = 'rel',
- [6] = 'open',
- [7] = 'close',
- [8] = 'punct',
- [9] = 'inner',
- [10] = 'under',
- [11] = 'over',
- [12] = 'vcenter',
- },
-% \end{macrocode}
-% \paragraph{radical (19)}
-% \begin{macrocode}
- radical = {
- [0] = 'radical',
- [1] = 'uradical',
- [2] = 'uroot',
- [3] = 'uunderdelimiter',
- [4] = 'uoverdelimiter',
- [5] = 'udelimiterunder',
- [6] = 'udelimiterover',
- },
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{nodetree-embed}
+ [2020/05/29 v2.0 Embed node trees into a LaTeX document]
% \end{macrocode}
%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item fraction (20)
-% \end{compactitem}
-%
-% \paragraph{accent (21)}
-% \begin{macrocode}
- accent = {
- [0] = 'bothflexible',
- [1] = 'fixedtop',
- [2] = 'fixedbottom',
- [3] = 'fixedboth',
- },
-% \end{macrocode}
-% \paragraph{fence (22)}
% \begin{macrocode}
- fence = {
- [0] = 'unset',
- [1] = 'left',
- [2] = 'middle',
- [3] = 'right',
- },
+\RequirePackage{xcolor,mdframed,expl3,xparse,fontspec}
% \end{macrocode}
%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item math\_char (23)
-% \item sub\_box (24)
-% \item sub\_mlist (25)
-% \item math\_text\_char (26)
-% \item delim (27)
-% \item margin\_kern (28)
-% \end{compactitem}
-%
-% \paragraph{glyph (29)}
% \begin{macrocode}
- glyph = {
- [0] = 'character',
- [1] = 'ligature',
- [2] = 'ghost',
- [3] = 'left',
- [4] = 'right',
- },
-% \end{macrocode}
-%
-% \noindent
-% Nodes without subtypes:
-% \begin{compactitem}
-% \item align\_record (30)
-% \item pseudo\_file (31)
-% \item pseudo\_line (32)
-% \item page\_insert (33)
-% \item split\_insert (34)
-% \item expr\_stack (35)
-% \item nested\_list (36)
-% \item span (37)
-% \item attribute (38)
-% \item glue\_spec (39)
-% \item attribute\_list (40)
-% \item temp (41)
-% \item align\_stack (42)
-% \item movement\_stack (43)
-% \item if\_stack (44)
-% \item unhyphenated (45)
-% \item hyphenated (46)
-% \item delta (47)
-% \item passive (48)
-% \item shape (49)
-% \end{compactitem}
-% \begin{macrocode}
- }
- subtypes.whatsit = node.whatsits()
- local out = ''
- if subtypes[typ] and subtypes[typ][n.subtype] then
- out = subtypes[typ][n.subtype]
- if options.verbosity > 1 then
- out = out .. tpl.type_id(n.subtype)
- end
- return out
- else
- return tostring(n.subtype)
- end
- assert(false)
-end
-% \end{macrocode}
-%
-% \subsubsection{tpl --- Template function}
-%
-% \begin{macrocode}
-function tpl.round(number)
- local mult = 10^(options.decimalplaces or 0)
- return math.floor(number * mult + 0.5) / mult
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.length(input)
- input = tonumber(input)
- input = input / tex.sp('1' .. options.unit)
- return string.format('%g%s', tpl.round(input), options.unit)
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.fill(number, order, field)
- if order ~= nil and order ~= 0 then
- if field == 'stretch' then
- out = '+'
- else
- out = '-'
- end
- return out .. string.format(
- '%gfi%s', number / 2^16,
- string.rep('l', order - 1)
- )
- else
- return tpl.length(number)
- end
-end
+\input{nodetree}
% \end{macrocode}
%
% \begin{macrocode}
-tpl.node_colors = {
- hlist = {'red', 'bright'},
- vlist = {'green', 'bright'},
- rule = {'blue', 'bright'},
- ins = {'blue'},
- mark = {'magenta'},
- adjust = {'cyan'},
- boundary = {'red', 'bright'},
- disc = {'green', 'bright'},
- whatsit = {'yellow', 'bright'},
- local_par = {'blue', 'bright'},
- dir = {'magenta', 'bright'},
- math = {'cyan', 'bright'},
- glue = {'magenta', 'bright'},
- kern = {'green', 'bright'},
- penalty = {'yellow', 'bright'},
- unset = {'blue'},
- style = {'magenta'},
- choice = {'cyan'},
- noad = {'red'},
- radical = {'green'},
- fraction = {'yellow'},
- accent = {'blue'},
- fence = {'magenta'},
- math_char = {'cyan'},
- sub_box = {'red', 'bright'},
- sub_mlist = {'green', 'bright'},
- math_text_char = {'yellow', 'bright'},
- delim = {'blue', 'bright'},
- margin_kern = {'magenta', 'bright'},
- glyph = {'cyan', 'bright'},
- align_record = {'red'},
- pseudo_file = {'green'},
- pseudo_line = {'yellow'},
- page_insert = {'blue'},
- split_insert = {'magenta'},
- expr_stack = {'cyan'},
- nested_list = {'red'},
- span = {'green'},
- attribute = {'yellow'},
- glue_spec = {'magenta'},
- attribute_list = {'cyan'},
- temp = {'magenta'},
- align_stack = {'red', 'bright'},
- movement_stack = {'green', 'bright'},
- if_stack = {'yellow', 'bright'},
- unhyphenated = {'magenta', 'bright'},
- hyphenated = {'cyan', 'bright'},
- delta = {'red'},
- passive = {'green'},
- shape = {'yellow'},
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{
+ family=NTE,
+ prefix=NTEK@
}
% \end{macrocode}
%
% \begin{macrocode}
-function tpl.color_code(code)
- return string.char(27) .. '[' .. tostring(code) .. 'm'
-end
-% \end{macrocode}
-%
-% \begin{code}
-% local colors = {
-% -- attributes
-% reset = 0,
-% clear = 0,
-% bright = 1,
-% dim = 2,
-% underscore = 4,
-% blink = 5,
-% reverse = 7,
-% hidden = 8,
-%
-% -- foreground
-% black = 30,
-% red = 31,
-% green = 32,
-% yellow = 33,
-% blue = 34,
-% magenta = 35,
-% cyan = 36,
-% white = 37,
-%
-% -- background
-% onblack = 40,
-% onred = 41,
-% ongreen = 42,
-% onyellow = 43,
-% onblue = 44,
-% onmagenta = 45,
-% oncyan = 46,
-% onwhite = 47,
-% }
-% \end{code}
-% \begin{macrocode}
-function tpl.color(color, mode, background)
- if options.color ~= 'colored' then
- return ''
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- local out = ''
- local code = ''
-% \end{macrocode}
-%
-% \begin{macrocode}
- if mode == 'bright' then
- out = tpl.color_code(1)
- elseif mode == 'dim' then
- out = tpl.color_code(2)
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- if not background then
- if color == 'reset' then code = 0
- elseif color == 'red' then code = 31
- elseif color == 'green' then code = 32
- elseif color == 'yellow' then code = 33
- elseif color == 'blue' then code = 34
- elseif color == 'magenta' then code = 35
- elseif color == 'cyan' then code = 36
- else code = 37 end
- else
- if color == 'black' then code = 40
- elseif color == 'red' then code = 41
- elseif color == 'green' then code = 42
- elseif color == 'yellow' then code = 43
- elseif color == 'blue' then code = 44
- elseif color == 'magenta' then code = 45
- elseif color == 'cyan' then code = 46
- elseif color == 'white' then code = 47
- else code = 40 end
- end
- return out .. tpl.color_code(code)
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.key_value(key, value)
- local out = tpl.color('yellow') .. key .. ': '
- if value then
- out = out .. tpl.color('white') .. value .. '; '
- end
- return out .. tpl.color('reset')
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.char(input)
- return string.format('%q', unicode.utf8.char(input))
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.type(type, id)
- local out = tpl.color(
- tpl.node_colors[type][1],
- tpl.node_colors[type][2]
- )
- .. string.upper(type)
- if options.verbosity > 1 then
- out = out .. tpl.type_id(id)
- end
- return out .. tpl.color('reset') .. ' '
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.callback_variable(variable_name, variable)
- if variable ~= nil and variable ~= '' then
- tpl.print(variable_name .. ': ' .. tostring(variable))
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.line(length)
- if length == 'long' then
- return '------------------------------------------'
- else
- return '-----------------------'
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.callback(callback_name, variables)
- tpl.print('\n\n')
- tpl.print('Callback: ' .. tpl.color('red', '', true) ..
- callback_name .. tpl.color('reset')
- )
- if variables then
- for name, value in pairs(variables) do
- if value ~= nil and value ~= '' then
- tpl.print(' - ' .. name .. ': ' .. tostring(value))
- end
- end
- end
- tpl.print(tpl.line('long'))
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.type_id(id)
- return '[' .. tostring(id) .. ']'
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.branch(connection_type, connection_state, last)
- local c = connection_type
- local s = connection_state
- local l = last
- if c == 'list' and s == 'stop' and l == false then
- return ' '
- elseif c == 'field' and s == 'stop' and l == false then
- return ' '
- elseif c == 'list' and s == 'continue' and l == false then
- return '│ '
- elseif c == 'field' and s == 'continue' and l == false then
- return '║ '
- elseif c == 'list' and s == 'continue' and l == true then
- return '├─'
- elseif c == 'field' and s == 'continue' and l == true then
- return '╠═'
- elseif c == 'list' and s == 'stop' and l == true then
- return '└─'
- elseif c == 'field' and s == 'stop' and l == true then
- return '╚═'
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.branches(level, connection_type)
- local out = ''
- for i = 1, level - 1 do
- out = out .. tpl.branch('list', tree.state[i]['list'], false)
- out = out .. tpl.branch('field', tree.state[i]['field'], false)
- end
-% \end{macrocode}
-% Format the last branches
-% \begin{macrocode}
- if connection_type == 'list' then
- out = out .. tpl.branch('list', tree.state[level]['list'], true)
- else
- out = out .. tpl.branch('list', tree.state[level]['list'], false)
- out = out .. tpl.branch('field', tree.state[level]['field'], true)
- end
- return out
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tpl.print(text)
-
- if options.channel == 'log' then
- if not log then
- log = io.open(tex.jobname .. '_nodetree.log', 'a')
- end
- log:write(text, '\n')
- else
- print(' ' .. text)
- end
-end
-% \end{macrocode}
-%
-% \subsubsection{tree --- Build the node tree}
-%
-% \begin{macrocode}
-function tree.format_field(head, field)
- local out = ''
-% \end{macrocode}
-%
-% \begin{macrocode}
- if not head[field] or head[field] == 0 then
- return ''
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- if options.verbosity < 2 and
- -- glyph
- field == 'font' or
- field == 'left' or
- field == 'right' or
- field == 'uchyph' or
- -- hlist
- field == 'dir' or
- field == 'glue_order' or
- field == 'glue_sign' or
- field == 'glue_set' or
- -- glue
- field == 'stretch_order' then
- return ''
- elseif options.verbosity < 3 and
- field == 'prev' or
- field == 'next' or
- field == 'id'
- then
- return ''
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- if field == 'prev' or field == 'next' then
- out = nodex.node_id(head[field])
- elseif field == 'subtype' then
- out = nodex.subtype(head)
- elseif
- field == 'width' or
- field == 'height' or
- field == 'depth' or
- field == 'kern' or
- field == 'shift' then
- out = tpl.length(head[field])
- elseif field == 'char' then
- out = tpl.char(head[field])
- elseif field == 'glue_set' then
- out = tpl.round(head[field])
- elseif field == 'stretch' or field == 'shrink' then
- out = tpl.fill(head[field], head[field .. '_order'], field)
- else
- out = tostring(head[field])
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- return tpl.key_value(field, out)
-end
-% \end{macrocode}
-%
-% |level| is a integer beginning with 1. The variable |connection_type|
-% is a string, which can be either |list| or |field|. The variable
-% |connection_state| is a string, which can be either |continue| or
-% |stop|.
-% \begin{macrocode}
-function tree.set_state(level, connection_type, connection_state)
- if not tree.state[level] then
- tree.state[level] = {}
- end
- tree.state[level][connection_type] = connection_state
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tree.analyze_fields(fields, level)
- local max = 0
- local connection_state = ''
- for _ in pairs(fields) do
- max = max + 1
- end
- local count = 0
- for field_name, recursion_node in pairs(fields) do
- count = count + 1
- if count == max then
- connection_state = 'stop'
- else
- connection_state = 'continue'
- end
- tree.set_state(level, 'field', connection_state)
- tpl.print(tpl.branches(level, 'field') .. tpl.key_value(field_name))
- tree.analyze_list(recursion_node, level + 1)
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tree.analyze_node(head, level)
- local connection_state
- local out = ''
- if head.next then
- connection_state = 'continue'
- else
- connection_state = 'stop'
- end
- tree.set_state(level, 'list', connection_state)
- out = tpl.branches(level, 'list')
- .. tpl.type(node.type(head.id), head.id)
- if options.verbosity > 1 then
- out = out .. tpl.key_value('no', nodex.node_id(head))
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- local fields = {}
- for field_id, field_name in pairs(node.fields(head.id, head.subtype)) do
- if field_name ~= 'next' and
- field_name ~= 'prev' and
- node.is_node(head[field_name]) then
- fields[field_name] = head[field_name]
- else
- out = out .. tree.format_field(head, field_name)
- end
- end
-% \end{macrocode}
-%
-% \begin{macrocode}
- tpl.print(out)
- tree.analyze_fields(fields, level)
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tree.analyze_list(head, level)
- while head do
- tree.analyze_node(head, level)
- head = head.next
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function tree.analyze_callback(head)
- tree.analyze_list(head, 1)
- tpl.print(tpl.line('short') .. '\n')
-end
-% \end{macrocode}
-%
-% \subsubsection{callbacks --- Callback wrapper}
-%
-% \begin{macrocode}
-function callbacks.contribute_filter(extrainfo)
- tpl.callback('contribute_filter', {extrainfo = extrainfo})
- return true
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function callbacks.buildpage_filter(extrainfo)
- tpl.callback('buildpage_filter', {extrainfo = extrainfo})
- return true
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function callbacks.pre_linebreak_filter(head, groupcode)
- tpl.callback('pre_linebreak_filter', {groupcode = groupcode})
- tree.analyze_callback(head)
- return true
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function callbacks.linebreak_filter(head, is_display)
- tpl.callback('linebreak_filter', {is_display = is_display})
- tree.analyze_callback(head)
- return true
-end
-% \end{macrocode}
-%
-% TODO: Fix return values, page output
-% \begin{macrocode}
-function callbacks.append_to_vlist_filter(head, locationcode, prevdepth, mirrored)
- local variables = {
- locationcode = locationcode,
- prevdepth = prevdepth,
- mirrored = mirrored,
- }
- tpl.callback('append_to_vlist_filter', variables)
- tree.analyze_callback(head)
- return true
-end
+\directlua{
+ nodetree = require('nodetree')
+ nodetree.check_shell_escape()
+}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.post_linebreak_filter(head, groupcode)
- tpl.callback('post_linebreak_filter', {groupcode = groupcode})
- tree.analyze_callback(head)
- return true
-end
+\define@key{NTE}{callback}[]{\NodetreeSetOption[callback]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.hpack_filter(head, groupcode, size, packtype, direction, attributelist)
- local variables = {
- groupcode = groupcode,
- size = size,
- packtype = packtype,
- direction = direction,
- attributelist = attributelist,
- }
- tpl.callback('hpack_filter', variables)
- tree.analyze_callback(head)
- return true
-end
+\DeclareStringOption[1]{verbosity}
+\define@key{NTE}{verbosity}[]{\NodetreeSetOption[verbosity]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.vpack_filter(head, groupcode, size, packtype, maxdepth, direction, attributelist)
- local variables = {
- groupcode = groupcode,
- size = size,
- packtype = packtype,
- maxdepth = tpl.length(maxdepth),
- direction = direction,
- attributelist = attributelist,
- }
- tpl.callback('vpack_filter', variables)
- tree.analyze_callback(head)
- return true
-end
+\DeclareStringOption[colored]{color}
+\define@key{NTE}{color}[]{\NodetreeSetOption[color]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.hpack_quality(incident, detail, head, first, last)
- local variables = {
- incident = incident,
- detail = detail,
- first = first,
- last = last,
- }
- tpl.callback('hpack_quality', variables)
- tree.analyze_callback(head)
-end
+\DeclareStringOption[1]{unit}
+\define@key{NTE}{unit}[]{\NodetreeSetOption[unit]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.vpack_quality(incident, detail, head, first, last)
- local variables = {
- incident = incident,
- detail = detail,
- first = first,
- last = last,
- }
- tpl.callback('vpack_quality', variables)
- tree.analyze_callback(head)
-end
+\DeclareStringOption[1]{decimalplaces}
+\define@key{NTE}{decimalplaces}[]{\NodetreeSetOption[decimalplaces]{#1}}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.process_rule(head, width, height)
- local variables = {
- width = width,
- height = height,
- }
- tpl.callback('process_rule', variables)
- tree.analyze_callback(head)
- return true
-end
+\DeclareStringOption[monokaisoda]{theme}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.pre_output_filter(head, groupcode, size, packtype, maxdepth, direction)
- local variables = {
- groupcode = groupcode,
- size = size,
- packtype = packtype,
- maxdepth = maxdepth,
- direction = direction,
- }
- tpl.callback('pre_output_filter', variables)
- tree.analyze_callback(head)
- return true
-end
+\DeclareStringOption[dark]{thememode}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.hyphenate(head, tail)
- tpl.callback('hyphenate')
- tpl.print('head:')
- tree.analyze_callback(head)
- tpl.print('tail:')
- tree.analyze_callback(tail)
-end
+\DeclareStringOption[Ubuntu Mono]{font}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.ligaturing(head, tail)
- tpl.callback('ligaturing')
- tpl.print('head:')
- tree.analyze_callback(head)
- tpl.print('tail:')
- tree.analyze_callback(tail)
-end
+\DeclareStringOption[\footnotesize]{fontsize}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.kerning(head, tail)
- tpl.callback('kerning')
- tpl.print('head:')
- tree.analyze_callback(head)
- tpl.print('tail:')
- tree.analyze_callback(tail)
-end
+\DeclareBoolOption{showmarkup}
% \end{macrocode}
%
% \begin{macrocode}
-function callbacks.insert_local_par(local_par, location)
- tpl.callback('insert_local_par', {location = location})
- tree.analyze_callback(local_par)
- return true
-end
+\ProcessKeyvalOptions{NTE}
% \end{macrocode}
%
+% \begin{macro}{\NTE@colors}
% \begin{macrocode}
-function callbacks.mlist_to_hlist(head, display_type, need_penalties)
- local variables = {
- display_type = display_type,
- need_penalties = need_penalties,
+\ExplSyntaxOn
+\def\NTE@colors{
+ \str_case_e:nn{\NTEK@theme}{
+ {bwdark}{
+ \definecolor{NTEblack}{gray}{0}
+ \definecolor{NTEred}{gray}{1}
+ \definecolor{NTEgreen}{gray}{1}
+ \definecolor{NTEyellow}{gray}{1}
+ \definecolor{NTEblue}{gray}{1}
+ \definecolor{NTEmagenta}{gray}{1}
+ \definecolor{NTEcyan}{gray}{1}
+ \definecolor{NTEwhite}{gray}{1}
+ \definecolor{NTEblackbright}{gray}{0}
+ \definecolor{NTEredbright}{gray}{1}
+ \definecolor{NTEgreenbright}{gray}{1}
+ \definecolor{NTEyellowbright}{gray}{1}
+ \definecolor{NTEbluebright}{gray}{1}
+ \definecolor{NTEmagentabright}{gray}{1}
+ \definecolor{NTEcyanbright}{gray}{1}
+ \definecolor{NTEwhitebright}{gray}{1}
+ }
+ {bwlight}{
+ \definecolor{NTEblack}{gray}{0}
+ \definecolor{NTEred}{gray}{0}
+ \definecolor{NTEgreen}{gray}{0}
+ \definecolor{NTEyellow}{gray}{0}
+ \definecolor{NTEblue}{gray}{0}
+ \definecolor{NTEmagenta}{gray}{0}
+ \definecolor{NTEcyan}{gray}{0}
+ \definecolor{NTEwhite}{gray}{1}
+ \definecolor{NTEblackbright}{gray}{0}
+ \definecolor{NTEredbright}{gray}{0}
+ \definecolor{NTEgreenbright}{gray}{0}
+ \definecolor{NTEyellowbright}{gray}{0}
+ \definecolor{NTEbluebright}{gray}{0}
+ \definecolor{NTEmagentabright}{gray}{0}
+ \definecolor{NTEcyanbright}{gray}{0}
+ \definecolor{NTEwhitebright}{gray}{1}
+ }
+ {monokaisoda}{
+ \definecolor{NTEblack}{HTML}{1a1a1a}
+ \definecolor{NTEred}{HTML}{f4005f}
+ \definecolor{NTEgreen}{HTML}{98e024}
+ \definecolor{NTEyellow}{HTML}{fa8419}
+ \definecolor{NTEblue}{HTML}{9d65ff}
+ \definecolor{NTEmagenta}{HTML}{f4005f}
+ \definecolor{NTEcyan}{HTML}{58d1eb}
+ \definecolor{NTEwhite}{HTML}{c4c5b5}
+ \definecolor{NTEblackbright}{HTML}{625e4c}
+ \definecolor{NTEredbright}{HTML}{f4005f}
+ \definecolor{NTEgreenbright}{HTML}{98e024}
+ \definecolor{NTEyellowbright}{HTML}{e0d561}
+ \definecolor{NTEbluebright}{HTML}{9d65ff}
+ \definecolor{NTEmagentabright}{HTML}{f4005f}
+ \definecolor{NTEcyanbright}{HTML}{58d1eb}
+ \definecolor{NTEwhitebright}{HTML}{f6f6ef}
+ }
}
- tpl.callback('mlist_to_hlist', variables)
- tree.analyze_callback(head)
- return node.mlist_to_hlist(head, display_type, need_penalties)
-end
-% \end{macrocode}
-%
-% \subsubsection{base --- Exported base functions}
-%
-% \begin{macrocode}
-function base.normalize_options()
- options.verbosity = tonumber(options.verbosity)
- options.decimalplaces = tonumber(options.decimalplaces)
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function base.set_default_options()
- local defaults = {
- verbosity = 1,
- callback = 'postlinebreak',
- engine = 'luatex',
- color = 'colored',
- decimalplaces = 2,
- unit = 'pt',
- channel = 'term',
+ \str_case_e:nn{\NTEK@thememode}{
+ {dark}{
+ \definecolor{NTEbackground}{named}{NTEblack}
+ \definecolor{NTEfont}{named}{NTEwhitebright}
+ }
+ {light}{
+ \definecolor{NTEbackground}{named}{NTEwhitebright}
+ \definecolor{NTEfont}{named}{NTEblack}
+ }
}
- if not options then
- options = {}
- end
- for key, value in pairs(defaults) do
- if not options[key] then
- options[key] = value
- end
- end
- base.normalize_options()
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function base.set_option(key, value)
- if not options then
- options = {}
- end
- options[key] = value
- base.normalize_options()
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function base.get_option(key)
- if not options then
- options = {}
- end
- if options[key] then
- return options[key]
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function base.get_callback_name(alias)
- if alias == 'contribute' or alias == 'contributefilter' then
- return 'contribute_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'buildpage' or alias == 'buildpagefilter' then
- return 'buildpage_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'preline' or alias == 'prelinebreakfilter' then
- return 'pre_linebreak_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'line' or alias == 'linebreakfilter' then
- return 'linebreak_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'append' or alias == 'appendtovlistfilter' then
- return 'append_to_vlist_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'postline' or alias == 'postlinebreakfilter' then
- return 'post_linebreak_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'hpack' or alias == 'hpackfilter' then
- return 'hpack_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'vpack' or alias == 'vpackfilter' then
- return 'vpack_filter'
-% \end{macrocode}
-% TODO: Fix: Unable to register callback
-% \begin{macrocode}
- elseif alias == 'hpackq' or alias == 'hpackquality' then
- return 'hpack_quality'
-% \end{macrocode}
-% TODO: Fix: Unable to register callback
-% \begin{macrocode}
- elseif alias == 'vpackq' or alias == 'vpackquality' then
- return 'vpack_quality'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'process' or alias == 'processrule' then
- return 'process_rule'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'preout' or alias == 'preoutputfilter' then
- return 'pre_output_filter'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'hyph' or alias == 'hyphenate' then
- return 'hyphenate'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'liga' or alias == 'ligaturing' then
- return 'ligaturing'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'kern' or alias == 'kerning' then
- return 'kerning'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'insert' or alias == 'insertlocalpar' then
- return 'insert_local_par'
-% \end{macrocode}
-%
-% \begin{macrocode}
- elseif alias == 'mhlist' or alias == 'mlisttohlist' then
- return 'mlist_to_hlist'
-% \end{macrocode}
-%
-% \begin{macrocode}
- else
- return 'post_linebreak_filter'
- end
-end
-% \end{macrocode}
-%
-% \begin{macrocode}
-function base.register(cb)
- if options.engine == 'lualatex' then
- luatexbase.add_to_callback(cb, callbacks[cb], 'nodetree')
- else
- id, error = callback.register(cb, callbacks[cb])
- end
-end
+}
+\ExplSyntaxOff
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\NTE@fonts}
% \begin{macrocode}
-function base.register_callbacks()
- for alias in string.gmatch(options.callback, '([^,]+)') do
- base.register(base.get_callback_name(alias))
- end
-end
+\def\NTE@fonts{
+ \bfseries%
+ \NTEK@fontsize%
+ \setmonofont{\NTEK@font}%
+ \ttfamily%
+ \setlength{\parindent}{0pt}%
+ \setlength{\parskip}{-0.9pt}%
+}
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\NodetreeSet}
+% Same definition as in nodetree.sty. Only implement this command
+% if not already registers.
% \begin{macrocode}
-function base.unregister(cb)
- if options.engine == 'lualatex' then
- luatexbase.remove_from_callback(cb, 'nodetree')
- else
- id, error = callback.register(cb, nil)
- end
-end
+\providecommand{\NodetreeSet}[1]{%
+ \setkeys{NTE}{#1}%
+}
% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
-function base.unregister_callbacks()
- for alias in string.gmatch(options.callback, '([^,]+)') do
- base.unregister(base.get_callback_name(alias))
- end
-end
+\newenvironment{NodetreeEmbedView}[1][]{
+ \setkeys{NTE}{#1}
+ \NTE@colors
+ \begin{mdframed}[
+ linecolor=black,
+ backgroundcolor=NTEbackground,
+ fontcolor=NTEfont,
+ ]%
+ \NTE@fonts
+}{
+ \end{mdframed}%
+}
% \end{macrocode}
%
-% \begin{macrocode}
-function base.execute()
- local c = base.get_callback()
- if options.engine == 'lualatex' then
- luatexbase.add_to_callback(c, callbacks.post_linebreak_filter, 'nodetree')
- else
- id, error = callback.register(c, callbacks.post_linebreak_filter)
- end
-end
+% \begin{environment}{NodetreeEmbedEnv}
+% \begin{macrocode}
+\NewDocumentEnvironment { NodetreeEmbedEnv } { O{} +b } {
+ \setkeys{NTE}{#1}
+ \ifNTEK@showmarkup
+ \noindent
+ \texttt{\detokenize{#2}}
+ \else
+ \fi
+ \NTE@colors
+ \begin{NodetreeEmbedView}
+ \directlua{
+ nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
+ }
+ \end{NodetreeEmbedView}
+}{}
+% \end{macrocode}
+% \end{environment}
+
+% \begin{macro}{\NodetreeEmbedCmd}
+% \begin{macrocode}
+\NewDocumentCommand { \NodetreeEmbedCmd } { O{} +v } {
+ \setkeys{NTE}{#1}
+ \ifNTEK@showmarkup
+ \noindent
+ \texttt{#2}
+ \else
+ \fi
+ \NTE@colors
+ \begin{NodetreeEmbedView}
+ \directlua{
+ nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
+ }
+ \end{NodetreeEmbedView}
+}
% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\NodetreeEmbedInput}
% \begin{macrocode}
-function base.analyze(head)
- tpl.print('\n')
- tree.analyze_list(head, 1)
-end
+\newcommand{\NodetreeEmbedInput}[2][]{
+ \setkeys{NTE}{#1}
+ \begin{NodetreeEmbedView}
+ \input{#2.nttex}
+ \end{NodetreeEmbedView}
+}
+\let\nodetreeterminalemulator\NodetreeEmbedInput
% \end{macrocode}
+% \end{macro}
%
-% \begin{macrocode}
-return base
-% \end{macrocode}
+\endinput
% \iffalse
-%</luamain>
+%</packageembed>
% \fi
%
% \Finale
diff --git a/macros/luatex/generic/nodetree/nodetree.ins b/macros/luatex/generic/nodetree/nodetree.ins
index 85d250818e..9b187ab25c 100644
--- a/macros/luatex/generic/nodetree/nodetree.ins
+++ b/macros/luatex/generic/nodetree/nodetree.ins
@@ -1,4 +1,4 @@
-% Copyright (C) 2016 by Josef Friedrich <josef@friedrich.rocks>
+% Copyright (C) 2016-2020 by Josef Friedrich <josef@friedrich.rocks>
% ----------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3c of this license
@@ -21,7 +21,7 @@
This is a generated file.
-Copyright (C) 2016 by Josef Friedrich <josef@friedrich.rocks>
+Copyright (C) 2016-2020 by Josef Friedrich <josef@friedrich.rocks>
----------------------------------------------------------------------
This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3c of this license
@@ -37,11 +37,7 @@ version 2008/05/05 or later.
\generate{\file{nodetree.tex}{\from{nodetree.dtx}{tex}}}
\generate{\file{nodetree.sty}{\from{nodetree.dtx}{package}}}
-
-\nopreamble
-\nopostamble
-\generate{\file{nodetree.lua}{\from{nodetree.dtx}{luamain}}}
-\generate{\file{README.md}{\from{nodetree.dtx}{readme}}}
+\generate{\file{nodetree-embed.sty}{\from{nodetree.dtx}{packageembed}}}
\obeyspaces
\Msg{*************************************************************}
diff --git a/macros/luatex/generic/nodetree/nodetree.lua b/macros/luatex/generic/nodetree/nodetree.lua
new file mode 100644
index 0000000000..666413578d
--- /dev/null
+++ b/macros/luatex/generic/nodetree/nodetree.lua
@@ -0,0 +1,1547 @@
+--- The nodetree package.
+--
+-- Nodetree uses [LDoc](https://github.com/stevedonovan/ldoc) for the
+-- source code documentation. The supported tags are described on in
+-- the [wiki](https://github.com/stevedonovan/LDoc/wiki).
+--
+-- Nodes in LuaTeX are connected. The nodetree view distinguishs
+-- between the `list` and `field` connections.
+--
+-- * `list`: Nodes, which are double connected by `next` and
+-- `previous` fields.
+-- * `field`: Connections to nodes by other fields than `next` and
+-- `previous` fields, e. g. `head`, `pre`.
+-- @module nodetree
+
+-- luacheck: globals node tex luatexbase lfs callback os unicode status modules
+
+if not modules then modules = { } end modules ['nodetree'] = {
+ version = '2.0',
+ comment = 'nodetree',
+ author = 'Josef Friedrich',
+ copyright = 'Josef Friedrich',
+ license = 'The LaTeX Project Public License Version 1.3c 2008-05-04'
+}
+
+--- A counter for the compiled TeX examples. Some TeX code snippets
+-- a written into file, wrapped with some TeX boilerplate code.
+-- This written files are compiled.
+local example_counter = 0
+
+--- The default options
+local default_options = {
+ callback = 'post_linebreak_filter',
+ channel = 'term',
+ color = 'colored',
+ decimalplaces = 2,
+ engine = 'luatex', -- Required for the callback registration
+ unit = 'pt',
+ verbosity = 1,
+}
+
+--- The current options
+-- They are changed very often.
+local options = {}
+for key, value in pairs(default_options) do
+ options[key] = value
+end
+
+if arg[0] == 'lualatex' then
+ options.engine = 'lualatex'
+end
+
+--- File descriptor
+local output_file
+
+--- The lua table named `tree_state` holds state values of the current
+-- tree item.
+--
+-- `tree_state`:
+--
+-- * `1` (level):
+-- * `list`: `continue`
+-- * `field`: `stop`
+-- * `2`:
+-- * `list`: `continue`
+-- * `field`: `stop`
+-- @table
+local tree_state = {}
+
+--- Format functions.
+--
+-- Low level template functions.
+--
+-- @section format
+
+local format = {
+ ---
+ -- @treturn string
+ underscore = function(string)
+ if options.channel == 'tex' then
+ return string.gsub(string, '_', '\\_')
+ else
+ return string
+ end
+ end,
+
+ ---
+ -- @treturn string
+ escape = function(string)
+ if options.channel == 'tex' then
+ return string.gsub(string, [[\]], [[\string\]])
+ else
+ return string
+ end
+ end,
+
+ -- @treturn number
+ number = function(number)
+ local mult = 10^(options.decimalplaces or 0)
+ return math.floor(number * mult + 0.5) / mult
+ end,
+
+ ---
+ -- @treturn string
+ whitespace = function(count)
+ local whitespace
+ local output = ''
+ if options.channel == 'tex' then
+ whitespace = '\\hspace{0.5em}'
+ else
+ whitespace = ' '
+ end
+ if not count then
+ count = 1
+ end
+ for _ = 1, count do
+ output = output .. whitespace
+ end
+ return output
+ end,
+
+ ---
+ -- @treturn string
+ color_code = function(code)
+ return string.char(27) .. '[' .. tostring(code) .. 'm'
+ end,
+
+ ---
+ -- @treturn string
+ color_tex = function(color, mode)
+ if not mode then mode = '' end
+ return 'NTE' .. color .. mode
+ end,
+
+ ---
+ -- @treturn string
+ node_begin = function()
+ if options.channel == 'tex' then
+ return '\\mbox{'
+ else
+ return ''
+ end
+ end,
+
+ ---
+ -- @treturn string
+ node_end = function()
+ if options.channel == 'tex' then
+ return '}'
+ else
+ return ''
+ end
+ end,
+
+ ---
+ -- @treturn string
+ new_line = function(count)
+ local output = ''
+ if not count then
+ count = 1
+ end
+ local new_line
+ if options.channel == 'tex' then
+ new_line = '\\par{}'
+ else
+ new_line = '\n'
+ end
+
+ for _ = 1, count do
+ output = output .. new_line
+ end
+ return output
+ end,
+
+ ---
+ -- @treturn string
+ type_id = function(id)
+ return '[' .. tostring(id) .. ']'
+ end
+}
+
+--- Print the output to stdout or write it into a file (`output_file`).
+-- New text is appended.
+--
+-- @tparam string text A text string.
+--
+local function nodetree_print(text)
+ if options.channel == 'log' or options.channel == 'tex' then
+ output_file:write(text)
+ else
+ io.write(text)
+ end
+end
+
+--- Template functions.
+-- @section template
+
+local template = {
+ node_colors = {
+ hlist = {'red', 'bright'},
+ vlist = {'green', 'bright'},
+ rule = {'blue', 'bright'},
+ ins = {'blue'},
+ mark = {'magenta'},
+ adjust = {'cyan'},
+ boundary = {'red', 'bright'},
+ disc = {'green', 'bright'},
+ whatsit = {'yellow', 'bright'},
+ local_par = {'blue', 'bright'},
+ dir = {'magenta', 'bright'},
+ math = {'cyan', 'bright'},
+ glue = {'magenta', 'bright'},
+ kern = {'green', 'bright'},
+ penalty = {'yellow', 'bright'},
+ unset = {'blue'},
+ style = {'magenta'},
+ choice = {'cyan'},
+ noad = {'red'},
+ radical = {'green'},
+ fraction = {'yellow'},
+ accent = {'blue'},
+ fence = {'magenta'},
+ math_char = {'cyan'},
+ sub_box = {'red', 'bright'},
+ sub_mlist = {'green', 'bright'},
+ math_text_char = {'yellow', 'bright'},
+ delim = {'blue', 'bright'},
+ margin_kern = {'magenta', 'bright'},
+ glyph = {'cyan', 'bright'},
+ align_record = {'red'},
+ pseudo_file = {'green'},
+ pseudo_line = {'yellow'},
+ page_insert = {'blue'},
+ split_insert = {'magenta'},
+ expr_stack = {'cyan'},
+ nested_list = {'red'},
+ span = {'green'},
+ attribute = {'yellow'},
+ glue_spec = {'magenta'},
+ attribute_list = {'cyan'},
+ temp = {'magenta'},
+ align_stack = {'red', 'bright'},
+ movement_stack = {'green', 'bright'},
+ if_stack = {'yellow', 'bright'},
+ unhyphenated = {'magenta', 'bright'},
+ hyphenated = {'cyan', 'bright'},
+ delta = {'red'},
+ passive = {'green'},
+ shape = {'yellow'},
+ },
+
+ ---
+ -- [SGR (Select Graphic Rendition) Parameters](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters)
+ --
+ -- __attributes__
+ --
+ -- | color |code|
+ -- |------------|----|
+ -- | reset | 0 |
+ -- | clear | 0 |
+ -- | bright | 1 |
+ -- | dim | 2 |
+ -- | underscore | 4 |
+ -- | blink | 5 |
+ -- | reverse | 7 |
+ -- | hidden | 8 |
+ --
+ -- __foreground__
+ --
+ -- | color |code|
+ -- |------------|----|
+ -- | black | 30 |
+ -- | red | 31 |
+ -- | green | 32 |
+ -- | yellow | 33 |
+ -- | blue | 34 |
+ -- | magenta | 35 |
+ -- | cyan | 36 |
+ -- | white | 37 |
+ --
+ -- __background__
+ --
+ -- | color |code|
+ -- |------------|----|
+ -- | onblack | 40 |
+ -- | onred | 41 |
+ -- | ongreen | 42 |
+ -- | onyellow | 43 |
+ -- | onblue | 44 |
+ -- | onmagenta | 45 |
+ -- | oncyan | 46 |
+ -- | onwhite | 47 |
+ --
+ -- @tparam string color A color name (`black`, `red`, `green`,
+ -- `yellow`, `blue`, `magenta`, `cyan`, `white`).
+ -- @tparam string mode `bright` or `dim`.
+ -- @tparam boolean background Colorize the background not the text.
+ --
+ -- @treturn string
+ color = function(color, mode, background)
+ if options.color ~= 'colored' then
+ return ''
+ end
+
+ local output = ''
+ local code
+
+ if mode == 'bright' then
+ output = format.color_code(1)
+ elseif mode == 'dim' then
+ output = format.color_code(2)
+ end
+
+ if not background then
+ if color == 'reset' then code = 0
+ elseif color == 'red' then code = 31
+ elseif color == 'green' then code = 32
+ elseif color == 'yellow' then code = 33
+ elseif color == 'blue' then code = 34
+ elseif color == 'magenta' then code = 35
+ elseif color == 'cyan' then code = 36
+ else code = 37 end
+ else
+ if color == 'black' then code = 40
+ elseif color == 'red' then code = 41
+ elseif color == 'green' then code = 42
+ elseif color == 'yellow' then code = 43
+ elseif color == 'blue' then code = 44
+ elseif color == 'magenta' then code = 45
+ elseif color == 'cyan' then code = 46
+ elseif color == 'white' then code = 47
+ else code = 40 end
+ end
+ return output .. format.color_code(code)
+ end,
+
+ --- Format a single unicode character.
+ --
+ -- @tparam string char A single input character.
+ --
+ -- @treturn string
+ char = function(char)
+ char = string.format('%s', unicode.utf8.char(char))
+ char = '\'' .. char .. '\''
+ if options.channel == 'tex' then
+ char = format.escape(char)
+ end
+ return char
+ end,
+
+ ---
+ -- @treturn string
+ line = function(length)
+ local output
+ if length == 'long' then
+ output = '------------------------------------------'
+ else
+ output = '-----------------------'
+ end
+ return output .. format.new_line()
+ end,
+
+ ---
+ -- @treturn string
+ branch = function(connection_type, connection_state, last)
+ local c = connection_type
+ local s = connection_state
+ local l = last
+ if c == 'list' and s == 'stop' and l == false then
+ return format.whitespace(2)
+ elseif c == 'field' and s == 'stop' and l == false then
+ return format.whitespace(2)
+ elseif c == 'list' and s == 'continue' and l == false then
+ return '│' .. format.whitespace()
+ elseif c == 'field' and s == 'continue' and l == false then
+ return '║' .. format.whitespace()
+ elseif c == 'list' and s == 'continue' and l == true then
+ return '├─'
+ elseif c == 'field' and s == 'continue' and l == true then
+ return '╠═'
+ elseif c == 'list' and s == 'stop' and l == true then
+ return '└─'
+ elseif c == 'field' and s == 'stop' and l == true then
+ return '╚═'
+ end
+ return ''
+ end,
+}
+
+---
+-- @treturn string
+function template.fill(number, order, field)
+ local output
+ if order ~= nil and order ~= 0 then
+ if field == 'stretch' then
+ output = '+'
+ else
+ output = '-'
+ end
+ return output .. string.format(
+ '%g%s', number / 2^16,
+ template.colored_string(
+ 'fi' .. string.rep('l', order - 1),
+ 'white',
+ 'dim'
+ )
+ )
+ else
+ return template.length(number)
+ end
+end
+
+--- Colorize a text string.
+--
+-- @tparam string text A text string.
+-- @tparam string color A color name (`black`, `red`, `green`,
+-- `yellow`, `blue`, `magenta`, `cyan`, `white`).
+-- @tparam string mode `bright` or `dim`.
+-- @tparam boolean background Colorize the background not the text.
+--
+-- @treturn string
+function template.colored_string(text, color, mode, background)
+ if options.channel == 'tex' then
+ if mode == 'dim' then
+ mode = ''
+ end
+ return '\\textcolor{' ..
+ format.color_tex(color, mode) ..
+ '}{' ..
+ text ..
+ '}'
+ else
+ return template.color(color, mode, background) .. text .. template.color('reset')
+ end
+end
+
+--- Format a scaled point input value into dimension string (`12pt`,
+-- `1cm`)
+--
+-- @tparam number input
+--
+-- @treturn string
+function template.length (input)
+ input = tonumber(input)
+ input = input / tex.sp('1' .. options.unit)
+ return string.format(
+ '%g%s',
+ format.number(input),
+ template.colored_string(options.unit, 'white', 'dim')
+ )
+end
+
+--- Convert a Lua table into a format string.
+--
+-- @tparam table table A table to generate a inline view of.
+--
+-- @treturn string
+function template.table_inline(table)
+ local tex_escape = ''
+ if options.channel == 'tex' then
+ tex_escape = '\\'
+ end
+ if type(table) == 'table' then
+ local output = tex_escape .. '{'
+ local kv_list = ''
+ for key, value in pairs(table) do
+ if type(key) ~= 'numbers' then
+ key = '\'' ..
+ template.colored_string(key, 'cyan', 'dim') .. '\''
+ end
+ kv_list = kv_list .. '[' .. key .. '] = ' ..
+ template.table_inline(value) .. ', '
+ end
+ output = output .. kv_list:gsub(', $', '')
+ return output .. tex_escape .. '}'
+ else
+ return tostring(table)
+ end
+end
+
+--- Format a key value pair (`key: value, `).
+--
+-- @tparam string key A key
+-- @tparam string|number value A value
+-- @tparam string color A color name (`black`, `red`, `green`,
+-- `yellow`, `blue`, `magenta`, `cyan`, `white`).
+--
+-- @treturn string
+function template.key_value(key, value, color)
+ if type(color) ~= 'string' then
+ color = 'yellow'
+ end
+ if options.channel == 'tex' then
+ key = format.underscore(key)
+ end
+ local output = template.colored_string(key .. ':', color)
+ if value then
+ output = output .. ' ' .. value .. ', '
+ end
+ return output
+end
+
+---
+-- @treturn string
+function template.type(type, id)
+ local output
+ if options.channel == 'tex' then
+ output = format.underscore(type)
+ else
+ output = type
+ end
+ output = string.upper(output)
+ if options.verbosity > 1 then
+ output = output .. format.type_id(id)
+ end
+ return template.colored_string(
+ output .. format.whitespace(),
+ template.node_colors[type][1],
+ template.node_colors[type][2]
+ )
+end
+
+---
+-- @treturn string
+function template.callback(callback_name, variables)
+ nodetree_print(
+ format.new_line(2) ..
+ 'Callback: ' ..
+ template.colored_string(format.underscore(callback_name), 'red', '', true) ..
+ format.new_line()
+ )
+ if variables then
+ for name, value in pairs(variables) do
+ if value ~= nil and value ~= '' then
+ nodetree_print(
+ '- ' ..
+ format.underscore(name) ..
+ ': ' ..
+ tostring(value) ..
+ format.new_line()
+ )
+ end
+ end
+ end
+ nodetree_print(template.line('long'))
+end
+
+---
+-- @treturn string
+function template.branches(level, connection_type)
+ local output = ''
+ for i = 1, level - 1 do
+ output = output .. template.branch('list', tree_state[i]['list'], false)
+ output = output .. template.branch('field', tree_state[i]['field'], false)
+ end
+-- Format the last branches
+ if connection_type == 'list' then
+ output = output .. template.branch('list', tree_state[level]['list'], true)
+ else
+ output = output .. template.branch('list', tree_state[level]['list'], false)
+ output = output .. template.branch('field', tree_state[level]['field'], true)
+ end
+ return output
+end
+
+--- Extend the node library
+-- @section node_extended
+
+local node_extended = {}
+
+--- Get the ID of a node.
+--
+-- We have to convert the node into a string and than have to extract
+-- the ID from this string using a regular expression. If you convert a
+-- node into a string it looks like: `<node nil < 172 > nil :
+-- hlist 2>`.
+--
+-- @tparam node n A node.
+--
+-- @treturn string
+function node_extended.node_id(n)
+ return string.gsub(tostring(n), '^<node%s+%S+%s+<%s+(%d+).*', '%1')
+end
+
+--- A table of all node subtype names.
+--
+-- __Nodes without subtypes:__
+--
+-- * `ins` (3)
+-- * `mark` (4)
+-- * `whatsit` (8)
+-- * `local_par` (9)
+-- * `dir` (10)
+-- * `penalty` (14)
+-- * `unset` (15)
+-- * `style` (16)
+-- * `choice` (17)
+-- * `fraction` (20)
+-- * `math_char` (23)
+-- * `sub_box` (24)
+-- * `sub_mlist` (25)
+-- * `math_text_char` (26)
+-- * `delim` (27)
+-- * `margin_kern` (28)
+-- * `align_record` (30)
+-- * `pseudo_file` (31)
+-- * `pseudo_line` (32)
+-- * `page_insert` (33)
+-- * `split_insert` (34)
+-- * `expr_stack` (35)
+-- * `nested_list` (36)
+-- * `span` (37)
+-- * `attribute` (38)
+-- * `glue_spec` (39)
+-- * `attribute_list` (40)
+-- * `temp` (41)
+-- * `align_stack` (42)
+-- * `movement_stack` (43)
+-- * `if_stack` (44)
+-- * `unhyphenated` (45)
+-- * `hyphenated` (46)
+-- * `delta` (47)
+-- * `passive` (48)
+-- * `shape` (49)
+--
+-- @treturn table
+local function get_node_subtypes ()
+ local subtypes = {
+ -- hlist (0)
+ hlist = {
+ [0] = 'unknown',
+ [1] = 'line',
+ [2] = 'box',
+ [3] = 'indent',
+ [4] = 'alignment',
+ [5] = 'cell',
+ [6] = 'equation',
+ [7] = 'equationnumber',
+ [8] = 'math',
+ [9] = 'mathchar',
+ [10] = 'hextensible',
+ [11] = 'vextensible',
+ [12] = 'hdelimiter',
+ [13] = 'vdelimiter',
+ [14] = 'overdelimiter',
+ [15] = 'underdelimiter',
+ [16] = 'numerator',
+ [17] = 'denominator',
+ [18] = 'limits',
+ [19] = 'fraction',
+ [20] = 'nucleus',
+ [21] = 'sup',
+ [22] = 'sub',
+ [23] = 'degree',
+ [24] = 'scripts',
+ [25] = 'over',
+ [26] = 'under',
+ [27] = 'accent',
+ [28] = 'radical',
+ },
+ -- vlist (1)
+ vlist = {
+ [0] = 'unknown',
+ [4] = 'alignment',
+ [5] = 'cell',
+ },
+ -- rule (2)
+ rule = {
+ [0] = 'normal',
+ [1] = 'box',
+ [2] = 'image',
+ [3] = 'empty',
+ [4] = 'user',
+ [5] = 'over',
+ [6] = 'under',
+ [7] = 'fraction',
+ [8] = 'radical',
+ [9] = 'outline',
+ },
+ -- adjust (5)
+ adjust = {
+ [0] = 'normal',
+ [1] = 'pre',
+ },
+ -- boundary (6)
+ boundary = {
+ [0] = 'cancel',
+ [1] = 'user',
+ [2] = 'protrusion',
+ [3] = 'word',
+ },
+ -- disc (7)
+ disc = {
+ [0] = 'discretionary',
+ [1] = 'explicit',
+ [2] = 'automatic',
+ [3] = 'regular',
+ [4] = 'first',
+ [5] = 'second',
+ },
+ -- math (11)
+ math = {
+ [0] = 'beginmath',
+ [1] = 'endmath',
+ },
+ -- glue (12)
+ glue = {
+ [0] = 'userskip',
+ [1] = 'lineskip',
+ [2] = 'baselineskip',
+ [3] = 'parskip',
+ [4] = 'abovedisplayskip',
+ [5] = 'belowdisplayskip',
+ [6] = 'abovedisplayshortskip',
+ [7] = 'belowdisplayshortskip',
+ [8] = 'leftskip',
+ [9] = 'rightskip',
+ [10] = 'topskip',
+ [11] = 'splittopskip',
+ [12] = 'tabskip',
+ [13] = 'spaceskip',
+ [14] = 'xspaceskip',
+ [15] = 'parfillskip',
+ [16] = 'mathskip',
+ [17] = 'thinmuskip',
+ [18] = 'medmuskip',
+ [19] = 'thickmuskip',
+ [98] = 'conditionalmathskip',
+ [99] = 'muglue',
+ [100] = 'leaders',
+ [101] = 'cleaders',
+ [102] = 'xleaders',
+ [103] = 'gleaders',
+ },
+ -- kern (13)
+ kern = {
+ [0] = 'fontkern',
+ [1] = 'userkern',
+ [2] = 'accentkern',
+ [3] = 'italiccorrection',
+ },
+ -- penalty (14)
+ penalty = {
+ [0] = 'userpenalty',
+ [1] = 'linebreakpenalty',
+ [2] = 'linepenalty',
+ [3] = 'wordpenalty',
+ [4] = 'finalpenalty',
+ [5] = 'noadpenalty',
+ [6] = 'beforedisplaypenalty',
+ [7] = 'afterdisplaypenalty',
+ [8] = 'equationnumberpenalty',
+ },
+ noad = {
+ [0] = 'ord',
+ [1] = 'opdisplaylimits',
+ [2] = 'oplimits',
+ [3] = 'opnolimits',
+ [4] = 'bin',
+ [5] = 'rel',
+ [6] = 'open',
+ [7] = 'close',
+ [8] = 'punct',
+ [9] = 'inner',
+ [10] = 'under',
+ [11] = 'over',
+ [12] = 'vcenter',
+ },
+ -- radical (19)
+ radical = {
+ [0] = 'radical',
+ [1] = 'uradical',
+ [2] = 'uroot',
+ [3] = 'uunderdelimiter',
+ [4] = 'uoverdelimiter',
+ [5] = 'udelimiterunder',
+ [6] = 'udelimiterover',
+ },
+ -- accent (21)
+ accent = {
+ [0] = 'bothflexible',
+ [1] = 'fixedtop',
+ [2] = 'fixedbottom',
+ [3] = 'fixedboth',
+ },
+ -- fence (22)
+ fence = {
+ [0] = 'unset',
+ [1] = 'left',
+ [2] = 'middle',
+ [3] = 'right',
+ [4] = 'no',
+ },
+ -- margin_kern (28)
+ margin_kern = {
+ [0] = 'left',
+ [1] = 'right',
+ },
+ -- glyph (29)
+ glyph = {
+ [0] = 'character',
+ [1] = 'ligature',
+ [2] = 'ghost',
+ [3] = 'left',
+ [4] = 'right',
+ },
+ }
+ subtypes.whatsit = node.whatsits()
+ return subtypes
+end
+
+---
+-- @treturn string
+function node_extended.subtype(n)
+ local typ = node.type(n.id)
+ local subtypes = get_node_subtypes()
+
+ local output
+ if subtypes[typ] and subtypes[typ][n.subtype] then
+ output = subtypes[typ][n.subtype]
+ if options.verbosity > 1 then
+ output = output .. format.type_id(n.subtype)
+ end
+ return output
+ else
+ return tostring(n.subtype)
+ end
+end
+
+--- Build the node tree.
+-- @section tree
+
+local tree = {}
+
+---
+-- @tparam node head
+-- @tparam string field
+--
+-- @treturn string
+function tree.format_field(head, field)
+ local output
+-- Character "0" should be printed in a tree, because in TeX fonts the
+-- 0 slot usually has a symbol.
+ if not head[field] or (head[field] == 0 and field ~= "char") then
+ return ''
+ end
+
+ if options.verbosity < 2 and
+ -- glyph
+ field == 'font' or
+ field == 'left' or
+ field == 'right' or
+ field == 'uchyph' or
+ -- hlist
+ field == 'dir' or
+ field == 'glue_order' or
+ field == 'glue_sign' or
+ field == 'glue_set' or
+ -- glue
+ field == 'stretch_order' then
+ return ''
+ elseif options.verbosity < 3 and
+ field == 'prev' or
+ field == 'next' or
+ field == 'id'
+ then
+ return ''
+ end
+
+ if field == 'prev' or field == 'next' then
+ output = node_extended.node_id(head[field])
+ elseif field == 'subtype' then
+ output = format.underscore(node_extended.subtype(head))
+ elseif
+ field == 'width' or
+ field == 'height' or
+ field == 'depth' or
+ field == 'kern' or
+ field == 'shift' then
+ output = template.length(head[field])
+ elseif field == 'char' then
+ output = template.char(head[field])
+ elseif field == 'glue_set' then
+ output = format.number(head[field])
+ elseif field == 'stretch' or field == 'shrink' then
+ output = template.fill(head[field], head[field .. '_order'], field)
+ else
+ output = tostring(head[field])
+ end
+
+ return template.key_value(field, output)
+end
+
+---
+-- Attributes are key/value number pairs. They are printed as an inline
+-- list. The attribute `0` with the value `0` is skipped because this
+-- attribute is in every node by default.
+--
+-- @tparam node head
+--
+-- @treturn string
+function tree.format_attributes(head)
+ if not head then
+ return ''
+ end
+ local output = ''
+ local attr = head.next
+ while attr do
+ if attr.number ~= 0 or (attr.number == 0 and attr.value ~= 0) then
+ output = output .. tostring(attr.number) .. '=' .. tostring(attr.value) .. ' '
+ end
+ attr = attr.next
+ end
+ return output
+end
+
+---
+-- @tparam number level `level` is a integer beginning with 1.
+-- @tparam number connection_type The variable `connection_type`
+-- is a string, which can be either `list` or `field`.
+-- @tparam connection_state `connection_state` is a string, which can
+-- be either `continue` or `stop`.
+function tree.set_state(level, connection_type, connection_state)
+ if not tree_state[level] then
+ tree_state[level] = {}
+ end
+ tree_state[level][connection_type] = connection_state
+end
+
+---
+-- @tparam table fields
+-- @tparam number level
+function tree.analyze_fields(fields, level)
+ local max = 0
+ local connection_state
+ for _ in pairs(fields) do
+ max = max + 1
+ end
+ local count = 0
+ for field_name, recursion_node in pairs(fields) do
+ count = count + 1
+ if count == max then
+ connection_state = 'stop'
+ else
+ connection_state = 'continue'
+ end
+ tree.set_state(level, 'field', connection_state)
+ nodetree_print(
+ format.node_begin() ..
+ template.branches(level, 'field') ..
+ template.key_value(field_name) ..
+ format.node_end() ..
+ format.new_line()
+ )
+ tree.analyze_list(recursion_node, level + 1)
+ end
+end
+
+---
+-- @tparam node head
+-- @tparam number level
+function tree.analyze_node(head, level)
+ local connection_state
+ local output
+ if head.next then
+ connection_state = 'continue'
+ else
+ connection_state = 'stop'
+ end
+ tree.set_state(level, 'list', connection_state)
+ output = template.branches(level, 'list')
+ .. template.type(node.type(head.id), head.id)
+ if options.verbosity > 1 then
+ output = output .. template.key_value('no', node_extended.node_id(head))
+ end
+
+ -- We store the attributes output to append it to the field list.
+ local attributes
+
+ -- We store fields which are nodes for later treatment.
+ local fields = {}
+
+ -- Inline fields, for example: char: 'm', width: 25pt, height: 13.33pt,
+ local output_fields = ''
+ for _, field_name in pairs(node.fields(head.id, head.subtype)) do
+ if field_name == 'attr' then
+ attributes = tree.format_attributes(head.attr)
+ elseif field_name ~= 'next' and field_name ~= 'prev' and
+ node.is_node(head[field_name]) then
+ fields[field_name] = head[field_name]
+ else
+ output_fields = output_fields .. tree.format_field(head, field_name)
+ end
+ end
+ if output_fields ~= '' then
+ output = output .. output_fields
+ end
+
+ -- Append the attributes output if available
+ if attributes ~= '' then
+ output = output .. template.key_value('attr', attributes, 'blue')
+ end
+
+ output = output:gsub(', $', '')
+
+ nodetree_print(
+ format.node_begin() ..
+ output ..
+ format.node_end() ..
+ format.new_line()
+ )
+
+ local property = node.getproperty(head)
+ if property then
+ nodetree_print(
+ format.node_begin() ..
+ template.branches(level, 'field') ..
+ ' ' ..
+ template.colored_string('properties:', 'blue') .. ' ' ..
+ template.table_inline(property) ..
+ format.node_end() ..
+ format.new_line()
+ )
+ end
+
+ tree.analyze_fields(fields, level)
+end
+
+---
+-- @tparam node head
+-- @tparam number level
+function tree.analyze_list(head, level)
+ while head do
+ tree.analyze_node(head, level)
+ head = head.next
+ end
+end
+
+---
+-- @tparam node head
+function tree.analyze_callback(head)
+ tree.analyze_list(head, 1)
+ nodetree_print(template.line('short') .. format.new_line())
+end
+
+--- Callback wrapper.
+-- @section callbacks
+
+local callbacks = {
+
+ ---
+ -- @tparam string extrainfo
+ contribute_filter = function(extrainfo)
+ template.callback('contribute_filter', {extrainfo = extrainfo})
+ return true
+ end,
+
+ ---
+ -- @tparam string extrainfo
+ buildpage_filter = function(extrainfo)
+ template.callback('buildpage_filter', {extrainfo = extrainfo})
+ return true
+ end,
+
+ ---
+ -- @tparam string n
+ -- @tparam string i
+ build_page_insert = function(n, i)
+ print('lol')
+ template.callback('build_page_insert', {n = n, i = i})
+ return 0
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string groupcode
+ pre_linebreak_filter = function(head, groupcode)
+ template.callback('pre_linebreak_filter', {groupcode = groupcode})
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam boolean is_display
+ linebreak_filter = function(head, is_display)
+ template.callback('linebreak_filter', {is_display = is_display})
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node box
+ -- @tparam string locationcode
+ -- @tparam number prevdepth
+ -- @tparam boolean mirrored
+ append_to_vlist_filter = function(box, locationcode, prevdepth, mirrored)
+ local variables = {
+ locationcode = locationcode,
+ prevdepth = prevdepth,
+ mirrored = mirrored,
+ }
+ template.callback('append_to_vlist_filter', variables)
+ tree.analyze_callback(box)
+ return box
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string groupcode
+ post_linebreak_filter = function(head, groupcode)
+ template.callback('post_linebreak_filter', {groupcode = groupcode})
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string groupcode
+ -- @tparam number size
+ -- @tparam string packtype
+ -- @tparam string direction
+ -- @tparam node attributelist
+ hpack_filter = function(head, groupcode, size, packtype, direction, attributelist)
+ local variables = {
+ groupcode = groupcode,
+ size = size,
+ packtype = packtype,
+ direction = direction,
+ attributelist = attributelist,
+ }
+ template.callback('hpack_filter', variables)
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string groupcode
+ -- @tparam number size
+ -- @tparam string packtype
+ -- @tparam number maxdepth
+ -- @tparam string direction
+ -- @tparam node attributelist
+ vpack_filter = function(head, groupcode, size, packtype, maxdepth, direction, attributelist)
+ local variables = {
+ groupcode = groupcode,
+ size = size,
+ packtype = packtype,
+ maxdepth = template.length(maxdepth),
+ direction = direction,
+ attributelist = attributelist,
+ }
+ template.callback('vpack_filter', variables)
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam string incident
+ -- @tparam number detail
+ -- @tparam node head
+ -- @tparam number first
+ -- @tparam number last
+ hpack_quality = function(incident, detail, head, first, last)
+ local variables = {
+ incident = incident,
+ detail = detail,
+ first = first,
+ last = last,
+ }
+ template.callback('hpack_quality', variables)
+ tree.analyze_callback(head)
+ end,
+
+ ---
+ -- @tparam string incident
+ -- @tparam number detail
+ -- @tparam node head
+ -- @tparam number first
+ -- @tparam number last
+ vpack_quality = function(incident, detail, head, first, last)
+ local variables = {
+ incident = incident,
+ detail = detail,
+ first = first,
+ last = last,
+ }
+ template.callback('vpack_quality', variables)
+ tree.analyze_callback(head)
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam number width
+ -- @tparam number height
+ process_rule = function(head, width, height)
+ local variables = {
+ width = width,
+ height = height,
+ }
+ template.callback('process_rule', variables)
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string groupcode
+ -- @tparam number size
+ -- @tparam string packtype
+ -- @tparam number maxdepth
+ -- @tparam string direction
+ pre_output_filter = function(head, groupcode, size, packtype, maxdepth, direction)
+ local variables = {
+ groupcode = groupcode,
+ size = size,
+ packtype = packtype,
+ maxdepth = maxdepth,
+ direction = direction,
+ }
+ template.callback('pre_output_filter', variables)
+ tree.analyze_callback(head)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam node tail
+ hyphenate = function(head, tail)
+ template.callback('hyphenate')
+ nodetree_print('head:')
+ tree.analyze_callback(head)
+ nodetree_print('tail:')
+ tree.analyze_callback(tail)
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam node tail
+ ligaturing = function(head, tail)
+ template.callback('ligaturing')
+ nodetree_print('head:')
+ tree.analyze_callback(head)
+ nodetree_print('tail:')
+ tree.analyze_callback(tail)
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam node tail
+ kerning = function(head, tail)
+ template.callback('kerning')
+ nodetree_print('head:')
+ tree.analyze_callback(head)
+ nodetree_print('tail:')
+ tree.analyze_callback(tail)
+ end,
+
+ ---
+ -- @tparam node local_par
+ -- @tparam string location
+ insert_local_par = function(local_par, location)
+ template.callback('insert_local_par', {location = location})
+ tree.analyze_callback(local_par)
+ return true
+ end,
+
+ ---
+ -- @tparam node head
+ -- @tparam string display_type
+ -- @tparam boolean need_penalties
+ mlist_to_hlist = function(head, display_type, need_penalties)
+ local variables = {
+ display_type = display_type,
+ need_penalties = need_penalties,
+ }
+ template.callback('mlist_to_hlist', variables)
+ tree.analyze_callback(head)
+ return node.mlist_to_hlist(head, display_type, need_penalties)
+ end,
+}
+
+--- Set a single option key value pair.
+--
+-- @tparam string key The key of the option pair.
+-- @tparam number|string value The value of the option pair.
+local function set_option(key, value)
+ if not options then
+ options = {}
+ end
+ if key == 'verbosity' or key == 'decimalplaces' then
+ options[key] = tonumber(value)
+ else
+ options[key] = value
+ end
+end
+
+--- Set multiple key value pairs using a table.
+--
+-- @tparam table opts Options
+local function set_options(opts)
+ if not options then
+ options = {}
+ end
+ for key, value in pairs(opts) do
+ set_option(key, value)
+ end
+end
+
+--- Check if the given callback name exists.
+--
+-- Throw an error if it doen’t.
+--
+-- @tparam string callback_name The name of a callback to check.
+--
+-- @treturn string The unchanged input of the function.
+local function check_callback_name(callback_name)
+ local info = callback.list()
+ if info[callback_name] == nil then
+ tex.error(
+ 'Package "nodetree": Unkown callback name or callback alias: "' ..
+ callback_name ..
+ '"'
+ )
+ end
+ return callback_name
+end
+
+--- Get the real callback name from an alias string.
+--
+-- @tparam string alias The alias of a callback name or the callback
+-- name itself.
+--
+-- @treturn string The real callback name.
+local function get_callback_name(alias)
+ local callback_name
+ -- Listed as in the LuaTeX reference manual.
+ if alias == 'contribute' or alias == 'contributefilter' then
+ callback_name = 'contribute_filter'
+
+ -- Formerly called buildpage, now there is a build_page_insert.
+ elseif alias == 'buildfilter' or alias == 'buildpagefilter' then
+ callback_name = 'buildpage_filter'
+
+ -- Untested: I don’t know how to invoke this filter.
+ elseif alias == 'buildinsert' or alias == 'buildpageinsert' then
+ callback_name = 'build_page_insert'
+
+ elseif alias == 'preline' or alias == 'prelinebreakfilter' then
+ callback_name = 'pre_linebreak_filter'
+
+ elseif alias == 'line' or alias == 'linebreakfilter' then
+ callback_name = 'linebreak_filter'
+
+ elseif alias == 'append' or alias == 'appendtovlistfilter' then
+ callback_name = 'append_to_vlist_filter'
+
+ -- postlinebreak is not documented.
+ elseif alias == 'postline' or alias == 'postlinebreak' or alias == 'postlinebreakfilter' then
+ callback_name = 'post_linebreak_filter'
+
+ elseif alias == 'hpack' or alias == 'hpackfilter' then
+ callback_name = 'hpack_filter'
+
+ elseif alias == 'vpack' or alias == 'vpackfilter' then
+ callback_name = 'vpack_filter'
+
+ elseif alias == 'hpackq' or alias == 'hpackquality' then
+ callback_name = 'hpack_quality'
+
+ elseif alias == 'vpackq' or alias == 'vpackquality' then
+ callback_name = 'vpack_quality'
+
+ elseif alias == 'process' or alias == 'processrule' then
+ callback_name = 'process_rule'
+
+ elseif alias == 'preout' or alias == 'preoutputfilter' then
+ callback_name = 'pre_output_filter'
+
+ elseif alias == 'hyph' or alias == 'hyphenate' then
+ callback_name = 'hyphenate'
+
+ elseif alias == 'liga' or alias == 'ligaturing' then
+ callback_name = 'ligaturing'
+
+ elseif alias == 'kern' or alias == 'kerning' then
+ callback_name = 'kerning'
+
+ elseif alias == 'insert' or alias == 'insertlocalpar' then
+ callback_name = 'insert_local_par'
+
+ elseif alias == 'mhlist' or alias == 'mlisttohlist' then
+ callback_name = 'mlist_to_hlist'
+
+ else
+ callback_name = alias
+ end
+ return check_callback_name(callback_name)
+end
+
+--- Register a callback.
+--
+-- @tparam string cb The name of a callback.
+local function register_callback(cb)
+ if options.engine == 'lualatex' then
+ luatexbase.add_to_callback(cb, callbacks[cb], 'nodetree')
+ else
+ callback.register(cb, callbacks[cb])
+ end
+end
+
+--- Unregister a callback.
+--
+-- @tparam string cb The name of a callback.
+local function unregister_callback(cb)
+ if options.engine == 'lualatex' then
+ luatexbase.remove_from_callback(cb, 'nodetree')
+ else
+ register_callback(cb, nil)
+ end
+end
+
+--- Exported functions.
+-- @section export
+
+local export = {
+ set_option = set_option,
+ set_options = set_options,
+
+ ---
+ register_callbacks = function()
+ if options.channel == 'log' or options.channel == 'tex' then
+ -- nt = nodetree
+ -- jobname.nttex
+ -- jobname.ntlog
+ local file_name = tex.jobname .. '.nt' .. options.channel
+ io.open(file_name, 'w'):close() -- Clear former content
+ output_file = io.open(file_name, 'a')
+ end
+ for alias in string.gmatch(options.callback, '([^,]+)') do
+ register_callback(get_callback_name(alias))
+ end
+ end,
+
+ ---
+ unregister_callbacks = function()
+ for alias in string.gmatch(options.callback, '([^,]+)') do
+ unregister_callback(get_callback_name(alias))
+ end
+ end,
+
+ --- Compile a TeX snippet.
+ --
+ -- Write some TeX snippets into a temporary LaTeX file, compile this
+ -- file using `latexmk` and read the generated `*.nttex` file and
+ -- return its content.
+ --
+ -- @tparam string tex_markup
+ --
+ -- @treturn string
+ compile_include = function(tex_markup)
+ -- Generate a subfolder for all tempory files: _nodetree-jobname.
+ local parent_path = lfs.currentdir() .. '/' .. '_nodetree-' .. tex.jobname
+ lfs.mkdir(parent_path)
+
+ -- Generate the temporary LuaTeX or LuaLaTeX file.
+ example_counter = example_counter + 1
+ local filename_tex = example_counter .. '.tex'
+ local absolute_path_tex = parent_path .. '/' .. filename_tex
+ output_file = io.open(absolute_path_tex, 'w')
+
+ local format_option = function (key, value)
+ return '\\NodetreeSetOption[' .. key .. ']{' .. value .. '}' .. '\n'
+ end
+
+ -- Process the options
+ local options =
+ format_option('channel', 'tex') ..
+ format_option('verbosity', options.verbosity) ..
+ format_option('unit', options.unit) ..
+ format_option('decimalplaces', options.decimalplaces) ..
+ '\\NodetreeUnregisterCallback{post_linebreak_filter}' .. '\n' ..
+ '\\NodetreeRegisterCallback{' .. options.callback .. '}'
+
+ local prefix = '%!TEX program = lualatex\n' ..
+ '\\documentclass{article}\n' ..
+ '\\usepackage{nodetree}\n' ..
+ options .. '\n' ..
+ '\\begin{document}\n'
+ local suffix = '\n\\end{document}'
+ output_file:write(prefix .. tex_markup .. suffix)
+ output_file:close()
+
+ -- Compile the temporary LuaTeX or LuaLaTeX file.
+ os.spawn({ 'latexmk', '-cd', '-pdflua', absolute_path_tex })
+ local include_file = assert(io.open(parent_path .. '/' .. example_counter .. '.nttex', 'rb'))
+ local include_content = include_file:read("*all")
+ include_file:close()
+ include_content = include_content:gsub('[\r\n]', '')
+ tex.print(include_content)
+ end,
+
+ --- Check for `--shell-escape`
+ --
+ check_shell_escape = function()
+ local info = status.list()
+ if info.shell_escape == 0 then
+ tex.error('Package "nodetree-embed": You have to use the --shell-escape option')
+ end
+ end,
+
+ --- Print a node tree.
+ ---
+ -- @tparam node head The head node of a node list.
+ -- @tparam table opts Options as a table.
+ print = function(head, opts)
+ if opts and type(opts) == 'table' then
+ set_options(opts)
+ end
+ nodetree_print(format.new_line())
+ tree.analyze_list(head, 1)
+ end,
+
+ --- Format a scaled point value into a formated string.
+ --
+ -- @tparam number sp A scaled point value
+ --
+ -- @treturn string
+ format_dim = function(sp)
+ return template.length(sp)
+ end,
+
+ --- Get a default option that is not changed.
+ -- @tparam string key The key of the option.
+ --
+ -- @treturn string|number|boolean
+ get_default_option = function(key)
+ return default_options[key]
+ end
+}
+
+--- Use export.print
+-- @tparam node head
+export.analyze = export.print
+
+return export
diff --git a/macros/luatex/generic/nodetree/nodetree.pdf b/macros/luatex/generic/nodetree/nodetree.pdf
index 0ea7228abe..c7cdf1d72c 100644
--- a/macros/luatex/generic/nodetree/nodetree.pdf
+++ b/macros/luatex/generic/nodetree/nodetree.pdf
Binary files differ