From 48a48c9d644d4a042198e9ec714d4a8ea02181a4 Mon Sep 17 00:00:00 2001 From: Marius Date: Thu, 6 Dec 2012 02:40:15 +0200 Subject: beta 2012.12.06 01:21 --- scripts/context/lua/mtxrun.lua | 74 +++++++++- scripts/context/stubs/mswin/mtxrun.lua | 74 +++++++++- scripts/context/stubs/unix/mtxrun | 74 +++++++++- tex/context/base/chem-str.mkiv | 1 - tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4142 -> 4140 bytes tex/context/base/context-version.png | Bin 40519 -> 40001 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/core-sys.mkiv | 6 + tex/context/base/data-tmp.lua | 3 +- tex/context/base/l-lpeg.lua | 18 ++- tex/context/base/l-md5.lua | 43 ++++-- tex/context/base/luat-ini.lua | 3 + tex/context/base/math-ini.mkiv | 5 + tex/context/base/meta-ini.mkiv | 6 +- tex/context/base/s-mat-20.mkiv | 161 +++++++++++++++++++++ tex/context/base/sort-ini.lua | 5 +- tex/context/base/status-files.pdf | Bin 24547 -> 24534 bytes tex/context/base/status-lua.pdf | Bin 199301 -> 199332 bytes tex/context/base/status-mkiv.lua | 5 + tex/context/base/strc-con.mkvi | 30 +++- tex/context/base/util-tab.lua | 22 +++ tex/generic/context/luatex/luatex-fonts-merged.lua | 20 ++- 25 files changed, 496 insertions(+), 62 deletions(-) create mode 100644 tex/context/base/s-mat-20.mkiv diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 00c1fc13c..af31ba8f8 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1612,7 +1612,8 @@ end -- Just for fun I looked at the used bytecode and -- p = (p and p + pp) or pp gets one more (testset). -function lpeg.replacer(one,two) +function lpeg.replacer(one,two,makefunction) + local pattern if type(one) == "table" then local no = #one local p = P(false) @@ -1620,22 +1621,29 @@ function lpeg.replacer(one,two) for k, v in next, one do p = p + P(k) / v end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) elseif no == 1 then local o = one[1] one, two = P(o[1]), o[2] - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) else for i=1,no do local o = one[i] p = p + P(o[1]) / o[2] end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) end else one = P(one) two = two or "" - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) + end + if makefunction then + return function(str) + return lpegmatch(pattern,str) + end + else + return pattern end end @@ -3435,6 +3443,37 @@ if not md5.HEX then function md5.HEX(str) return convert(str,"%02X") end end if not md5.hex then function md5.hex(str) return convert(str,"%02x") end end if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end +-- local P, Cs, lpegmatch = lpeg.P, lpeg.Cs,lpeg.match +-- +-- if not md5.HEX then +-- local function remap(chr) return format("%02X",byte(chr)) end +-- function md5.HEX(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.hex then +-- local function remap(chr) return format("%02x",byte(chr)) end +-- function md5.hex(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.dec then +-- local function remap(chr) return format("%03i",byte(chr)) end +-- function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end +-- end + +-- if not md5.HEX then +-- local pattern_HEX = Cs( ( P(1) / function(chr) return format("%02X",byte(chr)) end)^0 ) +-- function md5.HEX(str) return lpegmatch(pattern_HEX,md5.sum(str)) end +-- end +-- +-- if not md5.hex then +-- local pattern_hex = Cs( ( P(1) / function(chr) return format("%02x",byte(chr)) end)^0 ) +-- function md5.hex(str) return lpegmatch(pattern_hex,md5.sum(str)) end +-- end +-- +-- if not md5.dec then +-- local pattern_dec = Cs( ( P(1) / function(chr) return format("%02i",byte(chr)) end)^0 ) +-- function md5.dec(str) return lpegmatch(pattern_dec,md5.sum(str)) end +-- end function file.needsupdating(oldname,newname,threshold) -- size modification access change local oldtime = lfs.attributes(oldname,"modification") @@ -4892,6 +4931,22 @@ function tables.definetable(target,nofirst,nolast) -- defines undefined tables return concat(t,"\n"), composed end +-- local t = tables.definedtable("a","b","c","d") + +function tables.definedtable(...) + local l = { ... } + local t = _G + for i=1,#l do + local tl = t[l[i]] + if not tl then + tl = { } + t[l[i]] = tl + end + t = tl + end + return t +end + function tables.accesstable(target,root) local t = root or _G for name in gmatch(target,"([^%.]+)") do @@ -5149,6 +5204,12 @@ function table.drop(t,slow) end end +function table.autokey(t,k) + local v = { } + t[k] = v + return v +end + end -- of closure @@ -13220,8 +13281,7 @@ function caches.configfiles() end function caches.hashed(tree) - tree = gsub(tree,"\\$","/") - tree = gsub(tree,"/+$","") + tree = gsub(tree,"[\\/]+$","") tree = lower(tree) local hash = md5.hex(tree) if trace_cache or trace_locating then diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 00c1fc13c..af31ba8f8 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -1612,7 +1612,8 @@ end -- Just for fun I looked at the used bytecode and -- p = (p and p + pp) or pp gets one more (testset). -function lpeg.replacer(one,two) +function lpeg.replacer(one,two,makefunction) + local pattern if type(one) == "table" then local no = #one local p = P(false) @@ -1620,22 +1621,29 @@ function lpeg.replacer(one,two) for k, v in next, one do p = p + P(k) / v end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) elseif no == 1 then local o = one[1] one, two = P(o[1]), o[2] - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) else for i=1,no do local o = one[i] p = p + P(o[1]) / o[2] end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) end else one = P(one) two = two or "" - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) + end + if makefunction then + return function(str) + return lpegmatch(pattern,str) + end + else + return pattern end end @@ -3435,6 +3443,37 @@ if not md5.HEX then function md5.HEX(str) return convert(str,"%02X") end end if not md5.hex then function md5.hex(str) return convert(str,"%02x") end end if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end +-- local P, Cs, lpegmatch = lpeg.P, lpeg.Cs,lpeg.match +-- +-- if not md5.HEX then +-- local function remap(chr) return format("%02X",byte(chr)) end +-- function md5.HEX(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.hex then +-- local function remap(chr) return format("%02x",byte(chr)) end +-- function md5.hex(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.dec then +-- local function remap(chr) return format("%03i",byte(chr)) end +-- function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end +-- end + +-- if not md5.HEX then +-- local pattern_HEX = Cs( ( P(1) / function(chr) return format("%02X",byte(chr)) end)^0 ) +-- function md5.HEX(str) return lpegmatch(pattern_HEX,md5.sum(str)) end +-- end +-- +-- if not md5.hex then +-- local pattern_hex = Cs( ( P(1) / function(chr) return format("%02x",byte(chr)) end)^0 ) +-- function md5.hex(str) return lpegmatch(pattern_hex,md5.sum(str)) end +-- end +-- +-- if not md5.dec then +-- local pattern_dec = Cs( ( P(1) / function(chr) return format("%02i",byte(chr)) end)^0 ) +-- function md5.dec(str) return lpegmatch(pattern_dec,md5.sum(str)) end +-- end function file.needsupdating(oldname,newname,threshold) -- size modification access change local oldtime = lfs.attributes(oldname,"modification") @@ -4892,6 +4931,22 @@ function tables.definetable(target,nofirst,nolast) -- defines undefined tables return concat(t,"\n"), composed end +-- local t = tables.definedtable("a","b","c","d") + +function tables.definedtable(...) + local l = { ... } + local t = _G + for i=1,#l do + local tl = t[l[i]] + if not tl then + tl = { } + t[l[i]] = tl + end + t = tl + end + return t +end + function tables.accesstable(target,root) local t = root or _G for name in gmatch(target,"([^%.]+)") do @@ -5149,6 +5204,12 @@ function table.drop(t,slow) end end +function table.autokey(t,k) + local v = { } + t[k] = v + return v +end + end -- of closure @@ -13220,8 +13281,7 @@ function caches.configfiles() end function caches.hashed(tree) - tree = gsub(tree,"\\$","/") - tree = gsub(tree,"/+$","") + tree = gsub(tree,"[\\/]+$","") tree = lower(tree) local hash = md5.hex(tree) if trace_cache or trace_locating then diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 00c1fc13c..af31ba8f8 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1612,7 +1612,8 @@ end -- Just for fun I looked at the used bytecode and -- p = (p and p + pp) or pp gets one more (testset). -function lpeg.replacer(one,two) +function lpeg.replacer(one,two,makefunction) + local pattern if type(one) == "table" then local no = #one local p = P(false) @@ -1620,22 +1621,29 @@ function lpeg.replacer(one,two) for k, v in next, one do p = p + P(k) / v end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) elseif no == 1 then local o = one[1] one, two = P(o[1]), o[2] - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) else for i=1,no do local o = one[i] p = p + P(o[1]) / o[2] end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) end else one = P(one) two = two or "" - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) + end + if makefunction then + return function(str) + return lpegmatch(pattern,str) + end + else + return pattern end end @@ -3435,6 +3443,37 @@ if not md5.HEX then function md5.HEX(str) return convert(str,"%02X") end end if not md5.hex then function md5.hex(str) return convert(str,"%02x") end end if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end +-- local P, Cs, lpegmatch = lpeg.P, lpeg.Cs,lpeg.match +-- +-- if not md5.HEX then +-- local function remap(chr) return format("%02X",byte(chr)) end +-- function md5.HEX(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.hex then +-- local function remap(chr) return format("%02x",byte(chr)) end +-- function md5.hex(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.dec then +-- local function remap(chr) return format("%03i",byte(chr)) end +-- function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end +-- end + +-- if not md5.HEX then +-- local pattern_HEX = Cs( ( P(1) / function(chr) return format("%02X",byte(chr)) end)^0 ) +-- function md5.HEX(str) return lpegmatch(pattern_HEX,md5.sum(str)) end +-- end +-- +-- if not md5.hex then +-- local pattern_hex = Cs( ( P(1) / function(chr) return format("%02x",byte(chr)) end)^0 ) +-- function md5.hex(str) return lpegmatch(pattern_hex,md5.sum(str)) end +-- end +-- +-- if not md5.dec then +-- local pattern_dec = Cs( ( P(1) / function(chr) return format("%02i",byte(chr)) end)^0 ) +-- function md5.dec(str) return lpegmatch(pattern_dec,md5.sum(str)) end +-- end function file.needsupdating(oldname,newname,threshold) -- size modification access change local oldtime = lfs.attributes(oldname,"modification") @@ -4892,6 +4931,22 @@ function tables.definetable(target,nofirst,nolast) -- defines undefined tables return concat(t,"\n"), composed end +-- local t = tables.definedtable("a","b","c","d") + +function tables.definedtable(...) + local l = { ... } + local t = _G + for i=1,#l do + local tl = t[l[i]] + if not tl then + tl = { } + t[l[i]] = tl + end + t = tl + end + return t +end + function tables.accesstable(target,root) local t = root or _G for name in gmatch(target,"([^%.]+)") do @@ -5149,6 +5204,12 @@ function table.drop(t,slow) end end +function table.autokey(t,k) + local v = { } + t[k] = v + return v +end + end -- of closure @@ -13220,8 +13281,7 @@ function caches.configfiles() end function caches.hashed(tree) - tree = gsub(tree,"\\$","/") - tree = gsub(tree,"/+$","") + tree = gsub(tree,"[\\/]+$","") tree = lower(tree) local hash = md5.hex(tree) if trace_cache or trace_locating then diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index 3b50396d1..2d4449a25 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -62,7 +62,6 @@ %D a historical and practical reason (like shared keys with different meaning %D that could clash, e.g.\ align). - \defineMPinstance [chemistry] [\s!format=metafun] diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index b90a6cf70..3baf62f07 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.12.05 15:00} +\newcontextversion{2012.12.06 01:21} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 5bf5a9635..d818256a8 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.12.05 15:00} +\newcontextversion{2012.12.06 01:21} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index ececb7f6e..916253fcc 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index d3ff95c9e..03af39d50 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 03a40eac6..1b660a60c 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.12.05 15:00} +\edef\contextversion{2012.12.06 01:21} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 82ffbadc9..0dd1aeb1a 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.12.05 15:00} +\edef\contextversion{2012.12.06 01:21} %D For those who want to use this: diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv index 249500e0a..f58f90042 100644 --- a/tex/context/base/core-sys.mkiv +++ b/tex/context/base/core-sys.mkiv @@ -228,6 +228,12 @@ \dostoptagged \startstopparameter\c!inbetween}} +% \unexpanded\def\ignorestartstop[#1]% +% {\unexpanded\expandafter\def\csname\e!start#1\expandafter\endcsname\expandafter +% {\expandafter\gobbleuntil\csname\e!stop#1\endcsname}} +% +% \ignorestartstop[bagger] + \installcorenamespace{highlight} \installcommandhandler \??highlight {highlight} \??highlight % we could do with less diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua index 31c9485f4..f7e64895b 100644 --- a/tex/context/base/data-tmp.lua +++ b/tex/context/base/data-tmp.lua @@ -181,8 +181,7 @@ function caches.configfiles() end function caches.hashed(tree) - tree = gsub(tree,"\\$","/") - tree = gsub(tree,"/+$","") + tree = gsub(tree,"[\\/]+$","") tree = lower(tree) local hash = md5.hex(tree) if trace_cache or trace_locating then diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 819a1b9ab..c461df1ce 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -430,7 +430,8 @@ end -- Just for fun I looked at the used bytecode and -- p = (p and p + pp) or pp gets one more (testset). -function lpeg.replacer(one,two) +function lpeg.replacer(one,two,makefunction) + local pattern if type(one) == "table" then local no = #one local p = P(false) @@ -438,22 +439,29 @@ function lpeg.replacer(one,two) for k, v in next, one do p = p + P(k) / v end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) elseif no == 1 then local o = one[1] one, two = P(o[1]), o[2] - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) else for i=1,no do local o = one[i] p = p + P(o[1]) / o[2] end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) end else one = P(one) two = two or "" - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) + end + if makefunction then + return function(str) + return lpegmatch(pattern,str) + end + else + return pattern end end diff --git a/tex/context/base/l-md5.lua b/tex/context/base/l-md5.lua index 6abf2e17d..a60e4f575 100644 --- a/tex/context/base/l-md5.lua +++ b/tex/context/base/l-md5.lua @@ -18,18 +18,37 @@ if not md5.HEX then function md5.HEX(str) return convert(str,"%02X") end end if not md5.hex then function md5.hex(str) return convert(str,"%02x") end end if not md5.dec then function md5.dec(str) return convert(str,"%03i") end end ---~ if not md5.HEX then ---~ local function remap(chr) return format("%02X",byte(chr)) end ---~ function md5.HEX(str) return (gsub(md5.sum(str),".",remap)) end ---~ end ---~ if not md5.hex then ---~ local function remap(chr) return format("%02x",byte(chr)) end ---~ function md5.hex(str) return (gsub(md5.sum(str),".",remap)) end ---~ end ---~ if not md5.dec then ---~ local function remap(chr) return format("%03i",byte(chr)) end ---~ function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end ---~ end +-- local P, Cs, lpegmatch = lpeg.P, lpeg.Cs,lpeg.match +-- +-- if not md5.HEX then +-- local function remap(chr) return format("%02X",byte(chr)) end +-- function md5.HEX(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.hex then +-- local function remap(chr) return format("%02x",byte(chr)) end +-- function md5.hex(str) return (gsub(md5.sum(str),".",remap)) end +-- end +-- +-- if not md5.dec then +-- local function remap(chr) return format("%03i",byte(chr)) end +-- function md5.dec(str) return (gsub(md5.sum(str),".",remap)) end +-- end + +-- if not md5.HEX then +-- local pattern_HEX = Cs( ( P(1) / function(chr) return format("%02X",byte(chr)) end)^0 ) +-- function md5.HEX(str) return lpegmatch(pattern_HEX,md5.sum(str)) end +-- end +-- +-- if not md5.hex then +-- local pattern_hex = Cs( ( P(1) / function(chr) return format("%02x",byte(chr)) end)^0 ) +-- function md5.hex(str) return lpegmatch(pattern_hex,md5.sum(str)) end +-- end +-- +-- if not md5.dec then +-- local pattern_dec = Cs( ( P(1) / function(chr) return format("%02i",byte(chr)) end)^0 ) +-- function md5.dec(str) return lpegmatch(pattern_dec,md5.sum(str)) end +-- end function file.needsupdating(oldname,newname,threshold) -- size modification access change local oldtime = lfs.attributes(oldname,"modification") diff --git a/tex/context/base/luat-ini.lua b/tex/context/base/luat-ini.lua index 94c878eb1..0b8c5d951 100644 --- a/tex/context/base/luat-ini.lua +++ b/tex/context/base/luat-ini.lua @@ -25,6 +25,9 @@ moduledata = moduledata or { } -- only for development team documentdata = documentdata or { } -- for users (e.g. raw data) parametersets = parametersets or { } -- experimental for team +table.setmetatableindex(moduledata,table.autokey) +table.setmetatableindex(thirddata, table.autokey) + --[[ldx--

