diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-19 23:37:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-19 23:37:39 +0000 |
commit | 69de3344104bfec286cbe7ea63f03fab58d3c1ec (patch) | |
tree | 14d60f3983479b6a35b024ed1c170d109b86d4e9 /Master/texmf-dist/tex/context | |
parent | 9ff55323bdb88ede985266ee9123bc2cdda58848 (diff) |
context update from cont-tmf.zip of Apr 20 01:16, 11085698 bytes
git-svn-id: svn://tug.org/texlive/trunk@30044 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context')
80 files changed, 1334 insertions, 835 deletions
diff --git a/Master/texmf-dist/tex/context/base/cont-new.mkiv b/Master/texmf-dist/tex/context/base/cont-new.mkiv index df90979f08f..5734855aebe 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.04.11 19:55} +\newcontextversion{2013.04.20 01:15} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/Master/texmf-dist/tex/context/base/cont-new.tmp b/Master/texmf-dist/tex/context/base/cont-new.tmp index af47ccb20ff..4838c5219c8 100644 --- a/Master/texmf-dist/tex/context/base/cont-new.tmp +++ b/Master/texmf-dist/tex/context/base/cont-new.tmp @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.04.11 19:49} +\newcontextversion{2013.04.20 01:08} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/Master/texmf-dist/tex/context/base/cont-yes.mkiv b/Master/texmf-dist/tex/context/base/cont-yes.mkiv index 5eae3eecb77..1a10fc30ec4 100644 --- a/Master/texmf-dist/tex/context/base/cont-yes.mkiv +++ b/Master/texmf-dist/tex/context/base/cont-yes.mkiv @@ -26,7 +26,7 @@ local arguments = environment.arguments local suffix = environment.suffix - local filename = environment.filename + local filename = environment.filename -- hm, not inputfilename ! if suffix == "xml" or arguments.forcexml then @@ -80,7 +80,9 @@ -- We have a regular tex file so no \starttext yet as we can -- load fonts. + -- context.enabletrackers { "resolvers.*" } context.input(filename) + -- context.disabletrackers { "resolvers.*" } end diff --git a/Master/texmf-dist/tex/context/base/context-version.pdf b/Master/texmf-dist/tex/context/base/context-version.pdf Binary files differindex 69e004c07f1..a91d22aaa6b 100644 --- a/Master/texmf-dist/tex/context/base/context-version.pdf +++ b/Master/texmf-dist/tex/context/base/context-version.pdf diff --git a/Master/texmf-dist/tex/context/base/context-version.png b/Master/texmf-dist/tex/context/base/context-version.png Binary files differindex 5d84680bb54..d3ced9ec12b 100644 --- a/Master/texmf-dist/tex/context/base/context-version.png +++ b/Master/texmf-dist/tex/context/base/context-version.png diff --git a/Master/texmf-dist/tex/context/base/context.mkiv b/Master/texmf-dist/tex/context/base/context.mkiv index 81f7c188c9e..9945f2a15b7 100644 --- a/Master/texmf-dist/tex/context/base/context.mkiv +++ b/Master/texmf-dist/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.04.11 19:55} +\edef\contextversion{2013.04.20 01:15} \edef\contextkind {current} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/context.tmp b/Master/texmf-dist/tex/context/base/context.tmp index 197dbb5309d..144f265ae50 100644 --- a/Master/texmf-dist/tex/context/base/context.tmp +++ b/Master/texmf-dist/tex/context/base/context.tmp @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.04.11 19:49} +\edef\contextversion{2013.04.20 01:08} \edef\contextkind {beta} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/core-ctx.lua b/Master/texmf-dist/tex/context/base/core-ctx.lua index 33662731e23..18978a53021 100644 --- a/Master/texmf-dist/tex/context/base/core-ctx.lua +++ b/Master/texmf-dist/tex/context/base/core-ctx.lua @@ -332,7 +332,8 @@ function commands.getctxfile() end function ctxrunner.resolve(name) -- used a few times later on - return ctxrunner.prepfiles[file.collapsepath(name)] or name + local collapsedname = file.collapsepath(name,".") + return ctxrunner.prepfiles[collapsedname] or collapsedname end -- ctxrunner.load("t:/sources/core-ctx.ctx") diff --git a/Master/texmf-dist/tex/context/base/core-def.mkiv b/Master/texmf-dist/tex/context/base/core-def.mkiv index cf1049e58f8..dc2a30f4e28 100644 --- a/Master/texmf-dist/tex/context/base/core-def.mkiv +++ b/Master/texmf-dist/tex/context/base/core-def.mkiv @@ -56,6 +56,10 @@ \to \everydisplay % \appendtoks +% \flushpostponednodedata +% \to \neverypar + +% \appendtoks % \flushsyncpositions % \to \everyheadstart diff --git a/Master/texmf-dist/tex/context/base/core-sys.lua b/Master/texmf-dist/tex/context/base/core-sys.lua index 1741bbe0a7a..009ec16ea5b 100644 --- a/Master/texmf-dist/tex/context/base/core-sys.lua +++ b/Master/texmf-dist/tex/context/base/core-sys.lua @@ -67,15 +67,18 @@ function environment.initializefilenames() -- commands.updatefilenames(jobname,f local jobfilename = jobname or inputfilename or tex.jobname or "" local inputfilename = inputfilename or "" - jobfilename = gsub(jobfilename, "^./","") - inputfilename = gsub(inputfilename,"^./","") + local jobfilebase = basename(jobfilename) + local inputfilebase = basename(inputfilename) - environment.jobfilename = jobfilename - environment.jobfilesuffix = lower(suffixonly(jobfilename)) + -- jobfilename = gsub(jobfilename, "^./","") + -- inputfilename = gsub(inputfilename,"^./","") - environment.inputfilename = inputfilename - environment.inputfilebarename = removesuffix(basename(inputfilename)) - environment.inputfilesuffix = lower(suffixonly(inputfilename)) + environment.jobfilename = jobfilebase + environment.jobfilesuffix = lower(suffixonly(jobfilebase)) + + environment.inputfilename = inputfilename -- so here we keep e.g. ./ or explicit paths + environment.inputfilebarename = removesuffix(inputfilebase) + environment.inputfilesuffix = lower(suffixonly(inputfilebase)) environment.outputfilename = outputfilename or environment.inputfilebarename or "" diff --git a/Master/texmf-dist/tex/context/base/core-sys.mkiv b/Master/texmf-dist/tex/context/base/core-sys.mkiv index b65934432de..8f56b6f162c 100644 --- a/Master/texmf-dist/tex/context/base/core-sys.mkiv +++ b/Master/texmf-dist/tex/context/base/core-sys.mkiv @@ -285,9 +285,29 @@ \fi #1#2{#3}} +% new: +% +% \checked\def \whatever#alpha#beta{#alpha + #beta} +% \checked\edef\whatever#alpha#beta{#alpha + #beta} + +\unexpanded\def\unique#1#2% + {\ifdefined#2% + \showmessage\m!system4{\string#2}% + \expandafter#1\expandafter\gobbleddefinition + \else + \expandafter#1% + \fi#2} + +\unexpanded\def\checked#1#2% + {\ifdefined#2% + \showmessage\m!system4{\string#2}% + \fi + #1#2} + % \startluacode -% local contextsprint, ctxcatcodes = context.sprint, tex.ctxcatcodes -% local format, match, gmatch, rep = string.format, string.match, string.gmatch, string.rep +% local formatters = string.formatters +% local contextsprint, ctxcatcodes, prtcatcodes = context.sprint, tex.ctxcatcodes, tex.prtcatcodes +% local match, gmatch, rep = string.match, string.gmatch, string.rep % local empty = { % "single", % "double", @@ -315,22 +335,22 @@ % else % n = 0 % end -% contextsprint(ctxcatcodes,format("\\unexpanded\\def\\%s",cmd)) +% contextsprint(ctxcatcodes,formatters["\\unexpanded\\def\\%s"](cmd)) % if #a > 0 then -% contextsprint(ctxcatcodes,format("{\\do%sempty\\do%s}",empty[#a],cmd)) -% contextsprint(ctxcatcodes,format("\\def\\do%s",cmd)) +% contextsprint(prtcatcodes,formatters["{\\do%sempty\\user_defined_%s}"](empty[#a],cmd)) +% contextsprint(prtcatcodes,formatters["\\def\\user_defined_%s"](cmd)) % for i=1,#a do -% contextsprint(ctxcatcodes,"[#",i,"]") +% contextsprint(ctxcatcodes,formatters["[#%s]"](i)) % end % contextsprint(ctxcatcodes,"{") % for i=#a,1,-1 do -% contextsprint(ctxcatcodes,format("\\if%sargument",check[i])) -% contextsprint(ctxcatcodes,format("\\def\\next{\\dodo%s",cmd)) +% contextsprint(ctxcatcodes,formatters["\\if%sargument"](check[i])) +% contextsprint(prtcatcodes,formatters["\\def\\next{\\user_defined_indeed_%s"](cmd)) % for j=1,#a-i do -% contextsprint(ctxcatcodes,format("[%s]",a[j])) +% contextsprint(ctxcatcodes,formatters["[%s]"](a[j])) % end % for j=1,i do -% contextsprint(ctxcatcodes,format("[#%s]",j)) +% contextsprint(ctxcatcodes,formatters["[#%s]"](j)) % end % contextsprint(ctxcatcodes,"}") % if i == 1 then @@ -340,13 +360,13 @@ % end % end % contextsprint(ctxcatcodes,"\\next}") -% contextsprint(ctxcatcodes,format("\\def\\dodo%s",cmd)) +% contextsprint(prtcatcodes,formatters["\\def\\user_defined_indeed_%s"](cmd)) % for i=1,#a do -% contextsprint(ctxcatcodes,"[#",i,"]") +% contextsprint(ctxcatcodes,formatters["[#%s]"](i)) % end % end % for i=1,n do -% contextsprint(ctxcatcodes,"#",#a+i) +% contextsprint(ctxcatcodes,formatters["#%s"](#a+i)) % end % end % \stopluacode @@ -359,6 +379,8 @@ % \define[me][too][2]\whateverb{#1+#2+#3+#4} % \whateverb[A]{B}{C} % \whateverb[A][B]{C}{D} +% \define[alpha][beta][gamma][delta]\whateverc{#1+#2+#3+#4} +% \whateverc[P][Q] % \stoptext %D This is a checked variant of \type {\getvalue}. diff --git a/Master/texmf-dist/tex/context/base/data-lua.lua b/Master/texmf-dist/tex/context/base/data-lua.lua index 7e3d92585ab..0e7c81181bb 100644 --- a/Master/texmf-dist/tex/context/base/data-lua.lua +++ b/Master/texmf-dist/tex/context/base/data-lua.lua @@ -16,83 +16,83 @@ local addsuffix = file.addsuffix local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.Cs, lpeg.match -local libsuffixes = { 'tex', 'lua' } -local clibsuffixes = { 'lib' } -local libformats = { 'TEXINPUTS', 'LUAINPUTS' } -local clibformats = { 'CLUAINPUTS' } -local helpers = package.helpers +local luasuffixes = { 'tex', 'lua' } +local libsuffixes = { 'lib' } +local luaformats = { 'TEXINPUTS', 'LUAINPUTS' } +local libformats = { 'CLUAINPUTS' } +local helpers = package.helpers or { } +local methods = helpers.methods or { } trackers.register("resolvers.libraries", function(v) helpers.trace = v end) trackers.register("resolvers.locating", function(v) helpers.trace = v end) helpers.report = logs.reporter("resolvers","libraries") +helpers.sequence = { + "already loaded", + "preload table", + "lua variable format", + "lib variable format", + "lua extra list", + "lib extra list", + "path specification", + "cpath specification", + "all in one fallback", + "not loaded", +} + local pattern = Cs(P("!")^0 / "" * (P("/") * P(-1) / "/" + P("/")^1 / "/" + 1)^0) -local function cleanpath(path) -- hm, don't we have a helper for this? +function helpers.cleanpath(path) -- hm, don't we have a helper for this? return resolvers.resolve(lpegmatch(pattern,path)) end -helpers.cleanpath = cleanpath - -local loadedaslib = helpers.loadedaslib -local loadedbylua = helpers.loadedbylua -local loadedbypath = helpers.loadedbypath -local notloaded = helpers.notloaded - -local getlibpaths = package.libpaths -local getclibpaths = package.clibpaths - -function helpers.libpaths(libhash) - local libpaths = { } - for i=1,#libformats do - local paths = resolvers.expandedpathlistfromvariable(libformats[i]) - for i=1,#paths do - local path = cleanpath(paths[i]) - if not libhash[path] then - libpaths[#libpaths+1] = path - libhash[path] = true - end +local loadedaslib = helpers.loadedaslib +local getextraluapaths = package.extraluapaths +local getextralibpaths = package.extralibpaths +local registerpath = helpers.registerpath +local lualibfile = helpers.lualibfile + +local luaformatpaths +local libformatpaths + +local function getluaformatpaths() + if not luaformatpaths then + luaformatpaths = { } + for i=1,#luaformats do + registerpath("lua format","lua",luaformatpaths,resolvers.expandedpathlistfromvariable(luaformats[i])) end end - return libpaths + return luaformatpaths end -function helpers.clibpaths(clibhash) - local clibpaths = { } - for i=1,#clibformats do - local paths = resolvers.expandedpathlistfromvariable(clibformats[i]) - for i=1,#paths do - local path = cleanpath(paths[i]) - if not clibhash[path] then - clibpaths[#clibpaths+1] = path - clibhash[path] = true - end +local function getlibformatpaths() + if not libformatpaths then + libformatpaths = { } + for i=1,#libformats do + registerpath("lib format","lib",libformatpaths,resolvers.expandedpathlistfromvariable(libformats[i])) end end - return clibpaths + return libformatpaths end -local function loadedbyformat(name,rawname,suffixes,islib) +local function loadedbyformat(name,rawname,suffixes,islib,what) local trace = helpers.trace local report = helpers.report - if trace then - report("locating %a as %a using formats %a",rawname,name,suffixes) - end for i=1,#suffixes do -- so we use findfile and not a lookup loop local format = suffixes[i] local resolved = resolvers.findfile(name,format) or "" if trace then - report("checking %a using format %a",name,format) + report("%s format, identifying %a using format %a",what,name,format) end if resolved ~= "" then if trace then - report("lib %a located on %a",name,resolved) + report("%s format, %a found on %a",what,name,resolved) end if islib then - return true, loadedaslib(resolved,rawname) + return loadedaslib(resolved,rawname) else - return true, loadfile(resolved) + return loadfile(resolved) end end end @@ -100,16 +100,6 @@ end helpers.loadedbyformat = loadedbyformat --- alternatively we could set the package.searchers - -local pattern = Cs((((1-S("\\/"))^0 * (S("\\/")^1/"/"))^0 * (P(".")^1/"/"+P(1))^1) * -1) - -local function lualibfile(name) - return lpegmatch(pattern,name) or name -end - -helpers.lualibfile = lualibfile - -- print(lualibfile("bar")) -- print(lualibfile("foo.bar")) -- print(lualibfile("crap/foo...bar")) @@ -119,41 +109,23 @@ helpers.lualibfile = lualibfile -- alternatively we could split in path and base and temporary set the libpath to path -function helpers.loaded(name) - local thename = lualibfile(name) - local luaname = addsuffix(thename,"lua") - local libname = addsuffix(thename,os.libsuffix) - local libpaths = getlibpaths() - local clibpaths = getclibpaths() - local done, result = loadedbyformat(luaname,name,libsuffixes,false) - if done then - return result - end - local done, result = loadedbyformat(libname,name,clibsuffixes,true) - if done then - return result - end - local done, result = loadedbypath(luaname,name,libpaths,false,"lua") - if done then - return result - end - local done, result = loadedbypath(luaname,name,clibpaths,false,"lua") - if done then - return result - end - local done, result = loadedbypath(libname,name,clibpaths,true,"lib") - if done then - return result - end - local done, result = loadedbylua(name) - if done then - return result +-- we could build a list of relevant paths but for tracing it's better to have the +-- whole lot (ok, we could skip the duplicates) + +methods["lua variable format"] = function(name) + if helpers.trace then + helpers.report("%s format, checking %s paths","lua",#getluaformatpaths()) -- call triggers building end - return notloaded(name) + return loadedbyformat(addsuffix(lualibfile(name),"lua"),name,luasuffixes,false,"lua") end --- package.searchers[3] = nil -- get rid of the built in one (done in l-lua) +methods["lib variable format"] = function(name) + if helpers.trace then + helpers.report("%s format, checking %s paths","lib",#getlibformatpaths()) -- call triggers building + end + return loadedbyformat(addsuffix(lualibfile(name),os.libsuffix),name,libsuffixes,true,"lib") +end -- package.extraclibpath(environment.ownpath) -resolvers.loadlualib = require +resolvers.loadlualib = require -- hm diff --git a/Master/texmf-dist/tex/context/base/data-met.lua b/Master/texmf-dist/tex/context/base/data-met.lua index 28c73e46037..96da70bfdb2 100644 --- a/Master/texmf-dist/tex/context/base/data-met.lua +++ b/Master/texmf-dist/tex/context/base/data-met.lua @@ -9,8 +9,10 @@ if not modules then modules = { } end modules ['data-met'] = { local find, format = string.find, string.format local sequenced = table.sequenced local addurlscheme, urlhashed = url.addscheme, url.hashed +local getcurrentdir = lfs.currentdir local trace_locating = false +local trace_methods = false trackers.register("resolvers.locating", function(v) trace_methods = v end) trackers.register("resolvers.methods", function(v) trace_methods = v end) @@ -32,7 +34,10 @@ local function splitmethod(filename) -- todo: filetype in specification if type(filename) == "table" then return filename -- already split end - filename = file.collapsepath(filename) + filename = file.collapsepath(filename,".") -- hm, we should keep ./ in some cases + +-- filename = gsub(filename,"^%./",getcurrentdir().."/") -- we will merge dir.expandname and collapse some day + if not find(filename,"://") then return { scheme = "file", path = filename, original = filename, filename = filename } end diff --git a/Master/texmf-dist/tex/context/base/data-res.lua b/Master/texmf-dist/tex/context/base/data-res.lua index 74ec53f0daa..532b6261f19 100644 --- a/Master/texmf-dist/tex/context/base/data-res.lua +++ b/Master/texmf-dist/tex/context/base/data-res.lua @@ -36,6 +36,7 @@ local allocate = utilities.storage.allocate local settings_to_array = utilities.parsers.settings_to_array local setmetatableindex = table.setmetatableindex local luasuffixes = utilities.lua.suffixes +local getcurrentdir = lfs.currentdir local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end) local trace_detail = false trackers.register("resolvers.details", function(v) trace_detail = v end) @@ -67,7 +68,7 @@ resolvers.luacnfstate = "unknown" -- -- resolvers.luacnfspec = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,}/web2c}' -- --- but instead use: +-- but instead (for instance) use: -- -- resolvers.luacnfspec = 'selfautoparent:{/texmf{-local,}{,/web2c}}' -- @@ -77,16 +78,28 @@ resolvers.luacnfstate = "unknown" -- -- texlive: -- +-- selfautoloc: +-- selfautoloc:/share/texmf-local/web2c +-- selfautoloc:/share/texmf-dist/web2c +-- selfautoloc:/share/texmf/web2c +-- selfautoloc:/texmf-local/web2c +-- selfautoloc:/texmf-dist/web2c +-- selfautoloc:/texmf/web2c -- selfautodir: +-- selfautodir:/share/texmf-local/web2c +-- selfautodir:/share/texmf-dist/web2c +-- selfautodir:/share/texmf/web2c +-- selfautodir:/texmf-local/web2c +-- selfautodir:/texmf-dist/web2c +-- selfautodir:/texmf/web2c +-- selfautoparent:/../texmf-local/web2c -- selfautoparent: --- selfautodir:share/texmf-local/web2c --- selfautodir:share/texmf/web2c --- selfautodir:texmf-local/web2c --- selfautodir:texmf/web2c --- selfautoparent:share/texmf-local/web2c --- selfautoparent:share/texmf/web2c --- selfautoparent:texmf-local/web2c --- selfautoparent:texmf/web2c +-- selfautoparent:/share/texmf-local/web2c +-- selfautoparent:/share/texmf-dist/web2c +-- selfautoparent:/share/texmf/web2c +-- selfautoparent:/texmf-local/web2c +-- selfautoparent:/texmf-dist/web2c +-- selfautoparent:/texmf/web2c -- -- minimals: -- @@ -95,40 +108,25 @@ resolvers.luacnfstate = "unknown" -- selfautoparent:texmf-context/web2c -- selfautoparent:texmf/web2c --- -- Till 2013 we had this: --- --- if environment.default_texmfcnf then --- -- unfortunately we now have quite some overkill in the spec (not so nice on a network) --- resolvers.luacnfspec = environment.default_texmfcnf --- else --- resolvers.luacnfspec = "selfautoparent:texmf{-local,-context,-dist,}/web2c" --- -- resolvers.luacnfspec = "{selfautoloc:,selfautodir:,selfautoparent:}{,/texmf{-local,-dist,}/web2c}" --- end --- --- resolvers.luacnfspec = 'home:texmf/web2c;' .. resolvers.luacnfspec --- --- -- which (as we want users to use the web2c path) be can be simplified to this: --- --- if environment and environment.ownpath and string.find(environment.ownpath,"[\\/]texlive[\\/]") then --- resolvers.luacnfspec = 'selfautodir:/texmf-local/web2c,selfautoparent:/texmf-local/web2c,selfautoparent:/texmf/web2c' --- else --- resolvers.luacnfspec = 'selfautoparent:/texmf-local/web2c,selfautoparent:/texmf/web2c' --- end --- --- -- But I gave up on that after the change to texmf-dist (why-oh-why), so we stick to: - -resolvers.luacnfspec = { - "home:texmf/web2c", - "selfautoparent:/texmf-local/web2c", - "selfautoparent:/texmf-context/web2c", - "selfautoparent:/texmf-dist/web2c", - "selfautoparent:/texmf/web2c", -} - --- not yet table, some reporters expect strings - -if type(resolvers.luacnfspec) == "table" then - resolvers.luacnfspec = concat(resolvers.luacnfspec,";") +-- This is a real mess: you don't want to know what creepy paths end up in the default +-- configuration spec, for instance nested texmf- paths. I'd rather get away from it and +-- specify a proper search sequence but alas ... it is not permitted in texlive and there +-- is no way to check if we run a minimals as texmf-context is not in that spec. It's a +-- compiled-in permutation of historics with the selfautoloc, selfautodir, selfautoparent +-- resulting in weird combinations. So, when we eventually check the 30 something paths +-- we also report weird ones, with weird being: (1) duplicate /texmf or (2) no /web2c in +-- the names. + +if environment.default_texmfcnf then + resolvers.luacnfspec = "home:texmf/web2c;" .. environment.default_texmfcnf -- texlive + home: for taco etc +else + resolvers.luacnfspec = concat ( { + "home:texmf/web2c", + "selfautoparent:/texmf-local/web2c", + "selfautoparent:/texmf-context/web2c", + "selfautoparent:/texmf-dist/web2c", + "selfautoparent:/texmf/web2c", + }, ";") end local unset_variable = "unset" @@ -348,7 +346,6 @@ local function identify_configuration_files() if cnfspec == "" then cnfspec = resolvers.luacnfspec resolvers.luacnfstate = "default" --- resolvers.setenv("TEXMFCNF",cnfspec) -- for running texexec etc else resolvers.luacnfstate = "environment" end @@ -356,15 +353,20 @@ local function identify_configuration_files() local cnfpaths = expandedpathfromlist(resolvers.splitpath(cnfspec)) local luacnfname = resolvers.luacnfname for i=1,#cnfpaths do - local filename = collapsepath(filejoin(cnfpaths[i],luacnfname)) - local realname = resolvers.resolve(filename) + local filepath = cnfpaths[i] + local filename = collapsepath(filejoin(filepath,luacnfname)) + local realname = resolvers.resolve(filename) -- can still have "//" ... needs checking + -- todo: environment.skipweirdcnfpaths directive + if trace_locating then + local fullpath = gsub(resolvers.resolve(collapsepath(filepath)),"//","/") + local weirdpath = find(fullpath,"/texmf.+/texmf") or not find(fullpath,"/web2c") + report_resolving("looking for %a on %s path %a from specification %a",luacnfname,weirdpath and "weird" or "given",fullpath,filepath) + end if lfs.isfile(realname) then - specification[#specification+1] = filename + specification[#specification+1] = filename -- unresolved as we use it in matching, relocatable if trace_locating then report_resolving("found configuration file %a",realname) end - elseif trace_locating then - report_resolving("unknown configuration file %a",realname) end end if trace_locating then @@ -1305,7 +1307,10 @@ end collect_instance_files = function(filename,askedformat,allresults) -- uses nested askedformat = askedformat or "" - filename = collapsepath(filename) + filename = collapsepath(filename,".") + + filename = gsub(filename,"^%./",getcurrentdir().."/") -- we will merge dir.expandname and collapse some day + if allresults then -- no need for caching, only used for tracing local filetype, wantedfiles = find_analyze(filename,askedformat) @@ -1383,7 +1388,6 @@ end -- -- -- end of main file search routing -- -- -- - local function findfiles(filename,filetype,allresults) local result, status = collect_instance_files(filename,filetype or "",allresults) if not result or #result == 0 then diff --git a/Master/texmf-dist/tex/context/base/file-job.lua b/Master/texmf-dist/tex/context/base/file-job.lua index ea4623d7724..288a690d2da 100644 --- a/Master/texmf-dist/tex/context/base/file-job.lua +++ b/Master/texmf-dist/tex/context/base/file-job.lua @@ -987,8 +987,13 @@ if environment.initex then end -function commands.doifelsecontinuewithfile(inpname) - local continue = addsuffix(inpname,"tex") == addsuffix(environment.inputfilename,"tex") +function commands.doifelsecontinuewithfile(inpname,basetoo) + local inpnamefull = addsuffix(inpname,"tex") + local inpfilefull = addsuffix(environment.inputfilename,"tex") + local continue = inpnamefull == inpfilefull + if basetoo and not continue then + continue = inpnamefull == basename(inpfilefull) + end if continue then report_system("continuing input file %a",inpname) end diff --git a/Master/texmf-dist/tex/context/base/file-job.mkvi b/Master/texmf-dist/tex/context/base/file-job.mkvi index 3434e06f00e..087f1a6859e 100644 --- a/Master/texmf-dist/tex/context/base/file-job.mkvi +++ b/Master/texmf-dist/tex/context/base/file-job.mkvi @@ -193,9 +193,9 @@ \unexpanded\def\loadcldfileonce [#name]{\ctxcommand{usecldfile("#name",true)}} \unexpanded\def\loadanyfileonce [#name]{\ctxcommand{useanyfile("#name",true)}} -%D Handy for modules that have a test/demo appended. +%D Handy for modules that have a test/demo appended (true added). -\unexpanded\def\continueifinputfile#name{\ctxcommand{doifelsecontinuewithfile("#name")}\relax\endinput} % we cannot do \endinput via lua +\unexpanded\def\continueifinputfile#name{\ctxcommand{doifelsecontinuewithfile("#name",true)}\relax\endinput} % we cannot do \endinput via lua % \startproject test % 1: \startmode[*project] project \stopmode \endgraf diff --git a/Master/texmf-dist/tex/context/base/font-ctx.lua b/Master/texmf-dist/tex/context/base/font-ctx.lua index cb640b892e2..c894660d5b2 100644 --- a/Master/texmf-dist/tex/context/base/font-ctx.lua +++ b/Master/texmf-dist/tex/context/base/font-ctx.lua @@ -959,7 +959,7 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature csnames[tfmdata] = specification.cs tex.definefont(global,cs,tfmdata) -- resolved (when designsize is used): - setsomefontsize(fontdata[tfmdata].parameters.size .. "sp") + setsomefontsize((fontdata[tfmdata].parameters.size or 0) .. "sp") lastfontid = tfmdata else -- setting the extra characters will move elsewhere @@ -1533,6 +1533,22 @@ end) to scale virtual characters.</p> --ldx]]-- +function constructors.checkvirtualids(tfmdata) + -- begin of experiment: we can use { "slot", 0, number } in virtual fonts + local fonts = tfmdata.fonts + local selfid = font.nextid() + if fonts and #fonts > 0 then + for i=1,#fonts do + if fonts[i][2] == 0 then + fonts[i][2] = selfid + end + end + else + -- tfmdata.fonts = { "id", selfid } -- conflicts with other next id's (vf math), too late anyway + end + -- end of experiment +end + -- function constructors.getvirtualid(tfmdata) -- -- since we don't know the id yet, we use 0 as signal -- local tf = tfmdata.fonts diff --git a/Master/texmf-dist/tex/context/base/font-def.lua b/Master/texmf-dist/tex/context/base/font-def.lua index 5074e49ed75..cb056ff1bce 100644 --- a/Master/texmf-dist/tex/context/base/font-def.lua +++ b/Master/texmf-dist/tex/context/base/font-def.lua @@ -43,6 +43,7 @@ specifiers.variants = variants definers.methods = definers.methods or { } local internalized = allocate() -- internal tex numbers (private) +local lastdefined = nil -- we don't want this one to end up in s-tra-02 local loadedfonts = constructors.loadedfonts local designsizes = constructors.designsizes @@ -328,20 +329,8 @@ function definers.loadfont(specification) return tfmdata end -local function checkvirtual(tfmdata) - -- begin of experiment: we can use { "slot", 0, number } in virtual fonts - local fonts = tfmdata.fonts - local selfid = font.nextid() - if fonts and #fonts > 0 then - for i=1,#fonts do - if fonts[i][2] == 0 then - fonts[i][2] = selfid - end - end - else - tfmdata.fonts = { "id", selfid } - end - -- end of experiment +function constructors.checkvirtualids() + -- dummy in plain version end function constructors.readanddefine(name,size) -- no id -- maybe a dummy first @@ -356,7 +345,8 @@ function constructors.readanddefine(name,size) -- no id -- maybe a dummy first if not id then local tfmdata = definers.loadfont(specification) if tfmdata then - checkvirtual(tfmdata) -- experiment, will become obsolete when slots can selfreference + tfmdata.properties.hash = hash + constructors.checkvirtualids(tfmdata) -- experiment, will become obsolete when slots can selfreference id = font.define(tfmdata) definers.register(tfmdata,id) else @@ -378,9 +368,6 @@ not gain much. By the way, passing id's back to in the callback was introduced later in the development.</p> --ldx]]-- -local lastdefined = nil -- we don't want this one to end up in s-tra-02 -local internalized = { } - function definers.current() -- or maybe current return lastdefined end @@ -393,7 +380,9 @@ end function definers.register(tfmdata,id) if tfmdata and id then local hash = tfmdata.properties.hash - if not internalized[hash] then + if not hash then + report_defining("registering font, id %a, name %a, invalid hash",id,tfmdata.properties.filename or "?") + elseif not internalized[hash] then internalized[hash] = id if trace_defining then report_defining("registering font, id %s, hash %a",id,hash) diff --git a/Master/texmf-dist/tex/context/base/font-enh.lua b/Master/texmf-dist/tex/context/base/font-enh.lua index 9338fc20b15..2bf0741f535 100644 --- a/Master/texmf-dist/tex/context/base/font-enh.lua +++ b/Master/texmf-dist/tex/context/base/font-enh.lua @@ -154,9 +154,12 @@ local function initializeunicoding(tfmdata) oldcoding[name] = newcode end if tounicode then - local index = descriptions[newcode].index - if not tounicodes[index] then - tounicodes[index] = tosixteen(newcode) -- shared (we could have a metatable) + local description = descriptions[newcode] + if description then + local index = description.index + if not tounicodes[index] then + tounicodes[index] = tosixteen(newcode) -- shared (we could have a metatable) + end end end if trace_unicoding then diff --git a/Master/texmf-dist/tex/context/base/font-hsh.lua b/Master/texmf-dist/tex/context/base/font-hsh.lua index d6c226b7c13..f5c80d7053e 100644 --- a/Master/texmf-dist/tex/context/base/font-hsh.lua +++ b/Master/texmf-dist/tex/context/base/font-hsh.lua @@ -14,12 +14,16 @@ local fonts = fonts local hashes = fonts.hashes or allocate() fonts.hashes = hashes +-- todo: autoallocate ... just create on the fly .. use constructors.keys (problem: plurals) + local identifiers = hashes.identifiers or allocate() local characters = hashes.characters or allocate() -- chardata local descriptions = hashes.descriptions or allocate() local parameters = hashes.parameters or allocate() local properties = hashes.properties or allocate() local resources = hashes.resources or allocate() +local spacings = hashes.spacings or allocate() +local spaces = hashes.spaces or allocate() local quads = hashes.quads or allocate() -- maybe also spacedata local xheights = hashes.xheights or allocate() local csnames = hashes.csnames or allocate() -- namedata @@ -33,6 +37,8 @@ hashes.descriptions = descriptions hashes.parameters = parameters hashes.properties = properties hashes.resources = resources +hashes.spacings = spacings +hashes.spaces = spaces hashes.quads = quads hashes.emwidths = quads hashes.xheights = xheights hashes.exheights = xheights hashes.csnames = csnames @@ -47,6 +53,16 @@ local nulldata = allocate { descriptions = { }, properties = { }, parameters = { -- lmromanregular @ 12pt + slantperpoint = 0, + spacing = { + width = 256377, + stretch = 128188, + shrink = 85459, + extra = 85459, + }, + quad = 786432, + xheight = 338952, + -- compatibility: slant = 0, -- 1 space = 256377, -- 2 space_stretch = 128188, -- 3 @@ -128,6 +144,34 @@ setmetatableindex(quads, function(t,k) end end) +local nospacing = { + width = 0, + stretch = 0, + shrink = 0, + extra = 0, +} + +setmetatableindex(spacings, function(t,k) + if k == true then + return spacings[currentfont()] + else + local parameters = parameters[k] + local spacing = parameters and parameters.spacing or nospacing + t[k] = spacing + return spacing + end +end) + +setmetatableindex(spaces, function(t,k) + if k == true then + return spaces[currentfont()] + else + local space = spacings[k].width + t[k] = space + return space + end +end) + setmetatableindex(marks, function(t,k) if k == true then return marks[currentfont()] diff --git a/Master/texmf-dist/tex/context/base/font-mat.mkvi b/Master/texmf-dist/tex/context/base/font-mat.mkvi index eb2225d202a..4fe44a2da33 100644 --- a/Master/texmf-dist/tex/context/base/font-mat.mkvi +++ b/Master/texmf-dist/tex/context/base/font-mat.mkvi @@ -159,7 +159,8 @@ \def\font_helpers_set_math_family_bold#mbfam#familytag#mrfam% {\ifconditional\optimizemathfontdefinitions - \ifcsname\??fontinstanceclass\fontclass-\textface-\s!mm-#familytag-\fontsize-1\endcsname + %\ifcsname\??fontinstanceclass\fontclass-\textface-\s!mm-#familytag-\fontsize-1\endcsname + \ifcsname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname \font_helpers_preset_math_family_indeed#mbfam#familytag% \else \font_helpers_set_math_family_bold_indeed#mbfam#familytag#mrfam% @@ -178,32 +179,26 @@ %D test %D \stoptext %D -%D This is why we need the check: - -% \def\font_helpers_preset_math_family_indeed#fam#familytag% -% {\expandafter\ifx\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname\relax -% \writestatus{fonts}{math: unset for global bodyfont \fontclass\space at \fontbody}% -% \else -% \scriptscriptfont#fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname -% \scriptfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname -% \textfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname -% \fi} -% -% Uglier but more efficient (esp in tracing): +%D This is why we need the check. At the cost of some extra checking we gain a little +%D in restoring global states and, what's more important, we get rid of large math parameter +%D push/pop in tracingall when not needed. \def\font_helpers_preset_math_family_indeed#fam#familytag% {\expandafter\let\expandafter\v_font_math_one\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-1\endcsname \ifx\v_font_math_one\relax \font_helpers_preset_math_family_warning - \else - \scriptscriptfont#fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname - \scriptfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname - \textfont #fam\v_font_math_one - \fi} + \else\ifnum\fontid\textfont#fam=\fontid\v_font_math_one\else + \font_helpers_preset_math_family_indeed_changed#fam#familytag% + \fi\fi} \def\font_helpers_preset_math_family_warning {\writestatus{fonts}{math: unset for global bodyfont \fontclass\space at \fontbody}} +\def\font_helpers_preset_math_family_indeed_changed#fam#familytag% + {\scriptscriptfont#fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-3\endcsname + \scriptfont #fam\csname\??fontinstanceclass\fontclass-\fontbody-\s!mm-#familytag-\fontsize-2\endcsname + \textfont #fam\v_font_math_one} + \let\font_helpers_reset_fontclass_math_families\gobbleoneargument % It would be nice if characters could be defined in a neutral way (say fam 255) and @@ -238,13 +233,23 @@ \def\font_helpers_bidirectional_mathstrategy_yes {\font_helpers_set_math_family\c_font_fam_mr_lr\s!mrlr \font_helpers_set_math_family\c_font_fam_mr_rl\s!mrrl - \textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr + \ifnum\fontid\textfont\c_font_fam_mr=\fontid\textfont\c_font_fam_mr_lr\else + \font_helpers_bidirectional_mathstrategy_yes_changed + \fi} + +\def\font_helpers_bidirectional_mathstrategy_yes_changed + {\textfont \c_font_fam_mr\textfont \c_font_fam_mr_lr \scriptfont \c_font_fam_mr\scriptfont \c_font_fam_mr_lr \scriptscriptfont\c_font_fam_mr\scriptscriptfont\c_font_fam_mr_lr} \def\font_helpers_bidirectional_mathstrategy_nop {\font_helpers_set_math_family\c_font_fam_mr\s!mr - \textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr + \ifnum\fontid\textfont\c_font_fam_mr_rl=\fontid\textfont\c_font_fam_mr\else + \font_helpers_bidirectional_mathstrategy_nop_changed + \fi} + +\def\font_helpers_bidirectional_mathstrategy_nop_changed + {\textfont \c_font_fam_mr_rl\textfont \c_font_fam_mr \scriptfont \c_font_fam_mr_rl\scriptfont \c_font_fam_mr \scriptscriptfont\c_font_fam_mr_rl\scriptscriptfont\c_font_fam_mr \textfont \c_font_fam_mr_lr\textfont \c_font_fam_mr @@ -262,13 +267,23 @@ \def\font_helpers_complete_bold_math_strategy_yes_bidi {\font_helpers_set_math_family_bold\c_font_fam_mb_lr\s!mblr\c_font_fam_mr_lr \font_helpers_set_math_family_bold\c_font_fam_mb_rl\s!mbrl\c_font_fam_mr_rl - \textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr + \ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mb_lr\else + \font_helpers_complete_bold_math_strategy_yes_bidi_changed + \fi} + +\def\font_helpers_complete_bold_math_strategy_yes_bidi_changed + {\textfont \c_font_fam_mb\textfont \c_font_fam_mb_lr \scriptfont \c_font_fam_mb\scriptfont \c_font_fam_mb_lr \scriptscriptfont\c_font_fam_mb\scriptscriptfont\c_font_fam_mb_lr} \def\font_helpers_complete_bold_math_strategy_yes - {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr - \textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb + {\font_helpers_set_math_family_bold\c_font_fam_mb\s!mb\c_font_fam_mr\relax + \ifnum\fontid\textfont\c_font_fam_mb_rl=\fontid\textfont\c_font_fam_mb\else + \font_helpers_complete_bold_math_strategy_yes_changed + \fi} + +\def\font_helpers_complete_bold_math_strategy_yes_changed + {\textfont \c_font_fam_mb_rl\textfont \c_font_fam_mb \scriptfont \c_font_fam_mb_rl\scriptfont \c_font_fam_mb \scriptscriptfont\c_font_fam_mb_rl\scriptscriptfont\c_font_fam_mb \textfont \c_font_fam_mb_lr\textfont \c_font_fam_mb @@ -276,6 +291,11 @@ \scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mb} \def\font_helpers_complete_bold_math_strategy_nop + {\ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mr\else + \font_helpers_complete_bold_math_strategy_nop_changed + \fi} + +\def\font_helpers_complete_bold_math_strategy_nop_changed {\textfont \c_font_fam_mb \textfont \c_font_fam_mr \scriptfont \c_font_fam_mb \scriptfont \c_font_fam_mr \scriptscriptfont\c_font_fam_mb \scriptscriptfont\c_font_fam_mr diff --git a/Master/texmf-dist/tex/context/base/font-mis.lua b/Master/texmf-dist/tex/context/base/font-mis.lua index 247b0f641c9..c22548ac51c 100644 --- a/Master/texmf-dist/tex/context/base/font-mis.lua +++ b/Master/texmf-dist/tex/context/base/font-mis.lua @@ -22,7 +22,7 @@ local handlers = fonts.handlers handlers.otf = handlers.otf or { } local otf = handlers.otf -otf.version = otf.version or 2.741 +otf.version = otf.version or 2.742 otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true) function otf.loadcached(filename,format,sub) diff --git a/Master/texmf-dist/tex/context/base/font-otf.lua b/Master/texmf-dist/tex/context/base/font-otf.lua index b8abd590a3e..8a6183180ea 100644 --- a/Master/texmf-dist/tex/context/base/font-otf.lua +++ b/Master/texmf-dist/tex/context/base/font-otf.lua @@ -23,6 +23,7 @@ local lpegmatch = lpeg.match local reversed, concat, remove = table.reversed, table.concat, table.remove local ioflush = io.flush local fastcopy, tohash, derivetable = table.fastcopy, table.tohash, table.derive +local formatters = string.formatters local allocate = utilities.storage.allocate local registertracker = trackers.register @@ -47,7 +48,7 @@ local otf = fonts.handlers.otf otf.glists = { "gsub", "gpos" } -otf.version = 2.741 -- beware: also sync font-mis.lua +otf.version = 2.742 -- beware: also sync font-mis.lua otf.cache = containers.define("fonts", "otf", otf.version, true) local fontdata = fonts.hashes.identifiers @@ -1172,7 +1173,20 @@ local function t_hashed(t,cache) end end -local s_hashed = t_hashed +-- local s_hashed = t_hashed + +local function s_hashed(t,cache) + if t then + local ht = { } + local tf = t[1] + for i=1,#tf do + ht[i] = { [tf[i]] = true } + end + return ht + else + return nil + end +end local function r_uncover(splitter,cache,cover,replacements) if cover == "" then @@ -1307,6 +1321,9 @@ actions["reorganize lookups"] = function(data,filename,raw) -- we could check fo end end elseif format == "glyphs" then + -- I could store these more efficient (as not we use a nested tables for before, + -- after and current but this features happens so seldom that I don't bother + -- about it right now. for i=1,#rules do local rule = rules[i] local glyphs = rule.glyphs diff --git a/Master/texmf-dist/tex/context/base/font-otp.lua b/Master/texmf-dist/tex/context/base/font-otp.lua index 8a37c5cdf5c..c07d9ad4e70 100644 --- a/Master/texmf-dist/tex/context/base/font-otp.lua +++ b/Master/texmf-dist/tex/context/base/font-otp.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['font-otp'] = { } -- todo: pack math (but not that much to share) +-- -- pitfall 5.2: hashed tables can suddenly become indexed with nil slots local next, type = next, type @@ -203,7 +204,6 @@ local function packdata(data) end local function pack_mixed(v) local tag = tabstr_mixed(v) --- print(">>>",tag) local ht = h[tag] if ht then c[ht] = c[ht] + 1 @@ -344,13 +344,11 @@ local function packdata(data) if what == "baselig" then for _, a in next, anchor do for k=1,#a do --- a[k] = pack_normal(a[k]) a[k] = pack_indexed(a[k]) end end else for k, v in next, anchor do --- anchor[k] = pack_normal(v) anchor[k] = pack_indexed(v) end end diff --git a/Master/texmf-dist/tex/context/base/font-pre.mkiv b/Master/texmf-dist/tex/context/base/font-pre.mkiv index 410f2dcef51..74c39722f8f 100644 --- a/Master/texmf-dist/tex/context/base/font-pre.mkiv +++ b/Master/texmf-dist/tex/context/base/font-pre.mkiv @@ -211,6 +211,7 @@ \definecolor[font:mark][r=.75,b=.75] % [m=.75] \definecolor[font:rest][b=.75,g=.75] % [c=.75] +\definecolor[trace:w][s=1] \definecolor[trace:r][r=.75,t=.5,a=1] \definecolor[trace:g][g=.75,t=.5,a=1] \definecolor[trace:b][b=.75,t=.5,a=1] @@ -220,6 +221,7 @@ \definecolor[trace:s][s=.75,t=.5,a=1] \definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1] +\definecolor[trace:dw][s=1] \definecolor[trace:dr][r=.75,t=.75,a=1] \definecolor[trace:dg][g=.75,t=.75,a=1] \definecolor[trace:db][b=.75,t=.75,a=1] @@ -229,6 +231,7 @@ \definecolor[trace:ds][s=.75,t=.75,a=1] \definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1] +\definecolor[font:0] [s=1] \definecolor[font:1] [r=.75] \definecolor[font:2] [g=.75] \definecolor[font:3] [b=.75] diff --git a/Master/texmf-dist/tex/context/base/l-dir.lua b/Master/texmf-dist/tex/context/base/l-dir.lua index 00cda389913..3d0576eeb58 100644 --- a/Master/texmf-dist/tex/context/base/l-dir.lua +++ b/Master/texmf-dist/tex/context/base/l-dir.lua @@ -10,7 +10,7 @@ if not modules then modules = { } end modules ['l-dir'] = { local type, select = type, select local find, gmatch, match, gsub = string.find, string.gmatch, string.match, string.gsub -local concat, insert, remove = table.concat, table.insert, table.remove +local concat, insert, remove, unpack = table.concat, table.insert, table.remove, table.unpack local lpegmatch = lpeg.match local P, S, R, C, Cc, Cs, Ct, Cv, V = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Cv, lpeg.V @@ -447,3 +447,24 @@ function dir.pop() end return d end + +local function found(...) -- can have nil entries + for i=1,select("#",...) do + local path = select(i,...) + local kind = type(path) + if kind == "string" then + if isdir(path) then + return path + end + elseif kind == "table" then + -- here we asume no holes, i.e. an indexed table + local path = found(unpack(path)) + if path then + return path + end + end + end + -- return nil -- if we want print("crappath") to show something +end + +dir.found = found diff --git a/Master/texmf-dist/tex/context/base/l-file.lua b/Master/texmf-dist/tex/context/base/l-file.lua index af86f93976d..29416caf03b 100644 --- a/Master/texmf-dist/tex/context/base/l-file.lua +++ b/Master/texmf-dist/tex/context/base/l-file.lua @@ -62,7 +62,7 @@ elseif not lfs.isfile then end local insert, concat = table.insert, table.concat -local match = string.match +local match, find = string.match, string.find local lpegmatch = lpeg.match local getcurrentdir, attributes = lfs.currentdir, lfs.attributes local checkedsplit = string.checkedsplit @@ -410,11 +410,11 @@ local untouched = periods + (1-period)^1 * P(-1) local splitstarter = (Cs(drivespec * (bwslash/"/" + fwslash)^0) + Cc(false)) * Ct(lpeg.splitat(S("/\\")^1)) local absolute = fwslash -function file.collapsepath(str,anchor) +function file.collapsepath(str,anchor) -- anchor: false|nil, true, "." if not str then return end - if anchor and not lpegmatch(anchors,str) then + if anchor == true and not lpegmatch(anchors,str) then str = getcurrentdir() .. "/" .. str end if str == "" or str =="." then @@ -455,12 +455,17 @@ function file.collapsepath(str,anchor) elseif lpegmatch(absolute,str) then return "/" .. concat(newelements,'/') else - return concat(newelements, '/') + newelements = concat(newelements, '/') + if anchor == "." and find(str,"^%./") then + return "./" .. newelements + else + return newelements + end end end --- local function test(str) --- print(string.format("%-20s %-15s %-15s",str,file.collapsepath(str),file.collapsepath(str,true))) +-- local function test(str,...) +-- print(string.format("%-20s %-15s %-30s %-20s",str,file.collapsepath(str),file.collapsepath(str,true),file.collapsepath(str,"."))) -- end -- test("a/b.c/d") test("b.c/d") test("b.c/..") -- test("/") test("c:/..") test("sys://..") @@ -468,6 +473,7 @@ end -- test("a") test("./a") test("/a") test("a/../..") -- test("a/./b/..") test("a/aa/../b/bb") test("a/.././././b/..") test("a/./././b/..") -- test("a/b/c/../..") test("./a/b/c/../..") test("a/b/c/../..") +-- test("./a") local validchars = R("az","09","AZ","--","..") local pattern_a = lpeg.replacer(1-validchars) diff --git a/Master/texmf-dist/tex/context/base/l-lua.lua b/Master/texmf-dist/tex/context/base/l-lua.lua index 51816400ef4..fc05afa6714 100644 --- a/Master/texmf-dist/tex/context/base/l-lua.lua +++ b/Master/texmf-dist/tex/context/base/l-lua.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['l-lua'] = { license = "see context related readme files" } --- compatibility hacks ... try to avoid usage +-- compatibility hacksand helpers local major, minor = string.match(_VERSION,"^[^%d]+(%d+)%.(%d+).*$") @@ -148,257 +148,3 @@ function optionalrequire(...) return result end end - --- Code moved from data-lua and changed into a plug-in. - --- We overload the regular loader. We do so because we operate mostly in --- tds and use our own loader code. Alternatively we could use a more --- extensive definition of package.path and package.cpath but even then --- we're not done. Also, we now have better tracing. --- --- -- local mylib = require("libtest") --- -- local mysql = require("luasql.mysql") - -local type = type -local gsub, format = string.gsub, string.format - -local package = package -local searchers = package.searchers or package.loaders - -local libpaths = nil -local clibpaths = nil -local libhash = { } -local clibhash = { } -local libextras = { } -local clibextras = { } - --- dummies - -local filejoin = file and file.join or function(path,name) return path .. "/" .. name end -local isreadable = file and file.is_readable or function(name) local f = io.open(name) if f then f:close() return true end end -local addsuffix = file and file.addsuffix or function(name,suffix) return name .. "." .. suffix end - --- - -local function cleanpath(path) -- hm, don't we have a helper for this? - return path -end - -local helpers = package.helpers or { - libpaths = function() return { } end, - clibpaths = function() return { } end, - cleanpath = cleanpath, - trace = false, - report = function(...) print(format(...)) end, -} -package.helpers = helpers - -local function getlibpaths() - return libpaths or helpers.libpaths(libhash) -end - -local function getclibpaths() - return clibpaths or helpers.clibpaths(clibhash) -end - -package.libpaths = getlibpaths -package.clibpaths = getclibpaths - -local function addpath(what,paths,extras,hash,...) - local pathlist = { ... } - local cleanpath = helpers.cleanpath - local trace = helpers.trace - local report = helpers.report - -- - local function add(path) - local path = cleanpath(path) - if not hash[path] then - if trace then - report("extra %s path: %s",what,path) - end - paths [#paths +1] = path - extras[#extras+1] = path - end - end - -- - for p=1,#pathlist do - local path = pathlist[p] - if type(path) == "table" then - for i=1,#path do - add(path[i]) - end - else - add(path) - end - end - return paths, extras -end - -function package.extralibpath(...) - libpaths, libextras = addpath("lua", getlibpaths(), libextras, libhash,...) -end - -function package.extraclibpath(...) - clibpaths, clibextras = addpath("lib",getclibpaths(),clibextras,clibhash,...) -end - --- function package.extralibpath(...) --- libpaths = getlibpaths() --- local pathlist = { ... } --- local cleanpath = helpers.cleanpath --- local trace = helpers.trace --- local report = helpers.report --- -- --- local function add(path) --- local path = cleanpath(path) --- if not libhash[path] then --- if trace then --- report("extra lua path: %s",path) --- end --- libextras[#libextras+1] = path --- libpaths [#libpaths +1] = path --- end --- end --- -- --- for p=1,#pathlist do --- local path = pathlist[p] --- if type(path) == "table" then --- for i=1,#path do --- add(path[i]) --- end --- else --- add(path) --- end --- end --- end - --- function package.extraclibpath(...) --- clibpaths = getclibpaths() --- local pathlist = { ... } --- local cleanpath = helpers.cleanpath --- local trace = helpers.trace --- local report = helpers.report --- -- --- local function add(path) --- local path = cleanpath(path) --- if not clibhash[path] then --- if trace then --- report("extra lib path: %s",path) --- end --- clibextras[#clibextras+1] = path --- clibpaths [#clibpaths +1] = path --- end --- end --- -- --- for p=1,#pathlist do --- local path = pathlist[p] --- if type(path) == "table" then --- for i=1,#path do --- add(path[i]) --- end --- else --- add(path) --- end --- end --- end - -if not searchers[-2] then - -- use package-path and package-cpath - searchers[-2] = searchers[2] -end - -searchers[2] = function(name) - return helpers.loaded(name) -end - -searchers[3] = nil -- get rid of the built in one - -local function loadedaslib(resolved,rawname) - -- local init = "luaopen_" .. string.match(rawname,".-([^%.]+)$") - local init = "luaopen_"..gsub(rawname,"%.","_") - if helpers.trace then - helpers.report("calling loadlib with '%s' with init '%s'",resolved,init) - end - return package.loadlib(resolved,init) -end - -local function loadedbylua(name) - if helpers.trace then - helpers.report("locating '%s' using normal loader",name) - end - return true, searchers[-2](name) -- the original -end - -local function loadedbypath(name,rawname,paths,islib,what) - local trace = helpers.trace - local report = helpers.report - if trace then - report("locating '%s' as '%s' on '%s' paths",rawname,name,what) - end - for p=1,#paths do - local path = paths[p] - local resolved = filejoin(path,name) - if trace then -- mode detail - report("checking for '%s' using '%s' path '%s'",name,what,path) - end - if isreadable(resolved) then - if trace then - report("lib '%s' located on '%s'",name,resolved) - end - if islib then - return true, loadedaslib(resolved,rawname) - else - return true, loadfile(resolved) - end - end - end -end - -local function notloaded(name) - if helpers.trace then - helpers.report("unable to locate library '%s'",name) - end -end - -helpers.loadedaslib = loadedaslib -helpers.loadedbylua = loadedbylua -helpers.loadedbypath = loadedbypath -helpers.notloaded = notloaded - --- alternatively we could set the package.searchers - -function helpers.loaded(name) - local thename = gsub(name,"%.","/") - local luaname = addsuffix(thename,"lua") - local libname = addsuffix(thename,os.libsuffix or "so") -- brrr - local libpaths = getlibpaths() - local clibpaths = getclibpaths() - local done, result = loadedbypath(luaname,name,libpaths,false,"lua") - if done then - return result - end - local done, result = loadedbypath(luaname,name,clibpaths,false,"lua") - if done then - return result - end - local done, result = loadedbypath(libname,name,clibpaths,true,"lib") - if done then - return result - end - local done, result = loadedbylua(name) - if done then - return result - end - return notloaded(name) -end - -function helpers.unload(name) - if helpers.trace then - if package.loaded[name] then - helpers.report("unloading library '%s', %s",name,"done") - else - helpers.report("unloading library '%s', %s",name,"not loaded") - end - end - package.loaded[name] = nil -end diff --git a/Master/texmf-dist/tex/context/base/l-os.lua b/Master/texmf-dist/tex/context/base/l-os.lua index 42f3e4862c9..05ca0acdc6a 100644 --- a/Master/texmf-dist/tex/context/base/l-os.lua +++ b/Master/texmf-dist/tex/context/base/l-os.lua @@ -452,8 +452,20 @@ function os.now() return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 end -if not os.sleep and socket then - os.sleep = socket.sleep +-- if not os.sleep and socket then +-- os.sleep = socket.sleep +-- end + +if not os.sleep then + local socket = socket + function os.sleep(n) + if not socket then + -- so we delay ... if os.sleep is really needed then one should also + -- be sure that socket can be found + socket = require("socket") + end + socket.sleep(n) + end end -- print(os.which("inkscape.exe")) diff --git a/Master/texmf-dist/tex/context/base/l-package.lua b/Master/texmf-dist/tex/context/base/l-package.lua new file mode 100644 index 00000000000..09e65f9c896 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/l-package.lua @@ -0,0 +1,319 @@ +if not modules then modules = { } end modules ['l-package'] = { + version = 1.001, + comment = "companion to luat-lib.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Code moved from data-lua and changed into a plug-in. + +-- We overload the regular loader. We do so because we operate mostly in +-- tds and use our own loader code. Alternatively we could use a more +-- extensive definition of package.path and package.cpath but even then +-- we're not done. Also, we now have better tracing. +-- +-- -- local mylib = require("libtest") +-- -- local mysql = require("luasql.mysql") + +local type = type +local gsub, format = string.gsub, string.format + +local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.Cs, lpeg.match + +local package = package +local searchers = package.searchers or package.loaders + +-- dummies + +local filejoin = file and file.join or function(path,name) return path .. "/" .. name end +local isreadable = file and file.is_readable or function(name) local f = io.open(name) if f then f:close() return true end end +local addsuffix = file and file.addsuffix or function(name,suffix) return name .. "." .. suffix end + +-- local separator, concatinator, placeholder, pathofexecutable, ignorebefore = string.match(package.config,"(.-)\n(.-)\n(.-)\n(.-)\n(.-)\n") +-- +-- local config = { +-- separator = separator, -- \ or / +-- concatinator = concatinator, -- ; +-- placeholder = placeholder, -- ? becomes name +-- pathofexecutable = pathofexecutable, -- ! becomes executables dir (on windows) +-- ignorebefore = ignorebefore, -- - remove all before this when making lua_open +-- } + +local function cleanpath(path) -- hm, don't we have a helper for this? + return path +end + +local pattern = Cs((((1-S("\\/"))^0 * (S("\\/")^1/"/"))^0 * (P(".")^1/"/"+P(1))^1) * -1) + +local function lualibfile(name) + return lpegmatch(pattern,name) or name +end + +local helpers = package.helpers or { + cleanpath = cleanpath, + lualibfile = lualibfile, + trace = false, + report = function(...) print(format(...)) end, + builtin = { + ["preload table"] = searchers[1], -- special case, built-in libs + ["path specification"] = searchers[2], + ["cpath specification"] = searchers[3], + ["all in one fallback"] = searchers[4], -- special case, combined libs + }, + methods = { + }, + sequence = { + "already loaded", + "preload table", + "lua extra list", + "lib extra list", + "path specification", + "cpath specification", + "all in one fallback", + "not loaded", + } +} + +package.helpers = helpers + +local methods = helpers.methods +local builtin = helpers.builtin + +-- extra tds/ctx paths ... a bit of overhead for efficient tracing + +local extraluapaths = { } +local extralibpaths = { } +local luapaths = nil -- delayed +local libpaths = nil -- delayed +local oldluapath = nil +local oldlibpath = nil + +local nofextralua = -1 +local nofextralib = -1 +local nofpathlua = -1 +local nofpathlib = -1 + +local function listpaths(what,paths) + local nofpaths = #paths + if nofpaths > 0 then + for i=1,nofpaths do + helpers.report("using %s path %i: %s",what,i,paths[i]) + end + else + helpers.report("no %s paths defined",what) + end + return nofpaths +end + +local function getextraluapaths() + if helpers.trace and #extraluapaths ~= nofextralua then + nofextralua = listpaths("extra lua",extraluapaths) + end + return extraluapaths +end + +local function getextralibpaths() + if helpers.trace and #extralibpaths ~= nofextralib then + nofextralib = listpaths("extra lib",extralibpaths) + end + return extralibpaths +end + +local function getluapaths() + local luapath = package.path or "" + if oldluapath ~= luapath then + luapaths = file.splitpath(luapath,";") + oldluapath = luapath + nofpathlua = -1 + end + if helpers.trace and #luapaths ~= nofpathlua then + nofpathlua = listpaths("builtin lua",luapaths) + end + return luapaths +end + +local function getlibpaths() + local libpath = package.cpath or "" + if oldlibpath ~= libpath then + libpaths = file.splitpath(libpath,";") + oldlibpath = libpath + nofpathlib = -1 + end + if helpers.trace and #libpaths ~= nofpathlib then + nofpathlib = listpaths("builtin lib",libpaths) + end + return libpaths +end + +package.luapaths = getluapaths +package.libpaths = getlibpaths +package.extraluapaths = getextraluapaths +package.extralibpaths = getextralibpaths + +local hashes = { + lua = { }, + lib = { }, +} + +local function registerpath(tag,what,target,...) + local pathlist = { ... } + local cleanpath = helpers.cleanpath + local trace = helpers.trace + local report = helpers.report + local hash = hashes[what] + -- + local function add(path) + local path = cleanpath(path) + if not hash[path] then + target[#target+1] = path + hash[path] = true + if trace then + report("registered %s path %s: %s",tag,#target,path) + end + else + if trace then + report("duplicate %s path: %s",tag,path) + end + end + end + -- + for p=1,#pathlist do + local path = pathlist[p] + if type(path) == "table" then + for i=1,#path do + add(path[i]) + end + else + add(path) + end + end + return paths +end + +helpers.registerpath = registerpath + +function package.extraluapath(...) + registerpath("extra lua","lua",extraluapaths,...) +end + +function package.extralibpath(...) + registerpath("extra lib","lib",extralibpaths,...) +end + +-- lib loader (used elsewhere) + +local function loadedaslib(resolved,rawname) -- todo: strip all before first - + local base = gsub(rawname,"%.","_") + -- so, we can do a require("foo/bar") and initialize bar + -- local base = gsub(file.basename(rawname),"%.","_") + local init = "luaopen_" .. gsub(base,"%.","_") + if helpers.trace then + helpers.report("calling loadlib with '%s' with init '%s'",resolved,init) + end + return package.loadlib(resolved,init) +end + +helpers.loadedaslib = loadedaslib + +-- wrapped and new loaders + +local function loadedbypath(name,rawname,paths,islib,what) + local trace = helpers.trace + for p=1,#paths do + local path = paths[p] + local resolved = filejoin(path,name) + if trace then + helpers.report("%s path, identifying '%s' on '%s'",what,name,path) + end + if isreadable(resolved) then + if trace then + helpers.report("%s path, '%s' found on '%s'",what,name,resolved) + end + if islib then + return loadedaslib(resolved,rawname) + else + return loadfile(resolved) + end + end + end +end + +helpers.loadedbypath = loadedbypath + +methods["already loaded"] = function(name) + return package.loaded[name] +end + +methods["preload table"] = function(name) + return builtin["preload table"](name) +end + +methods["lua extra list"] = function(name) + return loadedbypath(addsuffix(lualibfile(name),"lua" ),name,getextraluapaths(),false,"lua") +end + +methods["lib extra list"] = function(name) + return loadedbypath(addsuffix(lualibfile(name),os.libsuffix),name,getextralibpaths(),true, "lib") +end + +methods["path specification"] = function(name) + getluapaths() -- triggers list building and tracing + return builtin["path specification"](name) +end + +methods["cpath specification"] = function(name) + getlibpaths() -- triggers list building and tracing + return builtin["cpath specification"](name) +end + +methods["all in one fallback"] = function(name) + return builtin["all in one fallback"](name) +end + +methods["not loaded"] = function(name) + if helpers.trace then + helpers.report("unable to locate '%s'",name or "?") + end + return nil +end + +local level = 0 + +function helpers.loaded(name) + local sequence = helpers.sequence + level = level + 1 + for i=1,#sequence do + local method = sequence[i] + if helpers.trace then + helpers.report("%s, level '%s', method '%s', name '%s'","locating",level,method,name) + end + local result, rest = methods[method](name) + if type(result) == "function" then + if helpers.trace then + helpers.report("%s, level '%s', method '%s', name '%s'","found",level,method,name) + end + level = level - 1 + return result, rest + end + end + -- safeguard, we never come here + level = level - 1 + return nil +end + +function helpers.unload(name) + if helpers.trace then + if package.loaded[name] then + helpers.report("unloading, name '%s', %s",name,"done") + else + helpers.report("unloading, name '%s', %s",name,"not loaded") + end + end + package.loaded[name] = nil +end + +-- overloading require does not work out well so we need to push it in +-- front .. + +table.insert(searchers,1,helpers.loaded) diff --git a/Master/texmf-dist/tex/context/base/l-table.lua b/Master/texmf-dist/tex/context/base/l-table.lua index 640bbbb283f..e57abe854c0 100644 --- a/Master/texmf-dist/tex/context/base/l-table.lua +++ b/Master/texmf-dist/tex/context/base/l-table.lua @@ -1094,7 +1094,7 @@ function table.tofile(filename,root,name,specification) end end -local function flattened(t,f,depth) +local function flattened(t,f,depth) -- also handles { nil, 1, nil, 2 } if f == nil then f = { } depth = 0xFFFF @@ -1110,19 +1110,16 @@ local function flattened(t,f,depth) if depth > 0 and type(v) == "table" then flattened(v,f,depth-1) else - f[k] = v + f[#f+1] = v end end end - local n = #f for k=1,#t do local v = t[k] if depth > 0 and type(v) == "table" then flattened(v,f,depth-1) - n = #f else - n = n + 1 - f[n] = v + f[#f+1] = v end end return f diff --git a/Master/texmf-dist/tex/context/base/lpdf-ano.lua b/Master/texmf-dist/tex/context/base/lpdf-ano.lua index e722446ee2c..adfea3812da 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-ano.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-ano.lua @@ -288,7 +288,6 @@ local function use_shared_annotations() statistics.register("pdf annotations", function() if nofused > 0 then - -- table.print(hashed,"hashed_annotations") return format("%s embedded, %s unique",nofused,nofunique) else return nil @@ -414,8 +413,6 @@ runners["special operation with arguments"] = runners["special"] function specials.internal(var,actions) -- better resolve in strc-ref local i = tonumber(var.operation) local v = i and references.internals[i] ---~ print(">>>>>>>",i) ---~ inspect(v) if not v then -- error report_reference("no internal reference %a",i) diff --git a/Master/texmf-dist/tex/context/base/lpdf-ini.lua b/Master/texmf-dist/tex/context/base/lpdf-ini.lua index 0b1473d2f93..cd601f21f4b 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-ini.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-ini.lua @@ -451,28 +451,36 @@ end local shareobjectcache, shareobjectreferencecache = { }, { } function lpdf.shareobject(content) - content = tostring(content) - local o = shareobjectcache[content] - if not o then - o = pdfimmediateobject(content) - shareobjectcache[content] = o - end - return o -end - -function lpdf.shareobjectreference(content) - content = tostring(content) - local r = shareobjectreferencecache[content] - if not r then + if content == nil then + -- invalid object not created + else + content = tostring(content) local o = shareobjectcache[content] if not o then o = pdfimmediateobject(content) shareobjectcache[content] = o end - r = pdfreference(o) - shareobjectreferencecache[content] = r + return o + end +end + +function lpdf.shareobjectreference(content) + if content == nil then + -- invalid object not created + else + content = tostring(content) + local r = shareobjectreferencecache[content] + if not r then + local o = shareobjectcache[content] + if not o then + o = pdfimmediateobject(content) + shareobjectcache[content] = o + end + r = pdfreference(o) + shareobjectreferencecache[content] = r + end + return r end - return r end --~ local d = lpdf.dictionary() diff --git a/Master/texmf-dist/tex/context/base/luat-bas.mkiv b/Master/texmf-dist/tex/context/base/luat-bas.mkiv index e24568b0a73..ddf90142423 100644 --- a/Master/texmf-dist/tex/context/base/luat-bas.mkiv +++ b/Master/texmf-dist/tex/context/base/luat-bas.mkiv @@ -14,6 +14,7 @@ \writestatus{loading}{ConTeXt Lua Macros / Basic Lua Libraries} \registerctxluafile{l-lua} {1.001} +\registerctxluafile{l-package} {1.001} \registerctxluafile{l-lpeg} {1.001} \registerctxluafile{l-function}{1.001} \registerctxluafile{l-string} {1.001} diff --git a/Master/texmf-dist/tex/context/base/luat-mac.lua b/Master/texmf-dist/tex/context/base/luat-mac.lua index 6a94012277b..c8be06b63ef 100644 --- a/Master/texmf-dist/tex/context/base/luat-mac.lua +++ b/Master/texmf-dist/tex/context/base/luat-mac.lua @@ -102,6 +102,8 @@ local stopcode = P("\\stoptexdefinition") local anything = patterns.anything local always = patterns.alwaysmatched +local definer = escape * (P("u")^-1 * S("egx")^-1 * P("def")) -- tex + -- The comment nilling can become an option but it nicely compensates the Lua -- parsing here with less parsing at the TeX end. We keep lines so the errors -- get reported all right, but comments are never seen there anyway. We keep @@ -147,6 +149,7 @@ local grammar = { "converter", )^0, definition = pushlocal * definer + * spaces^0 * escapedname -- * (declaration + furthercomment + commentline + (1-leftbrace))^0 * (declaration + furthercomment + commentline + csname_endcsname + (1-leftbrace))^0 @@ -326,7 +329,7 @@ end -- \stoptexdefinition -- ]])) --- print(macros.preprocessed([[\def\bla#bla{bla#{bla}}]])) +-- print(macros.preprocessed([[\checked \def \bla #bla{bla#{bla}}]])) -- print(macros.preprocessed([[\def\bla#bla{#{bla}bla}]])) -- print(macros.preprocessed([[\def\blä#{blá}{blà :#{blá}}]])) -- print(macros.preprocessed([[\def\blä#bla{blà :#bla}]])) diff --git a/Master/texmf-dist/tex/context/base/math-act.lua b/Master/texmf-dist/tex/context/base/math-act.lua index 8aeb0a97f2d..4f9b3b7e822 100644 --- a/Master/texmf-dist/tex/context/base/math-act.lua +++ b/Master/texmf-dist/tex/context/base/math-act.lua @@ -92,16 +92,23 @@ function mathematics.checkaccentbaseheight(target,original) end end -sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") +sequencers.appendaction("mathparameters","system","mathematics.checkaccentbaseheight") -- should go in lfg instead function mathematics.checkprivateparameters(target,original) local mathparameters = target.mathparameters if mathparameters then - if not mathparameters.FractionDelimiterSize then - mathparameters.FractionDelimiterSize = 1.01 * target.parameters.size - end - if not mathparameters.FractionDelimiterDisplayStyleSize then - mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * target.parameters.size + local parameters = target.parameters + if parameters then + if not mathparameters.FractionDelimiterSize then + mathparameters.FractionDelimiterSize = 1.01 * parameters.size + end + if not mathparameters.FractionDelimiterDisplayStyleSize then + mathparameters.FractionDelimiterDisplayStyleSize = 2.40 * parameters.size + end + elseif target.properties then + report_math("no parameters in font %a",target.properties.fullname or "?") + else + report_math("no parameters and properties in font") end end end diff --git a/Master/texmf-dist/tex/context/base/math-noa.lua b/Master/texmf-dist/tex/context/base/math-noa.lua index 2371110c14e..b309ba0777d 100644 --- a/Master/texmf-dist/tex/context/base/math-noa.lua +++ b/Master/texmf-dist/tex/context/base/math-noa.lua @@ -205,6 +205,9 @@ noads.process = processnoads -- 3-5 bold -- 6-8 pseudobold +-- this could best be integrated in the remapper, and if we run into problems, we +-- might as well do this + local families = { } local a_mathfamily = attributes.private("mathfamily") local boldmap = mathematics.boldmap @@ -295,9 +298,6 @@ local remapalphabets = mathematics.remapalphabets local fallbackstyleattr = mathematics.fallbackstyleattr local setnodecolor = nodes.tracers.colors.set ---~ This does not work out well, as there are no fallbacks. Ok, we could ---~ define a poor mans simplify mechanism. - local function checked(pointer) local char = pointer.char local fam = pointer.fam @@ -320,46 +320,6 @@ local function checked(pointer) end end --- processors.relocate[math_char] = function(pointer) --- local g = pointer[a_mathgreek] or 0 --- local a = pointer[a_mathalphabet] or 0 --- if a > 0 or g > 0 then --- if a > 0 then --- pointer[a_mathgreek] = 0 --- end --- if g > 0 then --- pointer[a_mathalphabet] = 0 --- end --- local char = pointer.char --- local newchar = remapalphabets(char,a,g) --- if newchar then --- local fam = pointer.fam --- local id = font_of_family(fam) --- local characters = fontcharacters[id] --- if characters and characters[newchar] then --- if trace_remapping then --- report_remap("char",id,char,newchar) --- end --- if trace_analyzing then --- setnodecolor(pointer,"font:isol") --- end --- pointer.char = newchar --- return true --- else --- if trace_remapping then --- report_remap("char",id,char,newchar," fails") --- end --- end --- end --- end --- if trace_analyzing then --- setnodecolor(pointer,"font:medi") --- end --- if check_coverage then --- return checked(pointer) --- end --- end - processors.relocate[math_char] = function(pointer) local g = pointer[a_mathgreek] or 0 local a = pointer[a_mathalphabet] or 0 diff --git a/Master/texmf-dist/tex/context/base/math-vfu.lua b/Master/texmf-dist/tex/context/base/math-vfu.lua index b169ec5e556..2f7c0507ba9 100644 --- a/Master/texmf-dist/tex/context/base/math-vfu.lua +++ b/Master/texmf-dist/tex/context/base/math-vfu.lua @@ -908,7 +908,6 @@ function vfmath.define(specification,set,goodies) size = size, } -- - -- main.mathparameters = mathparameters -- still traditional ones vfmath.addmissing(main,#fontlist,size) mathematics.addfallbacks(main) diff --git a/Master/texmf-dist/tex/context/base/meta-pdf.lua b/Master/texmf-dist/tex/context/base/meta-pdf.lua index 0287b82658e..32e48902a1a 100644 --- a/Master/texmf-dist/tex/context/base/meta-pdf.lua +++ b/Master/texmf-dist/tex/context/base/meta-pdf.lua @@ -14,9 +14,10 @@ if not modules then modules = { } end modules ['meta-pdf'] = { -- code often in \MKIV\ it makes no sense. local concat, unpack = table.concat, table.unpack -local format, gsub, find, byte, gmatch, match = string.format, string.gsub, string.find, string.byte, string.gmatch, string.match +local gsub, find, byte, gmatch, match = string.gsub, string.find, string.byte, string.gmatch, string.match local lpegmatch = lpeg.match local round = math.round +local formatters, format = string.formatters, string.format local report_mptopdf = logs.reporter("graphics","mptopdf") @@ -35,6 +36,9 @@ local mptopdf = metapost.mptopdf mptopdf.nofconverted = 0 +local f_translate = formatters["1 0 0 0 1 %f %f cm"] -- no %s due to 1e-035 issues +local f_concat = formatters["%f %f %f %f %f %f cm"] -- no %s due to 1e-035 issues + local m_path, m_stack, m_texts, m_version, m_date, m_shortcuts = { }, { }, { }, 0, 0, false local m_stack_close, m_stack_path, m_stack_concat = false, { }, nil @@ -80,7 +84,7 @@ end local function flushconcat() if m_stack_concat then - mpscode("%f %f %f %f %f %f cm",unpack(m_stack_concat)) -- no %s due to 1e-035 issues + mpscode(f_concatm(unpack(m_stack_concat))) m_stack_concat = nil end end @@ -139,15 +143,15 @@ function mps.boundingbox(llx, lly, urx, ury) end function mps.moveto(x,y) - m_stack_path[#m_stack_path+1] = {x,y,"m"} + m_stack_path[#m_stack_path+1] = { x, y, "m" } end function mps.curveto(ax, ay, bx, by, cx, cy) - m_stack_path[#m_stack_path+1] = {ax,ay,bx,by,cx,cy,"c"} + m_stack_path[#m_stack_path+1] = { ax, ay, bx, by, cx, cy, "c" } end function mps.lineto(x,y) - m_stack_path[#m_stack_path+1] = {x,y,"l"} + m_stack_path[#m_stack_path+1] = { x, y, "l" } end function mps.rlineto(x,y) @@ -162,7 +166,7 @@ function mps.rlineto(x,y) end function mps.translate(tx,ty) - mpscode("1 0 0 0 1 " .. tx .. " " .. ty .. " cm") + mpscode(f_translate(tx,ty) end function mps.scale(sx,sy) @@ -267,18 +271,18 @@ local nofshades, tn = 0, tonumber local function linearshade(colorspace,domain,ca,cb,coordinates) pdfcode(pdffinishtransparencycode()) nofshades = nofshades + 1 - local name = format("MpsSh%s",nofshades) + local name = formatters["MpsSh%s"](nofshades) lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates) - extra_path_code, ignore_path = format("/%s sh Q",name), true + extra_path_code, ignore_path = formatters["/%s sh Q"](name), true pdfcode("q /Pattern cs") end local function circularshade(colorspace,domain,ca,cb,coordinates) pdfcode(pdffinishtransparencycode()) nofshades = nofshades + 1 - local name = format("MpsSh%s",nofshades) + local name = formatters["MpsSh%s"](nofshades) lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates) - extra_path_code, ignore_path = format("/%s sh Q",name), true + extra_path_code, ignore_path = formatters["/%s sh Q"](name), true pdfcode("q /Pattern cs") end @@ -357,7 +361,7 @@ end function mps.setgray(s) pdfcode(pdffinishtransparencycode()) - pdfcode(pdfgrayliteral(mps.colormodel,s)) + pdfcode(pdfgraycode(mps.colormodel,s)) end function mps.specials(version,signal,factor) -- 2.0 123 1000 @@ -538,13 +542,11 @@ function mptopdf.convertmpstopdf(name) mps.colormodel = tex.attribute[a_colorspace] statistics.starttiming(mptopdf) mptopdf.nofconverted = mptopdf.nofconverted + 1 - -- pdfcode(format("%% mptopdf begin: n=%s, file=%s",mptopdf.nofconverted,file.basename(name))) - pdfcode(format("\\letterpercent\\space mptopdf begin: n=%s, file=%s",mptopdf.nofconverted,file.basename(name))) + pdfcode(formatters["\\letterpercent\\space mptopdf begin: n=%s, file=%s"](mptopdf.nofconverted,file.basename(name))) pdfcode("q 1 0 0 1 0 0 cm") parse(m_data) pdfcode(pdffinishtransparencycode()) pdfcode("Q") - -- pdfcode("% mptopdf end") pdfcode("\\letterpercent\\space mptopdf end") resetall() statistics.stoptiming(mptopdf) diff --git a/Master/texmf-dist/tex/context/base/mult-def.mkiv b/Master/texmf-dist/tex/context/base/mult-def.mkiv index 22b3880f631..ec33171da8c 100644 --- a/Master/texmf-dist/tex/context/base/mult-def.mkiv +++ b/Master/texmf-dist/tex/context/base/mult-def.mkiv @@ -54,6 +54,8 @@ \def\c!down {down} \def\c!instance {instance} \def\c!database {database} +\def\c!group {group} +\def\c!groupsuffix {groupsuffix} \def\v!compressseparator{compressseparator} \def\v!notation {notation} @@ -68,6 +70,7 @@ \def\v!chemical {chemical} \def\v!chemicals {chemicals} \def\v!words {words} +\def\v!combination {combination} \def\s!lcgreek {lcgreek} \def\s!ucgreek {ucgreek} @@ -77,6 +80,8 @@ \def\s!insert {insert} % maybe insertclass \def\s!marker {marker} +\def\s!mixedcolumn {mixedcolumn} + \def\s!double {double} \def\s!decimal {decimal} diff --git a/Master/texmf-dist/tex/context/base/mult-low.lua b/Master/texmf-dist/tex/context/base/mult-low.lua index d3c5add106f..d5848e5c70f 100644 --- a/Master/texmf-dist/tex/context/base/mult-low.lua +++ b/Master/texmf-dist/tex/context/base/mult-low.lua @@ -230,7 +230,7 @@ return { -- "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", -- - "wait", "writestatus", "define", "redefine", + "wait", "writestatus", "define", "defineexpandable", "redefine", -- "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", -- @@ -240,7 +240,7 @@ return { "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", -- - "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", + "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", -- "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", -- diff --git a/Master/texmf-dist/tex/context/base/mult-sys.mkiv b/Master/texmf-dist/tex/context/base/mult-sys.mkiv index 135d8bcf7bd..c184d91b5c9 100644 --- a/Master/texmf-dist/tex/context/base/mult-sys.mkiv +++ b/Master/texmf-dist/tex/context/base/mult-sys.mkiv @@ -264,6 +264,8 @@ \definesystemconstant {hastitle} \definesystemconstant {hascaption} \definesystemconstant {haslevel} +\definesystemconstant {hasparent} +\definesystemconstant {hassuffix} \definesystemconstant {mkiv} \definesystemconstant {mkii} diff --git a/Master/texmf-dist/tex/context/base/node-pro.lua b/Master/texmf-dist/tex/context/base/node-pro.lua index 24351b5b861..60f2d8a720e 100644 --- a/Master/texmf-dist/tex/context/base/node-pro.lua +++ b/Master/texmf-dist/tex/context/base/node-pro.lua @@ -123,6 +123,8 @@ local hpack = node.hpack function nodes.fasthpack(...) -- todo: pass explicit arguments enabled = false local hp, b = hpack(...) + hp.prev = nil + hp.next = nil enabled = true return hp, b end diff --git a/Master/texmf-dist/tex/context/base/pack-com.mkiv b/Master/texmf-dist/tex/context/base/pack-com.mkiv index d12c0d90aef..6c1363148b9 100644 --- a/Master/texmf-dist/tex/context/base/pack-com.mkiv +++ b/Master/texmf-dist/tex/context/base/pack-com.mkiv @@ -88,6 +88,15 @@ \installcommandhandler \??combination {combination} \??combination +\setfalse\c_strc_constructions_define_commands + +\definelabel + [\v!combination] % handy for configuring + [\c!numberconversion=\v!character, + \c!text=] + +\settrue\c_strc_constructions_define_commands + \setupcombination [\c!width=\v!fit, \c!height=\v!fit, @@ -105,6 +114,17 @@ \let\setupcombinations\setupcombination % for the moment (we might distinguish) \installcorenamespace{combinationlocation} +\installcorenamespace{combinationalternative} + +\appendtoks + \setfalse\c_strc_constructions_define_commands + \normalexpanded + {\definelabel + [\v!combination:\currentcombination]% + [\v!combination\ifx\currentcombinationparent\empty\else:\currentcombinationparent\fi]}% + [\s!counter=\currentcombination,\c!levels=1]% + \settrue\c_strc_constructions_define_commands +\to \everydefinecombination \setvalue{\??combinationlocation\v!left }{\let\m_pack_combinations_leftfiller\relax} \setvalue{\??combinationlocation\v!right }{\let\m_pack_combinations_rightfiller\relax} @@ -158,30 +178,41 @@ \unexpanded\def\pack_common_caption_stop {\removeunwantedspaces\egroup} \unexpanded\def\stopcombination - {\bgroup\normalexpanded{\egroup{}\ctxcommand{ntimes("{}{}",\number\c_pack_combinations_n)}}% + {\bgroup\normalexpanded{\egroup{}\ctxcommand{ntimes("{}{}",\number\c_pack_combinations_n)}}% brr \dostoptagged \egroup \egroup} +\newtoks\everycombination + \def\pack_combinations_start[#1][#2]% needs a cleanup, also nx ny (pretty old, this one) {\global\setsystemmode{combination}% % \edef\currentcombination{#1}% \edef\currentcombinationspec{#2}% \ifx\currentcombinationspec\empty - \doifinstringelse{*}\currentcombination - {\edef\currentcombinationspec{\currentcombination*\plusone*}% - \let\currentcombination\empty} - {\doifnumberelse\currentcombination + \doifassignmentelse{#1}% + {\let\currentcombination\empty + \setupcurrentcombination[#1]% + \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}} + {\doifinstringelse{*}\currentcombination {\edef\currentcombinationspec{\currentcombination*\plusone*}% \let\currentcombination\empty} - {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}% + {\doifnumberelse\currentcombination + {\edef\currentcombinationspec{\currentcombination*\plusone*}% + \let\currentcombination\empty} + {\edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}}}}% \else - \edef\currentcombinationspec{\currentcombinationspec*\plusone*}% + \doifassignmentelse{#2}% + {\setupcurrentcombination[#2]% + \edef\currentcombinationspec{\combinationparameter\c!nx*\combinationparameter\c!ny*}} + {\edef\currentcombinationspec{\currentcombinationspec*\plusone*}}% \fi % \forgetall % + \the\everycombination + % \let\startcontent\pack_common_content_start \let\stopcontent \pack_common_content_stop \let\startcaption\pack_common_caption_start @@ -220,6 +251,22 @@ \cr \pack_combinations_pickup} +% \def\pack_combinations_pickup_content % we want to add struts but still ignore an empty box +% {\dostoptagged +% \setbox\b_pack_combinations_content\box\nextbox +% \dostarttagged\t!combinationcaption\empty +% \dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup +% \afterassignment\pack_combinations_caption_first +% \let\nexttoken=} + +% I've first considered using a constructor directly but it's more overhead +% and some settings conflict with already used combination settings so instead +% we plug in labels. This also permits extensions later on. + +\appendtoks + \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}% +\to \everydefinecombination + \def\pack_combinations_pickup % we want to add struts but still ignore an empty box {\dostarttagged\t!combinationpair\empty \dostarttagged\t!combinationcontent\empty @@ -229,10 +276,33 @@ {\dostoptagged \setbox\b_pack_combinations_content\box\nextbox \dostarttagged\t!combinationcaption\empty - \dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup + \expandnamespacemacro\??combinationalternative\p_pack_combinations_alternative\v!text} + +\setvalue{\??combinationalternative\v!text}% + {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup \afterassignment\pack_combinations_caption_first \let\nexttoken=} +\setvalue{\??combinationalternative\v!label}% + {\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup + \hsize\wd\b_pack_combinations_content + \ifx\p_align\empty\else\setupalign[\p_align]\fi + \usecombinationstyleandcolor\c!style\c!color % but label style wins, so independent configuration + \begstrut + \normalexpanded{\strc_labels_command{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}}% + \endstrut + \egroup} + +\appendtoks + \edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}% + \ifx\p_pack_combinations_alternative\v!label + \edef\p_continue{\combinationparameter\c!continue}% + \ifx\p_continue\v!yes \else + \normalexpanded{\strc_labels_reset{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}{1}}% + \fi + \fi +\to \everycombination + \def\pack_combinations_pickup_caption {\dostoptagged \dostoptagged @@ -795,7 +865,7 @@ \usepairedboxstyleandcolor\c!style\c!color \tolerantTABLEbreaktrue % hm. \blank[\v!disable]% use fast one - \everypar{\begstrut}} + \everypar{\begstrut}} % also flushers here (see bTABLE) \definepairedbox[\v!legend] diff --git a/Master/texmf-dist/tex/context/base/pack-rul.lua b/Master/texmf-dist/tex/context/base/pack-rul.lua index c91dec09cc2..a990936e7d2 100644 --- a/Master/texmf-dist/tex/context/base/pack-rul.lua +++ b/Master/texmf-dist/tex/context/base/pack-rul.lua @@ -15,66 +15,9 @@ local hpack, free, copy, traverse_id = node.hpack, node.free, node.copy_list, no local texdimen, texcount = tex.dimen, tex.count local hlist_code = nodes.nodecodes.hlist +local box_code = nodes.listcodes.box local node_dimensions = node.dimensions --- function commands.doreshapeframedbox(n) --- local box = texbox[n] --- local noflines = 0 --- local firstheight = nil --- local lastdepth = nil --- local lastlinelength = 0 --- local minwidth = 0 --- local maxwidth = 0 --- local totalwidth = 0 --- if box.width ~= 0 then --- local list = box.list --- if list then --- for h in traverse_id(hlist_code,list) do -- no dir etc needed --- if not firstheight then --- firstheight = h.height --- end --- lastdepth = h.depth --- noflines = noflines + 1 --- local l = h.list --- if l then --- local p = hpack(copy(l)) --- lastlinelength = p.width --- if lastlinelength > maxwidth then --- maxwidth = lastlinelength --- end --- if lastlinelength < minwidth or minwidth == 0 then --- minwidth = lastlinelength --- end --- totalwidth = totalwidth + lastlinelength --- free(p) --- end --- end --- if firstheight then --- if maxwidth ~= 0 then --- for h in traverse_id(hlist_code,list) do --- local l = h.list --- if l then --- -- if h.width ~= maxwidth then -- else no display math handling (uses shift) --- h.list = hpack(l,maxwidth,'exactly',h.dir) --- h.shift = 0 -- needed for display math --- h.width = maxwidth --- -- end --- end --- end --- end --- box.width = maxwidth --- end --- end --- end --- -- print("reshape", noflines, firstheight or 0, lastdepth or 0) --- texsetcount("global","framednoflines", noflines) --- texsetdimen("global","framedfirstheight", firstheight or 0) --- texsetdimen("global","framedlastdepth", lastdepth or 0) --- texsetdimen("global","framedminwidth", minwidth) --- texsetdimen("global","framedmaxwidth", maxwidth) --- texsetdimen("global","framedaveragewidth", noflines > 0 and totalwidth/noflines or 0) --- end - function commands.doreshapeframedbox(n) local box = texbox[n] local noflines = 0 @@ -95,7 +38,11 @@ function commands.doreshapeframedbox(n) noflines = noflines + 1 local l = h.list if l then - lastlinelength = node_dimensions(l) + if h.subtype == box_code then -- maybe more + lastlinelength = h.width + else + lastlinelength = node_dimensions(l) -- used to be: hpack(copy(l)).width + end if lastlinelength > maxwidth then maxwidth = lastlinelength end @@ -110,14 +57,18 @@ function commands.doreshapeframedbox(n) for h in traverse_id(hlist_code,list) do local l = h.list if l then - -- if h.width ~= maxwidth then -- else no display math handling (uses shift) - -- challenge: adapt glue_set - -- h.glue_set = h.glue_set * h.width/maxwidth -- interesting ... doesn't matter much - -- h.width = maxwidth - h.list = hpack(l,maxwidth,'exactly',h.dir) - h.shift = 0 -- needed for display math - h.width = maxwidth - -- end + if h.subtype == box_code then + -- explicit box, no 'line' + else + -- if h.width ~= maxwidth then -- else no display math handling (uses shift) + -- challenge: adapt glue_set + -- h.glue_set = h.glue_set * h.width/maxwidth -- interesting ... doesn't matter much + -- h.width = maxwidth + h.list = hpack(l,maxwidth,'exactly',h.dir) + h.shift = 0 -- needed for display math + h.width = maxwidth + -- end + end end end end diff --git a/Master/texmf-dist/tex/context/base/page-flt.lua b/Master/texmf-dist/tex/context/base/page-flt.lua index 68383f175f9..ab7a534eb15 100644 --- a/Master/texmf-dist/tex/context/base/page-flt.lua +++ b/Master/texmf-dist/tex/context/base/page-flt.lua @@ -236,13 +236,15 @@ function floats.nofstacked() return #stacks[which or default] or 0 end +-- todo: check for digits ! + local method = C((1-S(", :"))^1) -local position = P(":") * C((1-S("*,"))^1) * P("*") * C((1-S(","))^1) +local position = P(":") * C((1-S("*,"))^1) * (P("*") * C((1-S(","))^1))^0 local label = P(":") * C((1-S(",*: "))^0) local pattern = method * ( - label * position - + C("") * position + label * position * C("") + + C("") * position * C("") + label * C("") * C("") + C("") * C("") * C("") ) + C("") * C("") * C("") * C("") @@ -255,7 +257,7 @@ local pattern = method * ( -- inspect { lpegmatch(pattern,"somewhere") } -- inspect { lpegmatch(pattern,"") } -function floats.analysemethod(str) +function floats.analysemethod(str) -- will become a more extensive parser return lpegmatch(pattern,str or "") end @@ -278,10 +280,10 @@ function commands.checkedpagefloat (...) local v = floats.checkedpagefloat(...) function commands.nofstackedfloats (...) context(floats.nofstacked(...)) end function commands.doifelsesavedfloat(...) commands.doifelse(floats.nofstacked(...)>0) end -function commands.analysefloatmethod(str) +function commands.analysefloatmethod(str) -- currently only one method local method, label, row, column = floats.analysemethod(str) - setvalue("floatmethod",method) - setvalue("floatlabel", label ) - setvalue("floatrow", row ) - setvalue("floatcolumn",column) + setvalue("floatmethod",method or "") + setvalue("floatlabel", label or "") + setvalue("floatrow", row or "") + setvalue("floatcolumn",column or "") end diff --git a/Master/texmf-dist/tex/context/base/page-mix.mkiv b/Master/texmf-dist/tex/context/base/page-mix.mkiv index a5c343fc7ee..a4a9bab0987 100644 --- a/Master/texmf-dist/tex/context/base/page-mix.mkiv +++ b/Master/texmf-dist/tex/context/base/page-mix.mkiv @@ -50,8 +50,6 @@ \installcorenamespace{mixedcolumns} -\def\s!mixedcolumn{mixedcolumn} - \installframedcommandhandler \??mixedcolumns {mixedcolumns} \??mixedcolumns \setupmixedcolumns diff --git a/Master/texmf-dist/tex/context/base/page-set.mkiv b/Master/texmf-dist/tex/context/base/page-set.mkiv index b7c26035ee9..9c232f5358b 100644 --- a/Master/texmf-dist/tex/context/base/page-set.mkiv +++ b/Master/texmf-dist/tex/context/base/page-set.mkiv @@ -327,7 +327,9 @@ {\bgroup \global\columnfirstcell\ifnum#2=0 1\else#2\fi\relax \OTRSETsetcorrectnofcells\currentcolumnmaxcells % sets \scratchcounter - \edef\columnmaxcells{\the\scratchcounter}% + \ifnum\scratchcounter<\columnmaxcells\relax + \edef\columnmaxcells{\the\scratchcounter}% added 2013.04.19 + \fi \ifnum\columnfirstcell>\columnmaxcells \global\columnfreecells\zerocount \global\columnfirstcell\plusone @@ -361,9 +363,7 @@ \ifnum\columnlastcell>\columnmaxcells \global\columnlastcell\columnmaxcells \fi - \global\columnfreecells\columnlastcell - \global\advance\columnfreecells -\columnfirstcell - \global\advance\columnfreecells \plusone + \global\columnfreecells\numexpr\columnlastcell-\columnfirstcell+\plusone\relax \global\somefreecolumncellstrue %\message{\number\columnfirstcell-\number\columnlastcell=\number\columnfreecells}% \fi diff --git a/Master/texmf-dist/tex/context/base/s-map-10.mkiv b/Master/texmf-dist/tex/context/base/s-map-10.mkiv index 33a372de868..b1218f6e276 100644 --- a/Master/texmf-dist/tex/context/base/s-map-10.mkiv +++ b/Master/texmf-dist/tex/context/base/s-map-10.mkiv @@ -171,7 +171,6 @@ \def\hfonti{\ssbfa} \def\hfontii{\ssbf} \def\hfontiii{\rm\it} -\def\runin#1#2{#2.} \doifmodeelse{nosubsub}{% \setuphead [section][% @@ -181,7 +180,6 @@ ] \setuphead [subsection][% style=\hfontiii, - command=\runin, alternative=text, distance=6pt, before={\blank[halfline]}% @@ -198,7 +196,6 @@ ] \setuphead [subsubsection][% style=\hfontiii, - command=\runin, distance=6pt, alternative=text, before={\blank[halfline]}% @@ -212,7 +209,6 @@ ] \setuphead [subsubject][% style=\hfontiii, - command=\runin, alternative=text, before={\blank[halfline]}% ]}{% @@ -228,7 +224,6 @@ ] \setuphead [subsubsubject][% style=\hfontiii, - command=\runin, alternative=text, before={\blank[halfline]}% ]} diff --git a/Master/texmf-dist/tex/context/base/scrn-fld.mkvi b/Master/texmf-dist/tex/context/base/scrn-fld.mkvi index cc84b9c71f8..049ac92c353 100644 --- a/Master/texmf-dist/tex/context/base/scrn-fld.mkvi +++ b/Master/texmf-dist/tex/context/base/scrn-fld.mkvi @@ -367,7 +367,7 @@ \begingroup \edef\currentdefaultfieldvalue{\ctxcommand{getdefaultfieldvalue("#tag")}}% \setbox\b_scrn_field_fit_symbol\hbox{\symbol[\currentdefaultfieldvalue]}% - \fitfieldframed[#tag] + \fitfieldframed {\fieldbody[#tag] [\c!width=\wd\b_scrn_field_fit_symbol, \c!height=\ht\b_scrn_field_fit_symbol, @@ -952,14 +952,14 @@ \def\scrn_rollbutton_symbol_m {\scrn_rollbutton_symbol_indeed - \getinteractionmenuparameter + \interactionmenuparameter \inheritedinteractionmenuframed \setinteractionmenuparameter \useinteractionmenustyleandcolor} \def\scrn_rollbutton_symbol_b {\scrn_rollbutton_symbol_indeed - \getbuttonparameter + \buttonparameter \inheritedbuttonframed \setbuttonparameter \usebuttonstyleandcolor} @@ -967,8 +967,8 @@ \def\scrn_rollbutton[#tag][#settings]#text[#reference]% {\dontleavehmode \bgroup - \doglobal\advance\c_scrn_rollbutton_n_button - \doglobal\advance\c_scrn_rollbutton_n_symbol + \advance\c_scrn_rollbutton_n_button\plusone + \advance\c_scrn_rollbutton_n_symbol\plusone \iffirstargument \ifsecondargument \edef\currentinteractionmenu{#tag}% diff --git a/Master/texmf-dist/tex/context/base/scrp-cjk.lua b/Master/texmf-dist/tex/context/base/scrp-cjk.lua index 5885c98671f..487d5a2672c 100644 --- a/Master/texmf-dist/tex/context/base/scrp-cjk.lua +++ b/Master/texmf-dist/tex/context/base/scrp-cjk.lua @@ -9,6 +9,11 @@ if not modules then modules = { } end modules ['scrp-cjk'] = { -- We can speed this up by preallocating nodes and copying them but the -- gain is not that large. +-- The input line endings: there is no way to distinguish between +-- inline spaces and endofline turned into spaces (would not make +-- sense either because otherwise a wanted space at the end of a +-- line would have to be a hard coded ones. + local utfchar = utf.char local insert_node_after = node.insert_after @@ -21,7 +26,10 @@ local new_kern = nodepool.kern local new_penalty = nodepool.penalty local nodecodes = nodes.nodecodes +local skipcodes = nodes.skipcodes local glyph_code = nodecodes.glyph +local glue_code = nodecodes.glue +local userskip_code = skipcodes.userskip local a_prestat = attributes.private('prestat') local a_preproc = attributes.private('preproc') @@ -34,6 +42,7 @@ local numbertodataset = scripts.numbertodataset local fonthashes = fonts.hashes local fontdata = fonthashes.identifiers local quaddata = fonthashes.quads +local spacedata = fonthashes.spaces local trace_details = false trackers.register("scripts.details", function(v) trace_details = v end) @@ -96,6 +105,12 @@ local function trace_detail(current,what) end end +local function trace_detail_between(p,n,what) + local p_ch = p.char + local n_ch = n.char + report_details("[%C %a] [%s] [%C %a]",p_ch,hash[p_ch],what,n_ch,hash[n_ch]) +end + local function nobreak(head,current) if trace_details then trace_detail(current,"break") @@ -868,8 +883,13 @@ local function process(head,first,last) end end previous = current + +-- elseif id == math_code then +-- upcoming = end_of_math(current).next +-- previous = "start" + else -- glue - local p, n = first.prev, upcoming + local p, n = first.prev, upcoming -- we should remember prev if p and n then local pid, nid = p.id, n.id if pid == glyph_code and nid == glyph_code then @@ -882,7 +902,17 @@ local function process(head,first,last) or pcjk == "half_width_close" or ncjk == "half_width_open" then -- extra compared to korean previous = "start" else -- if head ~= first then +if id == glue_code and first.subtype == userskip_code then -- also prestat check? + -- for the moment no distinction possible between space and userskip + local w = first.spec.width + local s = spacedata[p.font] + if w == s then -- could be option + if trace_details then + trace_detail_between(p,n,"space removed") + end remove_node(head,first,true) + end +end previous = pcjk -- else -- previous = pcjk diff --git a/Master/texmf-dist/tex/context/base/spac-chr.mkiv b/Master/texmf-dist/tex/context/base/spac-chr.mkiv index 6b7c8742f00..0b6ebe0a9ff 100644 --- a/Master/texmf-dist/tex/context/base/spac-chr.mkiv +++ b/Master/texmf-dist/tex/context/base/spac-chr.mkiv @@ -55,26 +55,25 @@ % catcode vector. % \nobreakspace {\begingroup\setalignstateattribute\normalUchar"00A0\endgroup} % 1 = left - -\edef\nobreakspace {\normalUchar"00A0} -\edef\ideographicspace {\normalUchar"2000} -\edef\ideographichalffillspace{\normalUchar"2001} -\edef\twoperemspace {\normalUchar"2002} -\edef\threeperemspace {\normalUchar"2004} -\edef\fourperemspace {\normalUchar"2005} -\edef\sixperemspace {\normalUchar"2006} -\edef\figurespace {\normalUchar"2007} -\edef\punctuationspace {\normalUchar"2008} -\edef\breakablethinspace {\normalUchar"2009} -\edef\hairspace {\normalUchar"200A} -\edef\zerowidthspace {\normalUchar"200B} -\edef\zwnj {\normalUchar"200C} -\edef\zwj {\normalUchar"200D} -\edef\narrownobreakspace {\normalUchar"202F} - -%edef\zerowidthnobreakspace {\normalUchar"FEFF} - -\unexpanded\def\zerowidthnobreakspace{\penalty\plustenthousand\kern\zeropoint} +\edef\nobreakspace {\normalUchar"00A0} % space +\edef\ideographicspace {\normalUchar"2000} % quad/2 +\edef\ideographichalffillspace{\normalUchar"2001} % quad +\edef\twoperemspace {\normalUchar"2002} % quad/2 +% % "2003 % quad == \quad == \hskip\emwidth +\edef\threeperemspace {\normalUchar"2004} % quad/3 +\edef\fourperemspace {\normalUchar"2005} % quad/4 +\edef\sixperemspace {\normalUchar"2006} % quad/6 +\edef\figurespace {\normalUchar"2007} % width of zero +\edef\punctuationspace {\normalUchar"2008} % width of period +\edef\breakablethinspace {\normalUchar"2009} % quad/8 +\edef\hairspace {\normalUchar"200A} % quad/8 +\edef\zerowidthspace {\normalUchar"200B} % 0 +\edef\zwnj {\normalUchar"200C} % 0 +\edef\zwj {\normalUchar"200D} % 0 +\edef\narrownobreakspace {\normalUchar"202F} % quad/8 +% % "205F % space/8 (math) +% \zerowidthnobreakspace {\normalUchar"FEFF} +\udef\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint} % Shortcuts: diff --git a/Master/texmf-dist/tex/context/base/spac-par.mkiv b/Master/texmf-dist/tex/context/base/spac-par.mkiv index 6b7ed4f7df6..b6116eb018f 100644 --- a/Master/texmf-dist/tex/context/base/spac-par.mkiv +++ b/Master/texmf-dist/tex/context/base/spac-par.mkiv @@ -193,13 +193,13 @@ \dowithnextboxcs\spac_postponed_finish\hbox} \def\spac_postponed_finish - {\global\setbox\b_spac_postponed_data\hbox + {\global\setbox\b_spac_postponed_data\hbox % to\zeropoint {\box\b_spac_postponed_data\box\nextbox}% \endgroup} \def\spac_postponed_flush {\ifvoid\b_spac_postponed_data\else - \hbox{\smashedbox\b_spac_postponed_data}% + \hbox{\smashedbox\b_spac_postponed_data}% \box\b_spac_postponed_data \fi \glet\flushpostponednodedata\relax} diff --git a/Master/texmf-dist/tex/context/base/status-files.pdf b/Master/texmf-dist/tex/context/base/status-files.pdf Binary files differindex bbeb36c4574..c946b365c08 100644 --- a/Master/texmf-dist/tex/context/base/status-files.pdf +++ b/Master/texmf-dist/tex/context/base/status-files.pdf diff --git a/Master/texmf-dist/tex/context/base/status-lua.pdf b/Master/texmf-dist/tex/context/base/status-lua.pdf Binary files differindex 9a8da370ab6..0a20f8d0366 100644 --- a/Master/texmf-dist/tex/context/base/status-lua.pdf +++ b/Master/texmf-dist/tex/context/base/status-lua.pdf diff --git a/Master/texmf-dist/tex/context/base/status-mkiv.lua b/Master/texmf-dist/tex/context/base/status-mkiv.lua index be26a2030e8..95139d1d4e2 100644 --- a/Master/texmf-dist/tex/context/base/status-mkiv.lua +++ b/Master/texmf-dist/tex/context/base/status-mkiv.lua @@ -3764,6 +3764,12 @@ return { }, { category = "lua", + filename = "math-frc", + loading = "math-frc", + status = "okay", + }, + { + category = "lua", comment = "okay, but we might have a few more low level definers some day", filename = "math-ini", loading = "math-ini", diff --git a/Master/texmf-dist/tex/context/base/strc-con.mkvi b/Master/texmf-dist/tex/context/base/strc-con.mkvi index 0f5b202b9c8..11cd31983c2 100644 --- a/Master/texmf-dist/tex/context/base/strc-con.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-con.mkvi @@ -105,6 +105,8 @@ \let\currentconstructionlevel \empty \let\currentconstructionhandler\empty +\settrue\c_strc_constructions_define_commands % use with care, might become a proper key + \appendtoks \ifx\currentconstructionparent\empty \letvalue{\??constructionmain\currentconstruction}\currentconstruction @@ -118,8 +120,10 @@ \to \everydefineconstruction \appendtoks - \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}% - \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}% + \ifconditional\c_strc_constructions_define_commands + \setuevalue{\e!start\currentconstruction}{\strc_constructions_start{\currentconstruction}}% + \setuevalue{\e!stop \currentconstruction}{\strc_constructions_stop}% + \fi \to \everydefineconstruction %D Just a basic environment (mostly for testing). We will provide a 'setup' based @@ -961,4 +965,11 @@ \installstructurelistprocessor{construction}{\usestructurelistprocessor{number+title}} +% Helpers: + +\def\currentconstructionnumber{\constructionparameter\s!counter} + +\unexpanded\def\strc_constructions_next_indeed #get#tag#level{\strc_counters_increment_sub{#get{#tag}\s!counter}{#level}} +\unexpanded\def\strc_constructions_reset_indeed#get#tag#level{\strc_counters_reset_sub {#get{#tag}\s!counter}{#level}} + \protect \endinput diff --git a/Master/texmf-dist/tex/context/base/strc-doc.lua b/Master/texmf-dist/tex/context/base/strc-doc.lua index a25d1e1b0da..50a9e67a086 100644 --- a/Master/texmf-dist/tex/context/base/strc-doc.lua +++ b/Master/texmf-dist/tex/context/base/strc-doc.lua @@ -593,6 +593,7 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref local separatorset = "" local conversionset = "" local conversion = "" + local groupsuffix = "" local stopper = "" local starter = "" local connector = "" @@ -605,6 +606,7 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref if separatorset == "" then separatorset = data.separatorset or "" end if conversionset == "" then conversionset = data.conversionset or "" end if conversion == "" then conversion = data.conversion or "" end + if groupsuffix == "" then groupsuffix = data.groupsuffix or "" end if stopper == "" then stopper = data.stopper or "" end if starter == "" then starter = data.starter or "" end if connector == "" then connector = data.connector or "" end @@ -616,6 +618,7 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref if separatorset == "" then separatorset = "default" end if conversionset == "" then conversionset = "default" end -- not used if conversion == "" then conversion = nil end + if groupsuffix == "" then groupsuffix = nil end if stopper == "" then stopper = nil end if starter == "" then starter = nil end if connector == "" then connector = nil end @@ -641,12 +644,13 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref if f and l then -- 0:100, chapter:subsubsection firstprefix = tonumber(f) or sections.getlevel(f) or 0 - lastprefix = tonumber(l) or sections.getlevel(l) or 100 + lastprefix = tonumber(l) or sections.getlevel(l) or 100 else -- 3, section local fl = tonumber(segments) or sections.getlevel(segments) -- generalize if fl then - firstprefix, lastprefix = fl, fl + firstprefix = fl + lastprefix = fl end end end @@ -724,17 +728,28 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref end end -- - if done and connector and kind == 'prefix' then - if result then - -- can't happen as we're in 'direct' - else - applyprocessor(connector) - end - elseif done and stopper then - if result then - result[#result+1] = strippedprocessor(stopper) + if done then + if connector and kind == 'prefix' then + if result then + -- can't happen as we're in 'direct' + else + applyprocessor(connector) + end else - applyprocessor(stopper) +if groupsuffix and kind ~= "prefix" then + if result then + result[#result+1] = strippedprocessor(groupsuffix) + else + applyprocessor(groupsuffix) + end +end + if stopper then + if result then + result[#result+1] = strippedprocessor(stopper) + else + applyprocessor(stopper) + end + end end end return result -- a table ! diff --git a/Master/texmf-dist/tex/context/base/strc-enu.mkvi b/Master/texmf-dist/tex/context/base/strc-enu.mkvi index 185b4177eed..e369bc2e142 100644 --- a/Master/texmf-dist/tex/context/base/strc-enu.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-enu.mkvi @@ -135,11 +135,11 @@ \setevalue{\??enumeration#tag:\s!parent}{\??enumeration}}% {\normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!enumeration,\c!level=#level]}% \setevalue{\??enumeration#tag:\s!parent}{\??enumeration#parent}}% - \setuevalue{\e!next #tag}{\strc_enumerations_next }% - \setuevalue{\c!reset#tag}{\strc_enumerations_reset }% - %setuevalue{\c!set #tag}{\strc_enumerations_set }% - \setuevalue {#tag}{\strc_enumerations_command{#tag}}% - \setuevalue{\e!start#tag}{\strc_enumerations_start {#tag}}% + \setuevalue{\e!next #tag}{\strc_enumerations_next {#tag}{\number#level}}% obsolete + \setuevalue{\c!reset#tag}{\strc_enumerations_reset {#tag}{\number#level}}% obsolete + %setuevalue{\c!set #tag}{\strc_enumerations_set {#tag}{\number#level}}% obsolete + \setuevalue {#tag}{\strc_enumerations_command{#tag}}% we could pass level here as well (faster) + \setuevalue{\e!start#tag}{\strc_enumerations_start {#tag}}% we could pass level here as well (faster) \setuevalue{\e!stop #tag}{\strc_enumerations_stop }} \appendtoks @@ -217,12 +217,9 @@ \let\strc_enumerations_start \strc_descriptions_start \let\strc_enumerations_stop \strc_descriptions_stop -\unexpanded\def\strc_enumerations_next {\strc_counters_increment_sub{\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}} -\unexpanded\def\strc_enumerations_reset {\strc_counters_reset_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}} -%unexpanded\def\strc_enumerations_set#tag{\strc_counters_set_sub {\specificconstructionnumber\currentconstruction}{\currentconstructionlevel}{#tag}} - -\def\currentconstructionnumber {\constructionparameter\s!counter} -\def\specificconstructionnumber#tag{\namedconstructionparameter{#tag}\s!counter} +\unexpanded\def\strc_enumerations_next {\strc_constructions_next_indeed \namedenumerationparameter} % #1#2 +\unexpanded\def\strc_enumerations_reset{\strc_constructions_reset_indeed\namedenumerationparameter} % #1#2 +%unexpanded\def\strc_enumerations_set {\strc_constructions_set_indeed \namedenumerationparameter} % #1#2 %D Counters (maybe we can share this code): (not ok yet, messy with notes) diff --git a/Master/texmf-dist/tex/context/base/strc-flt.mkvi b/Master/texmf-dist/tex/context/base/strc-flt.mkvi index 4fe1a96ff33..8122b953e2f 100644 --- a/Master/texmf-dist/tex/context/base/strc-flt.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-flt.mkvi @@ -26,7 +26,11 @@ % % todo: move variables from page-flt to strc-flt % +% todo: p_name etc +% % todo: less globals! +% +% todo: do all options in lua %D This module is being converted into a mkvi one. %D @@ -464,6 +468,13 @@ % place +\def\strc_floats_analyze_location + {% moved here, will do more + \let\floatlabel \empty + \let\floatcolumn\empty + \let\floatrow \empty + \setfloatmethodvariables\floatlocation} + \unexpanded\def\strc_floats_place#tag% {\flushnotes \page_otr_command_flush_side_floats % here ! @@ -477,6 +488,7 @@ \ifx\floatlocation\empty \edef\floatlocation{\floatparameter\c!default}% beware of a clash between alignment locations \fi + \strc_floats_analyze_location \setupcurrentfloatcaption[\c!reference={#reference},\c!title={#caption},\c!marking=,\c!list=,\c!bookmark=]% \doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal} @@ -522,6 +534,7 @@ \ifsecondargument \setupcurrentfloatuserdata[#userdata]% \fi + \strc_floats_analyze_location \doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal \bgroup \ignorespaces} @@ -778,6 +791,18 @@ \newconditional\usesamefloatnumber +% \startplacefigure[location=here,reference=first, title=first, group=alpha,groupsuffix=.a] +% \externalfigure[dummy][height=2cm] +% \stopplacefigure +% \startplacefigure[location=here,reference=second,title=second,group=alpha,groupsuffix=.b] +% \externalfigure[dummy][height=2cm] +% \stopplacefigure +% +% uses: + +\def\strc_floats_group_index + {\numexpr\ctxcommand{listgroupindex("\currentfloat","\currentfloatgroup")}\relax} + \def\strc_floats_place_packaged_boxes {\expandafter\strc_floats_place_packaged_boxes_indeed\expandafter{\m_strc_floats_saved_userdata}} @@ -789,10 +814,19 @@ \globallet\currentfloatsynchronize\relax \else \edef\currentfloatcounter{\namedcounterparameter\currentfloat\s!name}% - % *1* as an alternative we could set counter parameters here if needed + \edef\currentfloatgroup {\floatcaptionparameter\c!group}% \ifnofloatnumber \else \ifnofloatcaption \else - \strc_counters_increment\currentfloatcounter + \ifx\currentfloatgroup\empty + % independent + \strc_counters_increment\currentfloatcounter + \else\ifcase\strc_floats_group_index + % first in group + \strc_counters_increment\currentfloatcounter + \else + % next in group + \fi \fi \fi \fi + % *1* as an alternative we could set counter parameters here if needed \strc_counters_register_component \s!float \setupcurrentfloatcaption @@ -1969,10 +2003,10 @@ \def\strc_floats_get_box {\ifvisible - \let\floatlabel \empty - \let\floatcolumn\empty - \let\floatrow \empty - \setfloatmethodvariables\floatlocation +% \let\floatlabel \empty +% \let\floatcolumn\empty +% \let\floatrow \empty +% \setfloatmethodvariables\floatlocation % todo: nog algemeen otr \ifdefined\OTRSETsetpreferedcolumnslot \OTRSETsetpreferedcolumnslot\floatcolumn\floatrow diff --git a/Master/texmf-dist/tex/context/base/strc-lab.mkiv b/Master/texmf-dist/tex/context/base/strc-lab.mkiv index 772a9cc19b6..ce4cdcc5ec6 100644 --- a/Master/texmf-dist/tex/context/base/strc-lab.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-lab.mkiv @@ -15,6 +15,8 @@ \unprotect +% todo: reset and increment will go + %D Labels are implemented somewhat inefficient but have the advantage that they %D can be controlled like other constructions. Who knows when that comes in %D handy? @@ -55,10 +57,14 @@ \setevalue{\??label#1:\s!parent}{\??label}}% {\normalexpanded{\defineconstruction[#1][#3][\s!handler=\v!label,\c!level=#2]}% \setevalue{\??label#1:\s!parent}{\??label#3}}% - \setuevalue{\e!next #1}{\strc_labels_next }% - \setuevalue{\c!reset#1}{\strc_labels_reset }% - %setuevalue{\c!set #1}{\strc_labels_set }% - \setuevalue {#1}{\strc_labels_command{#1}}} + \ifconditional\c_strc_constructions_define_commands + \setuevalue{\e!next #1}{\strc_labels_next {#1}{\number#2}}% obsolete + \setuevalue{\c!reset#1}{\strc_labels_reset {#1}{\number#2}}% obsolete + %setuevalue{\c!set #1}{\strc_labels_set {#1}{\number#2}}% obsolete + \setuevalue {#1}{\strc_labels_command{#1}}% + \fi} + +% todo: \strc_labels_command for user \appendtoks \ifx\currentlabelparent\empty @@ -132,9 +138,10 @@ %D Interfaces: \let\strc_labels_command\strc_descriptions_command -\let\strc_labels_next \strc_enumerations_next -\let\strc_labels_reset \strc_enumerations_reset -%let\strc_labels_set \strc_enumerations_set + +\unexpanded\def\strc_labels_next {\strc_constructions_next_indeed \namedlabelparameter} % #1#2 +\unexpanded\def\strc_labels_reset{\strc_constructions_reset_indeed\namedlabelparameter} % #1#2 +%unexpanded\def\strc_labels_set {\strc_constructions_set_indeed \namedlabelparameter} % #1#2 % similar to enumerations diff --git a/Master/texmf-dist/tex/context/base/strc-lst.lua b/Master/texmf-dist/tex/context/base/strc-lst.lua index 95f5e675ecd..ad7dc0f5413 100644 --- a/Master/texmf-dist/tex/context/base/strc-lst.lua +++ b/Master/texmf-dist/tex/context/base/strc-lst.lua @@ -115,12 +115,31 @@ end job.register('structures.lists.collected', tobesaved, initializer) +local groupindices = table.setmetatableindex("table") + +function lists.groupindex(name,group) + local groupindex = groupindices[name] + return groupindex and groupindex[group] or 0 +end + function lists.addto(t) + local m = t.metadata local u = t.userdata if u and type(u) == "string" then t.userdata = helpers.touserdata(u) -- nicer at the tex end end - local m = t.metadata + local numberdata = t.numberdata + local group = numberdata and numberdata.group + if not group then + -- forget about it + elseif group == "" then + group, numberdata.group = nil, nil + else + local groupindex = groupindices[m.name][group] + if groupindex then + numberdata.numbers = cached[groupindex].numberdata.numbers + end + end local r = t.references local i = r and r.internal or 0 -- brrr local p = pushed[i] @@ -134,6 +153,9 @@ function lists.addto(t) if setcomponent then setcomponent(t) -- might move to the tex end end + if group then + groupindices[m.name][group] = p + end return p end @@ -196,11 +218,12 @@ end local nesting = { } function lists.pushnesting(i) - local r = lists.result[i] - local name = r.metadata.name - local numberdata = r and r.numberdata - local n = (numberdata and numberdata.numbers[sections.getlevel(name)]) or 0 - insert(nesting, { number = n, name = name, result = lists.result, parent = r }) + local parent = lists.result[i] + local name = parent.metadata.name + local numberdata = parent and parent.numberdata + local numbers = numberdata and numberdata.numbers + local number = numbers and numbers[sections.getlevel(name)] or 0 + insert(nesting, { number = number, name = name, result = lists.result, parent = parent }) end function lists.popnesting() @@ -656,11 +679,12 @@ commands.listprefixednumber = lists.prefixednumber commands.listprefixedpage = lists.prefixedpage -function commands.addtolist (...) context(lists.addto (...)) end -- we could use variables instead of print -function commands.listsize (...) context(lists.size (...)) end -function commands.listlocation(...) context(lists.location(...)) end -function commands.listlabel (...) context(lists.label (...)) end -function commands.listrealpage(...) context(lists.realpage(...)) end +function commands.addtolist (...) context(lists.addto (...)) end -- we could use variables instead of print +function commands.listsize (...) context(lists.size (...)) end +function commands.listlocation (...) context(lists.location (...)) end +function commands.listlabel (...) context(lists.label (...)) end +function commands.listrealpage (...) context(lists.realpage (...)) end +function commands.listgroupindex(...) context(lists.groupindex(...)) end function commands.listuserdata(...) local str, metadata = lists.userdata(...) diff --git a/Master/texmf-dist/tex/context/base/strc-not.lua b/Master/texmf-dist/tex/context/base/strc-not.lua index b3a50c0d6f4..882e00a4435 100644 --- a/Master/texmf-dist/tex/context/base/strc-not.lua +++ b/Master/texmf-dist/tex/context/base/strc-not.lua @@ -125,7 +125,10 @@ local function setstate(tag,newkind) state.kind = newkind end else +-- if newkind == "postpone" and state.kind == "store" then +-- else state.kind = newkind +-- end end -- state.start can already be set and will be set when an entry is added or flushed return state diff --git a/Master/texmf-dist/tex/context/base/strc-not.mkvi b/Master/texmf-dist/tex/context/base/strc-not.mkvi index 09ea41bc4fa..76816d0355c 100644 --- a/Master/texmf-dist/tex/context/base/strc-not.mkvi +++ b/Master/texmf-dist/tex/context/base/strc-not.mkvi @@ -17,8 +17,8 @@ \unprotect +% todo: finish local rendering % todo: more p_strc_notations_* (outside trial loop) - % todo: see if we can now use \insertpenalties (>0 == some left) \ifdefined\dotagsetnotesymbol \else \let\dotagsetnotesymbol\relax \fi @@ -37,12 +37,12 @@ % textcommand/textstyle/textcolor : set by note commandhandler and used for inline number %D \macros -%D {setupnote,setupnotedefinition} +%D {setupnote,setupnotation} %D %D We can influence footnote typesetting with the setup %D command: %D -%D \showsetup{setupnotes} +%D \showsetup{setupnotation} %D \showsetup{setupnote} %D %D The definition command indicate that we can frame the footnote @@ -131,11 +131,9 @@ {\normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!notation,\c!level=#level]}% \setevalue{\??note#tag:\s!parent}{\??note#parent}% see later for \s!note \setevalue{\??notation#tag:\s!parent}{\??notation#parent}}% - \setuevalue{\e!next #tag}{\strc_notations_next }% - \setuevalue{\c!reset#tag}{\strc_notations_reset }% - %setuevalue{\c!set #tag}{\strc_notations_set }% - %setuevalue {#tag}{\strc_notations_command{\currentnotation}}% - %setuevalue{\e!start#tag}{\strc_notations_start {\currentnotation}{#tag}}% + \setuevalue{\e!next #tag}{\strc_notations_next {#tag}{\number#level}}% obsolete + \setuevalue{\c!reset#tag}{\strc_notations_reset {#tag}{\number#level}}% obsolete + %setuevalue{\c!set #tag}{\strc_notations_set {#tag}{\number#level}}% obsolete \setuevalue {#tag}{\strc_notations_command{#tag}}% \setuevalue{\e!start#tag}{\strc_notations_start {#tag}{#tag}}% okay? \setuevalue{\e!stop #tag}{\strc_notations_stop }} @@ -221,9 +219,9 @@ % \notation[reference=,title=] % \startnotation[ref] title \stopnotation -\let\strc_notations_next \strc_enumerations_next -\let\strc_notations_reset\strc_enumerations_reset -%let\strc_notations_set \strc_enumerations_set +\unexpanded\def\strc_notations_next {\strc_constructions_next_indeed \namednotationparameter} % #1#2 +\unexpanded\def\strc_notations_reset{\strc_constructions_reset_indeed\namednotationparameter} % #1#2 +%unexpanded\def\strc_notations_set {\strc_constructions_set_indeed \namednotationparameter} % #1#2 \unexpanded\def\strc_notations_command#tag% {\begingroup @@ -1476,7 +1474,7 @@ %D These commands can be used like: %D %D \startbuffer -%D \startlocalnotes[width=.3\hsize,n=0] +%D \startlocalnotes[footnote] %D \placetable %D {Some Table} %D \placeontopofeachother @@ -1486,7 +1484,8 @@ %D \VL Bene\footnote{Nota} \VL Nota\footnote{Bene} \VL\SR %D \HL %D \stoptable} -%D {\placelocalnotes} +%D {\setupnotation[footnote][alternative={serried},distance=.5em,after=\hskip1em]% +%D \placelocalnotes[footnote]} %D \stoplocalnotes %D \stopbuffer %D @@ -1728,7 +1727,7 @@ %D Compatibility macros: -\unexpanded\def\setupfootnotedefinition{\setupnotedefinition [\v!footnote]} +\unexpanded\def\setupfootnotedefinition{\setupnotation [\v!footnote]} \unexpanded\def\setupfootnotes {\setupnote [\v!footnote]} \def\footnotetext {\setnotetext [\v!footnote]} \unexpanded\def\placefootnotes {\dodoubleempty\strc_notes_place_footnotes [\v!footnote]} diff --git a/Master/texmf-dist/tex/context/base/strc-num.mkiv b/Master/texmf-dist/tex/context/base/strc-num.mkiv index c4d54e51286..679dd0532c9 100644 --- a/Master/texmf-dist/tex/context/base/strc-num.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-num.mkiv @@ -494,7 +494,7 @@ \edef\p_prefixsegments{\autostructureprefixsegments#3}% \fi % - \edef\currentname{#3\c!name}% + \edef\currentname{#3\s!name}% \ifx\currentname\empty \edef\currentname{#1}% \fi @@ -504,7 +504,7 @@ \fi % \ifx\p_hascaption\v!yes - \xdef\currentstructurecomponentname {#3\c!name}% + \xdef\currentstructurecomponentname {#3\s!name}% \xdef\currentstructurecomponentlevel {#3\c!level}% \edef\currentstructurecomponentexpansion {#3\c!expansion}% \xdef\currentstructurecomponentxmlsetup {#3\c!xmlsetup}% @@ -593,8 +593,10 @@ segments = "\p_prefixsegments", connector = \!!bs#3\c!prefixconnector\!!es, }, - numberdata = { + numberdata = { % more helpers here, like compact elsewhere numbers = structures.counters.compact("\currentcounter",nil,true), + group = "#3\c!group", + groupsuffix = \!!bs#3\c!groupsuffix\!!es, counter = "\currentcounter", separatorset = "#3\c!numberseparatorset", conversion = \!!bs#3\c!numberconversion\!!es, diff --git a/Master/texmf-dist/tex/context/base/strc-reg.mkiv b/Master/texmf-dist/tex/context/base/strc-reg.mkiv index 558f266c837..8c9f040f0d6 100644 --- a/Master/texmf-dist/tex/context/base/strc-reg.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-reg.mkiv @@ -120,7 +120,7 @@ \ifdefined\Word \else \unexpanded\def\Word#1{#1} \fi \appendtoks - \ifconditional\c_strc_registers_defining \else + \ifconditional\c_strc_registers_defining \else % todo: dosingle ... \settrue\c_strc_registers_defining \ctxlua{structures.registers.define('\currentregister')}% \normalexpanded{\presetheadtext[\currentregister=\Word{\currentregister}]}% diff --git a/Master/texmf-dist/tex/context/base/symb-imp-cc.mkiv b/Master/texmf-dist/tex/context/base/symb-imp-cc.mkiv index 742a19f9f74..45ea977328e 100644 --- a/Master/texmf-dist/tex/context/base/symb-imp-cc.mkiv +++ b/Master/texmf-dist/tex/context/base/symb-imp-cc.mkiv @@ -11,33 +11,67 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\definefontfeature - [cc-icons] - [mode=base, - goodies=cc-icons, - unicoding=yes] -\definefontsynonym - [creativecommons] - [cc-icons*cc-icons] +\doiffontpresentelse{ccicons.otf} { % redone ctan version + \definefontfeature + [creativecommons] + [mode=base, + goodies=ccicons, + unicoding=yes] + \definefontsynonym + [creativecommons] + [ccicons*creativecommons] +} { % official version + \definefontfeature + [creativecommons] + [mode=base, + goodies=cc-icons, + unicoding=yes] + \definefontsynonym + [creativecommons] + [cc-icons*creativecommons] +} \startsymbolset[cc] + \definesymbol [sa] [\getnamedglyphdirect{creativecommons}{sa}] \definesymbol [by] [\getnamedglyphdirect{creativecommons}{by}] \definesymbol [cc] [\getnamedglyphdirect{creativecommons}{cc}] \definesymbol [nd] [\getnamedglyphdirect{creativecommons}{nd}] \definesymbol [nc] [\getnamedglyphdirect{creativecommons}{nc}] + \definesymbol [ncus] [\getnamedglyphdirect{creativecommons}{nc}] + \definesymbol [nceu] [\getnamedglyphdirect{creativecommons}{nceu}] + \definesymbol [ncjp] [\getnamedglyphdirect{creativecommons}{ncjp}] + \definesymbol [pd] [\getnamedglyphdirect{creativecommons}{pd}] \definesymbol [sampling] [\getnamedglyphdirect{creativecommons}{sampling}] \definesymbol [share] [\getnamedglyphdirect{creativecommons}{share}] \definesymbol [remix] [\getnamedglyphdirect{creativecommons}{remix}] + \definesymbol [zero] [\getnamedglyphdirect{creativecommons}{zero}] \definesymbol [logo] [\getnamedglyphdirect{creativecommons}{logo}] - \definesymbol [cc-by-sa-nc] [\dontleavehmode\lower.15ex\hbox\bgroup - \getnamedglyphdirect{creativecommons}{cc}\enspace - \getnamedglyphdirect{creativecommons}{by}\enspace - \getnamedglyphdirect{creativecommons}{sa}\enspace - \getnamedglyphdirect{creativecommons}{nc}% - \egroup] + % \definesymbol [cc-by-sa-nc] [\dontleavehmode\lower.15ex\hbox\bgroup + % \getnamedglyphdirect{creativecommons}{cc}\enspace + % \getnamedglyphdirect{creativecommons}{by}\enspace + % \getnamedglyphdirect{creativecommons}{sa}\enspace + % \getnamedglyphdirect{creativecommons}{nc}% + % \egroup] + % + % % more efficient: + % + % \definesymbol [cc-by-sa-nc] [\dontleavehmode\lower.15ex\hbox\bgroup + % \directsymbol{cc}{cc}\enspace\directsymbol{cc}{by}\enspace + % \directsymbol{cc}{sa}\enspace\directsymbol{cc}{nc}% + % \egroup] + % + % % more fun: + + \unexpanded\def\creativecommons#1% + {\dontleavehmode\lower.15\exheight\hbox\bgroup + \let\inbetween\relax + \processseparatedlist[#1][-]{\inbetween\let\inbetween\enspace\directsymbol{cc}}% + \egroup} + + \definesymbol [cc-by-sa-nc] [\creativecommons{cc-by-sa-nc}] \stopsymbolset diff --git a/Master/texmf-dist/tex/context/base/syst-aux.mkiv b/Master/texmf-dist/tex/context/base/syst-aux.mkiv index a5551b954d9..4a8c8d32f26 100644 --- a/Master/texmf-dist/tex/context/base/syst-aux.mkiv +++ b/Master/texmf-dist/tex/context/base/syst-aux.mkiv @@ -3088,6 +3088,14 @@ \fi \unexpanded\def#1} +\unexpanded\def\definemacro#1% + {\ifdefined#1% + \message{[\noexpand#1is already defined]}% + \unexpanded\expandafter\def\expandafter\gobbleddefinition + \else + \unexpanded\expandafter\def + \fi#1} + % \define\hans{hans} % \redefine\hans{hans} % \define\hans#1[]#2#3{hans} diff --git a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv index 9927256b1bb..ec1b78b13cd 100644 --- a/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv +++ b/Master/texmf-dist/tex/context/base/tabl-ntb.mkiv @@ -77,19 +77,36 @@ \ifdefined\dotagTABLEcell \else \let\dotagTABLEcell \relax \fi % todo: namespace \ifdefined\dotagTABLEsignal \else \let\dotagTABLEsignal\relax \fi % todo: namespace -\let\tabl_tnb_next_level\relax +\let\tabl_ntb_next_level\relax -\unexpanded\def\tabl_tnb_cell_start +\newtoks\t_tabl_ntb_cell_start +\newtoks\t_tabl_ntb_cell_stop + +\appendtoks + \naturaltablelocalparameter\c!left + \delayedbegstrut +\to \t_tabl_ntb_cell_start + +\appendtoks + \delayedendstrut + \naturaltablelocalparameter\c!right +\to \t_tabl_ntb_cell_stop + +\appendtoks + \flushpostponednodedata + % maybe: \the\neverypar +\to \t_tabl_ntb_cell_start + +\unexpanded\def\tabl_ntb_cell_start {\inhibitblank \dotagTABLEcell -% \tabl_tnb_next_level + %\tabl_ntb_next_level \usenaturaltablelocalstyleandcolor\c!style\c!color - \everypar{\naturaltablelocalparameter\c!left\delayedbegstrut}} + \everypar\t_tabl_ntb_cell_start} -\unexpanded\def\tabl_tnb_cell_stop +\unexpanded\def\tabl_ntb_cell_stop {\ifhmode - \delayedendstrut - \naturaltablelocalparameter\c!right + \the\t_tabl_ntb_cell_stop \par % added 13/4/2006 \else % not sure yet:\naturaltablelocalparameter\c!right @@ -175,15 +192,15 @@ \global\intablefalse \fi} -\unexpanded\def\tabl_tnb_next_level +\unexpanded\def\tabl_ntb_next_level {\advance\c_tabl_level\plusone \edef\m_tabl_tbl_level{\the\c_tabl_level}} -\unexpanded\def\tabl_tnb_prev_level +\unexpanded\def\tabl_ntb_prev_level {\advance\c_tabl_level\minusone \edef\m_tabl_tbl_level{\the\c_tabl_level}} -\tabl_tnb_next_level % go to level 1 +\tabl_ntb_next_level % go to level 1 \installcorenamespace{naturaltable} % was tbl \installcorenamespace{naturaltablelocal} % was tbltbl @@ -282,7 +299,7 @@ \unexpanded\def\tabl_ntb_set_txt_process#1#2#3#4#5#6% {\expandafter\def\csname\??naturaltabletxt\m_tabl_tbl_level:\number#1:\number#2\endcsname - {\tabl_ntb_cell_process{#3}{#4}[#5]{\tabl_tnb_next_level#6\tabl_tnb_prev_level}}} + {\tabl_ntb_cell_process{#3}{#4}[#5]{\tabl_ntb_next_level#6\tabl_ntb_prev_level}}} \def\tabl_ntb_get_txt#1#2% {\csname\??naturaltabletxt\m_tabl_tbl_level:\number#1:\number#2\endcsname} @@ -1236,7 +1253,7 @@ \fi \dostoptagged} % right spot -\def\tabl_tnb_cell_finalize +\def\tabl_ntb_cell_finalize {\doifnotinset\localwidth{\v!fit,\v!broad}% user set {\scratchdimen\tabl_ntb_get_aut\c_tabl_ntb_col\relax \ifdim\localwidth>\scratchdimen @@ -1522,7 +1539,7 @@ \tabl_ntb_set_dis{#2}{\the\scratchdimen}% \fi \setupcurrentnaturaltablelocal[#3,\c!background=,\c!frame=\v!off]% 25% faster - \inheritednaturaltablelocalframed{\tabl_tnb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_tnb_cell_stop\tabl_tnb_cell_finalize}}% + \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop\tabl_ntb_cell_finalize}}% \scratchdimen\tabl_ntb_get_wid\c_tabl_ntb_col\relax \ifdim\wd\scratchbox>\scratchdimen \ifsqueezeTBLspan @@ -1578,7 +1595,7 @@ {\setbox\scratchbox\hbox {\tabl_ntb_setup_cell{#2}{#3}% \setupcurrentnaturaltablelocal[#4,#1,\c!frame=\v!off,\c!background=]% - \inheritednaturaltablelocalframed{\tabl_tnb_cell_start#5\tabl_tnb_cell_stop}}% + \inheritednaturaltablelocalframed{\tabl_ntb_cell_start#5\tabl_ntb_cell_stop}}% \setbox2\emptyhbox \wd2\wd\scratchbox \ht2\ht\scratchbox @@ -1617,7 +1634,7 @@ {\tabl_ntb_setup_cell{#1}{#2}% \bgroup \setupcurrentnaturaltablelocal[#3,\c!width=\d_tabl_ntb_width,\c!background=,\c!frame=\v!off]% 25% faster - \inheritednaturaltablelocalframed{\tabl_tnb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_tnb_cell_stop}% + \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop}% \egroup} \unexpanded\def\tabl_ntb_cell_process_e#1#2[#3]#4% @@ -1630,7 +1647,7 @@ \else \setupcurrentnaturaltablelocal[\c!color=,\c!width=\d_tabl_ntb_width,\c!height=\d_tabl_ntb_height]% \fi - \inheritednaturaltablelocalframed{\tabl_tnb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_tnb_cell_stop}}% + \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop}}% \hskip\tabl_ntb_get_dis{#2}} \setupTABLE diff --git a/Master/texmf-dist/tex/context/base/task-ini.lua b/Master/texmf-dist/tex/context/base/task-ini.lua index 7f560335331..011ed50ca81 100644 --- a/Master/texmf-dist/tex/context/base/task-ini.lua +++ b/Master/texmf-dist/tex/context/base/task-ini.lua @@ -68,10 +68,13 @@ appendaction("shipouts", "finishers", "attributes.negatives.handler") appendaction("shipouts", "finishers", "attributes.effects.handler") -- disabled appendaction("shipouts", "finishers", "attributes.viewerlayers.handler") -- disabled +--maybe integrate relocate and families + appendaction("math", "normalizers", "noads.handlers.unscript", nil, "nohead") -- always on (maybe disabled) appendaction("math", "normalizers", "noads.handlers.variants", nil, "nohead") -- always on -appendaction("math", "normalizers", "noads.handlers.families", nil, "nohead") -- always on appendaction("math", "normalizers", "noads.handlers.relocate", nil, "nohead") -- always on +appendaction("math", "normalizers", "noads.handlers.families", nil, "nohead") -- always on + appendaction("math", "normalizers", "noads.handlers.render", nil, "nohead") -- always on appendaction("math", "normalizers", "noads.handlers.collapse", nil, "nohead") -- always on appendaction("math", "normalizers", "noads.handlers.resize", nil, "nohead") -- always on diff --git a/Master/texmf-dist/tex/context/base/trac-inf.lua b/Master/texmf-dist/tex/context/base/trac-inf.lua index fdc07d97d39..eefc15a6f7e 100644 --- a/Master/texmf-dist/tex/context/base/trac-inf.lua +++ b/Master/texmf-dist/tex/context/base/trac-inf.lua @@ -50,7 +50,7 @@ local function starttiming(instance) timer.timing = it + 1 end -local function stoptiming(instance, report) +local function stoptiming(instance) local timer = timers[instance or "notimer"] local it = timer.timing if it > 1 then @@ -62,9 +62,6 @@ local function stoptiming(instance, report) local loadtime = stoptime - starttime timer.stoptime = stoptime timer.loadtime = timer.loadtime + loadtime - if report then - statistics.report("load time %0.3f",loadtime) - end timer.timing = 0 return loadtime end diff --git a/Master/texmf-dist/tex/context/base/trac-log.lua b/Master/texmf-dist/tex/context/base/trac-log.lua index 0dadb855ec2..be2a954e3e9 100644 --- a/Master/texmf-dist/tex/context/base/trac-log.lua +++ b/Master/texmf-dist/tex/context/base/trac-log.lua @@ -810,3 +810,7 @@ io.stderr:setvbuf('no') -- windows: > nul 2>&1 -- unix : > null 2>&1 + +if package.helpers.report then + package.helpers.report = logs.reporter("package loader") -- when used outside mtxrun +end diff --git a/Master/texmf-dist/tex/context/base/trac-vis.lua b/Master/texmf-dist/tex/context/base/trac-vis.lua index f68da632fb2..df4909c3ef6 100644 --- a/Master/texmf-dist/tex/context/base/trac-vis.lua +++ b/Master/texmf-dist/tex/context/base/trac-vis.lua @@ -44,6 +44,7 @@ local glue_code = nodecodes.glue local penalty_code = nodecodes.penalty local whatsit_code = nodecodes.whatsit local user_code = nodecodes.user +local gluespec_code = nodecodes.gluespec local kerncodes = nodes.kerncodes local font_kern_code = kerncodes.fontkern @@ -290,6 +291,7 @@ local c_space = "trace:y" local c_skip_a = "trace:c" local c_skip_b = "trace:m" local c_glyph = "trace:o" +local c_white = "trace:w" local c_positive_d = "trace:db" local c_negative_d = "trace:dr" @@ -299,13 +301,19 @@ local c_space_d = "trace:dy" local c_skip_a_d = "trace:dc" local c_skip_b_d = "trace:dm" local c_glyph_d = "trace:do" +local c_white_d = "trace:dw" -local function sometext(str,layer,color) -- we can just paste verbatim together .. no typesteting needed +local function sometext(str,layer,color,textcolor) -- we can just paste verbatim together .. no typesteting needed local text = fast_hpack_string(str,usedfont) local size = text.width local rule = new_rule(size,2*exheight,exheight/2) local kern = new_kern(-size) - setcolor(rule,color) + if color then + setcolor(rule,color) + end + if textcolor then + setlistcolor(text.list,textcolor) + end local info = concat_nodes { rule, kern, @@ -399,7 +407,8 @@ local function whatsit(head,current) -- print("hit whatsit") else local tag = whatsitcodes[what] - info = sometext(formatters["W:%s"](tag and tags[tag] or what),usedfont) + -- maybe different text colors per tag + info = sometext(formatters["W:%s"](tag and tags[tag] or what),usedfont,nil,c_white) info[a_layer] = l_whatsit w_cache[what] = info end @@ -513,8 +522,12 @@ local function ruledbox(head,current,vertical,layer,what,simple) next.prev = info end if prev then +if prev.id == gluespec_code then + -- weird, how can this happen, an inline glue-spec +else info.prev = prev prev.next = info +end end if head == current then return info, info diff --git a/Master/texmf-dist/tex/context/base/util-env.lua b/Master/texmf-dist/tex/context/base/util-env.lua index 283b91c0a11..f4f3ef69f2f 100644 --- a/Master/texmf-dist/tex/context/base/util-env.lua +++ b/Master/texmf-dist/tex/context/base/util-env.lua @@ -206,6 +206,35 @@ function environment.reconstructcommandline(arg,noquote) end end +-- handy in e.g. package.addluapath(environment.relativepath("scripts")) + +function environment.relativepath(path,root) + if not path then + path = "" + end + if not file.is_rootbased_path(path) then + if not root then + root = file.pathpart(environment.ownscript or environment.ownname or ".") + end + if root == "" then + root = "." + end + path = root .. "/" .. path + end + return file.collapsepath(path,true) +end + +-- -- when script lives on e:/tmp we get this: +-- +-- print(environment.relativepath("x/y/z","c:/w")) -- c:/w/x/y/z +-- print(environment.relativepath("x")) -- e:/tmp/x +-- print(environment.relativepath("../x")) -- e:/x +-- print(environment.relativepath("./x")) -- e:/tmp/x +-- print(environment.relativepath("/x")) -- /x +-- print(environment.relativepath("c:/x")) -- c:/x +-- print(environment.relativepath("//x")) -- //x +-- print(environment.relativepath()) -- e:/tmp + -- -- to be tested: -- -- function environment.reconstructcommandline(arg,noquote) diff --git a/Master/texmf-dist/tex/context/base/util-lib.lua b/Master/texmf-dist/tex/context/base/util-lib.lua index 7d43e6c97b2..2ec3d395c28 100644 --- a/Master/texmf-dist/tex/context/base/util-lib.lua +++ b/Master/texmf-dist/tex/context/base/util-lib.lua @@ -90,10 +90,11 @@ local trace_swiglib = false trackers.register("resolvers.swiglib", function(v) local done = false local function requireswiglib(required,version) + local trace_swiglib = trace_swiglib or package.helpers.trace local library = loaded[required] if library == nil then -- initialize a few variables - local required_full = gsub(required,"%.","/") + local required_full = gsub(required,"%.","/") -- package.helpers.lualibfile local required_path = pathpart(required_full) local required_base = nameonly(required_full) local required_name = required_base .. "." .. os.libsuffix @@ -101,7 +102,7 @@ local function requireswiglib(required,version) local engine = environment.ownmain or false -- if trace_swiglib and not done then - local list = resolvers.expandedpathlistfromvariable("lib") + local list = resolvers.expandedpathlistfromvariable("lib") -- fresh, no reuse for i=1,#list do report_swiglib("tds path %i: %s",i,list[i]) end @@ -191,7 +192,7 @@ local function requireswiglib(required,version) -- load and initialize when found if not found_library then if trace_swiglib then - report_swiglib("not found: %a",asked_library) + report_swiglib("not found: %a",required) end library = false else diff --git a/Master/texmf-dist/tex/context/base/util-pck.lua b/Master/texmf-dist/tex/context/base/util-pck.lua index cf1445b4036..7be5e8f4244 100644 --- a/Master/texmf-dist/tex/context/base/util-pck.lua +++ b/Master/texmf-dist/tex/context/base/util-pck.lua @@ -108,11 +108,12 @@ function packers.pack(t,p,shared) if #p.index > 0 then t.packer = { version = p.version or packers.version, - keys = p.keys, - index = p.index, + keys = p.keys, + index = p.index, } end - p.hash, p.index = { }, { } + p.hash = { } + p.index = { } end end @@ -138,3 +139,6 @@ end function packers.strip(p) p.hash = nil end + +-- We could have a packer.serialize where we first flush the shared table +-- and then use inline a reference . This saves an unpack. diff --git a/Master/texmf-dist/tex/context/base/util-sql-imp-swiglib.lua b/Master/texmf-dist/tex/context/base/util-sql-imp-swiglib.lua index 9a22477a9b1..719620a6f9c 100644 --- a/Master/texmf-dist/tex/context/base/util-sql-imp-swiglib.lua +++ b/Master/texmf-dist/tex/context/base/util-sql-imp-swiglib.lua @@ -110,7 +110,10 @@ local typemap = mysql.MYSQL_TYPE_VAR_STRING and { -- real_escape_string local function finish(t) - mysql_free_result(t._result_) + local r = t._result_ + if r then + mysql_free_result(r) + end end -- will become metatable magic @@ -203,9 +206,17 @@ local mt = { __index = { numrows = numrows, getcolnames = getcolnames, getcoltypes = getcoltypes, + -- fallback + _result_ = nil, + names = { }, + types = { }, + noffields = 0, + nofrows = 0, } } +local nt = setmetatable({},mt) + -- session local function close(t) @@ -218,24 +229,28 @@ local function execute(t,query) local result = mysql_execute_query(connection,query,#query) if result == 0 then local result = mysql_store_result(connection) - mysql_field_seek(result,0) - local nofrows = mysql_num_rows(result) or 0 - local noffields = mysql_num_fields(result) - local names = { } - local types = { } - for i=1,noffields do - local field = mysql_fetch_field(result) - names[i] = field.name - types[i] = field.type + if result then + mysql_field_seek(result,0) + local nofrows = mysql_num_rows(result) or 0 + local noffields = mysql_num_fields(result) + local names = { } + local types = { } + for i=1,noffields do + local field = mysql_fetch_field(result) + names[i] = field.name + types[i] = field.type + end + local t = { + _result_ = result, + names = names, + types = types, + noffields = noffields, + nofrows = nofrows, + } + return setmetatable(t,mt) + else + return nt end - local t = { - _result_ = result, - names = names, - types = types, - noffields = noffields, - nofrows = nofrows, - } - return setmetatable(t,mt) end end return false diff --git a/Master/texmf-dist/tex/context/fonts/cc-icons.lfg b/Master/texmf-dist/tex/context/fonts/cc-icons.lfg index 2739918afee..fd0759b78d0 100644 --- a/Master/texmf-dist/tex/context/fonts/cc-icons.lfg +++ b/Master/texmf-dist/tex/context/fonts/cc-icons.lfg @@ -13,10 +13,14 @@ return { by = utfbyte("b"), cc = utfbyte("c"), nd = utfbyte("d"), - nc = utfbyte("n"), + -- nceu = utfbyte("e"), sampling = utfbyte("m"), - share = utfbyte("s"), + nc = utfbyte("n"), + pd = utfbyte("p"), remix = utfbyte("r"), + share = utfbyte("s"), + -- ncjp = utfbyte("y"), + -- zero = utfbyte("z"), logo = utfbyte("C"), }, }, diff --git a/Master/texmf-dist/tex/context/fonts/ccicons.lfg b/Master/texmf-dist/tex/context/fonts/ccicons.lfg new file mode 100644 index 00000000000..b79b3fb93a8 --- /dev/null +++ b/Master/texmf-dist/tex/context/fonts/ccicons.lfg @@ -0,0 +1,27 @@ +local utfbyte = utf.byte + +return { + name = "cc-icons", + version = "1.00", + comment = "Goodies that complement creative commons icons (ctan variant).", + author = "Hans Hagen", + copyright = "ConTeXt development team", + remapping = { + tounicode = true, + unicodes = { + sa = utfbyte("a"), + by = utfbyte("b"), + cc = utfbyte("c"), -- logo (so not the same name) + nd = utfbyte("d"), + nceu = utfbyte("e"), + sampling = utfbyte("m"), + nc = utfbyte("n"), + pd = utfbyte("p"), + remix = utfbyte("r"), + share = utfbyte("s"), + ncjp = utfbyte("y"), + zero = utfbyte("z"), + logo = 0x00A9, -- copyright + }, + }, +} diff --git a/Master/texmf-dist/tex/context/fonts/lucida-opentype-math.lfg b/Master/texmf-dist/tex/context/fonts/lucida-opentype-math.lfg index c8556ebca5b..946458deaa7 100644 --- a/Master/texmf-dist/tex/context/fonts/lucida-opentype-math.lfg +++ b/Master/texmf-dist/tex/context/fonts/lucida-opentype-math.lfg @@ -12,6 +12,11 @@ return { calligraphic = { feature = 'ss04', value = 1, comment = "Mathematical Alternative Calligraphic Characters" }, zero = { feature = 'ss05', value = 1, comment = "Mathematical Alternative Zero" }, partial = { feature = 'ss20', value = 1, comment = "Mathematical Alternative Upright Partial Differential" }, - } - } + }, + dimensions = { + default = { -- experimental values + [0x2044] = { xoffset = 275, width = 600 }, + }, + }, + }, } |