summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorPhilipp Gesang <gesang@stud.uni-heidelberg.de>2012-06-25 10:52:04 +0200
committerPhilipp Gesang <gesang@stud.uni-heidelberg.de>2012-06-25 10:52:04 +0200
commite7c981e0bb3e33871bcd85d2cf5b90b3529465fc (patch)
tree8b322e71f9a032509170a8cd088833a63329a7d2 /tex
parent98954b66be4d64d3e4a3abcf5c44c3d236677504 (diff)
downloadenigma-e7c981e0bb3e33871bcd85d2cf5b90b3529465fc.tar.gz
[cbk] fix handling of ligatures and multiple replacements
Diffstat (limited to 'tex')
-rw-r--r--tex/context/third/enigma/enigma.lua26
1 files changed, 19 insertions, 7 deletions
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