diff options
Diffstat (limited to 'tex/context/base/mkxl')
79 files changed, 1493 insertions, 451 deletions
diff --git a/tex/context/base/mkxl/anch-box.mkxl b/tex/context/base/mkxl/anch-box.mkxl index d480b2214..e1ab5662c 100644 --- a/tex/context/base/mkxl/anch-box.mkxl +++ b/tex/context/base/mkxl/anch-box.mkxl @@ -32,6 +32,11 @@ linecolor=\namedboxanchorcontentparameter{#1}{\c!rulecolor}, #2} +\mutable\lettonothing\boxanchorone +\mutable\lettonothing\boxanchortwo +\mutable\lettonothing\boxanchorposone +\mutable\lettonothing\boxanchorpostwo + \tolerant\permanent\protected\def\connectboxanchors[#1]#*[#2]#*[#3]#*[#4]#*#:#5#6% {\begingroup % diff --git a/tex/context/base/mkxl/catc-ini.mkxl b/tex/context/base/mkxl/catc-ini.mkxl index d8c4da040..4a473b476 100644 --- a/tex/context/base/mkxl/catc-ini.mkxl +++ b/tex/context/base/mkxl/catc-ini.mkxl @@ -236,8 +236,10 @@ %\letcsname\Uchar"FFFF\Uchar\expandafter`\string#1\endcsname\m_active \letcsname\csactive#1\endcsname\m_active} +\mutable\integerdef\c_active_char_code\zerocount + \permanent\protected\def\pushactivecharcode{\afterassignment\syst_active_push\integerdef\c_active_char_code} -\permanent\protected\def\popactivecharcode {\afterassignment\syst_active_pop\integerdef \c_active_char_code} +\permanent\protected\def\popactivecharcode {\afterassignment\syst_active_pop \integerdef\c_active_char_code} \permanent\protected\def\syst_active_push {\expandafter\let\expandafter\m_active\csname\csactive\Uchar\c_active_char_code\endcsname diff --git a/tex/context/base/mkxl/cldf-ini.mkxl b/tex/context/base/mkxl/cldf-ini.mkxl index 0c5788bb2..b9620ff1c 100644 --- a/tex/context/base/mkxl/cldf-ini.mkxl +++ b/tex/context/base/mkxl/cldf-ini.mkxl @@ -1,5 +1,5 @@ %D \module -%D [ file=cldf-int, +%D [ file=cldf-ini, %D version=2019.01.01, %D title=\CONTEXT\ Data Macros, %D subtitle=Integer, diff --git a/tex/context/base/mkxl/cldf-lmt.lmt b/tex/context/base/mkxl/cldf-lmt.lmt index aba3dacda..1eb80ac60 100644 --- a/tex/context/base/mkxl/cldf-lmt.lmt +++ b/tex/context/base/mkxl/cldf-lmt.lmt @@ -1008,6 +1008,7 @@ do return integer_code, code[n] else local v = scaninteger(true) + -- local v = scancardinal(true) -- if isglobal(what) then if what and (tonumber(what) & global_code) then setsparse(code,"global",n,v) diff --git a/tex/context/base/mkxl/cldf-pos.lmt b/tex/context/base/mkxl/cldf-pos.lmt new file mode 100644 index 000000000..40c88c716 --- /dev/null +++ b/tex/context/base/mkxl/cldf-pos.lmt @@ -0,0 +1,137 @@ +if not modules then modules = { } end modules ['cldf-pos'] = { + version = 1.001, + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- https://cse512-19s.github.io/FP-Well-Rounded/ + +local tostring, load, type, tonumber = tostring, load, type, tonumber +local lpegmatch = lpeg.match +local context = context + +local setmetatableindex = table.setmetatableindex + +local implement = interfaces.implement + +local fromposit = posit.fromposit +local toposit = posit.toposit +local posittonumber = posit.tonumber + +local values = tokens.values +local boolean_code = values.boolean + +do + + local scanners = tokens.scanners + local scanfloat = scanners.float + local scaninteger = scanners.integer + local scancsname = scanners.csname + + local codes = tex.codes + + local global_code = tex.flagcodes.global + + local savelua = token.savelua + ----- isdefined = token.isdefined + + local newsparse = sparse.new + local setsparse = sparse.set + ----- wipesparse = sparse.wipe + local restoresparse = sparse.restore + + local registerfunction = context.functions.register + + implement { + name = "positunumdef", + public = true, + untraced = true, + protected = true, + actions = function(what) + local name = scancsname(true) + local code = newsparse() + local restore = registerfunction(function() restoresparse(code) end) + implement { + name = name, + public = true, + protected = true, + usage = "value", + actions = function(what) + local n = scaninteger() + if what == "value" then + local v = fromposit(code[n]) + -- return float_code, v + context("%.99g",v) + else + local v = toposit(scanfloat()) + if what and (tonumber(what) & global_code) then + setsparse(code,"global",n,v) + else + savelua(restore,true) -- only once + setsparse(code,n,v) + end + end + end, + } + codes[name] = code + end, + } + +end + +do + + local p_number = lpeg.patterns.number + local p = lpeg.Cs( + lpeg.Cc("local new = new ; return ") + * ( + lpeg.C(p_number) / function(s) + return "new(" .. s .. ")" + end + + lpeg.P(1) + )^0 + ) + + local t = setmetatableindex({ new = posit.new }, posit) + + local function calculate(s) + local new = lpegmatch(p,s) + new = load(new,nil,nil,t) + if new then + new = new() + if new then + return new + end + end + return old + end + + implement { + name = "positunum", + public = true, + arguments = "string", + actions = function(s) + local r = calculate(s) + local t = type(r) + if t == "boolean" then + context(tostring(r)) + elseif t == "string" then + context(r) + else + context("%N",posittonumber(r)) + end + end + } + + implement { + name = "ifpositunum", + public = true, + usage = "condition", + arguments = "string", + actions = function(s) + return boolean_code, calculate(s) and true or false + end, + } + +end diff --git a/tex/context/base/mkxl/cldf-pos.mkxl b/tex/context/base/mkxl/cldf-pos.mkxl new file mode 100644 index 000000000..e8868eece --- /dev/null +++ b/tex/context/base/mkxl/cldf-pos.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=cldf-pos, +%D version=2023.04.21, +%D title=\CONTEXT\ Data Macros, +%D subtitle=Posit, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Posit Numbers / Initialization} + +% \newcount\trialtypesettingstate % gets aliased at the Lua end + +\registerctxluafile{cldf-pos}{autosuffix} + +\endinput diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index cc8a43777..ccac058fa 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{2023.04.15 00:19} +\newcontextversion{2023.04.26 23:28} %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 d866f4b94..d9dc5e9d1 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{2023.04.15 00:19} +\immutable\edef\contextversion{2023.04.26 23:28} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -104,6 +104,7 @@ \loadmkxlfile{luat-ini} \loadmkxlfile{toks-scn} +\loadmkxlfile{cldf-pos} \loadmkxlfile{syst-aux} \loadmkxlfile{syst-lua} @@ -162,7 +163,7 @@ \loadmkxlfile{node-fin} \loadmkxlfile{node-mig} -%loadmkxlfile{node-pag} +\loadmkxlfile{node-pag} \loadmkxlfile{driv-ini} % after node-ini (ext) diff --git a/tex/context/base/mkxl/driv-shp.lmt b/tex/context/base/mkxl/driv-shp.lmt index 18a12eff7..0048f4bb8 100644 --- a/tex/context/base/mkxl/driv-shp.lmt +++ b/tex/context/base/mkxl/driv-shp.lmt @@ -1804,7 +1804,7 @@ do literal = showdetails, } - callback.register("show_whatsit",function(n,what,l,tlp,l1,l2) + callbacks.register("show_whatsit",function(n,what,l,tlp,l1,l2) local s = nodes.whatsitcodes[n.subtype] if what == 1 then return s or "unknown" @@ -1815,12 +1815,10 @@ do w(n,l,tlp,l1,l2) end end - end) + end,"provide whatsit details") - local names = attributes.names + local names = attributes.names -- we show the name and number - callback.register("get_attribute",function(k,v) - return attributes.names[k], nil -- we show the name and number - end) + callbacks.register("get_attribute",function(k,v) return attributes.names[k], nil end,"provide verbose attrbute name") end diff --git a/tex/context/base/mkxl/font-chk.lmt b/tex/context/base/mkxl/font-chk.lmt index 05a3611cc..e70e9083d 100644 --- a/tex/context/base/mkxl/font-chk.lmt +++ b/tex/context/base/mkxl/font-chk.lmt @@ -487,7 +487,7 @@ do local cache = table.setmetatableindex("table") - callback.register("missing_character", function(n,f,c) + callbacks.register("missing_character", function(n,f,c) local cached = cache[f] local found = cached[c] if found == nil then @@ -530,7 +530,7 @@ do n.font = found[1] n.scale = found[2] end - end) + end,"report details about a missing character") function definers.registerfallbackfont(style,list) local l = fallbacks[style] diff --git a/tex/context/base/mkxl/font-ctx.lmt b/tex/context/base/mkxl/font-ctx.lmt index 1d59ad728..113cade52 100644 --- a/tex/context/base/mkxl/font-ctx.lmt +++ b/tex/context/base/mkxl/font-ctx.lmt @@ -1597,7 +1597,7 @@ do -- else too many locals return (define { name = name, size = size } or 0) end - callbacks.register('define_font', read, "definition of fonts (tfmdata preparation)") + callbacks.register("define_font",read,"define and/or load a font") -- here diff --git a/tex/context/base/mkxl/font-fil.mklx b/tex/context/base/mkxl/font-fil.mklx index 73348645d..89ec2f5c4 100644 --- a/tex/context/base/mkxl/font-fil.mklx +++ b/tex/context/base/mkxl/font-fil.mklx @@ -104,6 +104,11 @@ {\letcsname\??fontfile\fontclass\m_font_name\endcsname\m_font_file \normalexpanded{\font_basics_define_font_synonym_yes_opt[#spec]}} +\let\p_features \undefined +\let\p_fallbacks \undefined +\let\p_goodies \undefined +\let\p_designsize\undefined + \protected\def\font_basics_define_font_synonym_nop_opt[#specification]% {\let\p_features \undefined \let\p_fallbacks \undefined diff --git a/tex/context/base/mkxl/font-tex.lmt b/tex/context/base/mkxl/font-tex.lmt index 2d21687df..c8727de72 100644 --- a/tex/context/base/mkxl/font-tex.lmt +++ b/tex/context/base/mkxl/font-tex.lmt @@ -186,10 +186,10 @@ fonts.handlers.otf.features.register { -- fonts.helpers.registerboxglyph { category = "demo", unicode = 105 } -- fonts.helpers.registerboxglyph { category = "demo", unicode = 106 } -local callbacks = fonts.callbacks or { } -fonts.callbacks = callbacks +local fontcallbacks = fonts.callbacks or { } +fonts.callbacks = fontcallbacks -function callbacks.devirtualize(chardata,f,c) +function fontcallbacks.devirtualize(chardata,f,c) if chardata.commands then local h = node.hpack(nodes.pool.glyph(f,c)) local p = setboxdirectly(f,c,h) @@ -205,7 +205,7 @@ local function processcallback(f,c) if chardata then local callback = chardata.callback if callback then - local action = type(callback) == "function" and callback or callbacks[callback] + local action = type(callback) == "function" and callback or fontcallbacks[callback] if action then action(chardata,f,c) end @@ -213,6 +213,6 @@ local function processcallback(f,c) end end -callback.register("process_character",processcallback) +callbacks.register("process_character",processcallback,"apply an action to a character in a font") -callbacks.callback = processcallback +fontcallbacks.callback = processcallback diff --git a/tex/context/base/mkxl/lang-lab.mkxl b/tex/context/base/mkxl/lang-lab.mkxl index 6152d2874..c8dc33ccc 100644 --- a/tex/context/base/mkxl/lang-lab.mkxl +++ b/tex/context/base/mkxl/lang-lab.mkxl @@ -375,4 +375,27 @@ \permanent\protected\def\LABELTEXT#1{\WORD{\labeltext{#1}}} % only for simple cases! +%D For publications we have gender specific ones (one could use the main one for a +%D gender neutral one). +%D +%D \startbuffer +%D \startlines +%D (\labeltext {demo-texts}) +%D (\labeltexts {demo-texts}{ TEST }) +%D (\leftlabeltext {demo-texts}) +%D (\rightlabeltext{demo-texts}) +%D \stoplines +%D +%D \startlines \mainlanguage[cs] +%D test \btxlabeltext{editor} \par +%D test \btxlabeltext{editor:f} \par +%D test \btxlabeltext{editor:m} \par +%D test \btxlabeltext{editors} \par +%D test \btxlabeltext{editors:f} \par +%D test \btxlabeltext{editors:m} \par +%D \stoplines +%D \stopbuffer +%D +%D \typebuffer \getbuffer + \protect \endinput diff --git a/tex/context/base/mkxl/lpdf-lmt.lmt b/tex/context/base/mkxl/lpdf-lmt.lmt index f443632b8..7f3e53f28 100644 --- a/tex/context/base/mkxl/lpdf-lmt.lmt +++ b/tex/context/base/mkxl/lpdf-lmt.lmt @@ -38,6 +38,7 @@ local formatters, splitupstring = string.formatters, string.splitup local concat, sortedhash = table.concat, table.sortedhash local setmetatableindex = table.setmetatableindex local loaddata = io.loaddata +local ceil = math.ceil local bpfactor <const> = number.dimenfactors.bp @@ -2272,11 +2273,16 @@ end } end if xformtype == 0 or xformtype == 1 or xformtype == 3 then +-- wrapper.BBox = pdfarray { +-- -margin * bpfactor, +-- -margin * bpfactor, +-- (boundingbox[3] + margin) * bpfactor, +-- (boundingbox[4] + margin) * bpfactor, wrapper.BBox = pdfarray { - -margin * bpfactor, - -margin * bpfactor, - (boundingbox[3] + margin) * bpfactor, - (boundingbox[4] + margin) * bpfactor, + -ceil( margin * bpfactor), + -ceil( margin * bpfactor), + ceil((boundingbox[3] + margin) * bpfactor), + ceil((boundingbox[4] + margin) * bpfactor), } end if xformtype == 0 or xformtype == 2 or xformtype == 3 then diff --git a/tex/context/base/mkxl/luat-cbk.lmt b/tex/context/base/mkxl/luat-cbk.lmt index 2a3a58b04..1726f1e5a 100644 --- a/tex/context/base/mkxl/luat-cbk.lmt +++ b/tex/context/base/mkxl/luat-cbk.lmt @@ -166,12 +166,15 @@ function callbacks.known(name) end function callbacks.report() + local usage = list_callbacks() for name, _ in sortedhash(list) do local str = frozen[name] + local sta = state(name) + local use = usage[name] and "+" or "-" if str then - report_callbacks("%s: %s -> %s",state(name),name,str) + report_callbacks("%-9s : %s : %-22s -> %s",sta,use,name,str) else - report_callbacks("%s: %s",state(name),name) + report_callbacks("%-9s : %s : %-22s", sta,use,name) end end end diff --git a/tex/context/base/mkxl/luat-run.lmt b/tex/context/base/mkxl/luat-run.lmt index c53817697..7796bb4b9 100644 --- a/tex/context/base/mkxl/luat-run.lmt +++ b/tex/context/base/mkxl/luat-run.lmt @@ -156,10 +156,10 @@ appendaction(wrapupactions,"system",synctex.wrapup) -- this can be done later -callbacks.register('start_run', start_run, "actions performed at the beginning of a run") -callbacks.register('stop_run', stop_run, "actions performed at the end of a run") +callbacks.register("start_run", start_run, "actions performed at the beginning of a run") +callbacks.register("stop_run", stop_run, "actions performed at the end of a run") callbacks.register("pre_dump", pre_dump_actions, "lua related finalizers called before we dump the format") -- comes after \everydump -callbacks.register('wrapup_run', wrapup_run, "actions performed after closing files") +callbacks.register("wrapup_run", wrapup_run, "actions performed after closing files") -- an example: @@ -201,8 +201,6 @@ local report_open = logs.reporter("open source") local report_close = logs.reporter("close source") local report_load = logs.reporter("load resource") -local register = callbacks.register - local level = 0 local total = 0 local stack = { } @@ -219,56 +217,49 @@ function luatex.currenttotal() return total end +local enabled = true directives.register("system.reportfiles", function(v) enabled = v end) + local function report_start(name,rest) - if rest then - -- luatex - if name ~= 1 then + if enabled then + if rest then + -- luatex + if name ~= 1 then + insert(stack,false) + return + end + name = rest + end + if find(name,"virtual://",1,true) then insert(stack,false) - return + else + insert(stack,name) + total = total + 1 + level = level + 1 + -- report_open("%i > %i > %s",level,total,name or "?") + report_open("level %i, order %i, name %a",level,total,name or "?") + synctex.setfilename(name) end - name = rest - end - if find(name,"virtual://",1,true) then - insert(stack,false) - else - insert(stack,name) - total = total + 1 - level = level + 1 - -- report_open("%i > %i > %s",level,total,name or "?") - report_open("level %i, order %i, name %a",level,total,name or "?") - synctex.setfilename(name) end end local function report_stop() - local name = remove(stack) - if name then - -- report_close("%i > %i > %s",level,total,name or "?") - report_close("level %i, order %i, name %a",level,total,name or "?") - level = level - 1 - name = stack[#stack] --- synctex.setfilename(stack[#stack] or tex.jobname) + if enabled then + local name = remove(stack) if name then - synctex.setfilename(name) + -- report_close("%i > %i > %s",level,total,name or "?") + report_close("level %i, order %i, name %a",level,total,name or "?") + level = level - 1 + name = stack[#stack] + -- synctex.setfilename(stack[#stack] or tex.jobname) + if name then + synctex.setfilename(name) + end end end end -local function report_none() -end - -register("start_file",report_start) -register("stop_file", report_stop) - -directives.register("system.reportfiles", function(v) - if v then - register("start_file",report_start) - register("stop_file", report_stop) - else - register("start_file",report_none) - register("stop_file", report_none) - end -end) +callbacks.register("start_file",report_start,"report opening of a file") +callbacks.register("stop_file", report_stop, "report closing of a file") -- start_run doesn't work @@ -281,7 +272,7 @@ end) local report = logs.reporter("csname overload") local reported = { } -callback.register("handle_overload", function(fatal,overload,csname,flags) +callbacks.register("handle_overload", function(fatal,overload,csname,flags) if not reported[csname] then logs.newline() local readstate = status.readstate @@ -303,7 +294,7 @@ callback.register("handle_overload", function(fatal,overload,csname,flags) osexit(1) end end -end) +end,"handle primitive and macro overload protection") -- bonus diff --git a/tex/context/base/mkxl/lxml-ini.mkxl b/tex/context/base/mkxl/lxml-ini.mkxl index be249c1f3..a185efd12 100644 --- a/tex/context/base/mkxl/lxml-ini.mkxl +++ b/tex/context/base/mkxl/lxml-ini.mkxl @@ -83,7 +83,7 @@ \immutable\def\xmltempbuffername{xml-temp} \permanent\protected\def\prettyprintbuffer#1#2% only used here - {\ifdefined\scitebuffer + {\ifdefined\scitebuffer % we could predefine to relax \scitebuffer[#2][#1]% \else \typebuffer[#1][\c!option=#2]% diff --git a/tex/context/base/mkxl/math-acc.mklx b/tex/context/base/mkxl/math-acc.mklx index 8c5a1adfa..2201ed886 100644 --- a/tex/context/base/mkxl/math-acc.mklx +++ b/tex/context/base/mkxl/math-acc.mklx @@ -61,6 +61,20 @@ % \switchtobodyfont[termes] \getbuffer\par % \stop %TEXpage +% scale: +% +% no : only use base +% yes : use base, variants and extensible, stretch and shrink when set +% keep : use base, variants and extensible, stretch and shrink when set, but keep base +% +% alignsymbol: +% +% center when accent is wider than base +% +% stretch|shrink: +% +% scale accent to fit (base and variants depending on 'scale' value) + \installcorenamespace{mathaccents} \installcommandhandler \??mathaccents {mathaccent} \??mathaccents @@ -72,7 +86,10 @@ \c!bottom=, \c!mathstyle=, \c!color=, - \c!stretch=\v!no, + \c!scale=\v!no, + \c!alignsymbol=\v!yes, + %\c!stretch=\v!no, + %\c!shrink=\v!no, \c!define=\v!yes] % not used \definemathaccent @@ -135,20 +152,37 @@ \setlocalmathaccentcurrent{#class}% \edef\currentmathaccent{#class}% \startusemathstyleparameter\mathaccentparameter\c!mathstyle \setupcurrentmathaccent[#settings]% - \edef\m_fixed {\ifcstok{\mathaccentparameter\c!stretch}\v!yes \else\s!fixed \space\fi}% - \edef\m_center{\ifcstok{\mathaccentparameter\c!align }\v!middle \s!center\space\fi}% + \edef\p_scale{\mathaccentparameter\c!scale}% + \ifx\p_scale\v!keep + \lettonothing\m_fixed + \orelse\ifx\p_scale\v!yes + \lettonothing\m_fixed + \else + \let\m_fixed\s!fixed + \fi \Umathaccent \usedcolorparameterattributes{\mathaccentparameter\c!color}% - % nooverflow % there is never na overflow anyway but we do accept thekey - \m_center + % nooverflow % there is never na overflow anyway but we do accept the key + \ifcstok{\mathaccentparameter\c!align }\v!middle\s!center \space\fi + \ifcstok{\mathaccentparameter\c!stretch}\v!yes \s!stretch\space\fi + \ifcstok{\mathaccentparameter\c!shrink }\v!yes \s!shrink \space\fi + \ifx\p_scale\v!keep + \s!keepbase\space + \fi + \ifcstok{\mathaccentparameter\c!alignsymbol}\v!yes + \s!nooverflow\space + \fi \ifcase#kind\or - top \m_fixed + \s!top\space + \m_fixed \fam\zerocount#top \or - bottom \m_fixed + \s!bottom\space + \m_fixed \fam\zerocount#bottom \or - both \m_fixed + \s!both\space + \m_fixed \fam\zerocount#bottom \fam\zerocount#top \fi @@ -175,7 +209,7 @@ \pushoverloadmode % These retain the given unicode values ... but can stretch when configured -% to do so: \setupmathaccent[\v!top][\c!stretch=\v!yes] +% to do so: \setupmathaccent[\v!top][\c!scale=\v!yes] % Extended/modified below % @@ -229,17 +263,17 @@ \definemathaccent [\v!top:\v!stretch] [\v!top] - [\c!stretch=\v!yes] + [\c!scale=\v!keep,\c!stretch=\v!yes,\c!shrink=\v!yes] \definemathaccent [\v!bottom:\v!stretch] [\v!bottom] - [\c!stretch=\v!yes] + [\c!scale=\v!keep,\c!stretch=\v!yes,\c!shrink=\v!yes] \definemathaccent [\v!both:\v!stretch] [\v!both] - [\c!stretch=\v!yes] + [\c!scale=\v!keep,\c!stretch=\v!yes,\c!shrink=\v!yes] %D We have a problem. We can use stackers but then we need to adapt the dimensions %D which is font dependent. So, for now we keep them as accents. diff --git a/tex/context/base/mkxl/math-act.lmt b/tex/context/base/mkxl/math-act.lmt index f6fd5dab5..ee9e56f8f 100644 --- a/tex/context/base/mkxl/math-act.lmt +++ b/tex/context/base/mkxl/math-act.lmt @@ -433,6 +433,8 @@ local detail do return nxt end end + elseif list == "flataccent" then + return c.flataccent end end end @@ -1951,6 +1953,7 @@ do } local rrp = { + newprivateslot("radical rule left piece"), newprivateslot("radical rule middle piece"), newprivateslot("radical rule right piece"), } @@ -1968,14 +1971,21 @@ do parameters = { } end if parts then + what = copytable(what) parts = copytable(parts) - local xscale = parameters.xscale or 1 - local yscale = parameters.yscale or 1 - local mheight = minus.height - local height = (parameters.height or 1) * mheight - local yshift = (parameters.yoffset or 0) * mheight + local xscale = parameters.xscale or 1 -- why not applied to width ? + local yscale = parameters.yscale or 1 + local mwidth = minus.width + local mheight = minus.height + local height = (parameters.height or 1) * mheight + local yshift = (parameters.yoffset or 0) * mheight + local loverlap = parameters.leftoverlap or 0 + local roverlap = parameters.rightoverlap or 0 + local loffset = parameters.leftoffset or 0 + local roffset = parameters.rightoffset or 0 if skipfirst then - table.remove(parts,1) + remove(parts,1) + remove(what,1) end height = height / 2 yshift = yshift + height @@ -1985,36 +1995,46 @@ do local gdata = characters[glyph] local width = gdata.width local xshift = 0 - if i == 1 and parameters.leftoffset then - xshift = (parameters.leftoffset) * width + if i == 1 and loverlap ~= 0 then + xshift = loverlap * width width = width - xshift - elseif i == #parts and parameters.rightoffset then - width = (1 + parameters.rightoffset) * width + elseif i == #parts and roverlap ~= 0 then + width = width + roverlap * width end characters[what[i]] = { height = height, depth = height, width = width, + advance = gdata.width, commands = { leftcommand[xshift], downcommand[yshift], --- slotcommand[0][glyph], { "slot", 0, glyph, xscale, yscale }, }, } +if part["start"] >= width then + part["start"] = width +end +if part["end"] >= width then + part["end"] = width +end +part.advance = width part.glyph = what[i] - part.advance = width end + xshift = loffset * mwidth + loverlap * mwidth + width = mwidth - xshift - roffset * mwidth - roverlap * mwidth characters[unicode] = { + -- base character height = height, depth = height, - width = advance, + width = width, commands = { + leftcommand[xshift], downcommand[yshift], --- slotcommand[0][0x2212], { "slot", 0, 0x2212, xscale, yscale }, }, unicode = tounicode or unicode, + -- extensibles parts = parts, partsorientation = "horizontal", } @@ -2065,6 +2085,7 @@ do commands = { leftcommand[lshift], slotcommand[0][glyph], +-- { "offset", lshift, 0, glyph }, }, } part.glyph = what[i] @@ -2085,9 +2106,11 @@ do leftcommand[lshift], slotcommand[0][unicode], pop, +-- { "offset", lshift, 0, unicode }, }, }) - local step = width/2 +-- local step = width/2 + local step = .8*width minus.parts = { { extender = 0, glyph = p_normal, ["end"] = step, start = 0, advance = width }, { extender = 1, glyph = p_normal, ["end"] = step, start = step, advance = width }, @@ -2111,7 +2134,13 @@ do useminus(target,fbe,characters,fraction,false,frp,0x2044) -- division slash end if radical then - useminus(target,rbe,characters,radical,true,rrp,0x2061) -- apply function +if not characters[rbe] then + local skipfirst = true + if radical.skipfirst == false then -- explicit + skipfirst = false + end + useminus(target,rbe,characters,radical,skipfirst,rrp,0x2061) -- apply function +end end if stacker then useminus(target,0x203E,characters,stacker,false,frp) @@ -2739,15 +2768,31 @@ end if width == 0 then local d = chardata[data.unicode or unicode] local c = d and d.category - if c == "mn" then + if c == "mn" or c == "sk" or c == "lm" then -- we can probably can go local b = target.descriptions[unicode].boundingbox if b then - local llx = b[1] * factor - local urx = b[3] * factor - width = urx - llx + local topanchor = data.topanchor or 0 + local llx = b[1] * factor + local urx = b[3] * factor +-- if topanchor < 0 then +if true then + -- width = - topanchor + width = 2 * (topanchor - llx) +-- data.commands = { +-- -- rightcommand[width+width/2], +-- rightcommand[-llx], +-- slotcommand[0][unicode] +-- } +data.xoffset = -llx +else + width = urx - llx + -- data.advance = urx + data.commands = { + leftcommand[llx], + slotcommand[0][unicode] + } +end data.width = width - data.xoffset = - llx - data.advance = urx data.topanchor = width/2 data.bottomanchor = width/2 end @@ -2826,20 +2871,33 @@ end local force = parameters.force local squeeze = parameters.squeeze or 0.85 local ofactor = parameters.offset or (squeeze/8.5) - local hfactor = parameters.height or (1 - ofactor) + local hfactor = parameters.height or 0.95 -- (1 - ofactor) local done = false for stretching, entry in sortedhash(mapping) do - local code = stretching - local last = characters[stretching] + local code = stretching + local last = characters[stretching] while last do if force or not last.flataccent then local slot = nps(f_flat(code)) - local data = copytable(last) - local height = data.height or 0 - data.effect = { squeeze = squeeze } - data.height = hfactor * height - data.yoffset = ofactor * height - characters[slot] = data + local height = last.height or 0 +-- print(last.width/65536,code,slot) +-- data.effect = { squeeze = squeeze } +characters[slot] = { + width = last.width, + depth = last.depth, + height = last.height * hfactor, + topanchor = last.topanchor, + bottomanchor = last.bottomanchor, + commands = { { "offset", 0, ofactor * height, code, 1, squeeze } }, +-- commands = { slotcommand[0][code] }, +-- effect = { squeeze = squeeze }, +-- next = last.next, + unicode = last.unicode, +} +-- if code == 770 then +-- inspect(last) +-- end + last.flataccent = slot if not trace_tweaking then done = true @@ -2874,7 +2932,8 @@ end height = stretchingdata.height, depth = stretchingdata.depth, next = stretchingdata.next, - commands = { charcommand[stretching] }, +-- commands = { charcommand[stretching] }, + commands = stretchingdata.commands or { charcommand[stretching] }, topanchor = stretchingdata.topanchor, -- unicode = stretching, -- when we alias to combiners unicode = alias, -- when we keep the original @@ -2892,6 +2951,34 @@ end feedback_tweak("copyaccents",target,original,done) end + function mathtweaks.keepbases(target,original,parameters) + local characters = target.characters + local done = false + local list = parameters.list + if list == "default" then + list = sortedkeys(mapping) + end + if list and #list > 0 then + for i=1,#list do -- assumes sorting + local unicode = list[i] + local chardata = characters[unicode] + if chardata then + chardata.keepbase = true + if not trace_tweaking then + done = true + elseif done then + done[unicode] = true + else + done = { [unicode] = true } + end + end + end + else + -- maybe also hash + end + feedback_tweak("keepbases",target,original,done) + end + end do @@ -3782,7 +3869,7 @@ do end end - -- there is no real need for thios but let's play nice with memory anyway + -- there is no real need for this but let's play nice with memory anyway local efindex = 0 local effects = setmetatableindex (function (t,k) diff --git a/tex/context/base/mkxl/math-ali.mkxl b/tex/context/base/mkxl/math-ali.mkxl index b90bad174..7b61fd234 100644 --- a/tex/context/base/mkxl/math-ali.mkxl +++ b/tex/context/base/mkxl/math-ali.mkxl @@ -938,13 +938,18 @@ \def\math_cases_NC_two {\ifmmode\stopimath\fi} -\def\math_cases_TC_zero +\def\math_cases_TC_zero % needs checking + %{\ifmmode\else\startimath\fi} {} \def\math_cases_TC_one {\ifmmode\stopimath\fi \aligntab} +\def\math_cases_TC_two + %{\ifmmode\stopimath\fi} % needs checking + {} + \permanent\protected\def\math_cases_NC {\ifcase\c_math_cases_nc \expandafter\math_cases_NC_zero @@ -1268,6 +1273,7 @@ \newconditional\c_math_matrix_first \newconstant \c_math_matrix_anchor_mode +\newconditional\c_math_matrix_sl_seen % enabled : 1 % left/both : 2 @@ -1502,7 +1508,7 @@ \protected\def\math_matrix_horizontal_rule_indeed#1#2% {\math_matrix_check_rule[#2]% \global\setfalse\c_math_matrix_first - \global\settrue\c_math_matrix_sl_seen + \global\settrue \c_math_matrix_sl_seen \enablematrixrules \leaders#1% \s!attr \mathalignmenthruleattribute\plusone @@ -2886,6 +2892,8 @@ {\unskip \strc_formulas_place_number_nested{#1}{#2}\crcr} +\aliased\let\math_align_strut\relax + \permanent\tolerant\protected\def\math_simplealign_start[#1]#*[#2]% {\begingroup \edef\currentmathsimplealign{#1}% diff --git a/tex/context/base/mkxl/math-def.mkxl b/tex/context/base/mkxl/math-def.mkxl index b2b8d776f..3e4d724ae 100644 --- a/tex/context/base/mkxl/math-def.mkxl +++ b/tex/context/base/mkxl/math-def.mkxl @@ -46,6 +46,9 @@ \definemathfunction [deg] \definemathfunction [det] [\c!mathlimits=\v!yes] \definemathfunction [dim] +\definemathfunction [erf] +\definemathfunction [erfc] +\definemathfunction [erfi] \definemathfunction [exp] \definemathfunction [gcd] [\c!mathlimits=\v!yes] \definemathfunction [hom] @@ -185,8 +188,7 @@ \permanent\protected\def\amedian {\csname \ifcsname\currentmainlanguage:amedian\endcsname - \currentmainlanguage\else - \s!en + \currentmainlanguage\else\s!en \fi :amedian% \endcsname} diff --git a/tex/context/base/mkxl/math-dif.mkxl b/tex/context/base/mkxl/math-dif.mkxl index ad53ee25a..4c1117726 100644 --- a/tex/context/base/mkxl/math-dif.mkxl +++ b/tex/context/base/mkxl/math-dif.mkxl @@ -19,8 +19,8 @@ % For new times sake: - \let\normal_math_dd\dd - \let\normal_math_DD\DD + \ifdefined\dd \aliased\let\normal_math_dd\dd \else \lettonothing\normal_math_dd \fi + \ifdefined\DD \aliased\let\normal_math_DD\DD \else \lettonothing\normal_math_DD \fi \def\c!differentiald{differentiald} % for now diff --git a/tex/context/base/mkxl/math-fen.mkxl b/tex/context/base/mkxl/math-fen.mkxl index a01f589e5..53c34c567 100644 --- a/tex/context/base/mkxl/math-fen.mkxl +++ b/tex/context/base/mkxl/math-fen.mkxl @@ -305,6 +305,9 @@ \directsetup{math:fence:set:bar} \stopsetups +\mutable\lettonothing\suchthat +% \fastsetup{math:fence:set} + \protected\def\math_fenced_middle_common {\math_fenced_middle} % redefined inside atom @@ -717,6 +720,10 @@ % \im { \left\{ \frac{1}{2} \right\} } % \im { \left\lbrace \frac{1}{2} \right\rbrace } +\lettonothing\math_fenced_x_p_left +\lettonothing\math_fenced_x_p_right +\lettonothing\math_fenced_x_p_middle + \def\math_fenced_x_left {\advanceby\c_math_fence_nesting\plusone \ifx\math_fenced_x_p_left\bgroup\let\math_fenced_x_p_left\letterleftbrace\fi @@ -1046,7 +1053,7 @@ \let\math_fences_normal_left \left \let\math_fences_normal_right \right \let\math_fences_normal_middle\middle -\let\math_fences_normal_both \leftorright +\let\math_fences_normal_both \relax % undefined \protected\def\math_fences_auto_left #1{\c_attr_mathautofence\plusone #1\c_attr_mathautofence\attributeunsetvalue} \protected\def\math_fences_auto_right #1{\c_attr_mathautofence\plustwo #1\c_attr_mathautofence\attributeunsetvalue} @@ -1219,6 +1226,8 @@ {\let\math_fenced_trace\math_fenced_trace_indeed} {\let\math_fenced_trace\donothing} +\mutable\integerdef\c_math_fence_level\minusone + \appendtoks \integerdef\c_math_fence_level\minusone \c_math_fence_nesting\zerocount diff --git a/tex/context/base/mkxl/math-fnt.lmt b/tex/context/base/mkxl/math-fnt.lmt index 7e2c0c75c..87dfe16e5 100644 --- a/tex/context/base/mkxl/math-fnt.lmt +++ b/tex/context/base/mkxl/math-fnt.lmt @@ -54,100 +54,100 @@ local cache = setmetatableindex(function(t,width) return v end) +local enabled = "vertical" directives.register("math.extensibles", function(v) enabled = v end) -- default per 2022-08-25 + local function register_extensible(font,char,style,box) - -- We don't share (yet)! - local fontdata = chardata[font] - local oldchar = fontdata[char] - if oldchar and oldchar.keepvirtual then - -- for now, needed for iwona etc - return nil - else - local bx = tonut(box) - -- actually we don't want colors and such so if we do finalize we - -- should be more selctive: --- updaters.apply("tagging.state.disable") --- nodes.handlers.finalizelist(bx) --- updaters.apply("tagging.state.enable") - local id = getid(bx) - local al = getattrlst(bx) - local wd, ht, dp = getwhd(bx) - local unicode = oldchar.unicode or char - -- we cannot have self referencing t3 fonts - local oldcommands = oldchar.oldcommands - local newcommands = oldchar.commands - if oldcommands then - oldchar.commands = oldcommands - end - -- - local p = fonts.hashes.parameters[font] - local sx = round(1000/p.extendfactor) - local sy = round(1000/p.squeezefactor) - -- we saved a scaled glyph stream so we now use an unscaled one ... horrible hack: - if sx ~= 1000 then - wd = wd * 7200/7227 - end - if sy ~= 1000 then - ht = ht * 7200/7227 - dp = dp * 7200/7227 - end - -- - -- local private = fonts.helpers.setboxdirectly(font,unicode,box) - local private = cache[wd][ht][dp][font][unicode] - if not private then - private = fonts.helpers.setboxdirectly(font,unicode,box) - cache[wd][ht][dp][font][unicode] = private - end - local glyph = new_glyph(font,private,al) - nuts.setscales(glyph,1000,sx,sy) - -- - -- if fonts.hashes.properties[font].compactmath then - -- nuts.setscales(g,1000,1000,1000) - -- end - -- - -- nasty, testcase: bold math sqrt extensible - -- - local n = new_hlist(glyph) - -- - if newcommands then - oldchar.commands = newcommands - end - -- - -- local newchar = { - -- unicode = unicode, - -- width = wd, - -- height = ht, - -- depth = dp, - -- } - -- local p = oldchar.vparts - -- if p then - -- local first = fontdata[p[#p].glyph] - -- local last = fontdata[p[ 1].glyph] - -- if first then - -- newchar.topleft = first.topleft - -- newchar.topright = first.topright - -- end - -- if last then - -- newchar.bottomleft = last.bottomleft - -- newchar.bottomright = last.bottomright - -- end - -- end - -- addcharacters(font, { [private] = newchar }) - -- so the dimensions of the box don't match the glyph scale! - setwhd(n,wd,ht,dp) - setattrlst(n,al) - if id == vlist_code then - n = new_vlist(n) + if enabled then + -- We don't share (yet)! + local fontdata = chardata[font] + local oldchar = fontdata[char] + if oldchar and not oldchar.keepvirtual then +if enabled == true or enabled == "both" or oldchar.partsorientation == enabled then + -- we're okay +else + return +end + local bx = tonut(box) + -- actually we don't want colors and such so if we do finalize we + -- should be more selctive: + -- updaters.apply("tagging.state.disable") + -- nodes.handlers.finalizelist(bx) + -- updaters.apply("tagging.state.enable") + local id = getid(bx) + local al = getattrlst(bx) + local wd, ht, dp = getwhd(bx) + local unicode = oldchar.unicode or char + -- we cannot have self referencing t3 fonts + local oldcommands = oldchar.oldcommands + local newcommands = oldchar.commands + if oldcommands then + oldchar.commands = oldcommands + end + -- + local p = fonts.hashes.parameters[font] + local sx = round(1000/p.extendfactor) + local sy = round(1000/p.squeezefactor) + -- we saved a scaled glyph stream so we now use an unscaled one ... horrible hack: + if sx ~= 1000 then + wd = wd * 7200/7227 + end + if sy ~= 1000 then + ht = ht * 7200/7227 + dp = dp * 7200/7227 + end + -- + -- local private = fonts.helpers.setboxdirectly(font,unicode,box) + local private = cache[wd][ht][dp][font][unicode] + if not private then + private = fonts.helpers.setboxdirectly(font,unicode,box) + cache[wd][ht][dp][font][unicode] = private + end + local glyph = new_glyph(font,private,al) + nuts.setscales(glyph,1000,sx,sy) + -- + -- if fonts.hashes.properties[font].compactmath then + -- nuts.setscales(g,1000,1000,1000) + -- end + -- + -- nasty, testcase: bold math sqrt extensible + -- + local n = new_hlist(glyph) + -- + if newcommands then + oldchar.commands = newcommands + end + -- + -- local newchar = { + -- unicode = unicode, + -- width = wd, + -- height = ht, + -- depth = dp, + -- } + -- local p = oldchar.vparts + -- if p then + -- local first = fontdata[p[#p].glyph] + -- local last = fontdata[p[ 1].glyph] + -- if first then + -- newchar.topleft = first.topleft + -- newchar.topright = first.topright + -- end + -- if last then + -- newchar.bottomleft = last.bottomleft + -- newchar.bottomright = last.bottomright + -- end + -- end + -- addcharacters(font, { [private] = newchar }) + -- so the dimensions of the box don't match the glyph scale! setwhd(n,wd,ht,dp) setattrlst(n,al) + if id == vlist_code then + n = new_vlist(n) + setwhd(n,wd,ht,dp) + setattrlst(n,al) + end + return tonode(n) end - return tonode(n) end end -directives.register("math.extensibles", function(v) - callback.register("register_extensible", v and register_extensible or nil) -end) - --- Default per 2022-08-25 - -callback.register("register_extensible", register_extensible) +callbacks.register("register_extensible",register_extensible,"register math extensible construct") diff --git a/tex/context/base/mkxl/math-frc.mkxl b/tex/context/base/mkxl/math-frc.mkxl index 5c1eab8dd..7e6f7c5ce 100644 --- a/tex/context/base/mkxl/math-frc.mkxl +++ b/tex/context/base/mkxl/math-frc.mkxl @@ -110,7 +110,7 @@ \setupmathfractions [\c!rule=\v!symbol, - \c!middle=\fractionbarextenderuc] + \c!symbol=\fractionbarextenderuc] \appendtoks \instance\frozen\protected\edefcsname\currentmathfraction\endcsname{\math_frac{\currentmathfraction}}% @@ -311,15 +311,23 @@ {\edef\p_method {\mathfractionparameter\c!method}% \edef\p_rule {\mathfractionparameter\c!rule}% \edef\p_thickness{\mathfractionparameter\c!rulethickness}% - \scratchcounterone \mathfractionparameter\c!left \relax - \scratchcountertwo \mathfractionparameter\c!right \relax - \scratchcounterthree \mathfractionparameter\c!middle \relax + \scratchcounterone \mathfractionparameter\c!left \relax + \scratchcountertwo \mathfractionparameter\c!right \relax + \scratchcounterthree + \ifx\p_method\v!horizontal + \mathfractionparameter\c!middle + \orelse\ifx\p_method\v!line + \mathfractionparameter\c!middle + \else + \mathfractionparameter\c!symbol + \fi + \relax \ifcsname \??fractionmethods \p_method \ifx\p_method\v!horizontal \orelse\ifx\p_method\v!line - \orelse\ifcsname\??fractionmethods\p_method\p_rule\endcsname + \orelse\ifcsname\??fractionmethods\p_method\p_rule\endcsname % \v!vertical \p_rule \else \v!auto diff --git a/tex/context/base/mkxl/math-ini.lmt b/tex/context/base/mkxl/math-ini.lmt index f26f24c93..904b98d79 100644 --- a/tex/context/base/mkxl/math-ini.lmt +++ b/tex/context/base/mkxl/math-ini.lmt @@ -169,12 +169,11 @@ do local fontchardata = fonts.hashes.characters local f_dictionary = false - local register = callback.register local whatdetail = "all" local function trace(n,properties,group,index,font,char) -- local properties, group, index, font, char = nodes.nuts.getchardict(nodes.nuts.tonut(n)) - if properties ~= 0 or group ~= 0 or index ~= 0 then + if whatdetail and (properties ~= 0 or group ~= 0 or index ~= 0) then local char = fontchardata[font][char] if char or whatdetail == "all" then local unicode = char and char.unicode @@ -199,16 +198,9 @@ do end end - trackers.register("math.dictionaries",function(v) - whatdetail = v - if whatdetail then - register("get_math_dictionary",trace) - else - register("get_math_dictionary") - end - end) + trackers.register("math.dictionaries",function(v) whatdetail = v end) - register("get_math_dictionary",trace) + callbacks.register("get_math_dictionary",trace,"provide math dictionary details") -- This is experimental and a prelude to the long pending "relate math rendering to -- some field" wish. In TeX characters and symbols are grouped by class but that is @@ -410,7 +402,7 @@ classes["all"] = specialclasses["all"] classnames[specialclasses["all"] ] classes["begin"] = specialclasses["begin"] classnames[specialclasses["begin"]] = "beg" classes["end"] = specialclasses["end"] classnames[specialclasses["end"] ] = "end" -callback.register("get_noad_class", function(n) return classnames[n] end) +callbacks.register("get_noad_class", function(n) return classnames[n] end,"provide math class name") local function registerprivateclass(name,parent) local class = parent and classes[parent] or classes[name] diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index ef75ac4c4..cbcf6164d 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -2983,7 +2983,7 @@ function processors.mlisttohlist(head,style,penalties,beginclass,endclass,level) return head end -callbacks.register('mlist_to_hlist',processors.mlisttohlist,"preprocessing math list") +callbacks.register("mlist_to_hlist",processors.mlisttohlist,"convert a noad list into a node list") -- tracing diff --git a/tex/context/base/mkxl/math-stc.mklx b/tex/context/base/mkxl/math-stc.mklx index 5a701426a..1e488af2c 100644 --- a/tex/context/base/mkxl/math-stc.mklx +++ b/tex/context/base/mkxl/math-stc.mklx @@ -1022,7 +1022,7 @@ \immutable\protected\def\normaldoublebrace {\Umathaccent \s!both \zerocount \zerocount "23DE \zerocount \zerocount "23DF } \immutable\protected\def\normaldoubleparent{\Umathaccent \s!both \zerocount \zerocount "23DC \zerocount \zerocount "23DD } -% let's keep this +% let's keep this .. some are not defined so there's nothing normal \aliased\let\normaloverbrace \overbrace \aliased\let\normalunderbrace \underbrace @@ -1030,10 +1030,11 @@ \aliased\let\normalunderparent \underparent \aliased\let\normaloverbracket \overbracket \aliased\let\normalunderbracket \underbracket -\aliased\let\normalunderleftarrow \underleftarrow -\aliased\let\normaloverleftarrow \overleftarrow -\aliased\let\normalunderrightarrow\underrightarrow -\aliased\let\normaloverrightarrow \overrightarrow + +%aliased\let\normalunderleftarrow \underleftarrow +%aliased\let\normaloverleftarrow \overleftarrow +%aliased\let\normalunderrightarrow\underrightarrow +%aliased\let\normaloverrightarrow \overrightarrow %D Here come the new ones: diff --git a/tex/context/base/mkxl/math-ttv.lmt b/tex/context/base/mkxl/math-ttv.lmt index 06d92e8b9..3484d6c80 100644 --- a/tex/context/base/mkxl/math-ttv.lmt +++ b/tex/context/base/mkxl/math-ttv.lmt @@ -130,6 +130,7 @@ mathencodings["tex-ex"] = { mathencodings["tex-mr"] = { [0x00393] = 0x00, -- Gamma [0x00394] = 0x01, -- Delta + [0x02206] = 0x01, -- Laplace [0x00398] = 0x02, -- Theta [0x0039B] = 0x03, -- Lambda [0x0039E] = 0x04, -- Xi @@ -486,7 +487,8 @@ mathencodings["tex-sy"] = { [0x02240] = 0x6F, -- wr [0x0221A] = 0x70, -- sqrt. AM: Check surd?? [0x02A3F] = 0x71, -- amalg - [0x1D6FB] = 0x72, -- nabla + [0x02207] = 0x72, -- nabla (upright) + [0x1D6FB] = 0x72, -- nabla (italic) -- [0x0222B] = 0x73, -- smallint (TODO: what about intop?) [0x02294] = 0x74, -- sqcup [0x02293] = 0x75, -- sqcap diff --git a/tex/context/base/mkxl/math-vfu.lmt b/tex/context/base/mkxl/math-vfu.lmt index 237b39d9f..c29e16766 100644 --- a/tex/context/base/mkxl/math-vfu.lmt +++ b/tex/context/base/mkxl/math-vfu.lmt @@ -880,7 +880,7 @@ local function virtualize(s,uni,fci,skewchar,move,mathparameters,unicode,paramet end end -function vfmath.define(specification,set,goodies) +function vfmath.define(specification,virtual,goodies) local name = specification.name -- symbolic name local size = specification.size -- given size local loaded = { } @@ -891,8 +891,9 @@ function vfmath.define(specification,set,goodies) local okset = { } local n = 0 local f_extra = formatters["virtual.extra.%05X"] - for s=1,#set do - local ss = set[s] + local setlist = virtual.recipe or virtual + for s=1,#setlist do + local ss = setlist[s] local ssname = ss.name if add_optional and ss.optional then if trace_virtual then @@ -906,6 +907,8 @@ function vfmath.define(specification,set,goodies) main = s end local alreadyloaded = names[ssname] -- for px we load one twice (saves .04 sec) +-- local sshash = name .. ":" .. ssname +-- local alreadyloaded = names[sshash] -- for px we load one twice (saves .04 sec) local f, id if alreadyloaded then f, id = alreadyloaded.f, alreadyloaded.id @@ -915,6 +918,7 @@ function vfmath.define(specification,set,goodies) else f, id = fonts.constructors.readanddefine(ssname,size) names[ssname] = { +-- names[sshash] = { f = f, id = id, fontname = ssname, -- diagnostics @@ -1212,9 +1216,32 @@ function vfmath.define(specification,set,goodies) fontname = name, -- diagnostics } -- - local addmissing = goodies.mathematics.addmissing - if type(addmissing) == "function" then - addmissing(main) + local virtualtweaks = virtual.tweaks + if virtualtweaks then + -- + local mathtweaks = mathematics.tweaks + local knowntweaks = { + addmissing = function(main,specification) + local action = specification.action + if action then + action(main,specification) -- source == target + end + end + } + -- + for i=1,#virtualtweaks do + local specification = virtualtweaks[i] + local tweak = specification.tweak + local action = knowntweaks[tweak] + if action then + action(main,specification) + else + action = mathtweaks[tweak] + if action then + action(main,main,specification) + end + end + end end -- mathematics.addfallbacks(main) @@ -1227,27 +1254,6 @@ function vfmath.define(specification,set,goodies) main.MathConstants = main.mathconstants main.nomath = false -- - mathematics.tweaks.setoptions(main,main,{ - tweak = "setoptions", - set = { "ignorekerndimensions" } - }) -- we have dp > ht fences - -- - mathematics.tweaks.fixprimes(main, main, { - tweak = "fixprimes", - factor = 1, -- accent base height - fake = 0.9, -- replace multiples with this width proportion - }) - -- - mathematics.tweaks.addequals(main, main, { - tweak = "addequals", - force = true, - }) - -- --- mathematics.tweaks.addbars(main,main,{ --- tweak = "addbars", --- advance = 0.52, --- }) - -- if trace_virtual or trace_timings then report_virtual("loading and virtualizing font %a at size %p took %0.3f seconds",name,size,os.clock()-start) end diff --git a/tex/context/base/mkxl/meta-imp-kaktovik.mkxl b/tex/context/base/mkxl/meta-imp-kaktovik.mkxl new file mode 100644 index 000000000..40e9f826c --- /dev/null +++ b/tex/context/base/mkxl/meta-imp-kaktovik.mkxl @@ -0,0 +1,251 @@ +%D \module +%D [ file=meta-imp-kaktovik, +%D version=2023.04.18, +%D title=\METAPOST\ Graphics, +%D subtitle=Kaktovik Numbers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Just a quick hack for Hraban (after a post on the mailing list). + +\startMPcalculation{simplefun} + + path kaktovik_glyphs[] ; + + def InitializeKaktovik = + + save p, d, u ; + + pair p[] ; numeric d ; d := .1 ; numeric u ; u := .15 ; + + % d := getparameterdefault "mpsfont" "d" .10 ; + % u := getparameterdefault "mpsfont" "u" .15 ; + + p[0] := (0,1) ; + p[1] := (1,0) ; + p[2] := (2,1 - d) ; + p[3] := (3,0) ; + p[4] := (4,1 - 2d) ; + + p[5] := (4,1 + u) ; + p[6] := (0,1 + 2u) ; + p[7] := (4,1 + 4u) ; + + kaktovik_glyphs[0] := (1,1) { right } .. { left } (2,1/2) { left } .. { right } (3,1); + + for i= 1 upto 4 : + kaktovik_glyphs[i] := p[0] for j=1 upto i : -- p[j] endfor ; + endfor ; + + kaktovik_glyphs[ 5] := p[5] -- p[0] ; for i= 6 upto 9 : kaktovik_glyphs[i] := p[5] -- kaktovik_glyphs[i-5] ; endfor ; + kaktovik_glyphs[10] := p[6] -- kaktovik_glyphs[ 5] ; for i=11 upto 14 : kaktovik_glyphs[i] := p[6] -- kaktovik_glyphs[i-5] ; endfor ; + kaktovik_glyphs[15] := p[7] -- kaktovik_glyphs[10] ; for i=16 upto 19 : kaktovik_glyphs[i] := p[7] -- kaktovik_glyphs[i-5] ; endfor ; + + enddef ; + + vardef Kaktovik(expr i) = + draw image ( + draw kaktovik_glyphs[i] + xscaled (10/20 -1/20) + yscaled (25/20 -2/20) + withpen (pencircle xscaled 1/20 yscaled 5/20) rotated -(2*20) + % withpen (pencircle xscaled 1/40 yscaled 5/40) rotated -(2*20) + % withpen (pencircle xscaled 2.5/40 yscaled 5/40) rotated -(2*20) + ; + ) shifted (2/20,2/20) + enddef ; + + lmt_registerglyphs [ + name = "kaktovik", + units = 2, + usecolor = true, + width = 2, + height = 2, + depth = 0, + preamble = "InitializeKaktovik" + ] ; + + for i=0 upto 19 : + lmt_registerglyph [ + category = "kaktovik", + unicode = 119488 + i, % "0x1D2C0" + code = "Kaktovik(" & decimal i & ")" + ] ; + endfor ; + +\stopMPcalculation + +\startluacode + local kaktovik = moduledata.kaktovik or { } + moduledata.kaktovik = kaktovik + + local tonumber = tonumber + local load = load + local reverse = table.reverse + local utfchar = utf.char + local gsub = string.gsub + local concat = table.concat + local utfvalues = string.utfvalues + local lpegmatch = lpeg.match + + function kaktovik.tointeger(s) + local n = 0 + for b in utfvalues(s) do + local k = b - 0x1D2C0 + n = n * 20 + k + end + return n + end + +-- function kaktovik.tostring(n) +-- local digits = { } +-- local count = 1 +-- while true do +-- digits[count] = utfchar(0x1D2C0 + (n % 20)) +-- n = n // 20 +-- if n == 0 then +-- break; +-- end +-- count = count + 1 +-- end +-- return concat(reverse(digits)) +-- end + + local f = string.formatters["%N"] + + function kaktovik.tostring(n) + if n >= 0 and n <= 19 then + return utfchar(0x1D2C0 + n) + else + -- no need to optimize + local result = gsub(f(n),"(%d+)",function(s) + local digits = { } + local count = 1 + local n = tonumber(s) + while true do + digits[count] = utfchar(0x1D2C0 + (n % 20)) + n = n // 20 + if n == 0 then + break; + end + count = count + 1 + end + return concat(reverse(digits)) + end) + return result + end + end + + do + + local k = { } + local n = 0 + for i=0x1D2C0,0x1D2C0+19 do + k[utf.char(i)] = n + n = n + 1 + end + + local p = lpeg.Cs ( + lpeg.Cc("return ") + * ( + lpeg.utfchartabletopattern(k) / k + + lpeg.P(1) + )^0 + ) + + local t = setmetatable({ },{ __index = math }) + + function kaktovik.calculate(old) + local new = lpegmatch(p,old) + if new then + new = load(new,nil,nil,t) + if type(new) == "function" then + new = new() + if new then + return new + end + end + end + return old + end + + end + + interfaces.implement { + name = "kaktoviknumerals", + arguments = "integer", + actions = { kaktovik.tostring, context } + } + interfaces.implement { + name = "kaktovikcalculate", + public = true, + arguments = "string", + actions = { kaktovik.calculate, kaktovik.tostring, context } + } +\stopluacode + +\unprotect + +\permanent\def\kaktoviknumerals#1{\clf_kaktoviknumerals\numexpr#1\relax} + +\defineconversion [kaktoviknumerals] [\kaktoviknumerals] +\defineconversion [K] [\kaktoviknumerals] + +\definefontfeature + [kaktovik] + [metapost=kaktovik] + +\protect + +\continueifinputfile{meta-imp-kaktovik.mkxl} + +\definefontfeature + [default] + [default] + [metapost=kaktovik] +% [metapost={category=kaktovik,u=.25,d=.20,x=}] + +\setupbodyfont[dejavu] + +% \nopdfcompression + +\startTEXpage[offset=1ts,width=3es] + + \start + \showglyphs + KAKTOVIK + \dostepwiserecurse{0}{19}{1}{\kaktoviknumerals{#1}\space } + \stop + + kaktovik \start + \red\glyphxscale 700 + \dostepwiserecurse{0}{19}{1}{\kaktoviknumerals{#1}\space } + \stop + + \startitemize[packed,K][color=orange,stopper=] + \startitem first \stopitem + \startitem second \stopitem + \startitem third \stopitem + \stopitemize + + KAKTOVIK \start + \red \kaktoviknumerals{2023} -- + \green\kaktoviknumerals{4} -- + \blue \kaktoviknumerals{18} + \stop + + KAKTOVIK + + 𝋂 + 𝋂 = \kaktovikcalculate{𝋂 + 𝋂} = \kaktoviknumerals{4} + + \protected\def\ForWilli#1{#1 = \kaktovikcalculate{#1}} + + \ForWilli{(𝋂 + 𝋂) ^ (𝋂 + 𝋂)} + + \ForWilli{(sin ( 𝋂𝋓 ) )} +\stopTEXpage diff --git a/tex/context/base/mkxl/meta-imp-threesix.mkxl b/tex/context/base/mkxl/meta-imp-threesix.mkxl index 56a400b45..872d0b3e8 100644 --- a/tex/context/base/mkxl/meta-imp-threesix.mkxl +++ b/tex/context/base/mkxl/meta-imp-threesix.mkxl @@ -56,6 +56,15 @@ ["X"] = [[1111001110 1111000110 0001101000 0000110000 0000110000 0001011000 0110001111 0111001111]], ["Y"] = [[111100011 111100011 011000010 001110100 000111000 000011000 001111110 001111110]], ["Z"] = [[11111111 10000111 00001110 00011100 00111000 01110000 11100001 11111111]], + + [","] = [[0000 0000 0000 0000 0000 0011 0111 0111]], + [";"] = [[0011 0011 0011 0000 0000 0011 0111 0111]], + ["."] = [[0000 0000 0000 0000 0000 0111 0111 0111]], + [":"] = [[0111 0111 0111 0000 0000 0111 0111 0111]], + ["!"] = [[0111 0111 0111 0111 0111 0000 0111 0111]], + ["?"] = [[11111 10111 00111 01110 01110 00000 01110 01110]], + + [utf.char(0xAD)] = [[00000 00000 00000 11111 11111 00000 00000 00000]], -- hyphen } local f_code = string.formatters["ThreeSix(%s);"] @@ -206,41 +215,24 @@ [metapost={category=fontthreesix,shape=diamond,color=random,pen=fancy,spread=.1,random=yes}] \definefont[DEKFontA][Serif*fontthreesix-color @ 200pt] -\definefont[DEKFontB][Serif*fontthreesix-color @ 60pt] +\definefont[DEKFontB][Serif*fontthreesix-color @ 12pt] % Or course: -\startTEXpage +\startTEXpage[offset=1dk] \DEKFontA TEX \stopTEXpage -\startTEXpage +\startTEXpage[offset=1dk] \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX \stopTEXpage -% One of the \CONTEXT\ 2020 posters (inspired by NewYork State AC's press -% conferences as these keywords apply quite well to the audience of the -% meeting): - -% \startTEXpage[align={lohi,middle,nothyphenated},offset=20pt] -% \offinterlineskip \vskip10pt -% \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX \vskip60pt -% \DEKFontB TOUGH \vskip20pt -% SMART \vskip20pt -% UNITED \vskip20pt -% DISCIPLINED \vskip20pt -% LOVING \vskip10pt -% \stopTEXpage - -\startpagemakeup - \setupalign[middle,nothyphenated] - \offinterlineskip \vfil\vfil - \DEKFontA T\kern-0.05em\lower.75\exheight\hbox{E}\kern-.05emX \vfil\vfil\vfil - \DEKFontB TOUGH \vfil - SMART \vfil - UNITED \vfil - DISCIPLINED \vfil - LOVING \vfil -\stoppagemakeup +% We only have uppercase characters! But I added a few punctuation symbols so that +% we can do the following. Actually we can consider lowercase to be just smaller and +% another shape. + +\startTEXpage[offset=1dk,align=flushleft,foregroundstyle=\DEKFontB] + \WORD{\input{knuth}} +\stopTEXpage \stoptext diff --git a/tex/context/base/mkxl/meta-ini.mkxl b/tex/context/base/mkxl/meta-ini.mkxl index 16b97e8cc..c5d86e2af 100644 --- a/tex/context/base/mkxl/meta-ini.mkxl +++ b/tex/context/base/mkxl/meta-ini.mkxl @@ -211,6 +211,7 @@ \defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] \defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] \defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] +\defineMPinstance[positfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!posit] \defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] diff --git a/tex/context/base/mkxl/mlib-run.lmt b/tex/context/base/mkxl/mlib-run.lmt index de5ceb1db..dc71eefab 100644 --- a/tex/context/base/mkxl/mlib-run.lmt +++ b/tex/context/base/mkxl/mlib-run.lmt @@ -152,6 +152,7 @@ local methods = { -- binary = "binary", binary = "double", decimal = "decimal", + posit = "posit", default = "scaled", } diff --git a/tex/context/base/mkxl/mult-sys.mkxl b/tex/context/base/mkxl/mult-sys.mkxl index 47119ad20..b0df8703b 100644 --- a/tex/context/base/mkxl/mult-sys.mkxl +++ b/tex/context/base/mkxl/mult-sys.mkxl @@ -257,6 +257,7 @@ \definesystemconstant {italic} %definesystemconstant {it} \definesystemconstant {itemgroupcolumns} +\definesystemconstant {keepbase} \definesystemconstant {kernpairs} \definesystemconstant {language} \definesystemconstant {lcgreek} @@ -312,6 +313,7 @@ \definesystemconstant {noheight} \definesystemconstant {nomath} \definesystemconstant {none} +\definesystemconstant {nooverflow} \definesystemconstant {noskips} \definesystemconstant {normal} \definesystemconstant {Normal} @@ -333,6 +335,7 @@ \definesystemconstant {pickup} \definesystemconstant {plural} \definesystemconstant {plus} +\definesystemconstant {posit} %definesystemconstant {pt} \definesystemconstant {realpage} \definesystemconstant {register} @@ -375,6 +378,7 @@ \definesystemconstant {setup} \definesystemconstant {set} \definesystemconstant {themaintextcolor} +\definesystemconstant {shrink} \definesystemconstant {simple} \definesystemconstant {Simple} \definesystemconstant {single} @@ -395,6 +399,7 @@ \definesystemconstant {ss} \definesystemconstant {start} \definesystemconstant {stop} +\definesystemconstant {stretch} \definesystemconstant {subpage} \definesystemconstant {subtype} \definesystemconstant {sub} diff --git a/tex/context/base/mkxl/node-pag.mkxl b/tex/context/base/mkxl/node-pag.mkxl new file mode 100644 index 000000000..970939dcf --- /dev/null +++ b/tex/context/base/mkxl/node-pag.mkxl @@ -0,0 +1,20 @@ +%D \module +%D [ file=node-pag, +%D version=2008.09.30, +%D title=\CONTEXT\ Node Macros, +%D subtitle=Page Building, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Macros / Page Building} + +\unprotect + +\registerctxluafile{node-pag}{} + +\protect \endinput diff --git a/tex/context/base/mkxl/node-tsk.lmt b/tex/context/base/mkxl/node-tsk.lmt index c4871b568..edc435836 100644 --- a/tex/context/base/mkxl/node-tsk.lmt +++ b/tex/context/base/mkxl/node-tsk.lmt @@ -1016,6 +1016,56 @@ nonut = [[ -- } -- } +tasks.new { + name = "pagebuilders", + processor = nodeprocessor, + sequence = { + "before", -- for users + "normalizers", + "after", -- for users + }, + templates = { + +default = [[ +return function(head) + return head +end +]], + +process = [[ +local tonut = nodes.tonut +local tonode = nodes.nuts.tonode + +%localize% + +return function(head,groupcode,size,packtype,maxdepth,direction) + local nuthead = tonut(head) + +%actions% + return tonode(nuthead) +end +]], + +step = [[ + nuthead = tonut((%action%(tonode(nuthead),groupcode,size,packtype,maxdepth,direction))) +]], + +nut = [[ + nuthead = %action%(nuthead,groupcode,size,packtype,maxdepth,direction) +]], + +nohead = [[ + %action%(tonode(nuthead),groupcode,size,packtype,maxdepth,direction) +]], + +nonut = [[ + %action%(nuthead,groupcode,size,packtype,maxdepth,direction) +]], + + } + +} + -- for now quite useless (too fuzzy) -- -- tasks.new { @@ -1135,3 +1185,106 @@ nonut = [[ } } + +-- -- quality -- -- + +tasks.new { + name = "hquality", + processor = nodeprocessor, + sequence = { + "before", -- for users + "system", + "after", -- for users + }, + templates = { + +default = [[ +return function(how,detail,nod,first,last,filename) + -- nil +end +]], + +process = [[ +local tonut = nodes.tonut +local tonode = nodes.nuts.tonode + +%localize% + +return function(how,detail,nod,first,last,filename) + local nut = tonut(nod) + local rul = nil + +%actions% + + return rul and tonode(rul) +end +]], + +step = [[ + rul = tonut((%action%(how,detail,nod,first,last,filename,rul and tonode(rul)))) +]], + +nut = [[ + rul = %action%(how,detail,nut,first,last,filename,rul) +]], + +nohead = [[ + %action%(how,detail,nod,first,last,filename,rul and tonode(rul)) +]], + +nonut = [[ + %action%(how,detail,nut,first,last,filename,rul) +]], + + } +} + +tasks.new { + name = "vquality", + processor = nodeprocessor, + sequence = { + "before", -- for users + "system", + "after", -- for users + }, + templates = { + +default = [[ +return function(how,detail,nod,first,last,filename) + -- nil +end +]], + +process = [[ +local tonut = nodes.tonut +local tonode = nodes.nuts.tonode + +%localize% + +return function(how,detail,nod,first,last,filename) + local nut = tonut(nod) + local rul = nil + +%actions% + return rul and tonode(rul) +end +]], + +step = [[ + rul = tonut((%action%(how,detail,nod,first,last,filename,tonode(rul)))) +]], + +nut = [[ + rul = %action%(how,detail,nut,first,last,filename,rul) +]], + +nohead = [[ + %action%(how,detail,nod,first,last,filename,rul and tonode(rul)) +]], + +nonut = [[ + %action%(how,detail,nut,first,last,filename,rul) +]], + + } +} diff --git a/tex/context/base/mkxl/pack-box.mkxl b/tex/context/base/mkxl/pack-box.mkxl index 5a66d3945..ea270f88b 100644 --- a/tex/context/base/mkxl/pack-box.mkxl +++ b/tex/context/base/mkxl/pack-box.mkxl @@ -1165,6 +1165,8 @@ \fi \endgroup} +\mutable\lettonothing\currentanchorbox + \permanent\tolerant\protected\def\setanchorbox[#1]#*[#2]% {\begingroup \dowithnextbox diff --git a/tex/context/base/mkxl/pack-com.mkxl b/tex/context/base/mkxl/pack-com.mkxl index 0fff4ca1b..e07e0ff8d 100644 --- a/tex/context/base/mkxl/pack-com.mkxl +++ b/tex/context/base/mkxl/pack-com.mkxl @@ -501,17 +501,24 @@ \def\pack_combinations_caption_second {\ifx\nexttoken\egroup % the caption is empty - \orelse\ifx\nexttoken\stopcaption + \orelse\ifx\nexttoken\stopcaption % language % the caption is empty (new per 2014-05-24) + \orelse\ifx\nexttoken\pack_combinations_float_hack_b + % make sure we honor empty captions (new per 2023-04-20) \else % todo: \p_pack_combinations_alternative\v!none: no style, strut etc \hsize\wd\b_pack_combinations_content \usealignparameter\combinationparameter \usecombinationstyleandcolor\c!style\c!color \bgroup - \aftergroup\endstrut - \aftergroup\egroup - \begstrut + \ifcstok{\combinationparameter\c!strut}\v!no + % make sure we have empty captions (new per 2023-04-20) + \aftergroup\egroup + \else + \aftergroup\endstrut + \aftergroup\egroup + \begstrut + \fi \fi} \def\pack_combinations_pickup_package_pair % we need to store the caption row @@ -624,6 +631,10 @@ %D %D \typebuffer \getbuffer +\definecombination + [\v!float] +% [\c!strut=\v!no] % not needed, we intercept anyway + \protected\def\pack_combinations_float_hack_a#1% {\strc_floats_build_box_separate_split{#1}% \box\b_strc_floats_separate_content} @@ -657,7 +668,8 @@ {\pack_combinations_float_hack_b{\recurselevel}}% \to\scratchtoks}% brrr \let\pack_combinations_check_x_y\pack_combinations_float_check_x_y - \normalexpanded{\startcombination[#1]\the\scratchtoks}\stopcombination + % \normalexpanded{\startcombination[#1]\the\scratchtoks}\stopcombination + \normalexpanded{\startcombination[\v!float][#1]\the\scratchtoks}\stopcombination \resetlocalfloats \egroup} diff --git a/tex/context/base/mkxl/pack-lyr.mkxl b/tex/context/base/mkxl/pack-lyr.mkxl index b93d32960..cc4a7381f 100644 --- a/tex/context/base/mkxl/pack-lyr.mkxl +++ b/tex/context/base/mkxl/pack-lyr.mkxl @@ -97,35 +97,35 @@ \permanent\def\layeranchor{\currentlayer:\the\realpageno} +\lettonothing\m_pack_layers_anchor +\lettonothing\m_pack_layers_page +\lettonothing\m_pack_layers_region +\lettonothing\m_pack_layers_target +\lettonothing\p_pack_layers_column +\lettonothing\p_pack_layers_corner +\lettonothing\p_pack_layers_direction \lettonothing\p_pack_layers_doublesided -\lettonothing\p_pack_layers_state -\lettonothing\p_pack_layers_option +\lettonothing\p_pack_layers_dx +\lettonothing\p_pack_layers_dy +\lettonothing\p_pack_layers_height +\lettonothing\p_pack_layers_hoffset +\lettonothing\p_pack_layers_line +\lettonothing\p_pack_layers_location \lettonothing\p_pack_layers_method +\lettonothing\p_pack_layers_offset +\lettonothing\p_pack_layers_option +\lettonothing\p_pack_layers_position \lettonothing\p_pack_layers_preset +\lettonothing\p_pack_layers_region +\lettonothing\p_pack_layers_repeat \lettonothing\p_pack_layers_rotation -\lettonothing\p_pack_layers_position -\lettonothing\p_pack_layers_hoffset -\lettonothing\p_pack_layers_voffset -\lettonothing\p_pack_layers_offset -\lettonothing\p_pack_layers_dx -\lettonothing\p_pack_layers_dy +\lettonothing\p_pack_layers_state \lettonothing\p_pack_layers_sx \lettonothing\p_pack_layers_sy +\lettonothing\p_pack_layers_voffset +\lettonothing\p_pack_layers_width \lettonothing\p_pack_layers_x \lettonothing\p_pack_layers_y -\lettonothing\p_pack_layers_corner -\lettonothing\p_pack_layers_location -\lettonothing\p_pack_layers_line -\lettonothing\p_pack_layers_column -\lettonothing\p_pack_layers_width -\lettonothing\p_pack_layers_height -\lettonothing\p_pack_layers_direction -\lettonothing\p_pack_layers_region - -\lettonothing\m_pack_layers_page -\lettonothing\m_pack_layers_target -\lettonothing\m_pack_layers_region -\lettonothing\m_pack_layers_anchor \newconditional\c_pack_layers_repeated \newconditional\c_pack_layers_trace diff --git a/tex/context/base/mkxl/pack-rul.mkxl b/tex/context/base/mkxl/pack-rul.mkxl index 36b4fc7b0..1daa8bcf7 100644 --- a/tex/context/base/mkxl/pack-rul.mkxl +++ b/tex/context/base/mkxl/pack-rul.mkxl @@ -237,30 +237,34 @@ %newdimen \d_framed_linewidth \aliased\let \ruledlinewidth\d_framed_linewidth % needed at lua end \newdimension\d_framed_linewidth \aliasdimension\ruledlinewidth\d_framed_linewidth % needed at lua end -\lettonothing\p_framed_frame % \framedparameter\c!frame -\lettonothing\p_framed_backgroundoffset -\lettonothing\p_framed_foregroundstyle -\lettonothing\p_framed_autostrut -\lettonothing\p_framed_location -\lettonothing\p_framed_orientation +\lettonothing\p_frame +\lettonothing\p_framed_adaptive \lettonothing\p_framed_anchoring -\lettonothing\p_framed_synchronize +\lettonothing\p_framed_autostrut \lettonothing\p_framed_autowidth -\lettonothing\p_framed_franalyze +\lettonothing\p_framed_background +\lettonothing\p_framed_backgroundcolor \lettonothing\p_framed_backgroundcorner +\lettonothing\p_framed_backgroundoffset \lettonothing\p_framed_backgroundradius +\lettonothing\p_framed_component +\lettonothing\p_framed_empty +\lettonothing\p_framed_foregroundcolor +\lettonothing\p_framed_foregroundstyle +\lettonothing\p_framed_frame % \framedparameter\c!frame +\lettonothing\p_framed_framecolor \lettonothing\p_framed_framecorner \lettonothing\p_framed_frameradius +\lettonothing\p_framed_franalyze \lettonothing\p_framed_lines -\lettonothing\p_framed_empty -\lettonothing\p_framed_backgroundcolor -\lettonothing\p_framed_framecolor -\lettonothing\p_framed_component -\lettonothing\p_framed_background +\lettonothing\p_framed_location +\lettonothing\p_framed_minheight +\lettonothing\p_framed_orientation \lettonothing\p_framed_rulethickness -\lettonothing\p_framed_foregroundcolor \lettonothing\p_framed_setups \lettonothing\p_framed_synchronize +\lettonothing\p_framed_text_depthcorrection +\lettonothing\p_framed_text_strut %D We don't have to stick to a \TEX\ drawn rule, but also can use rounded %D or even fancier shapes, as we will see later on. diff --git a/tex/context/base/mkxl/page-flt.mkxl b/tex/context/base/mkxl/page-flt.mkxl index ae2bd4cf8..fb6996264 100644 --- a/tex/context/base/mkxl/page-flt.mkxl +++ b/tex/context/base/mkxl/page-flt.mkxl @@ -297,7 +297,31 @@ \newtoks\everybeforeflushedpagefloat -\def\page_floats_flush_page_floats_indeed#1% future releases can do more clever things +\let\m_page_otr_checked_page_float\relax + +\newconditional\c_page_floats_flushed + +% \def\page_floats_flush_page_floats_indeed#1% future releases can do more clever things +% {\page_floats_flush{#1}\plusone +% \edef\floatspecification{\clf_getfloatvariable{specification}}% Is this okay? +% \the\everybeforeflushedpagefloat +% \vpack to \textheight +% {\doifnotinset\v!high\floatspecification\vfill +% \box\floatbox +% \doifnotinset\v!low\floatspecification\vfill}% +% \page_otr_fill_and_eject_page} + +% \protected\def\page_floats_flush_page_floats % used in postpone +% {\edef\m_page_otr_checked_page_float{\clf_checkedpagefloat}% +% \ifempty\m_page_otr_checked_page_float +% % nothing +% \orelse\ifx\m_page_otr_checked_page_float\v!empty +% \emptyhbox \page_otr_fill_and_eject_page % why not dummy_page +% \else +% \page_floats_flush_page_floats_indeed\m_page_otr_checked_page_float +% \fi} + +\def\page_floats_flush_page_floats_inject#1% future releases can do more clever things {\page_floats_flush{#1}\plusone \edef\floatspecification{\clf_getfloatvariable{specification}}% Is this okay? \the\everybeforeflushedpagefloat @@ -305,18 +329,26 @@ {\doifnotinset\v!high\floatspecification\vfill \box\floatbox \doifnotinset\v!low\floatspecification\vfill}% - \page_otr_fill_and_eject_page} - -\let\m_page_otr_checked_page_float\relax + % \page_otr_fill_and_eject_page + \global\settrue\c_page_floats_flushed} \protected\def\page_floats_flush_page_floats % used in postpone + {\global\setfalse\c_page_floats_flushed + \page_floats_flush_page_floats_indeed + \ifconditional\c_page_floats_flushed + \page_otr_fill_and_eject_page + \fi} + +\protected\def\page_floats_flush_page_floats_indeed % used in postpone {\edef\m_page_otr_checked_page_float{\clf_checkedpagefloat}% \ifempty\m_page_otr_checked_page_float % nothing \orelse\ifx\m_page_otr_checked_page_float\v!empty \emptyhbox \page_otr_fill_and_eject_page % why not dummy_page + \expandafter\page_floats_flush_page_floats \else - \page_floats_flush_page_floats_indeed\m_page_otr_checked_page_float + \page_floats_flush_page_floats_inject\m_page_otr_checked_page_float + \expandafter\page_floats_flush_page_floats \fi} % temp hack, needed to prevent floatbox being forgotten during diff --git a/tex/context/base/mkxl/page-imp.mkxl b/tex/context/base/mkxl/page-imp.mkxl index 00a0430e6..4c192c554 100644 --- a/tex/context/base/mkxl/page-imp.mkxl +++ b/tex/context/base/mkxl/page-imp.mkxl @@ -1264,7 +1264,7 @@ % % \starttext \dorecurse{30}{test \recurselevel \page} \stoptext -\permanent\protected\protected\def\pusharrangedpageXY#1% +\permanent\protected\def\pusharrangedpageXY#1% {\advancearrangedpageN \global\advanceby\arrangedpageM\plusone \reportarrangedpage\arrangedpageN @@ -1300,7 +1300,7 @@ \poparrangedpages \fi} -\permanent\protected\protected\def\poparrangedpagesXY +\permanent\protected\def\poparrangedpagesXY {\ifnum\arrangedpageN>\zerocount \paperwidth \arrangedpageX\paperwidth \paperheight\arrangedpageY\paperheight diff --git a/tex/context/base/mkxl/page-inj.mklx b/tex/context/base/mkxl/page-inj.mklx index 02f853c55..2e245fd8b 100644 --- a/tex/context/base/mkxl/page-inj.mklx +++ b/tex/context/base/mkxl/page-inj.mklx @@ -32,6 +32,12 @@ \let\page_boxes_flush_before\clf_flushpageinjectionsbefore \let\page_boxes_flush_after \clf_flushpageinjectionsafter +\lettonothing\p_page_injections_delay +\lettonothing\p_page_injections_n +\lettonothing\p_page_injections_page +\lettonothing\p_page_injections_pagestate +\lettonothing\p_page_injections_state + \def\page_injections_flush_indeed {\begingroup \setbox\scratchbox\normalhpack diff --git a/tex/context/base/mkxl/page-mbk.mklx b/tex/context/base/mkxl/page-mbk.mklx index 57c23abc6..3dc1c4e7c 100644 --- a/tex/context/base/mkxl/page-mbk.mklx +++ b/tex/context/base/mkxl/page-mbk.mklx @@ -75,12 +75,16 @@ \setfalse\c_page_margin_blocks_enabled +\let\page_margin_blocks_stop_block\relax + \permanent\tolerant\protected\def\startmarginblock[#tag]% {\begingroup \edef\currentmarginblock{#tag}% - \doifelse{\marginblockparameter\c!state}\v!start - \page_margin_blocks_start_block_yes - \page_margin_blocks_start_block_nop} + \ifcstok{\marginblockparameter\c!state}\v!start + \expandafter\page_margin_blocks_start_block_yes + \else + \expandafter\page_margin_blocks_start_block_nop + \fi} \permanent\protected\def\stopmarginblock {\page_margin_blocks_stop_block diff --git a/tex/context/base/mkxl/phys-dim.mkxl b/tex/context/base/mkxl/phys-dim.mkxl index 2dc6e7e1e..e085ba844 100644 --- a/tex/context/base/mkxl/phys-dim.mkxl +++ b/tex/context/base/mkxl/phys-dim.mkxl @@ -531,10 +531,10 @@ \permanent\protected\def\unitsR #1#2{% todo: tagging \ifmmode #2% - \orelse\ifnum#1=\plusone + \orelse\ifnum#1=\plusone % why this test if we do the same in both cases \digitstextbinop{#2}% before and after \else - \digitstextbinnop{#2}% after + \digitstextbinop{#2}% after \fi \c_phys_units_state\zerocount \setfalse\c_phys_units_dospace diff --git a/tex/context/base/mkxl/publ-ini.mkxl b/tex/context/base/mkxl/publ-ini.mkxl index 802768a8c..f120c55fb 100644 --- a/tex/context/base/mkxl/publ-ini.mkxl +++ b/tex/context/base/mkxl/publ-ini.mkxl @@ -876,6 +876,7 @@ ignored {\btxrenderingparameter\c!ignore}% group {\btxrenderingparameter\c!group}% filter {\btxrenderingparameter\c!filter}% + filename {\btxrenderingparameter\c!file}% for now \relax \ifnum\nofbtxlistentries>\zerocount \clf_btxpreparelistentries{\currentbtxdataset}% could be put in collect @@ -1155,7 +1156,7 @@ {\the\t_btx_reference_inject \strc_lists_inject_direct % todo: make like \btx_list_reference_inject_now with { } [\s!btx]% - [\c!type=\s!btx]% \c!location=\v!none + [\c!type=\s!btx,\c!location=\v!here]% [\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% \s!btxref=\currentbtxtag,% %\ifempty\currentbtxcombis \else\s!btxcom={\currentbtxcombis},\fi% diff --git a/tex/context/base/mkxl/scrn-fld.mklx b/tex/context/base/mkxl/scrn-fld.mklx index d5dadcb78..e3bde47c6 100644 --- a/tex/context/base/mkxl/scrn-fld.mklx +++ b/tex/context/base/mkxl/scrn-fld.mklx @@ -274,7 +274,7 @@ %D A few testing macros (expandable for historic reasons): -\permanent\def\doifelsefieldbody #tag{\clf_doifelsefield{#tag}} +\permanent\def\doifelsefieldbody #tag{\clf_doifelsefieldset{#tag}} \permanent\def\doifelsefieldcategory#tag{\clf_doifelsefieldcategory{#tag}} \aliased\let\doiffieldbodyelse \doifelsefieldbody diff --git a/tex/context/base/mkxl/scrn-ref.lmt b/tex/context/base/mkxl/scrn-ref.lmt index be298e2d1..43c3a0276 100644 --- a/tex/context/base/mkxl/scrn-ref.lmt +++ b/tex/context/base/mkxl/scrn-ref.lmt @@ -51,7 +51,26 @@ function references.setclosepageaction(close) end end -implement { name = "setopendocumentaction", arguments = "string", actions = references.setopendocumentaction } -implement { name = "setclosedocumentaction", arguments = "string", actions = references.setclosedocumentaction } -implement { name = "setopenpageaction", arguments = "string", actions = references.setopenpageaction } -implement { name = "setclosepageaction", arguments = "string", actions = references.setclosepageaction } +implement { + name = "setopendocumentaction", + arguments = "string", + actions = references.setopendocumentaction +} + +implement { + name = "setclosedocumentaction", + arguments = "string", + actions = references.setclosedocumentaction +} + +implement { + name = "setopenpageaction", + arguments = "string", + actions = references.setopenpageaction +} + +implement { + name = "setclosepageaction", + arguments = "string", + actions = references.setclosepageaction +} diff --git a/tex/context/base/mkxl/spac-ali.mkxl b/tex/context/base/mkxl/spac-ali.mkxl index f5b0e2fb8..9d9feab9b 100644 --- a/tex/context/base/mkxl/spac-ali.mkxl +++ b/tex/context/base/mkxl/spac-ali.mkxl @@ -1325,4 +1325,17 @@ \permanent\protected\def\spaceorpar{\endgraf\ifhmode\space\fi} +%D Kind of documenting: +%D +%D \starttyping +%D \disabletrackers[builders.hpack.quality] % enabled by default +%D \enabletrackers[builders.hpack.collect] +%D \enabletrackers[builders.hpack.overflow] +%D +%D \starttext +%D {\hsize 4cm \input tufte \par} \page +%D {\hsize 8cm \input tufte \par} \page +%D \stoptext +%D \stoptyping + \protect \endinput diff --git a/tex/context/base/mkxl/spac-hor.mkxl b/tex/context/base/mkxl/spac-hor.mkxl index 3c4fd1eb4..ab15e7a6e 100644 --- a/tex/context/base/mkxl/spac-hor.mkxl +++ b/tex/context/base/mkxl/spac-hor.mkxl @@ -269,9 +269,15 @@ \aliased\let\dorechecknextindentation\relax % public (in macros) -\permanent\protected\protected\def\spac_indentation_check_next_indentation +% \permanent\protected\def\spac_indentation_check_next_indentation +% {\global\enforced\let\dorechecknextindentation\relax +% \doifelsenextchar\par\donothing\spac_indentation_variant_no} % messy check as next is seldom \par + +\permanent\protected\def\spac_indentation_check_next_indentation {\global\enforced\let\dorechecknextindentation\relax - \doifelsenextchar\par\donothing\spac_indentation_variant_no} % messy check as next is seldom \par + \begingroup + \autoparagraphmode\zerocount + \doifelsenextchar\par\endgroup{\endgroup\spac_indentation_variant_no}} % messy check as next is seldom \par \def\spac_indentation_variant_auto {\global\enforced\let\dorechecknextindentation\spac_indentation_check_next_indentation} diff --git a/tex/context/base/mkxl/strc-doc.mkxl b/tex/context/base/mkxl/strc-doc.mkxl index 11c96f9c1..e85d222c2 100644 --- a/tex/context/base/mkxl/strc-doc.mkxl +++ b/tex/context/base/mkxl/strc-doc.mkxl @@ -47,6 +47,7 @@ \mutable\lettonothing\currentstructurecomponentbookmark \mutable\lettonothing\currentstructurecomponentcatcodes \mutable\lettonothing\currentstructurecomponentcoding +\mutable\lettonothing\currentstructurecomponentcounter \mutable\lettonothing\currentstructurecomponentexpansion \mutable\lettonothing\currentstructurecomponentlabel \mutable\lettonothing\currentstructurecomponentlevel diff --git a/tex/context/base/mkxl/strc-flt.mklx b/tex/context/base/mkxl/strc-flt.mklx index c96fb02d0..b3f33734e 100644 --- a/tex/context/base/mkxl/strc-flt.mklx +++ b/tex/context/base/mkxl/strc-flt.mklx @@ -742,7 +742,7 @@ \edef\p_location {\floatcaptionparameter\c!location}% \edef\p_topoffset {\floatcaptionparameter\c!topoffset}% \edef\p_bottomoffset{\floatcaptionparameter\c!bottomoffset}% - \edef\P_freeregion {\floatcaptionparameter\c!freeregion}% + \edef\p_freeregion {\floatcaptionparameter\c!freeregion}% % preset \resetfloatcaptionparameter \c!location \setexpandedfloatcaptionparameter\c!topoffset {\floatparameter\c!topoffset}% @@ -778,7 +778,7 @@ \letfloatcaptionparameter\c!location \p_location \letfloatcaptionparameter\c!topoffset \p_topoffset \letfloatcaptionparameter\c!bottomoffset\p_bottomoffset - \letfloatcaptionparameter\c!freeregion \P_freeregion + \letfloatcaptionparameter\c!freeregion \p_freeregion % \strc_floats_analyze_location \doifelseinset\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal diff --git a/tex/context/base/mkxl/strc-itm.mklx b/tex/context/base/mkxl/strc-itm.mklx index 737580a27..a7dda8fdd 100644 --- a/tex/context/base/mkxl/strc-itm.mklx +++ b/tex/context/base/mkxl/strc-itm.mklx @@ -1325,7 +1325,7 @@ \strc_itemgroups_stop_head_indeed \strc_itemgroups_head_body_indeed} -\protected\permanent\def\stopitemgrouphead +\permanent\protected\def\stopitemgrouphead {\dostoptagged \stopitemgroupitem} diff --git a/tex/context/base/mkxl/strc-lst.mklx b/tex/context/base/mkxl/strc-lst.mklx index dd9f1fb4d..3fd0e979e 100644 --- a/tex/context/base/mkxl/strc-lst.mklx +++ b/tex/context/base/mkxl/strc-lst.mklx @@ -1257,8 +1257,8 @@ \noindent % otherwise annotations are mirrored up \typo_injectors_mark_list \hbox \strc_lists_get_reference_attribute\v!all \strc_lists_get_destination_attribute { - \letlistparameter \c!depth\zeropoint - \resettlistparameter\c!color + \letlistparameter \c!depth\zeropoint + \resetlistparameter\c!color \inheritedlistframed { \letinteractionparameter\c!strut\v!no % still needed? \strc_lists_set_style_color\c!style\c!color\v!all diff --git a/tex/context/base/mkxl/strc-mar.lmt b/tex/context/base/mkxl/strc-mar.lmt index e5266daf0..61972009c 100644 --- a/tex/context/base/mkxl/strc-mar.lmt +++ b/tex/context/base/mkxl/strc-mar.lmt @@ -109,7 +109,7 @@ implement { } implement { - name = "getsynchronizedmarking", + name = "getsynchronizemarking", arguments = { "integer", "string", "string" }, actions = function(class,category,what) local category, n = lpegmatch(pattern,category) @@ -136,7 +136,7 @@ implement { } implement { - name = "resetsynchronizedmarking", + name = "resetsynchronizemarking", arguments = "argument", actions = function(category) local category, n = lpegmatch(pattern,category) diff --git a/tex/context/base/mkxl/strc-mar.mkxl b/tex/context/base/mkxl/strc-mar.mkxl index 4c279f6dd..6dbb0e207 100644 --- a/tex/context/base/mkxl/strc-mar.mkxl +++ b/tex/context/base/mkxl/strc-mar.mkxl @@ -169,7 +169,7 @@ \ifcstok{#2}\v!page \markingcommand{#1}{\csname\??markingfilter#3\endcsname{#1}}% \else - \markingcommand{#1}{\clf_getsynchronizedmarking\begincsname\??markingclass#1\endcsname{#2}{#3}}% + \markingcommand{#1}{\clf_getsynchronizemarking\begincsname\??markingclass#1\endcsname{#2}{#3}}% \fi \orelse\ifparameter#2\or \markingcommand{#1}{\csname\??markingfilter#2\endcsname{#1}}% @@ -208,7 +208,7 @@ \ifcstok{#2}\v!page \markingcommand{#1}{\begincsname\??markingfilter#3\endcsname{#1}}% \else - \markingcommand{#1}{\clf_getsynchronizedmarking{#1}{#2}}% + \markingcommand{#1}{\clf_getsynchronizemarking{#1}{#2}}% \fi \fi \fi} @@ -221,9 +221,9 @@ \markingseparator{#1}% \markingcommand{#1}{\begincsname\??markingfilter\v!last\endcsname{#1}}% \else - \markingcommand{#1}{\clf_getsynchronizedmarking{#1}\v!first}% + \markingcommand{#1}{\clf_getsynchronizemarking{#1}\v!first}% \markingseparator{#1}% - \markingcommand{#1}{\clf_getsynchronizedmarking{#1}\v!last}% + \markingcommand{#1}{\clf_getsynchronizemarking{#1}\v!last}% \fi \fi \fi} @@ -240,9 +240,9 @@ \else %\markingcommand{#1}{\begincsname\??markclass:\v!previous\endcsname{#1}}% %\markingseparator{#1}% - \markingcommand{#1}{\clf_getsynchronizedmarking{#1}\v!first}% + \markingcommand{#1}{\clf_getsynchronizemarking{#1}\v!first}% \markingseparator{#1}% - \markingcommand{#1}{\clf_getsynchronizedmarking{#1}\v!last}% + \markingcommand{#1}{\clf_getsynchronizemarking{#1}\v!last}% \fi \fi \fi} diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 2e6c21ad2..6c639bb1f 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -1035,6 +1035,28 @@ \boundary\c_bndr_mathalign \fi} +% \tolerant\protected\def\strc_math_skip_here[#1]% +% {% no strut as it will influence fences +% \ifconditional\c_strc_math_trace_hang +% \strc_math_trace_okay{darkblue}{S #1}% +% \fi +% \scratchdimen\dimexpr\formulaparameter\c!textmargin\relax +% \ifchkdim#1\or +% \d_strc_math_hang_state#1% +% \orelse\ifchknum#1\or +% \d_strc_math_hang_state#1\scratchdimen +% \orelse\iftok{#1}{+}% +% \advanceby\d_strc_math_hang_state\scratchdimen +% \orelse\iftok{#1}{-}% +% \advanceby\d_strc_math_hang_state-\scratchdimen +% \else +% \d_strc_math_hang_state\scratchdimen +% \fi +% \kern\d_strc_math_hang_state +% \strc_math_pickup_again} + +\newboundary\c_bndr_skiphere + \tolerant\protected\def\strc_math_skip_here[#1]% {% no strut as it will influence fences \ifconditional\c_strc_math_trace_hang @@ -1052,6 +1074,7 @@ \else \d_strc_math_hang_state\scratchdimen \fi + \boundary\c_bndr_skiphere \kern\d_strc_math_hang_state \strc_math_pickup_again} diff --git a/tex/context/base/mkxl/strc-not.lmt b/tex/context/base/mkxl/strc-not.lmt index e05228b2b..2c68cc599 100644 --- a/tex/context/base/mkxl/strc-not.lmt +++ b/tex/context/base/mkxl/strc-not.lmt @@ -520,11 +520,13 @@ notes.check_spacing = check_spacing -- only notes, kind of hardcoded .. bah -callback.register("build_page_insert", function(index,slot) +local function action(index,slot) local state = notes.numbers[index] if state then return tonode(newgluespec(check_spacing(index,slot))) else return tonode(newgluespec()) end -end) +end + +callbacks.register("build_page_insert",action,"check spacing around inserts") diff --git a/tex/context/base/mkxl/strc-ref.lmt b/tex/context/base/mkxl/strc-ref.lmt index 6a320f141..272e7e992 100644 --- a/tex/context/base/mkxl/strc-ref.lmt +++ b/tex/context/base/mkxl/strc-ref.lmt @@ -386,12 +386,12 @@ references.currentorder = currentorder references.setstructure = resolvers.jobs.currentstructure -- yes or no here ----------.setcomponent = setcomponent --- implement { --- name = "setnextreferenceorder", --- actions = setnextorder, --- arguments = "2 strings", --- } --- +implement { + name = "setnextreferenceorder", -- used in strc-enu + actions = setnextorder, + arguments = "2 strings", +} + -- implement { -- name = "currentreferenceorder", -- actions = { currentorder, context }, @@ -2484,6 +2484,7 @@ local function filterreference(name,prefixspec,numberspec) -- number page title if data then if name == "realpage" then local cs = references.analyze() -- normally already analyzed but also sets state + -- or just get from references.realpage when present context(tonumber(cs.realpage) or 0) else -- assumes data is table local kind = false @@ -2519,6 +2520,26 @@ local function filterreferencedefault() return filterreference("default",getcurrentprefixspec("default")) end +local function getreferencesectionnumber(reference) + if references.valid("",reference,{},false) then + local data = currentreference and currentreference.i + if type(data) == "table" then + local metadata = data.metadata + if metadata and metadata.kind == "section" then + local numberdata = data.numberdata + if numberdata then + numberdata = numberdata.numbers + context(numberdata[#numberdata] or 0) + return + end + end + elseif trace_referencing then + report_references("name %a, no reference",reference) + end + end + context(0) +end + references.filter = filterreference references.filterdefault = filterreferencedefault @@ -2538,6 +2559,13 @@ implement { } } +implement { + name = "getreferencesectionnumber", + actions = getreferencesectionnumber, + arguments = "string", + public = true, +} + function genericfilters.title(data) if data then local titledata = data.titledata or data.useddata diff --git a/tex/context/base/mkxl/strc-ref.mklx b/tex/context/base/mkxl/strc-ref.mklx index a1b6ac22d..8619d084e 100644 --- a/tex/context/base/mkxl/strc-ref.mklx +++ b/tex/context/base/mkxl/strc-ref.mklx @@ -994,6 +994,8 @@ \aliased\let\from \strc_references_from \to \everydump +% can be defined visible at lua end + \permanent \def\filterreference #key{\clf_filterreference{#key}} % no checking, expandable \permanent\protected\def\getreferenceentry#key{\clf_filterreference{#key}} % no checking, not expandable @@ -1005,7 +1007,6 @@ \permanent\def\currentreferencerealpage{\clf_filterreference{realpage}} \aliased \let\currentreferenceorder \getinternalorderreference - %D The most straightforward way of retrieving references is using \type {\ref}. \permanent\tolerant\protected\def\getreference[#key]#spacer[#label]% #key = number page title text default realpage ... @@ -1017,6 +1018,25 @@ \aliased\let\ref\getreference +% setnumber-001.tex +% +% \starttext +% \chapter[one]{One} see setnumber-002 +% \chapter[two]{Two} see setnumber-002 +% \stoptext +% +% setnumber-002.tex +% +% \setupreferencing[autofile=yes] +% \useexternaldocument[foo] [setnumber-001] [{TEST 1}] +% \setupheadnumber[chapter][\getreferencesectionnumber{foo::two}] +% \starttext +% \chapter[three]{Three} from setnumber-001, one: \getreferencesectionnumber{foo::one}\par +% \chapter[four] {Four} from setnumber-001, two: \getreferencesectionnumber{foo::two}\par +% \stoptext +% +% \getreferencesectionnumber{reference} : defined at the lua end + %D Special cases: \permanent\protected\def\strc_references_about[#label]% diff --git a/tex/context/base/mkxl/strc-reg.lmt b/tex/context/base/mkxl/strc-reg.lmt index a8a7d0a90..6affc02f8 100644 --- a/tex/context/base/mkxl/strc-reg.lmt +++ b/tex/context/base/mkxl/strc-reg.lmt @@ -536,7 +536,13 @@ local function preprocessentries(rawdata) end local seeword = rawdata.seeword if seeword then - seeword.processor, seeword.text = splitprocessor(seeword.text or "") + local text = seeword.text or "" + local sp, st = splitprocessor(text) + seeword.text = text + -- seeword.list = lpegmatch(coding == "xml" and entrysplitter_xml or entrysplitter_tex,st) + if sp then + seeword.processor = sp + end end end @@ -1131,9 +1137,11 @@ local function analyzeregister(class,options) -- local u = u and { u.prefix } or nil local u = multiple and { string.formatters["%03i"](i) } or nil -- maybe prefix but then how about main for i=1,#e do + -- see has no pagedata local ei = e[i] -if multiple and ei.metadata.kind == "see" then - -- skip see, can become an option + local external = ei.external +if multiple and ei.metadata.kind == "see" and external then + -- too messy, could be an option but useless else nofentries = nofentries + 1 @@ -1141,7 +1149,9 @@ else if u then local eil = ei.list eil[#eil+1] = u +if external then ei.external = l -- this is the (current) abstract tag, used for prefix +end end end end @@ -1587,6 +1597,10 @@ function registers.flush(data,options,prefixspec,pagespec) local seetext = seeword.text or "" local processor = seeword.processor or (entry.processors and entry.processors[1]) or "" local seeindex = entry.external or entry.references.seeindex or "" + local seelist = lpegmatch(coding == "xml" and entrysplitter_xml or entrysplitter_tex,seetext) + if #seelist > 1 then + seetext = concat(seelist,", ") + end ctx_registerseeword( metadata.name or "", i, @@ -1821,6 +1835,7 @@ function registers.integrate(utilitydata) end references.external = filename -- not really needed end + entry.external = true end end end diff --git a/tex/context/base/mkxl/strc-reg.mkxl b/tex/context/base/mkxl/strc-reg.mkxl index 464ac4eb1..7dd07b2e2 100644 --- a/tex/context/base/mkxl/strc-reg.mkxl +++ b/tex/context/base/mkxl/strc-reg.mkxl @@ -155,16 +155,17 @@ \mutable\lettonothing\currentregisternumber \mutable\lettonothing\currentregisterownnumber \mutable\lettonothing\currentregisterpageindex +\mutable\lettonothing\currentregisterpageprefix \mutable\lettonothing\currentregisterpagesymbol +\mutable\lettonothing\currentregisterprocessors +\mutable\lettonothing\currentregisterprocessorsa +\mutable\lettonothing\currentregisterprocessorsb +\mutable\lettonothing\currentregisterprocessorsc \mutable\lettonothing\currentregistersectionindex \mutable\lettonothing\currentregisterseeindex \mutable\lettonothing\currentregisterseeword \mutable\lettonothing\currentregistersynchronize \mutable\lettonothing\currentregisterxmlsetup -\mutable\lettonothing\currentregisterprocessors -\mutable\lettonothing\currentregisterprocessorsa -\mutable\lettonothing\currentregisterprocessorsb -\mutable\lettonothing\currentregisterprocessorsc \newconditional\c_strc_registers_defining \setnewconstant\c_strc_registers_maxlevel \plusfive @@ -994,6 +995,8 @@ \setfalse\settrue\c_strc_registers_vertical \to \everysetupregister +\mutable\lettonothing\currentnestedregister + \permanent\protected\def\usenestedregisterstyleandcolor#1#2% will change {\useregisterstyleandcolor#1#2% % how about style diff --git a/tex/context/base/mkxl/strc-sec.mkxl b/tex/context/base/mkxl/strc-sec.mkxl index 227d24704..db100f0dd 100644 --- a/tex/context/base/mkxl/strc-sec.mkxl +++ b/tex/context/base/mkxl/strc-sec.mkxl @@ -704,7 +704,8 @@ \ifcsname\??headincrement\currentheadincrement\endcsname \lastnamedcs \else - \settrue \c_strc_sectioning_increment\settrue \c_strc_sectioning_to_list + \settrue\c_strc_sectioning_increment + \settrue\c_strc_sectioning_to_list % \filterheadnumber \fi} diff --git a/tex/context/base/mkxl/strc-syn.mkxl b/tex/context/base/mkxl/strc-syn.mkxl index 9b4c37ceb..9b4d410e1 100644 --- a/tex/context/base/mkxl/strc-syn.mkxl +++ b/tex/context/base/mkxl/strc-syn.mkxl @@ -266,6 +266,7 @@ \mutable\lettonothing\currentsynonym \mutable\lettonothing\currentsynonymtag \mutable\lettonothing\currentsynonymtext +\mutable\lettonothing\currentsynonymsortkey \permanent\tolerant\protected\def\definesynonyms[#1]#*[#2]#*[#3]#*[#4]% name plural \meaning \use {\ifnum\lastarguments=\plusfour @@ -626,7 +627,6 @@ \permanent\protected\def\currentsortingname {\clf_synonymname\currentsimplelist\currentsortingtag} \permanent\protected\def\currentsortingpages {\clf_synonympages\currentsimplelist\currentsortingtag} \permanent\protected\def\doifelsecurrentsortingused {\clf_doifelsesynonymused\currentsimplelist\currentsortingtag} -\permanent\protected\def\resetusedsortings [#1]{\clf_resetusedsynonyms{#1}} \permanent\protected\def\sortingname [#1]#*[#2]{\clf_synonymname {#1}{#2}} \permanent\protected\def\sortingpages[#1]#*[#2]{\clf_synonympages{#1}{#2}} diff --git a/tex/context/base/mkxl/supp-box.lmt b/tex/context/base/mkxl/supp-box.lmt index 093cac164..a26f77ae2 100644 --- a/tex/context/base/mkxl/supp-box.lmt +++ b/tex/context/base/mkxl/supp-box.lmt @@ -1395,6 +1395,8 @@ do actions = boxlinecount, } + -- todoL: just inline so that s-system-macros can find them + define_one("boxline", "get") define_one("setboxline", "set") define_one("copyboxline", "copy") diff --git a/tex/context/base/mkxl/symb-emj.lmt b/tex/context/base/mkxl/symb-emj.lmt index b043d835d..1bcb237f6 100644 --- a/tex/context/base/mkxl/symb-emj.lmt +++ b/tex/context/base/mkxl/symb-emj.lmt @@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['symb-emj'] = { license = "see context related readme files" } --- processors.hpack_filter does it all - local symbols = fonts.symbols local resolvedemoji = characters.emoji.resolve diff --git a/tex/context/base/mkxl/syst-aux.mkxl b/tex/context/base/mkxl/syst-aux.mkxl index c3a4a97b2..58678f9f3 100644 --- a/tex/context/base/mkxl/syst-aux.mkxl +++ b/tex/context/base/mkxl/syst-aux.mkxl @@ -6854,6 +6854,8 @@ %D %D \typebuffer \startpacked \getbuffer \stoppacked +\lettonothing\syst_helpers_wipe_tokens_yes + \def\syst_helpers_wipe_tokens_nop#-^^04{}% \permanent\def\wipetokens#1#2% diff --git a/tex/context/base/mkxl/syst-ini.mkxl b/tex/context/base/mkxl/syst-ini.mkxl index 46f02653a..d55a82175 100644 --- a/tex/context/base/mkxl/syst-ini.mkxl +++ b/tex/context/base/mkxl/syst-ini.mkxl @@ -322,6 +322,7 @@ \permanent\countdef\c_syst_max_allocated_toks = 216 \c_syst_max_allocated_toks = \directlua{tex.write(tex.magicconstants.max_toks_register_index)} % idem \permanent\countdef\c_syst_max_allocated_read = 217 \c_syst_max_allocated_read = \c_syst_max_allocated_iohandle \permanent\countdef\c_syst_max_allocated_write = 218 \c_syst_max_allocated_write = \c_syst_max_allocated_iohandle +\permanent\countdef\c_syst_max_allocated_float = 220 \c_syst_max_allocated_float = \directlua{tex.write(tex.magicconstants.max_float_register_index or 0)} % idem \permanent\countdef\c_syst_last_allocated_count = 221 \c_syst_last_allocated_count = \c_syst_min_allocated_register \permanent\countdef\c_syst_last_allocated_dimen = 222 \c_syst_last_allocated_dimen = \c_syst_min_allocated_register @@ -332,6 +333,7 @@ \permanent\countdef\c_syst_last_allocated_read = 227 \c_syst_last_allocated_read = \c_syst_min_allocated_iohandle \permanent\countdef\c_syst_last_allocated_write = 228 \c_syst_last_allocated_write = \c_syst_min_allocated_iohandle \permanent\countdef\c_syst_last_allocated_marks = 229 \c_syst_last_allocated_marks = \c_syst_min_allocated_mark +\permanent\countdef\c_syst_last_allocated_float = 230 \c_syst_last_allocated_float = \c_syst_min_allocated_register \permanent\countdef\c_syst_min_counter_value = 253 \c_syst_min_counter_value = -"7FFFFFFF \permanent\countdef\c_syst_max_counter_value = 254 \c_syst_max_counter_value = "7FFFFFFF @@ -358,6 +360,7 @@ \permanent\protected\def\newdimension #1{\dimensiondef #1\zeropoint} \permanent\protected\def\newgluespec #1{\gluespecdef #1\zeropoint} \permanent\protected\def\newmugluespec#1{\mugluespecdef#1\zeropoint} +\permanent\protected\def\newposit #1{\positdef #1\zerocount} %D The aliasing here is tricky: we need to make sure the alias is not let to the %D current value but behaves dynamic. Instead we can use just \newcount, unless of @@ -366,6 +369,7 @@ \protected\def\aliasinteger #1#2{\untraced\protected\def#1{#2}}% name parent \protected\def\aliasdimension#1#2{\untraced\protected\def#1{#2}}% name parent +\protected\def\aliasposit #1#2{\untraced\protected\def#1{#2}}% name parent %D So, effectively we start allocating from 256 and upwards. The inserts sit in the %D range 128 upto 254. Page numbers use the counters 0 upto 9 and the pagebox is @@ -386,6 +390,7 @@ \permanent\protected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \integerdef\c_syst_max_allocated_read} \permanent\protected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \integerdef\c_syst_max_allocated_write} \permanent\protected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \integerdef\c_syst_max_allocated_mark} +\permanent\protected\def\newfloat {\syst_basics_allocate\c_syst_last_allocated_float \float \floatdef \c_syst_max_allocated_float} \firstvalidlanguage \plusone % so zero is ignored in hyphenation, this might become the default diff --git a/tex/context/base/mkxl/syst-lua.lmt b/tex/context/base/mkxl/syst-lua.lmt index d8e06d4fd..0f80f57d3 100644 --- a/tex/context/base/mkxl/syst-lua.lmt +++ b/tex/context/base/mkxl/syst-lua.lmt @@ -58,6 +58,9 @@ local ctx_secondoftwoarguments = context.secondoftwoarguments local ctx_firstofoneargument = context.firstofoneargument local ctx_gobbleoneargument = context.gobbleoneargument +local values = tokens.values +local boolean_code = values.boolean + implement { -- will be overloaded later name = "writestatus", arguments = "2 arguments", @@ -309,6 +312,21 @@ end do + interfaces.implement { + name = "iflua", + public = true, + usage = "condition", + arguments = "string", + actions = function(s) + local c = load("return(" .. s .. ")") + return boolean_code, (c and c()) and true or false + end, + } + +end + +do + -- This is some 20% slower than native but we only provide this for compatibility -- reasons so we don't care that much about it. Eventually we can drop the built-in -- method. diff --git a/tex/context/base/mkxl/tabl-tab.mkxl b/tex/context/base/mkxl/tabl-tab.mkxl index c680a4474..ff0d201cf 100644 --- a/tex/context/base/mkxl/tabl-tab.mkxl +++ b/tex/context/base/mkxl/tabl-tab.mkxl @@ -58,7 +58,7 @@ \tabl_table_restore_lineskips \normalbaselines % \enforced\let~\fixedspace -` \enforced\letcharcode\tildeasciicode\fixedspace % why + \enforced\letcharcode\tildeasciicode\fixedspace % why \inhibitblank % \blank[\v!disable]% % added \the\everytableparbox} diff --git a/tex/context/base/mkxl/tabl-tbl.mkxl b/tex/context/base/mkxl/tabl-tbl.mkxl index 6b5e38f3a..b2e4f5090 100644 --- a/tex/context/base/mkxl/tabl-tbl.mkxl +++ b/tex/context/base/mkxl/tabl-tbl.mkxl @@ -791,6 +791,7 @@ \defcsname\??tabulatewidth\v!auto\endcsname {\c_tabl_tabulate_modus\plusthree\settrue\c_tabl_tabulate_reshape} +\lettonothing\tabl_tabulate_hook_box \lettonothing\tabl_tabulate_hook_box_begin \lettonothing\tabl_tabulate_hook_box_end @@ -2228,6 +2229,8 @@ % \fi % \fi} +\newconditional\c_tabl_tabulate_split_done + \protected\def\tabl_tabulate_flush_second_indeed {\glettonothing\tabl_tabulate_flush_collected_indeed \global\c_tabl_tabulate_column\zerocount @@ -3031,7 +3034,7 @@ \lettonothing\m_table_current_row_background \lettonothing\m_table_current_row_background_default \lettonothing\m_table_current_row_background_filler -\lettonothing\m_table_current_row_background_defaultfiller +\lettonothing\m_table_current_row_background_default_filler \lettonothing\m_table_current_row_background_auto \protected\def\tabl_register_row_background#1% diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 57376ae2b..962a7ef9a 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -176,11 +176,20 @@ appendaction("alignments", "normalizers", "nodes.handlers.mathmatrixrules", appendaction("localboxes", "lists", "typesetters.localboxes.handler", nil, "nut", "enabled" ) +appendaction("hquality", "system", "builders.hpack.report", nil, "nonut", "enabled" ) +appendaction("hquality", "system", "builders.hpack.show", nil, "nut", "enabled" ) +appendaction("vquality", "system", "builders.vpack.report", nil, "nonut", "enabled" ) +------------("vquality", "system", "builders.vpack.show", nil, "nut", "enabled" ) + -- some protection -freezecallbacks("find_.*_file", "find file using resolver") -freezecallbacks("read_.*_file", "read file at once") -freezecallbacks("open_.*_file", "open file for reading") +freezecallbacks("find_log_file", "provide the log file name") +freezecallbacks("find_format_file", "locate the format file") +freezecallbacks("open_data_file", "open the given file for reading") +freezecallbacks("process_jobname", "manipulate jobname") +freezecallbacks("trace_memory", "show memory usage details") + +freezecallbacks("hpack_filter", "hlist processing (not used, replaced)") -- no need to add more overhead -- experimental (needs to be updated): @@ -197,6 +206,9 @@ freezegroup("finalizers", "lists") freezegroup("math", "normalizers") freezegroup("math", "builders") +freezegroup("hquality", "system") +freezegroup("vquality", "system") + freezegroup("shipouts", "normalizers") freezegroup("shipouts", "finishers") freezegroup("shipouts", "wrapup") @@ -204,8 +216,8 @@ freezegroup("shipouts", "wrapup") freezegroup("mvlbuilders", "normalizers") freezegroup("vboxbuilders", "normalizers") ------------("parbuilders", "lists") ------------("pagebuilders", "lists") +-----------("parbuilders", "normalizers") +freezegroup("pagebuilders", "normalizers") freezegroup("math", "normalizers") freezegroup("math", "builders") diff --git a/tex/context/base/mkxl/toks-scn.lmt b/tex/context/base/mkxl/toks-scn.lmt index ab531a462..c08e8415a 100644 --- a/tex/context/base/mkxl/toks-scn.lmt +++ b/tex/context/base/mkxl/toks-scn.lmt @@ -262,6 +262,7 @@ local shortcuts = { toboolean = toboolean, inspect = inspect, report = report_scan, + posit = posit, } tokens.shortcuts = shortcuts diff --git a/tex/context/base/mkxl/trac-deb.lmt b/tex/context/base/mkxl/trac-deb.lmt index caa5464f8..83603ef59 100644 --- a/tex/context/base/mkxl/trac-deb.lmt +++ b/tex/context/base/mkxl/trac-deb.lmt @@ -289,15 +289,15 @@ end directives.register("system.errorcontext", function(v) local register = callback.register if v then - register('show_error_message', nop) - register('show_warning_message', function() processwarning(v) end) - register('intercept_lua_error', function() processerror(v) end) - register('intercept_tex_error', function(mode,eof) processerror(v,eof) return mode end) + register("show_error_message", nop) + register("show_warning_message", function() processwarning(v) end) + register("intercept_lua_error", function() processerror(v) end) + register("intercept_tex_error", function(mode,eof) processerror(v,eof) return mode end) else - register('show_error_message', nil) - register('show_warning_message', nil) - register('intercept_lua_error', nil) - register('intercept_tex_error', nil) + register("show_error_message", nil) + register("show_warning_message", nil) + register("intercept_lua_error", nil) + register("intercept_tex_error", nil) end end) diff --git a/tex/context/base/mkxl/typo-bld.lmt b/tex/context/base/mkxl/typo-bld.lmt index 00ff9f267..c0b42001e 100644 --- a/tex/context/base/mkxl/typo-bld.lmt +++ b/tex/context/base/mkxl/typo-bld.lmt @@ -19,6 +19,12 @@ local parbuilders = builders.paragraphs parbuilders.constructors = parbuilders.constructors or { } local constructors = parbuilders.constructors +builders.hpack = builders.hpack or { } +builders.vpack = builders.vpack or { } + +local hpackbuilders = builders.hpack +local vpackbuilders = builders.vpack + constructors.names = constructors.names or { } local names = constructors.names @@ -52,6 +58,7 @@ local nuts = nodes.nuts local tonode = nodes.tonode local tonut = nodes.tonut local getattr = nuts.getattr +local flush = nuts.flush local starttiming = statistics.starttiming local stoptiming = statistics.stoptiming @@ -200,13 +207,12 @@ local builders = nodes.builders local vpackactions = nodes.tasks.actions("vboxbuilders") function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction) - local done = false if head then starttiming(builders) - head, done = vpackactions(head,groupcode) + head = vpackactions(head,groupcode) stoptiming(builders) end - return head, done + return head end -- This one is special in the sense that it has no head and we operate on the mlv. Also, @@ -244,8 +250,8 @@ function builders.buildpage_filter(pagecontext) end end -registercallback('vpack_filter', builders.vpack_filter, "vertical spacing etc") -registercallback('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)") +registercallback("vpack_filter", builders.vpack_filter, "vertical spacing etc") +registercallback("buildpage_filter", builders.buildpage_filter, "vertical spacing etc (mvl)") local vboxactions = nodes.tasks.actions("vboxhandlers") @@ -258,7 +264,7 @@ function builders.vbox_filter(head,groupcode) return head end -registercallback('packed_vbox_filter', builders.vbox_filter, "packed vbox treatments") +registercallback("packed_vbox_filter", builders.vbox_filter, "packed vbox treatments") statistics.register("v-node processing time", function() return statistics.elapsedseconds(builders) @@ -297,37 +303,51 @@ local report_quality = logs.reporter("pack quality") -- overflow|badness w h d dir -local function vpack_quality(how,n,detail,first,last,filename) - if last <= 0 then - report_quality("%s vbox",how) - elseif first > 0 and first < last then - report_quality("%s vbox at line %i - %i in file %a",how,first,last,filename or "?") - else - report_quality("%s vbox at line %i in file %a",how,filename or "?",last) +local report = true trackers.register("builders.vpack.quality", function(v) report = v end) +local collect = false trackers.register("builders.vpack.collect", function(v) collect = v end) +---- show = false trackers.register("builders.vpack.overflow",function(v) show = v end) + +function vpackbuilders.report(how,detail,n,first,last,filename) -- no return value + if report then + if last <= 0 then + report_quality("%s vbox",how) + elseif first > 0 and first < last then + report_quality("%s vbox at line %i - %i in file %a",how,first,last,filename or "?") + else + report_quality("%s vbox at line %i in file %a",how,last,filename or "?") + end + end + if collect then + list[#list+1] = { "hbox", how, filename, first, last, how, detail } end - list[#list+1] = { "hbox", how, filename, first, last, how } end -trackers.register("builders.vpack.quality",function(v) - registercallback("vpack_quality",v and vpack_quality or nil,"check vpack quality") -end) +-- function builders.vpack.show(how,detail,n,first,last,filename) -- return value +-- if show then +-- end +-- end -local report = false -local show = false +local report = true trackers.register("builders.hpack.quality", function(v) report = v end) +local collect = false trackers.register("builders.hpack.collect", function(v) collect = v end) +local show = false trackers.register("builders.hpack.overflow",function(v) show = v end) -local function hpack_quality(how,detail,n,first,last,filename) - n = tonut(n) +function hpackbuilders.report(how,detail,n,first,last,filename) -- no return value + local str = (report or collect) and listtoutf(getlist(n),"",true,nil,true) if report then - local str = listtoutf(getlist(n),"",true,nil,true) if last <= 0 then - report_quality("%s hbox: %s",how,str) + report_quality("%s hbox: %s (%p)",how,str,detail) elseif first > 0 and first < last then - report_quality("%s hbox at line %i - %i in file %a: %s",how,first,last,filename or "?",str) + report_quality("%s hbox at line %i - %i in file %a: %s (%p)",how,first,last,filename or "?",str,detail) else - report_quality("%s hbox at line %i in file %a: %s",how,last,filename or "?",str) + report_quality("%s hbox at line %i in file %a: %s (%p)",how,last,filename or "?",str,detail) end - list[#list+1] = { "hbox", how, filename, first, last, str } end + if collect then + list[#list+1] = { "hbox", how, filename, first, last, str, detail } + end +end + +function hpackbuilders.show(how,detail,n,first,last,filename,rule) -- return value if show then local width = 2*65536 local height = getheight(n) @@ -339,7 +359,10 @@ local function hpack_quality(how,detail,n,first,last,filename) if depth < 2*65526 then depth = 2*65526 end - local rule = new_rule(width,height,depth) + if rule then + flush(rule) + end + rule = new_rule(width,height,depth) setdirection(rule,direction) if how == "overfull" then setcolor(rule,"red") @@ -356,19 +379,40 @@ local function hpack_quality(how,detail,n,first,last,filename) rule = hpack(rule) setwidth(rule,0) -- maybe better whd all zero setdirection(rule,direction) - return tonode(rule) -- can be a nut + else + local width = texget("overfullrule") + if width > 0 then + rule = new_rule(width) + end end + return rule end -trackers.register("builders.hpack.quality",function(v) - report = v - registercallback("hpack_quality",(report or show) and hpack_quality or nil,"check hpack quality") -end) +-- -trackers.register("builders.hpack.overflow",function(v) - show = v - registercallback("hpack_quality",(report or show) and hpack_quality or nil,"check hpack quality") -end) +local hqualityactions = nodes.tasks.actions("hquality") +local vqualityactions = nodes.tasks.actions("vquality") + +function hpackbuilders.qualityactions(how,detail,n,first,last,filename) + local rul = nil + -- starttiming(builders) + rul = hqualityactions(how,detail,n,first,last,filename) + -- stoptiming(builders) + return rul +end +function vpackbuilders.qualityactions(how,detail,n,first,last,filename) + local rul = nil + -- starttiming(builders) + rul = vqualityactions(how,detail,n,first,last,filename) + -- stoptiming(builders) + return rul +end + +registercallback("hpack_quality", hpackbuilders.qualityactions, "report horizontal packing quality") +registercallback("vpack_quality", vpackbuilders.qualityactions, "report vertical packing quality") + + +-- statistics.register("quality reports", function() local n = #list @@ -390,7 +434,7 @@ statistics.register("quality reports", function() logs.startfilelogging(report_quality) for i=1,n do local l = list[i] - report_quality("%-" .. fw .. "s [%04i - %04i] : %-" .. hw .. "s %s : %s",file.basename(l[3]),l[4],l[5],l[2],l[1],l[6]) + report_quality("%-" .. fw .. "s [%04i - %04i] : %-" .. hw .. "s %s : %s (%p)",file.basename(l[3]),l[4],l[5],l[2],l[1],l[6],l[7]) end logs.stopfilelogging() report_quality() diff --git a/tex/context/base/mkxl/typo-del.mkxl b/tex/context/base/mkxl/typo-del.mkxl index 08d0a9b09..bd427b954 100644 --- a/tex/context/base/mkxl/typo-del.mkxl +++ b/tex/context/base/mkxl/typo-del.mkxl @@ -412,10 +412,10 @@ {\begingroup \typo_delimited_push{#1}{#2}% \dostarttaggedchained\t!delimitedblock\currentdelimitedtext\??delimitedtext - \edef\p_delimited_method{\delimitedtextparameter\c!method}% - \ifx\p_delimited_method\v!font + \edef\p_method{\delimitedtextparameter\c!method}% + \ifx\p_method\v!font \expandafter\typo_delimited_start_font - \orelse\ifx\p_delimited_method\v!paragraph + \orelse\ifx\p_method\v!paragraph \expandafter\typo_delimited_start_font \else \expandafter\typo_delimited_start_other @@ -485,12 +485,14 @@ \endgroup \dostoptagged} +\lettonothing\p_delimited_left +\lettonothing\p_delimited_right +\lettonothing\p_delimited_nextleft +\lettonothing\p_delimited_nextright + \tolerant\def\typo_delimited_start_par[#1]% {\let\typo_delimited_stop\typo_delimited_stop_par - \edef\p_delimited_spacebefore{\delimitedtextparameter\c!spacebefore}% - \ifempty\p_delimited_spacebefore \else - \blank[\p_delimited_spacebefore]% - \fi + \checkedblank[\delimitedtextparameter\c!spacebefore]% \delimitedtextparameter\c!before \edef\m_delimited_argument{#1}% \ifempty\m_delimited_argument @@ -538,10 +540,7 @@ \pop_macro_checkindentation \typo_delimited_stop_par_indeed \delimitedtextparameter\c!after - \edef\p_delimited_spaceafter{\delimitedtextparameter\c!spaceafter}% - \ifempty\p_delimited_spaceafter \else - \blank[\p_delimited_spaceafter]% - \fi + \checkedblank[\delimitedtextparameter\c!spaceafter]% \useindentnextparameter\delimitedtextparameter \aftergroup\dorechecknextindentation}% AM: This was missing! @@ -566,10 +565,10 @@ \permanent\tolerant\protected\def\delimitedtext[#1]#*[#2]% {\dontleavehmode % following ones can be omited \typo_delimited_push{#1}{#2}% - \edef\p_delimited_method{\delimitedtextparameter\c!method}% - \ifx\p_delimited_method\v!font + \edef\p_method{\delimitedtextparameter\c!method}% + \ifx\p_method\v!font \expandafter\typo_delimited_fontdriven - \orelse\ifx\p_delimited_method\v!text + \orelse\ifx\p_method\v!text \expandafter\typo_delimited_fontdriven \else \expandafter\typo_delimited_other diff --git a/tex/context/base/mkxl/typo-lbx.mkxl b/tex/context/base/mkxl/typo-lbx.mkxl index 93a2fc86f..57186856f 100644 --- a/tex/context/base/mkxl/typo-lbx.mkxl +++ b/tex/context/base/mkxl/typo-lbx.mkxl @@ -100,6 +100,8 @@ %D existing local box we create nested ones. This is handled in the callback but if %D really needed one can do something like (do we need a primitive?): +\mutable\lettonothing\currentlocalboxeslocation + \def\typo_localboxes_localbox {\ifx\currentlocalboxeslocation\v!right \localrightbox |