summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/spac-chr.lmt
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkxl/spac-chr.lmt')
-rw-r--r--tex/context/base/mkxl/spac-chr.lmt63
1 files changed, 33 insertions, 30 deletions
diff --git a/tex/context/base/mkxl/spac-chr.lmt b/tex/context/base/mkxl/spac-chr.lmt
index a71c4a0e1..7c8e02fb6 100644
--- a/tex/context/base/mkxl/spac-chr.lmt
+++ b/tex/context/base/mkxl/spac-chr.lmt
@@ -114,6 +114,7 @@ local function inject_nobreak_space(unicode,head,current,space,spacestretch,spac
local glue = new_glue(space,spacestretch,spaceshrink)
local penalty = new_penalty(10000)
setattrlist(glue,current)
+ setattrlist(penalty,current)
setattrlist(current) -- why reset all
setattr(glue,a_character,unicode) -- bombs
head, current = insertnodeafter(head,current,penalty)
@@ -149,6 +150,7 @@ function characters.replacenbsp(head,original)
end
function characters.replacenbspaces(head)
+ -- todo: wiping as in characters.handler(head)
local wipe = false
for current, char, font in nextglyph, head do -- can be anytime so no traversechar
if char == 0x00A0 then
@@ -186,9 +188,10 @@ local methods = {
-- maybe also 0x0008 : backspace
+ -- Watch out: a return value means "remove"!
+
[0x001E] = function(head,current) -- kind of special
local next = getnext(current)
- head, current = remove_node(head,current,true)
if next and getid(next) == glue_code and getsubtype(next) == spaceskip_code then
local nextnext = getnext(next)
if nextnext then
@@ -198,18 +201,19 @@ local methods = {
end
end
end
+ return head, current
end,
[0x001F] = function(head,current) -- kind of special
local next = getnext(current)
if next then
local char, font = isglyph(next)
- head, current = remove_node(head,current,true)
if char and not ispunctuation[char] then
local p = fontparameters[font]
head, current = insertnodebefore(head,current,new_glue(p.space,p.spacestretch,p.spaceshrink))
end
end
+ return head, current
end,
[0x00A0] = function(head,current) -- nbsp
@@ -309,34 +313,6 @@ local methods = {
characters.methods = methods
--- function characters.handler(head) -- todo: use traverseid
--- local current = head
--- while current do
--- local char, id = isglyph(current)
--- if char then
--- local next = getnext(current)
--- local method = methods[char]
--- if method then
--- if trace_characters then
--- report_characters("replacing character %C, description %a",char,lower(chardata[char].description))
--- end
--- local h = method(head,current)
--- if h then
--- head = remove_node(h,current,true)
--- end
--- end
--- current = next
--- else
--- current = getnext(current)
--- end
--- end
--- return head
--- end
-
--- this also works ok in math as we run over glyphs and these stay glyphs ... not sure
--- about scripts and such but that is not important anyway ... some day we can consider
--- special definitions in math
-
function characters.handler(head)
local wipe = false
for current, char in nextchar, head do
@@ -360,3 +336,30 @@ function characters.handler(head)
end
return head
end
+
+-- function characters.handler(head)
+-- local wiped = false
+-- for current, char in nextchar, head do
+-- local method = methods[char]
+-- if method then
+-- if wiped then
+-- wiped[#wiped+1] = current
+-- else
+-- wiped = { current }
+-- end
+-- if trace_characters then
+-- report_characters("replacing character %C, description %a",char,lower(chardata[char].description))
+-- end
+-- local h = method(head,current)
+-- if h then
+-- head = h
+-- end
+-- end
+-- end
+-- if wiped then
+-- for i=1,#wiped do
+-- head = remove_node(head,wiped[i],true)
+-- end
+-- end
+-- return head
+-- end