Please create a namespace within these tables before using them!

diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index c588984a9..763ac4f68 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -1244,4 +1244,9 @@ \fi \to \everyswitchmathematics +% new: + +\unexpanded\def\smallmathsymbol#1% + {\mathematics{\mathbin{\normalexpanded{\raise.15\exheight\hbox{$\triggermathstyle{\the\numexpr\normalmathstyle+2\relax}#1$}}}}} + \protect \endinput diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 55080c78c..89f6b4dc9 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -46,11 +46,13 @@ {\dosinglegroupempty\meta_start_definitions} \def\meta_start_definitions#1#2\stopMPdefinitions - {\edef\currentMPinstance{#1}% + {\let\m_meta_saved_instance\currentMPinstance + \edef\currentMPinstance{#1}% \ifx\currentMPinstance\empty \let\currentMPinstance\defaultMPinstance \fi - \global\t_meta_instance\expandafter{\the\t_meta_instance#2}} + \global\t_meta_instance\expandafter{\the\t_meta_instance#2}% + \let\currentMPinstance\m_meta_saved_instance} \let\stopMPdefinitions\relax diff --git a/tex/context/base/s-mat-20.mkiv b/tex/context/base/s-mat-20.mkiv new file mode 100644 index 000000000..544612fec --- /dev/null +++ b/tex/context/base/s-mat-20.mkiv @@ -0,0 +1,161 @@ +%D \module +%D [ file=s-mat-20.mkiv, +%D version=2012.12.05, +%D title=\CONTEXT\ Style File, +%D subtitle=Math Tracing Macros, +%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. + +\startluacode + +local tables = utilities.tables.definedtable("math","tracing","spacing","tables") + +tables.styleaxis = { + "ord", "op", "bin", "rel", "open", "close", "punct", "inner", +} + +tables.parameters = { + "quad", "axis", "operatorsize", + "overbarkern", "overbarrule", "overbarvgap", + "underbarkern", "underbarrule", "underbarvgap", + "radicalkern", "radicalrule", "radicalvgap", + "radicaldegreebefore", "radicaldegreeafter", "radicaldegreeraise", + "stackvgap", "stacknumup", "stackdenomdown", + "fractionrule", "fractionnumvgap", "fractionnumup", + "fractiondenomvgap", "fractiondenomdown", "fractiondelsize", + "limitabovevgap", "limitabovebgap", "limitabovekern", + "limitbelowvgap", "limitbelowbgap", "limitbelowkern", + "underdelimitervgap", "underdelimiterbgap", + "overdelimitervgap", "overdelimiterbgap", + "subshiftdrop", "supshiftdrop", "subshiftdown", + "subsupshiftdown", "subtopmax", "supshiftup", + "supbottommin", "supsubbottommax", "subsupvgap", + "spaceafterscript", "connectoroverlapmin", +} + +tables.styles = { + "display", + "text", + "script", + "scriptscript", +} + +function tables.stripmu(str) + str = string.gsub(str,"mu","") + str = string.gsub(str," ","") + str = string.gsub(str,"plus","+") + str = string.gsub(str,"minus","-") + return str +end + +function tables.strippt(old) + local new = string.gsub(old,"pt","") + if new ~= old then + new = string.format("%0.4f",tonumber(new)) + end + return new +end + +function tables.showspacing() + + local styles = tables.styles + local styleaxis = tables.styleaxis + + context.starttabulate { "|Tl|Tl|" .. string.rep("Tc|",(#styles*2)) } + context.HL() + context.NC() + context.NC() + context.NC() + for i=1,#styles do + context.bold(styles[i]) + context.NC() + context.bold("(cramped)") + context.NC() + end + context.NR() + context.HL() + for i=1,#styleaxis do + -- print(key,tex.getmath(key,"text")) + local one = styleaxis[i] + for j=1,#styleaxis do + local two = styleaxis[j] + context.NC() + if j == 1 then + context.bold(one) + end + context.NC() + context.bold(two) + context.NC() + for i=1,#styles do + context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\%sstyle'))}",one,two,styles[i]) + context.NC() + context("\\ctxlua{context(math.tracing.spacing.tables.stripmu('\\the\\Umath%s%sspacing\\cramped%sstyle'))}",one,two,styles[i]) + context.NC() + end + context.NR() + end + end + context.stoptabulate() +end + +function tables.showparameters() + + local styles = tables.styles + local parameters = tables.parameters + + context.starttabulate { "|l|" .. string.rep("Tc|",(#styles*2)) } + context.HL() + context.NC() + context.NC() + for i=1,#styles do + context.bold(styles[i]) + context.NC() + context.bold("(cramped)") + context.NC() + end + context.NR() + context.HL() + for i=1,#parameters do + local parameter = parameters[i] + -- print(parameter,tex.getmath(parameter,"text")) + context.NC() + context.type(parameter) + context.NC() + for i=1,#styles do + context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\%sstyle'))}",parameter,styles[i]) + context.NC() + context("\\ctxlua{context(math.tracing.spacing.tables.strippt('\\the\\Umath%s\\cramped%sstyle'))}",parameter,styles[i]) + context.NC() + end + context.NR() + end + context.stoptabulate() + +end + +\stopluacode + +\continueifinputfile{s-mat-20.mkiv} + +\setuplayout + [width=middle, + height=middle, + backspace=1cm, + topspace=1cm, + footer=0pt, + header=0pt] + +\setupbodyfont + [dejavu,8pt] + +\starttext + + \ctxlua{math.tracing.spacing.tables.showspacing()} + % \ctxlua{math.tracing.spacing.tables.showparameters()} + +\stoptext diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index a6181f5e4..aa3caff96 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -528,8 +528,9 @@ local function numify(s) end function sorters.strip(str) -- todo: only letters and such - if str then - str = gsub(str,"\\[\"\'~^`]*","") -- \"e + if str and str ~= "" then + -- todo: make a lpeg + str = gsub(str,"\\[\"\'~^`]*","") -- \"e -- hm, too greedy str = gsub(str,"\\%S*","") -- the rest str = gsub(str,"%s","\001") -- can be option str = gsub(str,"[%s%[%](){}%$\"\']*","") diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 5b7a2622e..ad7c200c0 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index a100524a3..e3f326b5a 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 1bcdd3278..adc393f5c 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -5269,6 +5269,11 @@ return { filename = "s-mat-10", status = "todo", }, + { + category = "mkiv", + filename = "s-mat-20", + status = "okay", + }, { category = "mkiv", filename = "s-mat-11", diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi index 64371579a..249594998 100644 --- a/tex/context/base/strc-con.mkvi +++ b/tex/context/base/strc-con.mkvi @@ -236,6 +236,9 @@ \let\p_strc_constructions_hang \empty \let\p_strc_constructions_inbetween \empty \let\p_strc_constructions_closesymbol \empty +\let\p_strc_constructions_distance \empty + +\newconditional\c_strc_constructions_distance_none \unexpanded\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing {\dostarttagged\t!construction\currentconstruction @@ -250,11 +253,18 @@ \let\currentconstructionalternative\v!left}% \doadaptleftskip{\constructionparameter\c!margin}% \setlocalhsize % so we can use \localhsize in width assignments - \constructionsheaddistance\constructionalternativeparameter\c!distance\relax + \edef\p_strc_constructions_distance{\constructionalternativeparameter\c!distance}% \edef\p_strc_constructions_width{\constructionalternativeparameter\c!width}% - \ifdim\constructionsheaddistance=\zeropoint - \ifx\p_strc_constructions_width\v!broad - \constructionsheaddistance\emwidth + \ifx\p_strc_constructions_distance\v!none + \settrue\c_strc_constructions_distance_none + \constructionsheaddistance\zeropoint + \else + \setfalse\c_strc_constructions_distance_none + \constructionsheaddistance\p_strc_constructions_distance\relax + \ifdim\constructionsheaddistance=\zeropoint + \ifx\p_strc_constructions_width\v!broad + \constructionsheaddistance\emwidth + \fi \fi \fi % inefficient and not always needed, for instance not with margins so we will make checkers @@ -428,7 +438,9 @@ \else \setupalign[\p_strc_constructions_headalign]% use fast one \fi - \advance\ifx#1\v!flushleft\rightskip\else\leftskip\fi\constructionsheaddistance % only difference and wrong anyway + \ifconditional\c_strc_constructions_distance_none \else + \advance\ifx#1\v!flushleft\rightskip\else\leftskip\fi\constructionsheaddistance % only difference and wrong anyway + \fi \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox}% \setbox\constructionheadbox\hbox{\box\constructionheadbox}% needed in case of e.g. a real big head font, see descriptions-006.tex \ht\constructionheadbox\strutht @@ -693,7 +705,9 @@ \let\\=\crlf \noindent \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox - \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \ifconditional\c_strc_constructions_distance_none \else + \hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax + \fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups @@ -732,7 +746,9 @@ \fi \hskip-\leftskipadaption\relax \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox - \kern\ifdim\constructionsheaddistance=\zeropoint .75\emwidth\else\constructionsheaddistance\fi + \ifconditional\c_strc_constructions_distance_none \else + \kern\ifdim\constructionsheaddistance=\zeropoint .75\emwidth\else\constructionsheaddistance\fi + \fi \useconstructionstyleandcolor\c!style\c!color \ignorespaces \stopsetups diff --git a/tex/context/base/util-tab.lua b/tex/context/base/util-tab.lua index cd6826983..c547d5b3e 100644 --- a/tex/context/base/util-tab.lua +++ b/tex/context/base/util-tab.lua @@ -56,6 +56,22 @@ function tables.definetable(target,nofirst,nolast) -- defines undefined tables return concat(t,"\n"), composed end +-- local t = tables.definedtable("a","b","c","d") + +function tables.definedtable(...) + local l = { ... } + local t = _G + for i=1,#l do + local tl = t[l[i]] + if not tl then + tl = { } + t[l[i]] = tl + end + t = tl + end + return t +end + function tables.accesstable(target,root) local t = root or _G for name in gmatch(target,"([^%.]+)") do @@ -312,3 +328,9 @@ function table.drop(t,slow) return fastdrop(t) -- some 15% faster end end + +function table.autokey(t,k) + local v = { } + t[k] = v + return v +end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 8ca138458..219cbbc9d 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 12/05/12 15:00:04 +-- merge date : 12/06/12 01:21:29 do -- begin closure to overcome local limits and interference @@ -1604,7 +1604,8 @@ end -- Just for fun I looked at the used bytecode and -- p = (p and p + pp) or pp gets one more (testset). -function lpeg.replacer(one,two) +function lpeg.replacer(one,two,makefunction) + local pattern if type(one) == "table" then local no = #one local p = P(false) @@ -1612,22 +1613,29 @@ function lpeg.replacer(one,two) for k, v in next, one do p = p + P(k) / v end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) elseif no == 1 then local o = one[1] one, two = P(o[1]), o[2] - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) else for i=1,no do local o = one[i] p = p + P(o[1]) / o[2] end - return Cs((p + 1)^0) + pattern = Cs((p + 1)^0) end else one = P(one) two = two or "" - return Cs(((1-one)^1 + one/two)^0) + pattern = Cs(((1-one)^1 + one/two)^0) + end + if makefunction then + return function(str) + return lpegmatch(pattern,str) + end + else + return pattern end end -- cgit v1.2.3