summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/math-noa.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-08-13 17:00:01 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-08-13 17:00:01 +0200
commit3ac1a4bbf84101cca4e80acb31eb7fc5754248d3 (patch)
tree3d97b1742ef8bca623e24328b94ecabcec3d2285 /tex/context/base/mkiv/math-noa.lua
parent75db37fb5f8e98bbd8a702ff1d0e765015bab61f (diff)
downloadcontext-3ac1a4bbf84101cca4e80acb31eb7fc5754248d3.tar.gz
2017-08-13 16:44:00
Diffstat (limited to 'tex/context/base/mkiv/math-noa.lua')
-rw-r--r--tex/context/base/mkiv/math-noa.lua72
1 files changed, 50 insertions, 22 deletions
diff --git a/tex/context/base/mkiv/math-noa.lua b/tex/context/base/mkiv/math-noa.lua
index 317b2b6f1..acd2c0dc6 100644
--- a/tex/context/base/mkiv/math-noa.lua
+++ b/tex/context/base/mkiv/math-noa.lua
@@ -62,7 +62,7 @@ local trace_domains = false registertracker("math.domains", function
local trace_families = false registertracker("math.families", function(v) trace_families = v end)
local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end)
-local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end)
+local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end)
local report_processing = logreporter("mathematics","processing")
local report_remapping = logreporter("mathematics","remapping")
@@ -1399,9 +1399,7 @@ do
return true
end
- local enable
-
- enable = function()
+ local enable = function()
enableaction("math", "noads.handlers.italics")
if trace_italics then
report_italics("enabling math italics")
@@ -1538,9 +1536,10 @@ do
-- is validpair stil needed?
- local collapse = { }
- local mathlists = characters.mathlists
- local validpair = {
+ local a_mathcollapsing = privateattribute("mathcollapsing")
+ local collapse = { }
+ local mathlists = characters.mathlists
+ local validpair = {
[noad_ord] = true,
[noad_rel] = true,
[noad_bin] = true, -- new
@@ -1557,7 +1556,7 @@ do
collapse[math_char] = function(pointer,what,n,parent)
if parent and mathlists[getchar(pointer)] then
- local found, last, lucleus, lsup, lsub
+ local found, last, lucleus, lsup, lsub, category
local tree = mathlists
local current = parent
while current and validpair[getsubtype(current)] do
@@ -1568,19 +1567,34 @@ do
if char then
local match = tree[char]
if match then
- local ligature = match.ligature
- if ligature then
- found = ligature
- last = current
- lucleus = nucleus
- lsup = sup
- lsub = sub
- end
- tree = match
- if sub or sup then
- break
+ local method = getattr(current,a_mathcollapsing)
+ if method and method > 0 and method <= 3 then
+ local specials = match.specials
+ local mathlist = match.mathlist
+ local ligature
+ if method == 1 then
+ ligature = specials
+ elseif method == 2 then
+ ligature = specials or mathlist
+ else -- 3
+ ligature = mathlist or specials
+ end
+ if ligature then
+ category = mathlist and "mathlist" or "specials"
+ found = ligature
+ last = current
+ lucleus = nucleus
+ lsup = sup
+ lsub = sub
+ end
+ tree = match
+ if sub or sup then
+ break
+ else
+ current = getnext(current)
+ end
else
- current = getnext(current)
+ break
end
else
break
@@ -1596,10 +1610,10 @@ do
if not replace then
if not reported[id][found] then
reported[id][found] = true
- report_collapsing("missing ligature %C",found)
+ report_collapsing("%s ligature %C from %s","ignoring",found,category)
end
elseif trace_collapsing then
- report_collapsing("creating ligature %C",found)
+ report_collapsing("%s ligature %C from %s","creating",found,category)
end
setchar(pointer,found)
local l = getnext(last)
@@ -1627,6 +1641,20 @@ do
return true
end
+ local enable = function()
+ enableaction("math", "noads.handlers.collapse")
+ if trace_collapsing then
+ report_collapsing("enabling math collapsing")
+ end
+ enable = false
+ end
+
+ implement {
+ name = "initializemathcollapsing",
+ actions = enable,
+ onlyonce = true,
+ }
+
end
do