summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/context/third/enigma/enigma_manual.tex4
-rw-r--r--tex/context/third/enigma/enigma.lua26
2 files changed, 21 insertions, 9 deletions
diff --git a/doc/context/third/enigma/enigma_manual.tex b/doc/context/third/enigma/enigma_manual.tex
index 34dee9b..49dac4b 100644
--- a/doc/context/third/enigma/enigma_manual.tex
+++ b/doc/context/third/enigma/enigma_manual.tex
@@ -51,7 +51,7 @@
\startdocchapter[title=Usage]
-\startdocsection[title=Loading the Module/Package]
+\startdocsection[title=Loading the Module / Package]
The intention is for the \modulename{Enigma} codebase to integrate
with the three most popular (as of 2012) \TEX\ formats:
\CONTEXT,
@@ -395,7 +395,7 @@ following listing, two instances of the same machine are generated and
applied.
\startcontexttyping
-\usemodule[enigma] %% load the module
+\usemodule [enigma] %% load the module
\defineenigma [secretmessage] %% generate and
\setupenigma [secretmessage] [ %% configure a machine
day_key = B IV V II 01 01 01 AD CN ET FL GI JV KZ PU QY WX,
diff --git a/tex/context/third/enigma/enigma.lua b/tex/context/third/enigma/enigma.lua
index 5c3e20c..48d1134 100644
--- a/tex/context/third/enigma/enigma.lua
+++ b/tex/context/third/enigma/enigma.lua
@@ -1423,6 +1423,7 @@ local new_callback = function (machine, name)
if machine.spacing then -- auto-group output
insert_encoded = function (head, n, replacement)
local insertion = nodecopy(n)
+ local current_node = insertion -- needed for multi replacements
if replacement then -- inefficient but bulletproof
insertion.char = utf8byte(replacement)
--print(utf8char(n.char), "=>", utf8char(insertion.char))
@@ -1431,9 +1432,11 @@ local new_callback = function (machine, name)
mod_5 = mod_5 + 1
if mod_5 >= 5 then
mod_5 = 0
- nodeinsert_after(head, insertion, nodecopy(space_node))
+ current_node = nodecopy(space_node)
+ nodeinsert_after(head, insertion, nodecopy(current_node))
end
noderemove(head, n)
+ return current_node -- so we know where to insert
end
else
insert_encoded = function (head, n, replacement)
@@ -1443,6 +1446,7 @@ local new_callback = function (machine, name)
end
nodeinsert_before(head, n, insertion)
noderemove(head, n)
+ return insertion
end
end
local format_is_context_p = format_is_context_p
@@ -1468,8 +1472,9 @@ local new_callback = function (machine, name)
elseif treplacement == "string" then
insert_encoded(head, n, replacement)
elseif treplacement == "table" then
+ local current = n
for i=1, #replacement do
- insert_encoded(head, n, replacement)
+ current = insert_encoded(head, current, replacement[i])
end
end
elseif nid == GLUE_NODE then
@@ -1482,11 +1487,18 @@ local new_callback = function (machine, name)
elseif nid == DISC_NODE then
--- ligatures need to be resolved if they are characters
local npre, npost = n.pre, n.post
- if npre and npost then
- local replacement_pre = machine:encode(utf8char(npre.char))
- local replacement_post = machine:encode(utf8char(npost.char))
- insert_encoded(head, npre, replacement_pre)
- insert_encoded(head, npost, replacement_post)
+ if nodeid(npre) == GLYPH_NODE and
+ nodeid(npost) == GLYPH_NODE then
+ if npre.char and npost.char then -- ligature between glyphs
+ local replacement_pre = machine:encode(utf8char(npre.char))
+ local replacement_post = machine:encode(utf8char(npost.char))
+ insert_encoded(head, npre, replacement_pre)
+ insert_encoded(head, npost, replacement_post)
+ else -- hlists or whatever
+ -- pass
+ --noderemove(head, npre)
+ --noderemove(head, npost)
+ end
end
noderemove(head, n)
--else