Difference between revisions of "Encrypt your document using ROT13"
From LuaTeXWiki
(Copied from the old bluwiki.com luatex wiki) |
(No difference)
|
Latest revision as of 21:19, 7 December 2010
The following PlainTeX code example uses the ligaturing callback to "encrypt" the document using ROT13-"encryption".
%&luatex
% Notes:
%
% - Hyphenation is applied before rotating.
% - Ligaturing is performed after rotating.
\pdfoutput=1
\begingroup
\catcode`\%=12
\directlua0{
callback.register('ligaturing', function(head)
for v in node.traverse_id(33, head) do
if v.subtype == 1 then
local c = v.char
if c >= 65 and c <= 90 then
v.char = (c - 65 + 13) % 26 + 65
elseif c >= 97 and c <= 122 then
v.char = (c - 97 + 13) % 26 + 97
end
end
end
node.ligaturing(head)
end)
}
\endgroup
% Hello World; fi -- fl -- ffl -- ffi -- enough with the ligatures!
% Better do some kerning instead: AV
Uryyb Jbeyq; sv -- sy -- ssy -- ssv -- rabhtu jvgu gur yvtngherf!
Orggre qb fbzr xreavat vafgrnq: NI
\bye