summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2022-09-11 21:22:12 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2022-09-11 21:22:12 +0200
commite94fa4dc30ec28a6727aa85e17aaac18b76aeadb (patch)
treefe878c16484f7dc4344d16b61cec14b9b9ee5449 /tex/context/base/mkxl
parent809177a0640771ac59eb13a1b52c91acb644e3a1 (diff)
downloadcontext-e94fa4dc30ec28a6727aa85e17aaac18b76aeadb.tar.gz
2022-09-11 20:44:00
Diffstat (limited to 'tex/context/base/mkxl')
-rw-r--r--tex/context/base/mkxl/cont-new.mkxl2
-rw-r--r--tex/context/base/mkxl/context.mkxl2
-rw-r--r--tex/context/base/mkxl/math-act.lmt7
-rw-r--r--tex/context/base/mkxl/math-fen.mkxl7
-rw-r--r--tex/context/base/mkxl/math-ini.mkxl21
-rw-r--r--tex/context/base/mkxl/math-noa.lmt104
-rw-r--r--tex/context/base/mkxl/node-res.lmt2
-rw-r--r--tex/context/base/mkxl/strc-mat.mkxl2
-rw-r--r--tex/context/base/mkxl/task-ini.lmt1
9 files changed, 133 insertions, 15 deletions
diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl
index a9631b7bb..6fc406a17 100644
--- a/tex/context/base/mkxl/cont-new.mkxl
+++ b/tex/context/base/mkxl/cont-new.mkxl
@@ -13,7 +13,7 @@
% \normalend % uncomment this to get the real base runtime
-\newcontextversion{2022.09.10 02:42}
+\newcontextversion{2022.09.11 20:42}
%D This file is loaded at runtime, thereby providing an excellent place for hacks,
%D patches, extensions and new features. There can be local overloads in cont-loc
diff --git a/tex/context/base/mkxl/context.mkxl b/tex/context/base/mkxl/context.mkxl
index 4ec59e791..47e196a62 100644
--- a/tex/context/base/mkxl/context.mkxl
+++ b/tex/context/base/mkxl/context.mkxl
@@ -29,7 +29,7 @@
%D {YYYY.MM.DD HH:MM} format.
\immutable\edef\contextformat {\jobname}
-\immutable\edef\contextversion{2022.09.10 02:42}
+\immutable\edef\contextversion{2022.09.11 20:42}
%overloadmode 1 % check frozen / warning
%overloadmode 2 % check frozen / error
diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt
index 4f12bf92e..687f5fed5 100644
--- a/tex/context/base/mkxl/math-act.lmt
+++ b/tex/context/base/mkxl/math-act.lmt
@@ -2208,10 +2208,12 @@ do
["end"] = used,
glyph = unicode,
start = 0,
+ -- start = used/5,
},
{
advance = total,
- ["end"] = 0,
+ -- ["end"] = 0,
+ ["end"] = used/5, -- prevents small gap with inward curved endpoints
extender = 1,
glyph = unicode,
start = used,
@@ -2226,7 +2228,8 @@ do
local height = basechar.height
local depth = basechar.depth
local advance = (parameters.advance or 1/10) * width
- local used = 0.8*height
+ -- local used = 0.8*height
+ local used = 1.2*height -- large overlap because no smaller pieces
local total = height + depth
characters[single].vparts = extensible(single,total,used)
characters[double] = {
diff --git a/tex/context/base/mkxl/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl
index 5dd7ee118..7cb775294 100644
--- a/tex/context/base/mkxl/math-fen.mkxl
+++ b/tex/context/base/mkxl/math-fen.mkxl
@@ -349,7 +349,9 @@
\setfalse\c_math_fenced_sized
\let\math_fenced_middle\math_fenced_middle_sized
% \enforced\let\middle\math_fenced_middle_sized
- #1%
+\begingroup
+ #1% otherwise middle interferes
+\endgroup
\settrue\c_math_fenced_sized
\math_fenced_right
\setfalse\c_math_fenced_sized
@@ -1122,6 +1124,9 @@
\relax
\setmathoptions\mathclosecode\numexpression
\setmathoptions\mathclosecode bor \autoinjectclassoptioncode
+ \relax
+ \setmathoptions\mathmiddlecode\numexpression
+ \setmathoptions\mathmiddlecode bor \autoinjectclassoptioncode
\relax}
\protect
diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl
index a1e5c29a6..ce5f73d74 100644
--- a/tex/context/base/mkxl/math-ini.mkxl
+++ b/tex/context/base/mkxl/math-ini.mkxl
@@ -737,6 +737,7 @@
\definesystemattribute[mathvariant] [public]
\definesystemattribute[mathnumbers] [public]
\definesystemattribute[mathspacing] [public]
+\definesystemattribute[mathfencing] [public]
\definesystemattribute[displaymath] [public]
@@ -2817,6 +2818,26 @@
\setupmathematics
[\c!autonumbers=\v!no]
+\installcorenamespace{autofencing}
+
+\permanent\protected\def\enablemathautofencing
+ {\attribute\mathfencingattribute\plusone
+ \clf_initializemathfencing}
+
+\permanent\protected\def\disablemathautofencing
+ {\attribute\mathfencingattribute\attributeunsetvalue}
+
+\appendtoks
+ \ifcstok{\mathematicsparameter\c!autofencing}\v!yes
+ \enablemathautofencing
+ \else
+ \disablemathautofencing
+ \fi
+\to \everysetupmathematics
+
+\setupmathematics
+ [\c!autofencing=\v!no]
+
%D The consequences of setting this are as follows:
%D
%D \def\TestA#1#2#3%
diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt
index dfdfa6766..8ac0c1cef 100644
--- a/tex/context/base/mkxl/math-noa.lmt
+++ b/tex/context/base/mkxl/math-noa.lmt
@@ -96,6 +96,8 @@ local setattrlist = nuts.setattrlist
local setwidth = nuts.setwidth
local setheight = nuts.setheight
local setdepth = nuts.setdepth
+local setdelimiter = nuts.setdelimiter
+local setclass = nuts.setclass
local getfield = nuts.getfield
local getnext = nuts.getnext
@@ -878,7 +880,7 @@ do
local method = div(a,100)
local size = a % 100
setattr(pointer,a_mathsize,0)
- local delimiter = getfield(pointer,"delimiter")
+ local delimiter = getdelimiter(pointer)
if delimiter then
local chr, fnt, fam = getcharspec(delimiter)
if chr > 0 and fnt > 0 then
@@ -920,8 +922,8 @@ do
local dummyfencechar = 0x2E
local function makefence(what,char,template)
- local d = new_delimiter() -- todo: attr
- local f = new_fence() -- todo: attr
+ local d = new_delimiter()
+ local f = new_fence()
if char then
local sym = getnucleus(char)
local chr, fnt, fam = getcharspec(sym)
@@ -935,8 +937,8 @@ do
setattrlist(d,template)
setattrlist(f,template)
setsubtype(f,what)
- setfield(f,"delimiter",d)
- setfield(f,"class",-1) -- tex itself does this, so not fenceclasses[what]
+ setdelimiter(f,d)
+ setclass(f,-1) -- tex itself does this, so not fenceclasses[what]
return f
end
@@ -1834,9 +1836,11 @@ do
local a_numbers = privateattribute("mathnumbers")
local a_spacing = privateattribute("mathspacing")
+ local a_fencing = privateattribute("mathfencing")
- local numbers = { }
- local spacing = { }
+ local numbers = { }
+ local spacing = { }
+ local fencing = { }
local separators = {
[0x2E] = { 0x2E, 0x2C, 0x002E, 0x002C, 0x2008, 0x2008 }, -- . -- punctuationspace
@@ -1861,6 +1865,18 @@ do
[0x2236] = snoloc,
}
+ local middles = {
+ [0x007C] = true,
+ [0x2016] = true,
+ [0x2980] = true,
+ }
+
+ local singles = {
+ 0x007C,
+ 0x2016,
+ 0x2980,
+ }
+
local followedbyspace_code = tex.noadoptioncodes.followedbyspace
local function followedbyspace(n)
@@ -1942,6 +1958,56 @@ do
end
end
+ -- we can share code, see earlier
+
+ local function makefence(chr,fam,subtype,class,template)
+ local f = new_fence()
+ local d = new_delimiter()
+ setchar(d,chr)
+ setfam(d,fam)
+ setattrlist(d,template)
+ setattrlist(f,template)
+ setsubtype(f,subtype)
+ setdelimiter(f,d)
+ setclass(f,class) -- tex itself does this, so not fenceclasses[what]
+ return f
+ end
+
+ -- we loose scripts so maybe also copy these
+
+ fencing[mathchar_code] = function(pointer,what,n,parent)
+ if getattr(pointer,a_fencing) and pointer == getnucleus(parent) then
+ local oldchar = getcharspec(pointer)
+ local found = middles[oldchar]
+ if found then
+ local prev, next = getboth(parent)
+ if getcharspec(next) == oldchar then
+ local nextnext = getnext(next)
+ -- we need to preserve the followed property
+ if getcharspec(nextnext) == oldchar then
+ oldchar = singles[3]
+ prev, parent = nuts.remove(prev,parent,true)
+ prev, parent = nuts.remove(prev,parent,true)
+ else
+ oldchar = singles[2]
+ prev, parent = nuts.remove(prev,parent,true)
+ end
+ next = getnext(parent)
+ pointer = getnucleus(parent)
+ setchar(pointer,oldchar)
+ end
+ if followedbyspace(prev) and followedbyspace(parent) then
+ local chr, fnt, fam = getcharspec(pointer)
+ local f1 = makefence(0,0,0,0,pointer)
+ local f2 = makefence(chr,fam,middlefence_code,middle_class,pointer)
+ setlink(prev,f1,f2,next)
+ flushnode(parent)
+ end
+ return true, parent
+ end
+ end
+ end
+
-- numbers
function handlers.numbers(head,style,penalties)
@@ -1970,8 +2036,8 @@ do
local enable = function()
enableaction("math", "noads.handlers.spacing")
- -- if trace_numbers then
- -- report_spacing("enabling math spacinf")
+ -- if trace_spacing then
+ -- report_spacing("enabling math spacing")
-- end
enable = false
end
@@ -1982,6 +2048,26 @@ do
onlyonce = true,
}
+ -- fences
+
+ function handlers.fencing(head,style,penalties)
+ processnoads(head,fencing,"fencing")
+ end
+
+ local enable = function()
+ enableaction("math", "noads.handlers.fencing")
+ -- if trace_fencing then
+ -- report_fencing("enabling math fencing")
+ -- end
+ enable = false
+ end
+
+ implement {
+ name = "initializemathfencing",
+ actions = enable,
+ onlyonce = true,
+ }
+
end
-- primes and such
diff --git a/tex/context/base/mkxl/node-res.lmt b/tex/context/base/mkxl/node-res.lmt
index 5b7ac3fb5..e023499e5 100644
--- a/tex/context/base/mkxl/node-res.lmt
+++ b/tex/context/base/mkxl/node-res.lmt
@@ -462,6 +462,8 @@ function nutpool.noad(class)
return n
end
+-- maybe also the rest wrt subtype and class
+
function nutpool.delimiter() return copy_nut(delimiter) end nutpool.delim = nutpool.delimiter
function nutpool.fence() return copy_nut(fence) end
function nutpool.submlist() return copy_nut(submlist) end
diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl
index a8d674723..71676c9ec 100644
--- a/tex/context/base/mkxl/strc-mat.mkxl
+++ b/tex/context/base/mkxl/strc-mat.mkxl
@@ -1319,7 +1319,7 @@
{\raggedright
\mathgluemode\plustwo
\c_strc_math_ragged_status\plustwo
- \strc_math_analyze_box}\stopformula
+ \strc_math_analyze_box}
\def\strc_math_setup_align_auto
{\ifcsname\??mathtextalign\formulaparameter\c!align:\v!auto\endcsname
diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt
index 862192c83..9c90aba02 100644
--- a/tex/context/base/mkxl/task-ini.lmt
+++ b/tex/context/base/mkxl/task-ini.lmt
@@ -100,6 +100,7 @@ appendaction("shipouts", "wrapup", "luatex.synctex.collect",
appendaction("math", "normalizers", "noads.handlers.showtree", nil, "nonut", "disabled" )
appendaction("math", "normalizers", "noads.handlers.numbers", nil, "nonut", "disabled" )
appendaction("math", "normalizers", "noads.handlers.spacing", nil, "nonut", "disabled" )
+appendaction("math", "normalizers", "noads.handlers.fencing", nil, "nonut", "disabled" )
appendaction("math", "normalizers", "noads.handlers.unscript", nil, "nonut", "enabled" )
appendaction("math", "normalizers", "noads.handlers.unstack", nil, "nonut", "disabled" )
appendaction("math", "normalizers", "noads.handlers.relocate", nil, "nonut", "enabled" )