diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-06-06 13:57:28 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-06-06 13:57:28 +0200 |
commit | 5e668aa418d6d082446e9369ae06625b50e49943 (patch) | |
tree | 8f6acc7855a1f43463d7ac6ae28c6ecc7c42c958 /tex/context/base/mkiv/math-noa.lua | |
parent | 32f8047624c2fa49c3031a66edb5a039a813f276 (diff) | |
download | context-5e668aa418d6d082446e9369ae06625b50e49943.tar.gz |
2017-06-06 13:28:00
Diffstat (limited to 'tex/context/base/mkiv/math-noa.lua')
-rw-r--r-- | tex/context/base/mkiv/math-noa.lua | 100 |
1 files changed, 57 insertions, 43 deletions
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua index 8b1fa87fd..abc5337c6 100644 --- a/tex/context/base/mkiv/math-noa.lua +++ b/tex/context/base/mkiv/math-noa.lua @@ -1525,30 +1525,30 @@ mathpairs[0x222C] = { [0x222B] = 0x222D } mathpairs[0x007C] = { [0x007C] = 0x2016, [0x2016] = 0x2980 } -- bar+bar=double bar+double=triple mathpairs[0x2016] = { [0x007C] = 0x2980, [0x02B9] = 0x2016 } -- double+bar=triple --- local movesub = { --- -- primes --- [0x2032] = 0xFE932, --- [0x2033] = 0xFE933, --- [0x2034] = 0xFE934, --- [0x2057] = 0xFE957, --- -- reverse primes --- [0x2035] = 0xFE935, --- [0x2036] = 0xFE936, --- [0x2037] = 0xFE937, --- } - local movesub = { -- primes - [0x2032] = 0x2032, - [0x2033] = 0x2033, - [0x2034] = 0x2034, - [0x2057] = 0x2057, + [0x2032] = 0xFE932, + [0x2033] = 0xFE933, + [0x2034] = 0xFE934, + [0x2057] = 0xFE957, -- reverse primes - [0x2035] = 0x2035, - [0x2036] = 0x2036, - [0x2037] = 0x2037, + [0x2035] = 0xFE935, + [0x2036] = 0xFE936, + [0x2037] = 0xFE937, } +-- local movesub = { +-- -- primes +-- [0x2032] = 0x2032, +-- [0x2033] = 0x2033, +-- [0x2034] = 0x2034, +-- [0x2057] = 0x2057, +-- -- reverse primes +-- [0x2035] = 0x2035, +-- [0x2036] = 0x2036, +-- [0x2037] = 0x2037, +-- } + -- inner under over vcenter local validpair = { @@ -1563,38 +1563,48 @@ local validpair = { [noad_opnolimits] = true, } -local function movesubscript(parent,current_nucleus,current_char) +local options_supported = tokens.defined("Unosuperscript") + +local function fixsupscript(parent,current,current_char,new_char) + if new_char ~= current_char and new_char ~= true then + setchar(current,new_char) + if trace_collapsing then + report_collapsing("fixing subscript, replacing supscript %U by %U",current_char,new_char) + end + else + if trace_collapsing then + report_collapsing("fixing subscript, supscript %U",current_char) + end + end + if options_supported then + setfield(parent,"options",0x08+0x22) + end +end + +local function movesubscript(parent,current_nucleus,current_char,new_char) local prev = getprev(parent) if prev and getid(prev) == math_noad then local psup = getsup(prev) local psub = getsub(prev) if not psup and not psub then -- {f} {'}_n => f_n^' - -- setchar(current_nucleus,movesub[current_char or getchar(current_nucleus)]) + fixsupscript(prev,current_nucleus,current_char,new_char) local nucleus = getnucleus(parent) local sub = getsub(parent) - local sup = getsup(parent) setsup(prev,nucleus) setsub(prev,sub) local dummy = copy_node(nucleus) setchar(dummy,0) setnucleus(parent,dummy) setsub(parent) - if trace_collapsing then - report_collapsing("fixing subscript") - end elseif not psup then -- {f} {'}_n => f_n^' - -- setchar(current_nucleus,movesub[current_char or getchar(current_nucleus)]) + fixsupscript(prev,current_nucleus,current_char,new_char) local nucleus = getnucleus(parent) - local sup = getsup(parent) setsup(prev,nucleus) local dummy = copy_node(nucleus) setchar(dummy,0) setnucleus(parent,dummy) - if trace_collapsing then - report_collapsing("fixing subscript") - end end end end @@ -1605,7 +1615,9 @@ local function collapsepair(pointer,what,n,parent,nested) -- todo: switch to tur local current_nucleus = getnucleus(parent) if getid(current_nucleus) == math_char then local current_char = getchar(current_nucleus) - if not getsub(parent) and not getsup(parent) then + local p_sub = getsub(parent) + local p_sup = getsup(parent) + if not p_sub and not p_sup then local mathpair = mathpairs[current_char] if mathpair then local next_noad = getnext(parent) @@ -1642,24 +1654,26 @@ local function collapsepair(pointer,what,n,parent,nested) -- todo: switch to tur flush_node(next_noad) collapsepair(pointer,what,n,parent,true) end --- elseif not nested and movesub[current_char] then --- movesubscript(parent,current_nucleus,current_char) end end end --- elseif not nested and movesub[current_char] then --- movesubscript(parent,current_nucleus,current_char) end --- elseif not nested and movesub[current_char] then --- movesubscript(parent,current_nucleus,current_char) end --- elseif not nested and movesub[current_char] then --- movesubscript(parent,current_nucleus,current_char) + elseif p_sup then + if getid(p_sup) == math_char then + local current_char = getchar(p_sup) + local new_char = movesub[current_char] + if new_char then + fixsupscript(parent,p_sup,current_char,new_char) + end + end + return + end + local current_char = getchar(current_nucleus) + local new_char = movesub[current_char] + if new_char then + movesubscript(parent,current_nucleus,current_char,new_char) end -local current_char = getchar(current_nucleus) -if movesub[current_char] then - movesubscript(parent,current_nucleus,current_char) -end end end end |