diff options
-rw-r--r-- | tex/context/third/enigma/enigma.lua | 51 | ||||
-rw-r--r-- | tex/context/third/enigma/t-enigma.mkvi | 12 | ||||
-rw-r--r-- | tex/plain/enigma/enigma.tex | 12 |
3 files changed, 42 insertions, 33 deletions
diff --git a/tex/context/third/enigma/enigma.lua b/tex/context/third/enigma/enigma.lua index 73c481f..47eeb5b 100644 --- a/tex/context/third/enigma/enigma.lua +++ b/tex/context/third/enigma/enigma.lua @@ -12,7 +12,7 @@ --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Format Dependent Code] +\startdocsection[title=Format Dependent Code] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph @@ -45,12 +45,12 @@ else -- external call, mtx-script or whatever _G.enigma = enigma end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Prerequisites] +\startdocsection[title=Prerequisites] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph First of all, we generate local copies of all those library functions @@ -132,13 +132,13 @@ limit has been exceeded during the \TEX\ run. --ichd]]-- local max_msg_length = 250 --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Globals] +\startdocsection[title=Globals] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph The following mappings are used all over the place as we convert back @@ -232,12 +232,12 @@ mnemonic. end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Pretty printing for debug purposes] +\startdocsection[title=Pretty printing for debug purposes] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph The functions below allow for formatting of the terminal output; they @@ -451,12 +451,12 @@ end local new do --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Rotation] +\startdocsection[title=Rotation] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph The following function \luafunction{do_rotate} increments the rotational @@ -502,12 +502,12 @@ has been reached and covers the corner case \emph{double stepping}. machine.rotors = { rc, rb, ra } end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Input Preprocessing] +\startdocsection[title=Input Preprocessing] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph Internally, we will use lowercase strings as they are a lot more @@ -575,12 +575,12 @@ ten. } --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[ +\startdocsection[ title={Main function chain to be applied to single characters}, ] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -739,12 +739,12 @@ extraction of successive characters from the sequence. -- return tableconcat(result) --end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Initialization string parser] +\startdocsection[title=Initialization string parser] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \placetable[here][]{Initialization strings}{% @@ -842,12 +842,12 @@ extraction of successive characters from the sequence. --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Initialization routines] +\startdocsection[title=Initialization routines] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph @@ -961,12 +961,13 @@ consists of three elements: local encode_general = function (machine, chr) local replacement = pp_substitutions[chr] or valid_char_p[chr] and chr if not replacement then return false end + if utf8len(replacement) == 1 then - return encode_char(machine, chr) + return encode_char(machine, replacement) end local result = { } - for chr in next, utfcharacters(replacement) do - result[#result+1] = encode_char(machine, chr) + for new_chr in utfcharacters(replacement) do + result[#result+1] = encode_char(machine, new_chr) end return result end @@ -1044,13 +1045,13 @@ consists of three elements: end end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\startsection[title=Setup Argument Handling] +\startdocsection[title=Setup Argument Handling] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \startparagraph @@ -1165,11 +1166,11 @@ do end --[[ichd -\stopsection +\stopdocsection --ichd]]-- --[[ichd -\startsection[title=Callback] +\startdocsection[title=Callback] \startparagraph This is the interface to \TEX. We generate a new callback handler for each defined Enigma machine. \CONTEXT\ delivers the head as third @@ -1244,7 +1245,7 @@ enigma.new_machine = function (args, name) end --stub --[[ichd -\stopsection +\stopdocsection --ichd]]-- ------------------------------------------------------------------------ diff --git a/tex/context/third/enigma/t-enigma.mkvi b/tex/context/third/enigma/t-enigma.mkvi index 49ebc54..3165e43 100644 --- a/tex/context/third/enigma/t-enigma.mkvi +++ b/tex/context/third/enigma/t-enigma.mkvi @@ -39,13 +39,15 @@ thirddata = thirddata or { } \stopluacode \registerctxluafile{enigma} -%D \startsection[title=setups] +%D \startdocsection[title=setups] +%D \startparagraph %D The main setup. The \texmacro{defineenigma} macro does not adhere to %D the reommended practis of automatical macro derivation. Rather, we %D have our own parser do the job of setting globals. This is a %D consequence of the intention to offer the same behavior in any of the %D three main formats, \PLAIN, \CONTEXT and \LATEX. Hence, we don’t rely %D on the internal mechanisms but implement our own macro generator. +%D \stopparagraph \def\do_define_enigma#id{% \expandafter\gdef\csname start\enigmaid\endcsname{% @@ -76,8 +78,9 @@ thirddata = thirddata or { } \endgroup% } -%D \stopsection +%D \stopdocsection +%D \startdocsection[title=Setup] \def\do_setup_enigma#args{% \ctxlua{ local enigma = thirddata.enigma @@ -91,8 +94,11 @@ thirddata = thirddata or { } \egroup% } +%D \startparagraph %D The module setup \texmacro{setupenigma} expects key=value, notation. %D All the logic is at the Lua end, not much to see here … +%D \stopparagraph + \def\setupenigma#id{% \bgroup \edef\currentenigmaid{#id} @@ -101,5 +107,7 @@ thirddata = thirddata or { } \do_setup_enigma% } +%D \stopdocsection + \protect % vim:ft=context:sw=2:ts=2:tw=72 diff --git a/tex/plain/enigma/enigma.tex b/tex/plain/enigma/enigma.tex index a81815a..df260d7 100644 --- a/tex/plain/enigma/enigma.tex +++ b/tex/plain/enigma/enigma.tex @@ -1,6 +1,6 @@ \input{luatexbase.sty} \catcode`\_=11 % There’s no reason why this shouldn’t be the case. -%D \startsection[title=Prerequisites] +%D \startdocsection[title=Prerequisites] %D \startparagraph %D Package loading and the namespacing issue are commented on in %D \identifier{enigma.lua}. @@ -31,9 +31,9 @@ \catcode`\^^M = \lettercatcode % eol } \egroup -%D \stopsection +%D \stopdocsection -%D \startsection[title=Setups] +%D \startdocsection[title=Setups] %D \startparagraph %D Once the proper catcodes are in place, the setup macro %D \texmacro{do-setup_enigma} doesn’t to anything besides passing stuff @@ -58,9 +58,9 @@ \luatexcatcodetable \enigmasetupcatcodes \do_setup_enigma% } -%D \stopsection +%D \stopdocsection -%D \startsection[title=Encoding Macros] +%D \startdocsection[title=Encoding Macros] %D \startparagraph %D The environment of \texmacro{\start<enigmaid>} and %D \texmacro{\stop<enigmaid>} allow enabling of Enigma encoding in @@ -97,7 +97,7 @@ \@EA\do_define_enigma\@EA{\enigmaid}% \endgroup% } -%D \stopsection +%D \stopdocsection \catcode`\_=8 % vim:ft=tex:sw=2:ts=2:expandtab:tw=72 |