summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/luatex/chickenize
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/luatex/chickenize')
-rw-r--r--Master/texmf-dist/source/luatex/chickenize/chickenize.dtx200
1 files changed, 172 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx b/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx
index d6705e348ba..f8441bc442c 100644
--- a/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx
+++ b/Master/texmf-dist/source/luatex/chickenize/chickenize.dtx
@@ -12,17 +12,17 @@ To produce the package files, run lualatex on chickinize.dtx, wich should result
chickenize.sty (LaTeX user interface)
chickenize.lua (Lua package code) [does the actual work]
-You need an up-to-date TeX Live (2011 or 2012, if possible) to use this package. Maybe a full MiKTeX will do, too. (Not tested!)
+You need an up-to-date TeX Live (2012, if possible, maybe 2011 will do) to use this package. Maybe a full MiKTeX will will also work. (Not tested!)
For any comments or suggestions, contact me:
arno dot trautmann at gmx dot de
Hope you have fun with this package!
-This package is copyright © 20012 Arno L. Trautmann. It may be distributed and/or
+This package is copyright © 2012 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version. This work has the LPPL mainten-
-ance status ‘author-maintained’.
+ance status ‘maintained’.
%</readme>
%<*driver>
\fi
@@ -40,7 +40,7 @@ EXPERIMENTAL CODE
This package is copyright © 20012 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version. This work has the LPPL mainten-
-ance status ‘author-maintained’.
+ance status ‘maintained’.
\endpreamble
\let\MetaPrefix\DoubleperCent
\postamble
@@ -95,6 +95,8 @@ ance status ‘author-maintained’.
\pagestyle{scrheadings}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
+\newfontfamily\XITS{XITS}
+\newfontfamily\TGChorus{TeX Gyre Chorus}
\usepackage{chickenize}
\chickenizesetup{
@@ -102,7 +104,7 @@ ance status ‘author-maintained’.
}
\begin{document}
-{\hfill \parbox{6.3cm}{{\fontspec{TeX Gyre Chorus}{\large »\,}The Monty Pythons, were they \TeX~users,\\\hspace*{.2em} could have written the chickenize macro.{\large \textit «}}\\[1ex]
+{\hfill \parbox{6.3cm}{{\TGChorus{\large »\,}The Monty Pythons, were they \TeX~users,\\\hspace*{.2em} could have written the chickenize macro.{\large \textit «}}\\[1ex]
\hspace*{4cm}\small Paul Isambert}\kern-2.5cm
}
@@ -114,14 +116,14 @@ chickenize
\unrainbowcolor
-\centerline{v0.1}
+\centerline{v0.1a}
\centerline{\hspace*{2cm} Arno Trautmann}
\centerline{\href{mailto:arno.trautmann@gmx.de}{arno.trautmann@gmx.de}}
\kern.5cm
-This is the documentation of the package |chickenize|. It allows manipulations of any Lua\TeX\ document\footnote{The code is based on pure Lua\TeX\ features, so don't even try to use it with any other \TeX\ flavour. The package is tested under plain Lua\TeX\ and Lua\LaTeX. If you tried using it with Con\TeX t, please share your experience, I will gladly try to make it compatible!} exploiting the possibilities offered by the callbacks that influence line breaking. Most of this package's content is just for fun and educational use, but there are also some functions that can be useful in a normal document.
+This is the documentation of the package |chickenize|. It allows manipulations of any Lua\TeX\ document\footnote{The code is based on pure Lua\TeX\ features, so don't even try to use it with any other \TeX\ flavour. The package is tested under plain Lua\TeX\ and Lua\LaTeX. If you tried using it with Con\TeX t, please share your experience, I will gladly try to make it compatible!} exploiting the possibilities offered by the callbacks that influence line breaking (and some other stuff). Most of this package's content is just for fun and educational use, but there are also some functions that can be useful in a normal document.
-The table on the next page informs you shortly about some of your possibilities and provides links to the Lua functions. The \TeX\ interface is presented \hyperlink{texinterface}{below}.
+The table on the next page shortly informs you about some of your possibilities and provides links to the (documented) Lua functions. The \TeX\ interface is presented \hyperlink{texinterface}{below}.
The documentation of this package is far from being well-readable, consistent or even complete. This is caused either by lack of time or priority. If you miss anything that should be documented or if you have suggestions on how to increase the readability of the descriptions, please let me know.
@@ -134,23 +136,31 @@ If you have any suggestions or comments, just drop me a mail, I’ll be happy to
\vfill
\small\noindent
-This package is copyright © 20012 Arno L. Trautmann. It may be distributed and/or
+\fbox{\parbox{.97\textwidth}{
+This package is copyright © 2012 Arno L. Trautmann. It may be distributed and/or
modified under the conditions of the LaTeX Project Public License, either version 1.3c
-of this license or (at your option) any later version. This work has the LPPL maintenance status ‘author-maintained’.
+of this license or (at your option) any later version. This work has the LPPL maintenance status ‘maintained’.}}
\vspace*{1cm}
\newpage
+\section*{\rainbowcolor For the Impatient:}
+
+\unrainbowcolor
+A small and incomplete overview of the functionalities offered by this package. I try to keep this list as complete as possible.\footnote{If you notice that something is missing, please help me improving the documentation!} Of course, the label “complete nonsense” depends on what you are doing …\\[2ex]
+
\noindent
\tabulinesep=.5ex
\begin{longtabu} to .95\textwidth [c]{lX[j]}
\hbox to 0cm{\bfseries \hspace*{2cm} maybe useful functions}\\
\cmidrule(lr){1-2}
\hyperref[sec:colorstretch]{colorstretch} & shows grey boxes that visualise the badness and font expansion of each line\\
-\hyperref[sec:letterspaceadjust]{letterspaceadjust} & uses a small amount of letterspacing to improve the greyness, especially for narrow lines\\
+\hyperref[sec:letterspaceadjust]{letterspaceadjust} & improves the greyness by using a small amount of letterspacing\\
+\hyperref[sec:substitutewords]{substitutewords} & replaces words by other words (user-controlled!)\\
\addlinespace\addlinespace
\hbox to 0cm{\bfseries \hspace*{2cm} less useful functions} \\
\cmidrule(lr){1-2}
+\hyperref[sec:countglyphs]{countglyphs} & counts the number of glyphs in the whole document\\
\hyperref[sec:leetspeak]{leetspeak} & translates the (latin-based) input into 1337 5p34k\\
\hyperref[sec:randomuclc]{randomuclc} & alternates randomly between uppercase and lowercase\\
\hyperref[sec:randomrainbowcolor]{rainbowcolor} & changes the color of letters slowly according to a rainbow\\
@@ -160,10 +170,10 @@ of this license or (at your option) any later version. This work has the LPPL ma
\addlinespace\addlinespace
\hbox to 0cm{\bfseries \hspace*{2cm} complete nonsense} \\
\cmidrule(lr){1-2}
-\hyperref[sec:chickenize]{chickenize} & replaces every word with “chicken”\\
+\hyperref[sec:chickenize]{chickenize} & replaces every word with “chicken” (or user-adjustable words)\\
\hyperref[sec:guttenbergenize]{guttenbergenize} & deletes every quote and footnotes\\
\hyperref[sec:hammertime]{hammertime} & U can't touch this!\\
-\hyperref[sec:kernmanipulation]{kernmanipulation} & manipulates the kerning (tbi)\\
+\hyperref[sec:kernmanipulate]{kernmanipulate} & manipulates the kerning (tbi)\\
\hyperref[sec:matrixize]{matrixize} & replaces every glyph by its ASCII value in binary code\\
\hyperref[sec:randomerror]{randomerror} & just throws random (La)\TeX\ errors at random times\\
\hyperref[sec:randomfonts]{randomfonts} & changes the font randomly between every letter\\
@@ -191,6 +201,7 @@ The effect of the commands can be influenced, not with arguments, but only via t
\begin{description}
\def\command#1{\item[\ttfamily \color{blue} \textbackslash#1]}
+\command{countglyphs} Counts every printed character that appeared in anything that is a paragraph. Which is quite everything, in fact, \emph{exept} math mode! The total number will be printed at the end of the log file/console output.
\command{chickenize} Replaces every word of the input with the word “chicken”. Maybe sometime the replacement will be made configurable, but up to now, it's only chicken. To be a bit less static, about every 10\textsuperscript{th} chicken is uppercase. However, the beginning of a sentence is not recognized automatically.\footnote{If you have a nice implementation idea, I'd love to include this!}
\command{dubstepize} wub wub wub wub wub BROOOOOAR WOBBBWOBBWOBB BZZZRRRRRRROOOOOOAAAAA … (inspired by \url{http://www.youtube.com/watch?v=ZFQ5EpO7iHk} and \url{http://www.youtube.com/watch?v=nGxpSsbodnw})
\command{dubstepenize} synomym for |\dubstepize| as I am not sure what is the better name. Both macros are just a special case of |chickenize| with a very special “zoo” … there is no |\undubstepize| – once you go dubstep, you cannot go back …
@@ -207,6 +218,7 @@ The effect of the commands can be influenced, not with arguments, but only via t
\command{nyanize} A synonym for |rainbowcolor|.
\command{matrixize} Replaces every glyph by a binary representation of its ASCII value.
\command{colorstretch} Inspired by Paul Isambert's code, this command prints boxes instead of lines. The greyness of the first (left-hand) box corresponds to the badness of the line, i.\,e. it is a measure for how much the space between words has been extended to get proper paragraph justification. The second box on the right-hand side shows the amount of stretching/shrinking when font expansion is used. Together, the greyness of both boxes indicate how well the greyness is distributed over the typeset page.
+\command{substitutewords} You have to specify pairs of words by using |\addtosubstitutions{word1}{word2}|. Then call |\substitutewords| (or the other way round, doesn't matter) and each occurance of |word1| will be replaced by |word2|. You can add replacement pairs by repeated calls to |\addtosubstitutions|. Take care! This function warks with the input directly, therefore it does \emph{not} work on text that is inserted by macros, but it \emph{will} work on macro names itself! This way, you may use it to change macros (or environments) at will. Bug or feature? I'm not sure right now …
\end{description}
\subsection{How to Deactivate It}
@@ -357,6 +369,29 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\input{luatexbase.sty}
\directlua{dofile(kpse.find_file("chickenize.lua"))}
+\def\BEClerize{
+ \chickenize
+ \directlua{
+ chickenstring[1] = "noise noise"
+ chickenstring[2] = "atom noise"
+ chickenstring[3] = "shot noise"
+ chickenstring[4] = "photon noise"
+ chickenstring[5] = "camera noise"
+ chickenstring[6] = "noising noise"
+ chickenstring[7] = "thermal noise"
+ chickenstring[8] = "electronic noise"
+ chickenstring[9] = "spin noise"
+ chickenstring[10] = "electron noise"
+ chickenstring[11] = "Bogoliubov noise"
+ chickenstring[12] = "white noise"
+ chickenstring[13] = "brown noise"
+ chickenstring[14] = "pink noise"
+ chickenstring[15] = "bloch sphere"
+ chickenstring[16] = "atom shot noise"
+ chickenstring[17] = "nature physics"
+ }
+}
+
\def\chickenize{
\directlua{luatexbase.add_to_callback("pre_linebreak_filter",chickenize,"chickenize")
luatexbase.add_to_callback("start_page_number",
@@ -382,6 +417,13 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\def\uncolorstretch{
\directlua{luatexbase.remove_from_callback("post_linebreak_filter","stretch_expansion")}}
+\def\countglyphs{
+ \directlua{glyphnumber = 0
+ luatexbase.add_to_callback("post_linebreak_filter",countglyphs,"countglyphs")
+ luatexbase.add_to_callback("stop_run",printglyphnumber,"printglyphnumber")
+ }
+}
+
\def\dosomethingfunny{
%% should execute one of the “funny” commands, but randomly. So every compilation is completely different. Maybe a list of commands could be specified to exclude total nonesense-functions. Maybe also on a per-paragraph-basis?
}
@@ -460,6 +502,13 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\def\unletterspaceadjust{
\directlua{luatexbase.remove_from_callback("pre_linebreak_filter","letterspaceadjust")}}
+\def\listallcommands{
+ \directlua{
+ for name in pairs(tex.hashtokens()) do
+ print(name)
+ end}
+}
+
\let\stealsheep\letterspaceadjust %% synonym in honor of Paul
\let\unstealsheep\unletterspaceadjust
\let\returnsheep\unletterspaceadjust
@@ -492,9 +541,9 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\directlua{luatexbase.remove_from_callback("post_linebreak_filter","randomcolor")}}
\def\randomerror{ %% FIXME
- \directlua{luatexbase.add_to_callback("post_linebreak_filter",randomcolor,"randomcolor")}}
+ \directlua{luatexbase.add_to_callback("post_linebreak_filter",randomerror,"randomerror")}}
\def\unrandomerror{ %% FIXME
- \directlua{luatexbase.remove_from_callback("post_linebreak_filter","randomcolor")}}
+ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","randomerror")}}
\def\randomfonts{
\directlua{luatexbase.add_to_callback("post_linebreak_filter",randomfonts,"randomfonts")}}
@@ -516,6 +565,15 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\def\unspankmonkey{
\directlua{}}
+\def\substitutewords{
+ \directlua{luatexbase.add_to_callback("process_input_buffer",substitutewords,"substitutewords")}}
+\def\unsubstitutewords{
+ \directlua{luatexbase.remove_from_callback("process_input_buffer","substitutewords")}}
+
+\def\addtosubstitutions#1#2{
+ \directlua{addtosubstitutions("#1","#2")}
+}
+
\def\tabularasa{
\directlua{luatexbase.add_to_callback("post_linebreak_filter",tabularasa,"tabularasa")}}
\def\untabularasa{
@@ -534,6 +592,7 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
% Now the setup for the |\text|-versions. We utilize Lua\TeX s attributes to mark all nodes that should be manipulated. The macros should be |\long| to allow arbitrary input.
% \begin{macrocode}
\newluatexattribute\leetattr
+\newluatexattribute\letterspaceadjustattr
\newluatexattribute\randcolorattr
\newluatexattribute\randfontsattr
\newluatexattribute\randuclcattr
@@ -542,6 +601,18 @@ The namespace of the chickenize package is \emph{not} consistent. Please don't t
\long\def\textleetspeak#1%
{\setluatexattribute\leetattr{42}#1\unsetluatexattribute\leetattr}
+
+\long\def\textletterspaceadjust#1{
+ \setluatexattribute\letterspaceadjustattr{42}#1\unsetluatexattribute\letterspaceadjustattr
+ \directlua{
+ if (textletterspaceadjustactive) then else % -- if already active, do nothing
+ luatexbase.add_to_callback("pre_linebreak_filter",textletterspaceadjust,"textletterspaceadjust")
+ end
+ textletterspaceadjustactive = true % -- set to active
+ }
+}
+\let\textlsa\textletterspaceadjust
+
\long\def\textrandomcolor#1%
{\setluatexattribute\randcolorattr{42}#1\unsetluatexattribute\randcolorattr}
\long\def\textrandomfonts#1%
@@ -614,12 +685,12 @@ sloppyline(flugel_vorne,flugel_unten) sloppyline(flugel_hinten,flugel_unten)
% Some code might be implemented to manipulate figures for full chickenization. However, I will \emph{not} load any packages at this place, as loading of expl3 or TikZ or whatever takes too much time for such a tiny package like this one. If you require any of the features presented here, you have to load the packages on your own. Maybe this will change.
% \begin{macrocode}
\ProvidesPackage{chickenize}%
- [2012/05/20 v0.1 chickenize package]
+ [2012/09/16 v0.1a chickenize package]
\input{chickenize}
% \end{macrocode}
% \subsection{Definition of User-Level Macros}
+% Nothing done so far, just some minor ideas. If you want to implement some cool things, contact me! :)
% \begin{macrocode}
- %% We want to “chickenize” figures, too. So …
\iffalse
\DeclareDocumentCommand\includegraphics{O{}m}{
\fbox{Chicken} %% actually, I'd love to draw an MP graph showing a chicken …
@@ -638,9 +709,9 @@ sloppyline(flugel_vorne,flugel_unten) sloppyline(flugel_hinten,flugel_unten)
%\fi
% \section{Lua Module}
% \label{sec:luamodule}
-% This file contains all the necessary functions, sorted alphabetically, not by sense.
+% This file contains all the necessary functions and is the actual work horse of this package. The functions are sorted strictly alphabetically (or, they \emph{should} be …) and not by sense, functionality or anything.
%
-% First, we set up some constants. These are made global so the code can be manipulated at the document level, too.
+% First, we set up some constants that are used by many of the following functions. These are made global so the code can be manipulated at the document level, too.
% \begin{macrocode}
local nodenew = node.new
@@ -650,6 +721,7 @@ local nodeinsertafter = node.insert_after
local noderemove = node.remove
local nodeid = node.id
local nodetraverseid = node.traverse_id
+local nodeslide = node.slide
Hhead = nodeid("hhead")
RULE = nodeid("rule")
@@ -673,7 +745,7 @@ color_pop.cmd = 2
chicken_pagenumbers = true
chickenstring = {}
-chickenstring[1] = "Chicken" -- chickenstring is a table, please remeber this!
+chickenstring[1] = "chicken" -- chickenstring is a table, please remeber this!
chickenizefraction = 0.5
-- set this to a small value to fool somebody, or to see if your text has been read carefully. This is also a great way to lay easter eggs for your own class / package …
@@ -685,7 +757,9 @@ local shrink = tbl.parameters.space_shrink
local stretch = tbl.parameters.space_stretch
local match = unicode.utf8.match
chickenize_ignore_word = false
-
+% \end{macrocode}
+% The function |chickenize_real_stuff| is started once the beginning of a to-be-substituted word is found.
+% \begin{macrocode}
chickenize_real_stuff = function(i,head)
while ((i.next.id == 37) or (i.next.id == 11) or (i.next.id == 7) or (i.next.id == 0)) do --find end of a word
i.next = i.next.next
@@ -718,7 +792,7 @@ chickenize_real_stuff = function(i,head)
j = j+1
end
- node.slide(chicken[1])
+ nodeslide(chicken[1])
lang.hyphenate(chicken[1])
chicken[1] = node.kerning(chicken[1]) -- FIXME: does not work
chicken[1] = node.ligaturing(chicken[1]) -- dito
@@ -726,12 +800,19 @@ chickenize_real_stuff = function(i,head)
nodeinsertbefore(head,i,chicken[1])
chicken[1].next = chicken[2] -- seems to be necessary … to be fixed
chicken[string.len(chickenstring_tmp)].next = i.next
+
+ -- shift lowercase latin letter to uppercase if the original input was an uppercase
+ if (chickenize_capital and (chicken[1].char > 96 and chicken[1].char < 123)) then
+ chicken[1].char = chicken[1].char - 32
+ end
+
return head
end
chickenize = function(head)
for i in nodetraverseid(37,head) do --find start of a word
if (chickenize_ignore_word == false) then -- normal case: at the beginning of a word, we jump into chickenization
+ if (i.char > 64 and i.char < 91) then chickenize_capital = true else chickenize_capital = false end
head = chickenize_real_stuff(i,head)
end
@@ -750,6 +831,9 @@ chickenize = function(head)
return head
end
+% \end{macrocode}
+% A small additional feature: Some nice text to cheer up the user. Mainly to show that and how we can access the |stop_run| callback. (see above)
+% \begin{macrocode}
local separator = string.rep("=", 28)
local texiowrite_nl = texio.write_nl
nicetext = function()
@@ -767,6 +851,27 @@ nicetext = function()
end
end
% \end{macrocode}
+
+% \subsection{countglyphs}\label{sec:countglyphs}
+% Counts the glyphs in your documnt. Where “glyph” means every printed character in everything that is a paragraph – formulas do \emph{not} work! However, hyphenations \emph{do} work and the hyphen sign \emph{is counted}! And that is the sole reason for this function – every simple script could read the letters in a doucment, but only after the hyphenation it is possible to count the real number of printed characters – where the hyphen does count.
+%
+% This function will be extended to allow counting of whatever you want.
+% \begin{macrocode}
+countglyphs = function(head)
+ for line in nodetraverseid(0,head) do
+ for glyph in nodetraverseid(37,line.head) do
+ glyphnumber = glyphnumber + 1
+ end
+ end
+ return head
+end
+% \end{macrocode}
+% To print out the number at the end of the document, the following function is registered in the |stop_run| callback. This will prevent the normal message from being printed, informing the user about page and memory stats etc. But I guess when counting characters, everything else does not matter at all? …
+% \begin{macrocode}
+printglyphnumber = function()
+ texiowrite_nl("Number of glyphs in this document: "..glyphnumber)
+end
+% \end{macrocode}
% \subsection{guttenbergenize}\label{sec:guttenbergenize}
% A function in honor of the German politician Guttenberg.\footnote{Thanks to Jasper for bringing me to this idea!} Please do \emph{not} confuse him with the grand master Gutenberg!
%
@@ -948,7 +1053,23 @@ letterspaceadjust = function(head)
return head
end
% \end{macrocode}
-%
+% \subsubsection{textletterspaceadjust}
+% The |\text...|-version of |letterspaceadjust|. Just works, without the need to call |\letterspaceadjust| globally or anything else. Just put the |\textletterspaceadjust| around the part of text you want the function to work on. Might have problems with surrounding spacing, take care!
+% \begin{macrocode}
+textletterspaceadjust = function(head)
+ for glyph in node.traverse_id(node.id"glyph", head) do
+ if node.has_attribute(glyph,luatexbase.attributes.letterspaceadjustattr) then
+ if glyph.prev and (glyph.prev.id == node.id"glyph" or glyph.prev.id == node.id"disc") then
+ local g = node.copy(letterspace_glue)
+ node.insert_before(head, glyph, g)
+ node.insert_before(head, g, node.copy(letterspace_pen))
+ end
+ end
+ end
+ luatexbase.remove_from_callback("pre_linebreak_filter","textletterspaceadjust")
+ return head
+end
+% \end{macrocode}
% \subsection{matrixize}\label{sec:matrixize}
% Substitutes every glyph by a representation of its ASCII value. Migth be extended to cover the entire unicode range, but so far only 8bit is supported. The code is quite straight-forward and works OK. The line ends are not necessarily adjusted correctly. However, with microtype, i.\,e. font expansion, everything looks fine.
% \begin{macrocode}
@@ -988,14 +1109,18 @@ pancaketext = function()
texiowrite_nl("(This goes by document, not compilation.)")
texiowrite_nl(separator.."\n\n")
texiowrite_nl("Looking forward for my pancake! :)")
+ texiowrite_nl("\n\n")
end
% \end{macrocode}
+% \subsection{randomerror}\label{sec:randomerror}
+
+
% \subsection{randomfonts}\label{sec:randomfonts}
% Traverses the output and substitutes fonts randomly. A check is done so that the font number is existing.
% One day, the fonts should be easily given explicitly in terms of |\bf| etc.
% \begin{macrocode}
-local randomfontslower = 1
-local randomfontsupper = 0
+randomfontslower = 1
+randomfontsupper = 0
%
randomfonts = function(head)
local rfub
@@ -1126,6 +1251,24 @@ end
% Another tribute to pop culture. Either: substitute word-by-word as in pancake. OR: substitute each link to a youtube-rickroll …
% \begin{macrocode}
% \end{macrocode}
+% \subsection{substitutewords}\label{sec:substitutewords}
+% This function is one of the rather usefull ones of this package. It replaces each occurance of one word by another word, which both are specified by the user. So nothing random or funny, but a real serious function! There are three levels for this function: At user-level, the user just specifies two strings that are passed to the function |addtosubstitutions|. This is needed as the |#| has a special meaning both in \TeX s definitions and in Lua. In this second step, the list of substitutions is just extended, and the real work is done by the function |substiuteword| which is registered in the |process_input_buffer| callback. Once the substitution list is built, the rest is very simple: We just use |gsub| to substitute, do this for every item in the list, and that's it.
+% \begin{macrocode}
+substitutewords_strings = {}
+
+addtosubstitutions = function(input,output)
+ substitutewords_strings[#substitutewords_strings + 1] = {}
+ substitutewords_strings[#substitutewords_strings][1] = input
+ substitutewords_strings[#substitutewords_strings][2] = output
+end
+
+substitutewords = function(head)
+ for i = 1,#substitutewords_strings do
+ head = string.gsub(head,substitutewords_strings[i][1],substitutewords_strings[i][2])
+ end
+ return head
+end
+% \end{macrocode}
% \subsection{tabularasa}\label{sec:tabularasa}
% Removes every glyph from the output and replaces it by empty space. In the end, next to nothing will be visible. Should be extended to also remove rules or just anything visible.
% \begin{macrocode}
@@ -1347,9 +1490,9 @@ function zebranize(head)
return (head)
end
% \end{macrocode}
-% And that's it!\qquad {\fontsize{40}{0}\raisebox{-2ex}{\fontspec{XITS}☺}}
+% And that's it!\qquad {\fontsize{40}{0}\raisebox{-2ex}{\XITS ☺}}
% \newpage
-% Well, it's not the whole story so far. I plan to test some drawing using only Lua code, writing directly to the pdf file. This section will grow and get better in parallel to my understandings of what's going on. I.e. it will be very slowly … Nothing here is to be taken as good and/or correct LuaTeXing, and most code is plain ugly. However, it kind of works already {\fontspec{XITS}☺}
+% Well, it's not the whole story so far. I plan to test some drawing using only Lua code, writing directly to the pdf file. This section will grow and get better in parallel to my understandings of what's going on. I.e. it will be very slowly … Nothing here is to be taken as good and/or correct LuaTeXing, and most code is plain ugly. However, it kind of works already {\XITS ☺}
% \section{Drawing}
% A \emph{very} first, experimental implementation of a drawing of a chicken. The parameters should be consistent, easy to change and that monster should look more like a cute chicken. However, it is chicken, it is Lua, so it belongs into this package. So far, all numbers and positions are hard coded, this will of course change!
% \begin{macrocode}
@@ -1443,9 +1586,10 @@ end
% \begin{description}
% \item[babel] Using |chickenize| with |babel| leads to a problem with the " (double quote) character, as it is made active: When using |\chickenizesetup| \emph{after} |\begin{document}|, you can \emph{not} use " for strings, but you have to use ' (single quote) instead. No problem really, but take care of this.
% \end{description}
-% \section{To Dos}
+% \section{To Do's}
% Some things that should be implemented but aren’t so far or are very poor at the moment:
% \begin{description}
+% \item[countglyphs] should be extended to count anything the user wants to count
% \item[rainbowcolor] should be more flexible – the angle of the rainbow should be easily adjustable.
% \item[pancakenize] should do something funny.
% \item[chickenize] should differ between character and punctuation.