diff options
19 files changed, 356 insertions, 107 deletions
diff --git a/doc/context/documents/general/manuals/onandon.pdf b/doc/context/documents/general/manuals/onandon.pdf Binary files differindex 029f83609..e9c6930b5 100644 --- a/doc/context/documents/general/manuals/onandon.pdf +++ b/doc/context/documents/general/manuals/onandon.pdf diff --git a/doc/context/sources/general/manuals/onandon/onandon-expansion.tex b/doc/context/sources/general/manuals/onandon/onandon-expansion.tex index e20d7e192..a25b75246 100644 --- a/doc/context/sources/general/manuals/onandon/onandon-expansion.tex +++ b/doc/context/sources/general/manuals/onandon/onandon-expansion.tex @@ -75,6 +75,11 @@ the other with user defined conditions. The first one relates directly to expansion, the second one concerns conditions and relates more to parsing branches which on purpose avoids expansion. +{\em In the meantime \LUAMETATEX\ has a slightly different implementation which +goes under the umbrella \quote {local control}. We show both ways here. The +example where two token lists are compared can be done easier with \type +{\iftok}.} + For the first one I use some silly examples. I must admit that although I can envision useful application, I really need to go over the large amount of \CONTEXT\ source code to really find a place where it is making things better. @@ -106,8 +111,14 @@ preventing look ahead interference by using a space or \tex {relax} (often an expression works better as it doesn't leave an \tex {relax}). \startbuffer +% luatex + \def\TestMe{\immediateassignment\advance\NumberOfCalls1 } +% luametatex + +\def\TestMe{\localcontrolled{\advance\NumberOfCalls1 }} + \edef\Tested{\TestMe bar:\the\NumberOfCalls} \edef\Tested{\TestMe bar:\the\NumberOfCalls} \edef\Tested{\TestMe bar:\the\NumberOfCalls} @@ -126,7 +137,9 @@ Here is a somewhat silly example of an expanded comparison of two \quote {strings}: \startbuffer -\def\expandeddoifelse#1#2#3#4% +% luatex + +\def\ExpandedDoifElse#1#2#3#4% {\immediateassignment\edef\tempa{#1}% \immediateassignment\edef\tempb{#2}% \ifx\tempa\tempb @@ -136,9 +149,21 @@ Here is a somewhat silly example of an expanded comparison of two \quote \fi \next} +% luametatex + +\def\ExpandedDoifElse#1#2#3#4% + {\localcontrolled{\edef\tempa{#1}}% + \localcontrolled{\edef\tempb{#2}}% + \ifx\tempa\tempb + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} + \edef\Tested - {(\expandeddoifelse{abc}{def}{yes}{nop}/% - \expandeddoifelse{abc}{abc}{yes}{nop})} + {(\ExpandedDoifElse{abc}{def}{yes}{nop}/% + \ExpandedDoifElse{abc}{abc}{yes}{nop})} \meaning\Tested \stopbuffer @@ -162,7 +187,9 @@ In addition to this one|-|time immediate assignment a pseudo token list variant is provided, so the above could be rewritten to: \starttyping -\def\expandeddoifelse#1#2#3#4% +% luatex + +\def\ExpandedDoifElse#1#2#3#4% {\immediateassigned { \edef\tempa{#1} \edef\tempb{#2} @@ -173,6 +200,20 @@ is provided, so the above could be rewritten to: \immediateassignment\def\next{#4}% \fi \next} + +% luametatex + +\def\ExpandedDoifElse#1#2#3#4% + {\beginlocalcontrol + \edef\tempa{#1} + \edef\tempb{#2} + \endlocalcontrol + \ifx\tempa\tempb + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} \stoptyping While \tex {expanded} first builds a token lists that then gets used, the \tex @@ -261,18 +302,35 @@ previously mentioned immediate assignment. Here is another example: The previously defined comparison macro can now be rewritten as: \starttyping -\def\equaltokens#1#2% +% luatex + +\def\EqualTokens#1#2% {\immediateassignment\edef\tempa{#1}% \immediateassignment\edef\tempb{#2}% \ifx\tempa\tempb} -\def\expandeddoifelse#1#2#3#4% - {\ifcondition\equaltokens{#1}{#2}% +\def\ExpandedDoifElse#1#2#3#4% + {\ifcondition\EqualTokens{#1}{#2}% \immediateassignment\def\next{#3}% \else \immediateassignment\def\next{#4}% \fi \next} + +% luametatex + +\def\EqualTokens#1#2% + {\localcontrolled{\edef\tempa{#1}}% + \localcontrolled{\edef\tempb{#2}}% + \ifx\tempa\tempb} + +\def\ExpandedDoifElse#1#2#3#4% + {\ifcondition\EqualTokens{#1}{#2}% + \localcontrolled{\def\next{#3}}% + \else + \localcontrolled{\def\next{#4}}% + \fi + \next} \stoptyping When used this way it will of course also work without the \tex {ifcondition} but diff --git a/doc/context/sources/general/manuals/onandon/onandon-fences.tex b/doc/context/sources/general/manuals/onandon/onandon-fences.tex index ff50ebe5e..76ade938e 100644 --- a/doc/context/sources/general/manuals/onandon/onandon-fences.tex +++ b/doc/context/sources/general/manuals/onandon/onandon-fences.tex @@ -1,5 +1,10 @@ % language=us +% This feature has been removed because we have different control now in the +% reworked engine so this chapter cnanot be processed any longer. + +\endinput + \startcomponent onandon-fences \environment onandon-environment diff --git a/doc/context/sources/general/manuals/onandon/onandon.tex b/doc/context/sources/general/manuals/onandon/onandon.tex index 3b6f22cf9..7ea81205d 100644 --- a/doc/context/sources/general/manuals/onandon/onandon.tex +++ b/doc/context/sources/general/manuals/onandon/onandon.tex @@ -39,7 +39,7 @@ \component onandon-emoji \component onandon-performance \component onandon-editing - \component onandon-fences % first published in user group magazines + % \component onandon-fences % first published in user group magazines / obsolete \component onandon-media \component onandon-53 % first published in user group magazines \component onandon-execute % first published in user group magazines diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e5eeff7b9..40172106d 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2022.08.05 11:40} +\newcontextversion{2022.08.05 17:16} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index e302eb6f9..e7b236699 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2022.08.05 11:40} +\edef\contextversion{2022.08.05 17:16} %D For those who want to use this: diff --git a/tex/context/base/mkiv/char-def.lua b/tex/context/base/mkiv/char-def.lua index 3208eab6b..6449e085e 100644 --- a/tex/context/base/mkiv/char-def.lua +++ b/tex/context/base/mkiv/char-def.lua @@ -456,6 +456,7 @@ characters.data={ direction="es", linebreak="pr", mathclass="binary", + mathgroup="nary arithmic", unicodeslot=0x2B, }, { @@ -479,6 +480,7 @@ characters.data={ direction="es", linebreak="hy", mathclass="ordinary", + mathgroup="binary arithmic", mathextensible="h", mathfiller="relfill", mathname="mathhyphen", @@ -656,6 +658,7 @@ characters.data={ direction="on", linebreak="al", mathclass="relation", + mathgroup="nary relation", mathname="lt", mirror=0x3E, textclass="open", @@ -671,6 +674,7 @@ characters.data={ linebreak="al", mathextensible="h", mathfiller="equalfill", + mathgroup="nary relation", mathspec={ { class="relation", @@ -691,6 +695,7 @@ characters.data={ direction="on", linebreak="al", mathclass="relation", + mathgroup="nary relation", mathname="gt", mirror=0x3C, textclass="close", @@ -2299,6 +2304,7 @@ characters.data={ direction="on", linebreak="ai", mathclass="binary", + mathgroup="nary arithmic", mathname="times", synonyms={ "cartesian product" }, unicodeslot=0xD7, @@ -2698,6 +2704,7 @@ characters.data={ direction="on", linebreak="ai", mathclass="binary", + mathgroup="binary arithmic", mathname="div", synonyms={ "obelus" }, unicodeslot=0xF7, @@ -64126,6 +64133,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL C", direction="l", linebreak="al", + mathgroup="constant set", mathname="complexes", specials={ "font", 0x43 }, synonyms={ "complex numbers", "the set of complex numbers" }, @@ -64318,6 +64326,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL N", direction="l", linebreak="al", + mathgroup="constant set", mathname="naturalnumbers", specials={ "font", 0x4E }, synonyms={ "natural number" }, @@ -64358,6 +64367,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL P", direction="l", linebreak="al", + mathgroup="constant set", mathname="primes", specials={ "font", 0x50 }, unicodeslot=0x2119, @@ -64367,6 +64377,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL Q", direction="l", linebreak="al", + mathgroup="constant set", mathname="rationals", specials={ "font", 0x51 }, synonyms={ "rational numbers", "the set of rational numbers" }, @@ -64399,6 +64410,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL R", direction="l", linebreak="al", + mathgroup="constant set", mathname="reals", specials={ "font", 0x52 }, synonyms={ "real numbers", "the set of real numbers" }, @@ -64462,6 +64474,7 @@ characters.data={ description="DOUBLE-STRUCK CAPITAL Z", direction="l", linebreak="al", + mathgroup="constant set", mathname="integers", specials={ "font", 0x5A }, synonyms={ "integers", "the set of integers" }, @@ -66814,6 +66827,7 @@ characters.data={ description="EMPTY SET", direction="on", linebreak="al", + mathgroup="constant set", mathclass="ordinary", mathname="emptyset", synonyms={ "null set" }, @@ -66981,6 +66995,7 @@ characters.data={ description="MINUS SIGN", direction="es", linebreak="pr", + mathgroup="binary arithmic", mathspec={ { class="binary", @@ -67937,6 +67952,7 @@ characters.data={ description="LESS-THAN OR EQUAL TO", direction="on", linebreak="ai", + mathgroup="nary relation", mathlist={ 0x3C, 0x3D }, mathspec={ { @@ -67958,6 +67974,7 @@ characters.data={ description="GREATER-THAN OR EQUAL TO", direction="on", linebreak="ai", + mathgroup="nary relation", mathlist={ 0x3E, 0x3D }, mathspec={ { diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 493ef50a7..e4a711f11 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.08.05 11:40} +\newcontextversion{2022.08.05 17:16} %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/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 736cd6e73..664316e97 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -49,7 +49,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2022.08.05 11:40} +\edef\contextversion{2022.08.05 17:16} %D Kind of special: diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex a41240d11..3c36ed7cf 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex aafa04ff5..c57cfee7c 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkxl/cont-new.mkxl b/tex/context/base/mkxl/cont-new.mkxl index f9cc4b1b1..8b974f841 100644 --- a/tex/context/base/mkxl/cont-new.mkxl +++ b/tex/context/base/mkxl/cont-new.mkxl @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2022.08.05 11:40} +\newcontextversion{2022.08.05 17:16} %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 f167c0f58..6d8c81284 100644 --- a/tex/context/base/mkxl/context.mkxl +++ b/tex/context/base/mkxl/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \immutable\edef\contextformat {\jobname} -\immutable\edef\contextversion{2022.08.05 11:40} +\immutable\edef\contextversion{2022.08.05 17:16} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error diff --git a/tex/context/base/mkxl/math-ini.lmt b/tex/context/base/mkxl/math-ini.lmt index 48d905ca6..0af62a45e 100644 --- a/tex/context/base/mkxl/math-ini.lmt +++ b/tex/context/base/mkxl/math-ini.lmt @@ -6,19 +6,23 @@ if not modules then modules = { } end modules ['math-ini'] = { license = "see context related readme files" } --- if needed we can use the info here to set up xetex definition files --- the "8000 hackery influences direct characters (utf) as indirect \char's --- --- isn't characters.data loaded already ... shortcut it here --- --- replace code 7 by 0 as we don't use it anyway (chars with code 7 will adapt to --- to the fam when set ... we use other means .. ok, we could use it for spacing but --- then we also have to set the other characters (only a subset done now) +-- The way we do math in \CONTEXT\ \MKIV\ differs from other macro packages so you +-- should not mix the somewhat unique (and bit weird) approach here with the more +-- traditional (\TEX) approach. Also, we use char-def.lua as starting point and that +-- file is quite \CONTEXT\ specific. When we added math to that there was no +-- interest (quite the contrary) so we didn't went generic there which in retrospect +-- also gives us the freedom to add more information, something that happens +-- occasionally. Because that file is shared between \MKIV\ and \LMTX\ some +-- information is only used by \LMTX. We also have quite some runs over the math +-- list but that has been so since we started and performance will not degrade much +-- by it; after all math is not that demanding. More details can be found in the +-- manuals that discuss math. Most code (and concepts) date from 2005 so maybe I +-- will upgrade the lot some day, although it has been adapted on the way to the +-- changes in the engine(s). local next, type = next, type local formatters, find, nospaces = string.formatters, string.find, string.nospaces -local utfchar, utfbyte, utflength = utf.char, utf.byte, utf.length ------ floor = math.floor +local utfchar, utfbyte = utf.char, utf.byte local sortedhash = table.sortedhash local toboolean = toboolean @@ -31,8 +35,6 @@ local ctx_doifelsesomething = commands.doifelsesomething local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end) -trace_defining = true - local report_math = logs.reporter("mathematics","initializing") mathematics = mathematics or { } @@ -54,17 +56,32 @@ local texintegerdef = tex.integerdef do - local dictionaries = { } + local dictionaries = mathematics.dictionaries or { } mathematics.dictionaries = dictionaries - local names = dictionaries.names or utilities.storage.allocate() - local groups = dictionaries.groups or utilities.storage.allocate() - local data = dictionaries.data or utilities.storage.allocate() - - if storage then - storage.register("mathematics/dictionaries/names", names, "characters.dictionaries.names") - storage.register("mathematics/dictionaries/groups", groups, "characters.dictionaries.groups") - storage.register("mathematics/dictionaries/data", data, "characters.dictionaries.data") + local names = dictionaries.names or utilities.storage.allocate() + local groups = dictionaries.groups or utilities.storage.allocate() + local data = dictionaries.data or utilities.storage.allocate() + local sets = dictionaries.sets or utilities.storage.allocate() + local variants = dictionaries.variants or utilities.storage.allocate() -- todo: get from char-def + local defaults = dictionaries.defaults or utilities.storage.allocate() -- todo: get from char-def + + storage.register("mathematics/dictionaries/names", names, "mathematics.dictionaries.names") + storage.register("mathematics/dictionaries/groups", groups, "mathematics.dictionaries.groups") + storage.register("mathematics/dictionaries/data", data, "mathematics.dictionaries.data") + storage.register("mathematics/dictionaries/sets", sets, "mathematics.dictionaries.sets") + storage.register("mathematics/dictionaries/variants", variants, "mathematics.dictionaries.variants") + storage.register("mathematics/dictionaries/defaults", defaults, "mathematics.dictionaries.defaults") + + dictionaries.names = dictionaries.names or names + dictionaries.groups = dictionaries.groups or groups + dictionaries.data = dictionaries.data or data + dictionaries.sets = dictionaries.sets or sets + dictionaries.variants = dictionaries.variants or variants + dictionaries.defaults = dictionaries.defaults or defaults + + if not sets.n then + sets.n = 0 end function dictionaries.registergroup(name) @@ -81,13 +98,71 @@ do return group end + function dictionaries.registergroupset(name,set) + local s = sets[name] + if not s then + local d = dictionaries.registergroup(name) + local n = sets.n + 1 + local l = utilities.parsers.settings_to_array(set) + local g = { } + for i=1,#l do + local n = names[l[i]] + if n then + g[#g+1] = n -- ordered + end + end + s = { + names = l, + groups = g, + group = d, + } + sets[name] = s + sets[d] = s + + end + end + + function dictionaries.groupset(name) + return sets[name] or { } + end + + function dictionaries.groupsetgroup(name) + local s = sets[name] + if s then + return s.group + else + return names[name] or 0 + end + end + function dictionaries.registercharacter(group,index,description) local d = names[group] -- can be number or string if d then - data[d][index] = description + data[d][index] = description or true + local v = variants[index] + if v then + v[d] = true + else + variants[index] = { [d] = true } + end + if not defaults[index] then + defaults[index] = d + end end end + implement { + name = "registergroupset", + arguments = "2 strings", + actions = dictionaries.registergroupset, + } + + implement { + name = "groupsetgroup", + arguments = "string", + actions = { dictionaries.groupsetgroup, context }, + } + local fontchardata = fonts.hashes.characters local f_dictionary = false local register = callback.register @@ -106,7 +181,7 @@ do else groupname = "unknown" end - if not indexname then + if not indexname or indexname == true then indexname = chardata[unicode] indexname = indexname and indexname.description or "unknown" end @@ -143,42 +218,46 @@ do -- -- The char-def.lua file will have mathgroup entries reflecting this. - local registergroup = mathematics.dictionaries.registergroup - - registergroup("default") - registergroup("binary arithmic") - registergroup("binary linear algebra") - registergroup("binary logical") - registergroup("binary relation") - registergroup("binary set") - registergroup("constant arithmic") - registergroup("constant set") - registergroup("differential") - registergroup("integral") - registergroup("interval") - registergroup("lambda") - registergroup("limit") - registergroup("nary arithmic") - registergroup("nary constructor") - registergroup("nary functional") - registergroup("nary linear algebra") - registergroup("nary logical") - registergroup("nary minmax") - registergroup("nary relation") - registergroup("nary set list") - registergroup("nary set relation") - registergroup("nary set") - registergroup("nary statistics") - registergroup("partial") -- partial differential - registergroup("product") - registergroup("quantifier") - registergroup("unary arithmic") - registergroup("unary elementary") - registergroup("unary functional") - registergroup("unary linear algebra") - registergroup("unary logical") - registergroup("unary set") - registergroup("unary vector") + if environment.initex then + + local registergroup = mathematics.dictionaries.registergroup + + registergroup("default") + registergroup("binary arithmic") + registergroup("binary linear algebra") + registergroup("binary logical") + registergroup("binary relation") + registergroup("binary set") + registergroup("constant arithmic") + registergroup("constant set") + registergroup("differential") + registergroup("integral") + registergroup("interval") + registergroup("lambda") + registergroup("limit") + registergroup("nary arithmic") + registergroup("nary constructor") + registergroup("nary functional") + registergroup("nary linear algebra") + registergroup("nary logical") + registergroup("nary minmax") + registergroup("nary relation") + registergroup("nary set list") + registergroup("nary set relation") + registergroup("nary set") + registergroup("nary statistics") + registergroup("partial") -- partial differential + registergroup("product") + registergroup("quantifier") + registergroup("unary arithmic") + registergroup("unary elementary") + registergroup("unary functional") + registergroup("unary linear algebra") + registergroup("unary logical") + registergroup("unary set") + registergroup("unary vector") + + end -- \Umathdictdef\vdash 1 \mathbinarylogicaldictionary "22A2 \mathrelationcode 0 "22A2 -- @@ -408,7 +487,10 @@ mathematics.virtualized = virtualized do - local setmathcharacter = function(class,family,slot,unicode,mset,dset) + local registercharacter = mathematics.dictionaries.registercharacter + local groupnames = mathematics.dictionaries.names + + local setmathcharacter = function(class,family,slot,unicode,mset,dset,group) if mset and class ~= ordinary_class then setmathcode("global",slot,class,family,unicode) mset = false @@ -417,6 +499,14 @@ do setdelcode("global",slot,family,unicode,0,0) dset = false end + if group then + group = groupnames[group] or 0 + if group ~= 0 then + -- which one + registercharacter(group,unicode) + -- registercharacter(group,slot) + end + end return mset, dset end @@ -446,7 +536,7 @@ do local texmathchardef = tex.mathchardef - local setmathsymbol = function(name,class,engine,family,slot,stretch) -- hex is nicer for tracing + local setmathsymbol = function(name,class,engine,family,slot,stretch,group) -- hex is nicer for tracing if class == accent_class then ctx_sprint(f_topaccent(name,0,family,slot)) elseif class == topaccent_class then @@ -468,6 +558,13 @@ do elseif class == root_class then ctx_sprint(f_root(name,family,slot)) elseif texmathchardef then + if group then + group = groupnames[group] or 0 + if group ~= 0 then + texmathchardef(name,engine,family,slot,"permanent",0,group,slot) + return + end + end texmathchardef(name,engine,family,slot,"permanent") else -- beware, open/close and other specials should not end up here @@ -505,7 +602,7 @@ do if trace_defining then report(class,engine,family,unicode,symbol) end - mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset,group) end local spec = other.mathspec if spec then @@ -515,7 +612,7 @@ do if class then local engine = toengineclass(class) -- todo: trace - mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,symbol,mset,dset,group) end end end @@ -524,6 +621,7 @@ do local spec = character.mathspec local name = character.mathname local stretch = character.mathstretch + local group = character.mathgroup if spec then local done = false if class then @@ -536,7 +634,7 @@ do if trace_defining then report(class,engine,family,unicode) end - mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset,group) done = true end end @@ -544,6 +642,7 @@ do local m = spec[i] local name = m.name local class = m.class or class + local group = m.group or group if class then class = classes[class] or ordinary_class else @@ -555,7 +654,7 @@ do if trace_defining then report(class,engine,family,unicode,name) end - setmathsymbol(name,class,engine,family,unicode,stretch) + setmathsymbol(name,class,engine,family,unicode,stretch,group) else name = (class == classes.ordinary or class == classes.digit) and character.adobename -- bad if name and trace_defining then @@ -563,7 +662,7 @@ do end end if not done then - mset, dset = setmathcharacter(engine,family,unicode,m.unicode or unicode,mset,dset) -- see solidus + mset, dset = setmathcharacter(engine,family,unicode,m.unicode or unicode,mset,dset,group) -- see solidus done = true end end @@ -580,7 +679,7 @@ do if trace_defining then report(class,engine,family,unicode,name) end - mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset,group) else -- if not name then -- name = character.contextname -- too dangerous, we loose textslash and a few more @@ -589,20 +688,20 @@ do if trace_defining then report(class,engine,family,unicode,name) end - setmathsymbol(name,class,engine,family,unicode,stretch) + setmathsymbol(name,class,engine,family,unicode,stretch,group) else if trace_defining then report(class,engine,family,unicode,character.adobename) end end - mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset,group) end elseif class ~= ordinary_class then local engine = toengineclass(class) if trace_defining then report(class,engine,family,unicode,character.adobename) end - mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset) + mset, dset = setmathcharacter(engine,family,unicode,unicode,mset,dset,group) end end end diff --git a/tex/context/base/mkxl/math-ini.mkxl b/tex/context/base/mkxl/math-ini.mkxl index 0ce6d14ef..9dd9675f3 100644 --- a/tex/context/base/mkxl/math-ini.mkxl +++ b/tex/context/base/mkxl/math-ini.mkxl @@ -4072,6 +4072,14 @@ #2\ifparameter#1\or\low{#1}\fi \fi} +%D New: + +\permanent\tolerant\protected\def\definemathgroupset[#1]#*[#2]% + {\clf_registergroupset{#1}{#2}} + +\permanent\tolerant\protected\def\setmathgroupset[#1]% + {\mathdictgroup\clf_groupsetgroup{#1}\relax} + \protect \endinput % % not used (yet) diff --git a/tex/context/base/mkxl/math-noa.lmt b/tex/context/base/mkxl/math-noa.lmt index 9ba92bbc7..8e5b75ef4 100644 --- a/tex/context/base/mkxl/math-noa.lmt +++ b/tex/context/base/mkxl/math-noa.lmt @@ -57,26 +57,27 @@ local mathmode_code = tex.modelevels.math local colortracers = nodes.tracers.colors -local trace_remapping = false registertracker("math.remapping", function(v) trace_remapping = v end) -local trace_processing = false registertracker("math.processing", function(v) trace_processing = v end) -local trace_analyzing = false registertracker("math.analyzing", function(v) trace_analyzing = v end) -local trace_normalizing = false registertracker("math.normalizing", function(v) trace_normalizing = v end) -local trace_collapsing = false registertracker("math.collapsing", function(v) trace_collapsing = v end) -local trace_fixing = false registertracker("math.fixing", function(v) trace_fixing = v end) -local trace_patching = false registertracker("math.patching", function(v) trace_patching = v end) -local trace_goodies = false registertracker("math.goodies", function(v) trace_goodies = v end) -local trace_variants = false registertracker("math.variants", function(v) trace_variants = v end) -local trace_alternates = false registertracker("math.alternates", function(v) trace_alternates = v end) -local trace_italics = false registertracker("math.italics", function(v) trace_italics = v end) -local trace_kernpairs = false registertracker("math.kernpairs", function(v) trace_kernpairs = v end) -local trace_domains = false registertracker("math.domains", function(v) trace_domains = v end) -local trace_families = false registertracker("math.families", function(v) trace_families = v end) -local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end) -local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end) -local trace_snapping = false registertracker("math.snapping", function(v) trace_snapping = v end) - -local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end) -local use_math_goodies = true registerdirective("math.nogoodies", function(v) use_math_goodies = not v end) +local trace_remapping = false registertracker("math.remapping", function(v) trace_remapping = v end) +local trace_processing = false registertracker("math.processing", function(v) trace_processing = v end) +local trace_analyzing = false registertracker("math.analyzing", function(v) trace_analyzing = v end) +local trace_normalizing = false registertracker("math.normalizing", function(v) trace_normalizing = v end) +local trace_collapsing = false registertracker("math.collapsing", function(v) trace_collapsing = v end) +local trace_fixing = false registertracker("math.fixing", function(v) trace_fixing = v end) +local trace_patching = false registertracker("math.patching", function(v) trace_patching = v end) +local trace_goodies = false registertracker("math.goodies", function(v) trace_goodies = v end) +local trace_variants = false registertracker("math.variants", function(v) trace_variants = v end) +local trace_alternates = false registertracker("math.alternates", function(v) trace_alternates = v end) +local trace_italics = false registertracker("math.italics", function(v) trace_italics = v end) +local trace_kernpairs = false registertracker("math.kernpairs", function(v) trace_kernpairs = v end) +local trace_domains = false registertracker("math.domains", function(v) trace_domains = v end) +local trace_families = false registertracker("math.families", function(v) trace_families = v end) +local trace_fences = false registertracker("math.fences", function(v) trace_fences = v end) +local trace_unstacking = false registertracker("math.unstack", function(v) trace_unstacking = v end) +local trace_snapping = false registertracker("math.snapping", function(v) trace_snapping = v end) +local trace_dictionaries = false registertracker("math.dictionaries", function(v) trace_dictionaries = v end) + +local check_coverage = true registerdirective("math.checkcoverage", function(v) check_coverage = v end) +local use_math_goodies = true registerdirective("math.nogoodies", function(v) use_math_goodies = not v end) local report_processing = logreporter("mathematics","processing") local report_remapping = logreporter("mathematics","remapping") @@ -679,7 +680,6 @@ do local remapalphabets = mathematics.remapalphabets local fallbackstyleattr = mathematics.fallbackstyleattr - local setnodecolor = colortracers.set local function report_remap(tag,id,old,new,extra) if new then @@ -2551,6 +2551,67 @@ do end +-- for Mikael and me + +-- This could be an early callback, when we actually assign a character. + +do + + local setnodecolor = colortracers.set + local getchardict = nuts.getchardict + local setchardict = nuts.setchardict + + local dictionaries = { } noads.processors.dictionaries = dictionaries + local groups = mathematics.dictionaries.groups + local sets = mathematics.dictionaries.sets + local variants = mathematics.dictionaries.variants + local defaults = mathematics.dictionaries.defaults + + local function check(pointer,group,index) + local v = variants[index] + if v and v[group] then + return group + end + return 1 + end + + dictionaries[mathchar_code] = function(pointer) + local properties, group, index = getchardict(pointer) + local set = sets[group] + local real = 1 + if set then + local groups = set.groups + local nofgroups = groups and #groups + if nofgroups > 0 then + for i=1,nofgroups do + real = check(pointer,groups[i],index) + if real ~= 1 then + goto done + end + end + end + else + real = check(pointer,group,index) + end + ::done:: + if real == 1 then + real = defaults[index] or 1 + end + setchardict(pointer,properties,real,index) + if trace_dictionaries and real > 1 then + local groupname = groups[real] + if groupname then + setnodecolor(pointer,"dictionary:"..groupname) + end + end + end + + function handlers.dictionaries(head,style,penalties) + processnoads(head,dictionaries,"dictionaries") + end + +end + -- the normal builder -- do diff --git a/tex/context/base/mkxl/task-ini.lmt b/tex/context/base/mkxl/task-ini.lmt index 1f53a13b9..397f02292 100644 --- a/tex/context/base/mkxl/task-ini.lmt +++ b/tex/context/base/mkxl/task-ini.lmt @@ -115,6 +115,7 @@ appendaction("math", "normalizers", "noads.handlers.tags", appendaction("math", "normalizers", "noads.handlers.italics", nil, "nonut", "disabled" ) appendaction("math", "normalizers", "noads.handlers.kernpairs", nil, "nonut", "disabled" ) appendaction("math", "normalizers", "noads.handlers.classes", nil, "nonut", "disabled" ) +appendaction("math", "normalizers", "noads.handlers.dictionaries", nil, "nonut", "enabled" ) appendaction("math", "builders", "builders.kernel.mlisttohlist", nil, "nut", "enabled" ) -- mandate appendaction("math", "builders", "typesetters.directions.processmath", nil, "nut", "disabled" ) diff --git a/tex/context/modules/mkiv/s-fonts-emoji.mkiv b/tex/context/modules/mkiv/s-fonts-emoji.mkiv index 096b90263..f26a2bb09 100644 --- a/tex/context/modules/mkiv/s-fonts-emoji.mkiv +++ b/tex/context/modules/mkiv/s-fonts-emoji.mkiv @@ -79,7 +79,7 @@ local function emojiglyphs(name) end end end - nodes.flush_list(e) + nodes.flushlist(e) return #s > 0 and s or nil end end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index ae49b363f..05086a7f8 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2022-08-05 11:40 +-- merge date : 2022-08-05 17:16 do -- begin closure to overcome local limits and interference |