diff options
Diffstat (limited to 'tex')
| -rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
| -rw-r--r-- | tex/context/base/context-version.pdf | bin | 4434 -> 4444 bytes | |||
| -rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
| -rw-r--r-- | tex/context/base/data-res.lua | 86 | ||||
| -rw-r--r-- | tex/context/base/file-job.lua | 114 | ||||
| -rw-r--r-- | tex/context/base/font-otf.lua | 4 | ||||
| -rw-r--r-- | tex/context/base/lpdf-epd.lua | 7 | ||||
| -rw-r--r-- | tex/context/base/mlib-run.lua | 18 | ||||
| -rw-r--r-- | tex/context/base/publ-aut.lua | 100 | ||||
| -rw-r--r-- | tex/context/base/publ-dat.lua | 3 | ||||
| -rw-r--r-- | tex/context/base/publ-ini.lua | 161 | ||||
| -rw-r--r-- | tex/context/base/sort-ini.lua | 1 | ||||
| -rw-r--r-- | tex/context/base/status-files.pdf | bin | 24925 -> 24971 bytes | |||
| -rw-r--r-- | tex/context/base/status-lua.pdf | bin | 326318 -> 326426 bytes | |||
| -rw-r--r-- | tex/context/base/syst-aux.mkiv | 2 | ||||
| -rw-r--r-- | tex/context/base/syst-ini.mkiv | 4 | ||||
| -rw-r--r-- | tex/context/base/tabl-xtb.lua | 259 | ||||
| -rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 6 | 
18 files changed, 490 insertions, 279 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 71b4c6066..5bd79250a 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@  %C therefore copyrighted by \PRAGMA. See mreadme.pdf for  %C details. -\newcontextversion{2014.07.14 19:25} +\newcontextversion{2014.07.17 13:24}  %D This file is loaded at runtime, thereby providing an excellent place for  %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex 6ba007d52..fe0a62735 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index e318bdea9..6ce975ae7 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@  %D up and the dependencies are more consistent.  \edef\contextformat {\jobname} -\edef\contextversion{2014.07.14 19:25} +\edef\contextversion{2014.07.17 13:24}  \edef\contextkind   {beta}  %D For those who want to use this: diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index dfb50413f..69bdc508c 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -710,12 +710,19 @@ function resolvers.resetextrapath()  end  function resolvers.registerextrapath(paths,subpaths) -    paths = settings_to_array(paths) -    subpaths = settings_to_array(subpaths) -    local ep = instance.extra_paths or { } -    local oldn = #ep -    local newn = oldn -    local nofpaths = #paths +    if not subpaths or subpaths == "" then +        if not paths or path == "" then +            return -- invalid spec +        elseif done[paths] then +            return -- already done +        end +    end +    local paths       = settings_to_array(paths) +    local subpaths    = settings_to_array(subpaths) +    local ep          = instance.extra_paths or { } +    local oldn        = #ep +    local newn        = oldn +    local nofpaths    = #paths      local nofsubpaths = #subpaths      if nofpaths > 0 then          if nofsubpaths > 0 then @@ -762,14 +769,50 @@ function resolvers.registerextrapath(paths,subpaths)      end  end +-- local function made_list(instance,list,extra_too) +--     if not extra_too then +--         return list +--     end +--     local ep = instance.extra_paths +--     if not ep or #ep == 0 then +--         return list +--     end +--     local done, new, newn = { }, { }, 0 +--     -- honour . .. ../.. but only when at the start +--     for k=1,#list do +--         local v = list[k] +--         if not done[v] then +--             if find(v,"^[%.%/]$") then +--                 done[v] = true +--                 newn = newn + 1 +--                 new[newn] = v +--             else +--                 break +--             end +--         end +--     end +--     -- first the extra paths +--     for k=1,#ep do +--         local v = ep[k] +--         if not done[v] then +--             done[v] = true +--             newn = newn + 1 +--             new[newn] = v +--         end +--     end +--     -- next the formal paths +--     for k=1,#list do +--         local v = list[k] +--         if not done[v] then +--             done[v] = true +--             newn = newn + 1 +--             new[newn] = v +--         end +--     end +--     return new +-- end +  local function made_list(instance,list,extra_too) -    if not extra_too then -        return list -    end -    local ep = instance.extra_paths -    if not ep or #ep == 0 then -        return list -    end      local done, new, newn = { }, { }, 0      -- honour . .. ../.. but only when at the start      for k=1,#list do @@ -785,12 +828,17 @@ local function made_list(instance,list,extra_too)          end      end      -- first the extra paths -    for k=1,#ep do -        local v = ep[k] -        if not done[v] then -            done[v] = true -            newn = newn + 1 -            new[newn] = v +    if extra_too then +        local ep = instance.extra_paths +        if ep and #ep > 0 then +            for k=1,#ep do +                local v = ep[k] +                if not done[v] then +                    done[v] = true +                    newn = newn + 1 +                    new[newn] = v +                end +            end          end      end      -- next the formal paths diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index bbc7abcd0..85fa996de 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -44,6 +44,12 @@ local cleanpath         = resolvers.cleanpath  local inputstack        = resolvers.inputstack  local resolveprefix     = resolvers.resolve +local hasscheme         = url.hasscheme + +local jobresolvers      = resolvers.jobs + +local registerextrapath = resolvers.registerextrapath +  local v_outer           = variables.outer  local v_text            = variables.text  local v_project         = variables.project @@ -57,7 +63,7 @@ local c_prefix          = variables.prefix  local function findctxfile(name) -- loc ? any ?      if is_qualified_path(name) then -- maybe when no suffix do some test for tex          return name -    elseif not url.hasscheme(name) then +    elseif not hasscheme(name) then          return resolvers.finders.byscheme("loc",name) or ""      else          return resolvers.findtexfile(name) or "" @@ -82,11 +88,11 @@ function commands.locatefilepath(name)  end  function commands.usepath(paths) -    resolvers.registerextrapath(paths) +    registerextrapath(paths)  end  function commands.usesubpath(subpaths) -    resolvers.registerextrapath(nil,subpaths) +    registerextrapath(nil,subpaths)  end  function commands.allinputpaths() @@ -246,7 +252,7 @@ end  commands.useanyfile = useanyfile -function resolvers.jobs.usefile(name,onlyonce,notext) +function jobresolvers.usefile(name,onlyonce,notext)      local s = suffixes[suffixonly(name)]      if s then       -- s(removesuffix(name),onlyonce,notext) @@ -404,10 +410,11 @@ luatex.registerstopactions(function()      logspoptarget()  end) -job.structure            = job.structure or { } -job.structure.collected  = job.structure.collected or { } -job.structure.tobesaved  = root -job.structure.components = { } +local jobstructure      = job.structure or { } +job.structure           = jobstructure +jobstructure.collected  = jobstructure.collected or { } +jobstructure.tobesaved  = root +jobstructure.components = { }  local function initialize()      local function collect(root,result) @@ -423,7 +430,7 @@ local function initialize()          end          return result      end -    job.structure.components = collect(job.structure.collected,{}) +    jobstructure.components = collect(jobstructure.collected,{})  end  job.register('job.structure.collected',root,initialize) @@ -435,48 +442,63 @@ local context_processfilemany = context.processfilemany  local context_processfileonce = context.processfileonce  local context_processfilenone = context.processfilenone +local function processfilecommon(name,action) +    if not hasscheme(name) then +        local path = dirname(name) +        if path ~= "" then +            registerextrapath(path) +            report_jobfiles("adding search path %a",path) +        end +    end +    action(name) +end + +local function processfilemany(name) processfilecommon(name,context_processfilemany) end +local function processfileonce(name) processfilecommon(name,context_processfileonce) end +local function processfilenone(name) processfilecommon(name,context_processfilenone) end +  local processors = utilities.storage.allocate {   -- [v_outer] = { - --     [v_text]        = { "many", context_processfilemany }, - --     [v_project]     = { "once", context_processfileonce }, - --     [v_environment] = { "once", context_processfileonce }, - --     [v_product]     = { "once", context_processfileonce }, - --     [v_component]   = { "many", context_processfilemany }, + --     [v_text]        = { "many", processfilemany }, + --     [v_project]     = { "once", processfileonce }, + --     [v_environment] = { "once", processfileonce }, + --     [v_product]     = { "once", processfileonce }, + --     [v_component]   = { "many", processfilemany },   -- },      [v_text] = { -        [v_text]        = { "many", context_processfilemany }, -        [v_project]     = { "once", context_processfileonce }, -- dubious -        [v_environment] = { "once", context_processfileonce }, -        [v_product]     = { "many", context_processfilemany }, -- dubious -        [v_component]   = { "many", context_processfilemany }, +        [v_text]        = { "many", processfilemany }, +        [v_project]     = { "once", processfileonce }, -- dubious +        [v_environment] = { "once", processfileonce }, +        [v_product]     = { "many", processfilemany }, -- dubious +        [v_component]   = { "many", processfilemany },      },      [v_project] = { -        [v_text]        = { "many", context_processfilemany }, -        [v_project]     = { "none", context_processfilenone }, -        [v_environment] = { "once", context_processfileonce }, -        [v_product]     = { "none", context_processfilenone }, -        [v_component]   = { "none", context_processfilenone }, +        [v_text]        = { "many", processfilemany }, +        [v_project]     = { "none", processfilenone }, +        [v_environment] = { "once", processfileonce }, +        [v_product]     = { "none", processfilenone }, +        [v_component]   = { "none", processfilenone },      },      [v_environment] = { -        [v_text]        = { "many", context_processfilemany }, -        [v_project]     = { "none", context_processfilenone }, -        [v_environment] = { "once", context_processfileonce }, -        [v_product]     = { "none", context_processfilenone }, -        [v_component]   = { "none", context_processfilenone }, +        [v_text]        = { "many", processfilemany }, +        [v_project]     = { "none", processfilenone }, +        [v_environment] = { "once", processfileonce }, +        [v_product]     = { "none", processfilenone }, +        [v_component]   = { "none", processfilenone },      },      [v_product] = { -        [v_text]        = { "many", context_processfilemany }, -        [v_project]     = { "once", context_processfileonce }, -        [v_environment] = { "once", context_processfileonce }, -        [v_product]     = { "many", context_processfilemany }, -        [v_component]   = { "many", context_processfilemany }, +        [v_text]        = { "many", processfilemany }, +        [v_project]     = { "once", processfileonce }, +        [v_environment] = { "once", processfileonce }, +        [v_product]     = { "many", processfilemany }, +        [v_component]   = { "many", processfilemany },      },      [v_component] = { -        [v_text]        = { "many", context_processfilemany }, -        [v_project]     = { "once", context_processfileonce }, -        [v_environment] = { "once", context_processfileonce }, -        [v_product]     = { "none", context_processfilenone }, -        [v_component]   = { "many", context_processfilemany }, +        [v_text]        = { "many", processfilemany }, +        [v_project]     = { "once", processfileonce }, +        [v_environment] = { "once", processfileonce }, +        [v_product]     = { "none", processfilenone }, +        [v_component]   = { "many", processfilemany },      }  } @@ -496,7 +518,7 @@ local stop = {      [v_component]   = context.stoptext,  } -resolvers.jobs.processors = processors +jobresolvers.processors = processors  local function topofstack(what)      local stack = stacks[what] @@ -523,13 +545,13 @@ local function justacomponent()      end  end -resolvers.jobs.productcomponent = productcomponent -resolvers.jobs.justacomponent   = justacomponent +jobresolvers.productcomponent = productcomponent +jobresolvers.justacomponent   = justacomponent -function resolvers.jobs.currentproject    () return topofstack(v_project    ) end -function resolvers.jobs.currentproduct    () return topofstack(v_product    ) end -function resolvers.jobs.currentcomponent  () return topofstack(v_component  ) end -function resolvers.jobs.currentenvironment() return topofstack(v_environment) end +function jobresolvers.currentproject    () return topofstack(v_project    ) end +function jobresolvers.currentproduct    () return topofstack(v_product    ) end +function jobresolvers.currentcomponent  () return topofstack(v_component  ) end +function jobresolvers.currentenvironment() return topofstack(v_environment) end  local done     = { }  local tolerant = false -- too messy, mkii user with the wrong sructure should adapt diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 430f18a2f..8e9a43929 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -699,7 +699,9 @@ end                                  unicode = cidunicodes[index]                              end                              if unicode and descriptions[unicode] then -                                report_otf("preventing glyph %a at index %H to overload unicode %U",name or "noname",index,unicode) +                                if trace_private then +                                    report_otf("preventing glyph %a at index %H to overload unicode %U",name or "noname",index,unicode) +                                end                                  unicode = -1                              end                              if not unicode or unicode == -1 then -- or unicode >= criterium then diff --git a/tex/context/base/lpdf-epd.lua b/tex/context/base/lpdf-epd.lua index a7399f6b4..c37336d07 100644 --- a/tex/context/base/lpdf-epd.lua +++ b/tex/context/base/lpdf-epd.lua @@ -252,7 +252,7 @@ local function getlayers(document)              local n = layers.n              for i=1,n do                  local layer = layers[i] ---~ print(document.xrefs[layer]) +             -- print(document.xrefs[layer])                  t[i] = layer.Name              end              t.n = n @@ -261,6 +261,10 @@ local function getlayers(document)      end  end +local function getstructure(document) +    -- this might become a tree +    return document.Catalog.StructTreeRoot +end  local function getpages(document,Catalog)      local data  = document.data @@ -353,6 +357,7 @@ function lpdf.epdf.load(filename)              document.widgets       = delayed(document,"widgets",      function() return getnames(document,Catalog.Names and Catalog.Names.AcroForm) end)              document.embeddedfiles = delayed(document,"embeddedfiles",function() return getnames(document,Catalog.Names and Catalog.Names.EmbeddedFiles) end)              document.layers        = delayed(document,"layers",       function() return getlayers(document) end) +            document.structure     = delayed(document,"structure",    function() return getstructure(document) end)          else              document = false          end diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 2a34f44d5..bd00cc260 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -106,14 +106,24 @@ end  mplib.preprocessed = preprocessed -- helper +local function validftype(ftype) +    if ftype == "" then +        -- whatever +    elseif ftype == 0 then +        -- mplib bug +    else +        return ftype +    end +end +  finders.file = function(specification,name,mode,ftype) -    return preprocessed(resolvers.findfile(name,ftype)) +    return preprocessed(resolvers.findfile(name,validftype(ftype)))  end  local function i_finder(name,mode,ftype) -- fake message for mpost.map and metafun.mpvi      local specification = url.hashed(name)      local finder = finders[specification.scheme] or finders.file -    return finder(specification,name,mode,ftype) +    return finder(specification,name,mode,validftype(ftype))  end  local function o_finder(name,mode,ftype) @@ -123,9 +133,9 @@ end  local function finder(name,mode,ftype)      if mode == "w" then -        return o_finder(name,mode,ftype) +        return o_finder(name,mode,validftype(ftype))      else -        return i_finder(name,mode,ftype) +        return i_finder(name,mode,validftype(ftype))      end  end diff --git a/tex/context/base/publ-aut.lua b/tex/context/base/publ-aut.lua index 0167d66e7..73d50f614 100644 --- a/tex/context/base/publ-aut.lua +++ b/tex/context/base/publ-aut.lua @@ -28,8 +28,11 @@ local publications    = publications or { }  local datasets        = publications.datasets or { }  publications.datasets = datasets -publications.authors  = publications.authors or { } -local authors         = publications.authors +local writers         = publications.writers or { } +publications.writers  = writers + +local authors         = publications.authors or { } +publications.authors  = authors  -- local function makesplitter(separator)  --     return Ct { "start", @@ -379,78 +382,7 @@ local splitter = sorters.splitters.utf  local pubsorters = { }  authors.sorters  = pubsorters --- local function assemble(snippets,key) ---     -- maybe an option is to also sort the authors first ---     if not key then ---         return "" ---     end ---     local n = #key ---     if n == 0 then ---         return "" ---     end ---     local s = 0 ---     for i=1,n do ---         local k = key[i] ---         local vons     = k.vons ---         local surnames = k.surnames ---         local initials = k.initials ---         if vons and #vons > 0 then ---             s = s + 1 ; snippets[s] = concat(vons," ") ---         end ---         if surnames and #surnames > 0 then ---             s = s + 1 ; snippets[s] = concat(surnames," ") ---         end ---         if initials and #initials > 0 then ---             s = s + 1 ; snippets[s] = concat(initials," ") ---         end ---     end ---     local result = concat(snippets," ",1,s) ---     return strip(result) --- end - --- local function byauthor(dataset,list,sorttype_a,sorttype_b,sorttype_c) ---     local luadata  = datasets[dataset].luadata ---     local details  = datasets[dataset].details ---     local valid    = { } ---     local splitted = { } ---     table.setmetatableindex(splitted,function(t,k) -- could be done in the sorter but seldom that many shared ---         local v = splitter(k,true)                 -- in other cases ---         t[k] = v ---         return v ---     end) ---     local snippets = { } ---     for i=1,#list do ---         -- either { tag, tag, ... } or { { tag, index }, { tag, index } } ---         local li        = list[i] ---         local tag       = type(li) == "string" and li or li[1] ---         local entry     = luadata[tag] ---         local detail    = details[tag] ---         local suffix    = tostring(i) ---         local year      = nil ---         local assembled = nil ---         if entry and detail then ---             assembled = assemble(snippets,detail.author or detail.editor) ---             year      = entry.year or "9998" ---         else ---             assembled = "" ---             year      = "9999" ---         end ---         valid[i] = { ---             index  = i, ---             split  = { ---                 splitted[strip(assembled)], ---                 splitted[year], ---                 splitted[suffix], ---                 splitted[entry.journal or ""], ---                 splitted[entry.title   or ""], ---                 splitted[entry.pages   or ""], ---             }, ---         } ---     end ---     return valid --- end - -local function writer(snippets,key) +local function writer(key,snippets)      if not key then          return ""      end @@ -458,6 +390,9 @@ local function writer(snippets,key)      if n == 0 then          return ""      end +    if not snippets then +        snippets = { } +    end      local s = 0      for i=1,n do          local k = key[i] @@ -474,10 +409,12 @@ local function writer(snippets,key)              s = s + 1 ; snippets[s] = concat(initials," ")          end      end -    local result = concat(snippets," ",1,s) -    return strip(result) +    return concat(snippets," ",1,s)  end +writers.author = writer +writers.editor = editor +  local function newsplitter(splitter)      return table.setmetatableindex({},function(t,k) -- could be done in the sorter but seldom that many shared          local v = splitter(k,true)                  -- in other cases @@ -502,11 +439,11 @@ local function byauthor(dataset,list,method) -- todo: yearsuffix              result[i] = {                  index  = i,                  split  = { -                    splitted[writer(snippets,detail.author or detail.editor or "")], -                    splitted[entry.year     or "9998"], -                    splitted[entry.journal  or ""], -                    splitted[entry.title    or ""], -                    splitted[entry.pages    or ""], +                    splitted[strip(writer(detail.author or detail.editor or "",snippets))], +                    splitted[entry.year or "9998"], +                    splitted[strip(entry.journal or "")], +                    splitted[strip(entry.title or "")], +                    splitted[entry.pages or ""],                      splitted[tostring(i)],                  },              } @@ -527,6 +464,7 @@ local function byauthor(dataset,list,method) -- todo: yearsuffix      return result  end +authors.sorters.writer = writer  authors.sorters.author = byauthor  function authors.sorted(dataset,list,sorttype) -- experimental diff --git a/tex/context/base/publ-dat.lua b/tex/context/base/publ-dat.lua index 1823b33c2..f35ae2fa9 100644 --- a/tex/context/base/publ-dat.lua +++ b/tex/context/base/publ-dat.lua @@ -48,6 +48,9 @@ local publications      = publications  local datasets          = publications.datasets or { }  publications.datasets   = datasets +local writers           = publications.writers or { } +publications.writers    = writers +  publications.statistics = publications.statistics or { }  local publicationsstats = publications.statistics diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 4d4c9ef09..191e11db8 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -23,7 +23,7 @@ local settings_to_array, settings_to_set = utilities.parsers.settings_to_array,  local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash  local setmetatableindex = table.setmetatableindex  local lpegmatch = lpeg.match -local P, C, Ct, R, Carg = lpeg.P, lpeg.C, lpeg.Ct, lpeg.R, lpeg.Carg +local P, S, C, Ct, R, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.R, lpeg.Carg  local report           = logs.reporter("publications")  local report_cite      = logs.reporter("publications","cite") @@ -35,6 +35,7 @@ local trace_missing    = false  trackers.register("publications.cite.missing",  local trace_references = false  trackers.register("publications.cite.references", function(v) trace_references = v end)  local datasets       = publications.datasets +local writers        = publications.writers  local variables      = interfaces.variables @@ -904,6 +905,39 @@ setmetatableindex(renderings,function(t,k)      return v  end) +-- helper + +-- local function sortedtags(dataset,list,sorttype) +--     local luadata = datasets[dataset].luadata +--     local valid = { } +--     for i=1,#list do +--         local tag = list[i] +--         local entry = luadata[tag] +--         if entry then +--             local key = entry[sorttype] +--             if key then +--                 valid[#valid+1] = { +--                     tag   = tag, +--                     split = sortsplitter(sortstripper(key)) +--                 } +--             end +--         end +--     end +--     if #valid == 0 or #valid ~= #list then +--         return list +--     else +--         sorters.sort(valid,basicsorter) +--         for i=1,#valid do +--             valid[i] = valid[i].tag +--         end +--         return valid +--     end +-- end +-- +--     if sorttype and sorttype ~= "" then +--         tags = sortedtags(dataset,tags,sorttype) +--     end +  -- why shorts vs tags: only for sorting  function lists.register(dataset,tag,short) -- needs checking now that we split @@ -1060,6 +1094,82 @@ function lists.collectentries(specification)      filtermethod(dataset,rendering,keyword)  end +-- experiment + +local splitspec = lpeg.splitat(S(":.")) +local splitter  = sorters.splitters.utf +local strip     = sorters.strip + +local function newsplitter(splitter) +    return table.setmetatableindex({},function(t,k) -- could be done in the sorter but seldom that many shared +        local v = splitter(k,true)                  -- in other cases +        t[k] = v +        return v +    end) +end + +local template = [[ +    local strip   = sorters.strip +    local writers = publications.writers +    return function(entry,detail,splitted,i) -- snippets +        return { +            index = i, +            split = { %s, splitted[tostring(i)] } +        } +    end +]] + +local function byspec(dataset,list,method) -- todo: yearsuffix +    local luadata  = datasets[dataset].luadata +    local details  = datasets[dataset].details +    local result   = { } +    local splitted = newsplitter(splitter) -- saves mem + -- local snippets = { } -- saves mem +    local fields   = settings_to_array(method) +    for i=1,#fields do +        local f = settings_to_array(fields[i]) +        local r = { } +        for i=1,#f do +            local a, b = lpegmatch(splitspec,f[i]) +            if b then +                if a == "detail" or a == "entry" then +                    local w = writers[b] +                    if w then +                     -- r[#r+1] = formatters["(%s.%s and writers[%q](%s.%s,snippets))"](a,b,b,a,b) +                        r[#r+1] = formatters["(%s.%s and writers[%q](%s.%s))"](a,b,b,a,b) +                    else +                        r[#r+1] = formatters["%s.%s"](a,b,a,b) +                    end +                end +            elseif a then +                r[#r+1] = formatters["%s"](a) +            end +        end +        r[#r+1] = '""' +        fields[i] = "splitted[strip(" .. concat(r," or ") .. ")]" +    end +    local action  = formatters[template](concat(fields,", ")) +    local prepare = loadstring(action) +    if prepare then +        prepare = prepare() +        local dummy = { } +        for i=1,#list do +            -- either { tag, tag, ... } or { { tag, index }, { tag, index } } +            local li     = list[i] +            local tag    = type(li) == "string" and li or li[1] +            local entry  = luadata[tag] +            local detail = details[tag] +            if entry and detail then +                result[i] = prepare(entry,detail,splitted,i) -- ,snippets) +            else +                result[i] = prepare(dummy,dummy,splitted,i) -- ,snippets) +            end +        end +    end +    return result +end + +  lists.sorters = {      [v_short] = function(dataset,rendering,list)          local shorts = rendering.shorts @@ -1106,6 +1216,20 @@ lists.sorters = {   --     end   --     sort(list,compare)   -- end, +    [v_default] = function(dataset,rendering,list,sorttype) -- experimental +        local valid = byspec(dataset,list,sorttype) +        if #valid == 0 or #valid ~= #list then +            -- nothing to sort +        else +            -- if needed we can wrap compare and use the list directly but this is cleaner +            sorters.sort(valid,sortcomparer) +            for i=1,#valid do +                local v = valid[i] +                valid[i] = list[v.index] +            end +            return valid +        end +    end,      [v_author] = function(dataset,rendering,list)          local valid = publications.authors.sorters.author(dataset,list)          if #valid == 0 or #valid ~= #list then @@ -1152,7 +1276,7 @@ function lists.flushentries(dataset,sorttype)      local repeated  = rendering.repeated == v_yes      local luadata = datasets[dataset].luadata      if type(sorter) == "function" then -        list = sorter(dataset,rendering,list) or list +        list = sorter(dataset,rendering,list,sorttype) or list      end   -- local details = datasets[dataset].details      for i=1,#list do @@ -1208,39 +1332,6 @@ commands.btxflushlistentries     = lists.flushentries  local citevariants        = { }  publications.citevariants = citevariants --- helper - -local function sortedtags(dataset,list,sorttype) -    local luadata = datasets[dataset].luadata -    local valid = { } -    for i=1,#list do -        local tag = list[i] -        local entry = luadata[tag] -        if entry then -            local key = entry[sorttype] -            if key then -                valid[#valid+1] = { -                    tag   = tag, -                    split = sortsplitter(sortstripper(key)) -                } -            end -        end -    end -    if #valid == 0 or #valid ~= #list then -        return list -    else -        sorters.sort(valid,basicsorter) -        for i=1,#valid do -            valid[i] = valid[i].tag -        end -        return valid -    end -end - ---     if sorttype and sorttype ~= "" then ---         tags = sortedtags(dataset,tags,sorttype) ---     end -  local optionalspace  = lpeg.patterns.whitespace^0  local prefixsplitter = optionalspace * lpeg.splitat(optionalspace * P("::") * optionalspace) diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index ab6ad0649..3937c77d5 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -535,6 +535,7 @@ local function prepare()      pattern = Cs( (          characters.tex.toutfpattern()        + lpeg.patterns.whitespace / "\000" +      + (P("\\") / "") * R("AZ")^0 * (P(-1) + #(1-R("AZ")))        + (P("\\") * P(1) * R("az","AZ")^0) / ""        + S("[](){}$\"'") / ""        + R("09")^1 / numify diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex 8cd6959c3..4cd7076d1 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 75bf20d23..0b0f756c7 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 3642d6753..8af86a35e 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -6883,7 +6883,7 @@  \def\syst_helpers_direct_double_empty_one_nop#1{#1[][]}  \def\syst_helpers_direct_double_empty_two_nop#1[#2]{#1[#2][]} -%D Used in math definitions (in an type {\edef}): +%D Used in math definitions (in an \type {\edef}):  %D \startbuffer  %D [\docheckedpair{}] diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index e01b8315c..f1aeb094d 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -766,8 +766,8 @@  \normalprotected\def\newfraction#1{\let#1\!!plusone} -%D It would be handy to have a primitive \unless\ifcase because then we could -%D use nicer values. Anyhow, this conditional code used to be in the \type +%D It would be handy to have a primitive \type {\unless\ifcase} because then we +%D could use nicer values. Anyhow, this conditional code used to be in the \type  %D {syst-aux} module but is now promoted to here.  %D \macros diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua index 04f3eaa50..46f08c6df 100644 --- a/tex/context/base/tabl-xtb.lua +++ b/tex/context/base/tabl-xtb.lua @@ -25,7 +25,7 @@ this mechamism will be improved so that it can replace its older cousin.  -- todo: use linked list instead of r/c array -local tonumber = tonumber +local tonumber, next = tonumber, next  local commands                = commands  local context                 = context @@ -110,36 +110,36 @@ local stack, data = { }, nil  function xtables.create(settings)      table.insert(stack,data) -    local rows          = { } -    local widths        = { } -    local heights       = { } -    local depths        = { } -    local spans         = { } -    local distances     = { } -    local autowidths    = { } -    local modes         = { } -    local fixedrows     = { } -    local fixedcolumns  = { } -    local frozencolumns = { } -    local options       = { } +    local rows           = { } +    local widths         = { } +    local heights        = { } +    local depths         = { } +    local spans          = { } +    local distances      = { } +    local autowidths     = { } +    local modes          = { } +    local fixedrows      = { } +    local fixedcolumns   = { } +    local frozencolumns  = { } +    local options        = { }      data = { -        rows          = rows, -        widths        = widths, -        heights       = heights, -        depths        = depths, -        spans         = spans, -        distances     = distances, -        modes         = modes, -        autowidths    = autowidths, -        fixedrows     = fixedrows, -        fixedcolumns  = fixedcolumns, -        frozencolumns = frozencolumns, -        options       = options, -        nofrows       = 0, -        nofcolumns    = 0, -        currentrow    = 0, -        currentcolumn = 0, -        settings      = settings or { }, +        rows           = rows, +        widths         = widths, +        heights        = heights, +        depths         = depths, +        spans          = spans, +        distances      = distances, +        modes          = modes, +        autowidths     = autowidths, +        fixedrows      = fixedrows, +        fixedcolumns   = fixedcolumns, +        frozencolumns  = frozencolumns, +        options        = options, +        nofrows        = 0, +        nofcolumns     = 0, +        currentrow     = 0, +        currentcolumn  = 0, +        settings       = settings or { },      }      local function add_zero(t,k)          t[k] = 0 @@ -155,6 +155,9 @@ function xtables.create(settings)              nx     = 0,              ny     = 0,              list   = false, +            wd     = 0, +            ht     = 0, +            dp     = 0,          }          row[c] = cell          if c > data.nofcolumns then @@ -210,7 +213,7 @@ function xtables.initialize_reflow_width(option)      end      if option and option ~= "" then          local options = settings_to_hash(option) -        data.options[r][c] = options +     -- data.options[r][c] = options -- not yet used (commented elsewhere)          if options[v_fixed] then              data.frozencolumns[c] = true          end @@ -218,8 +221,7 @@ function xtables.initialize_reflow_width(option)      data.currentcolumn = c  end --- local function rather_fixed(n) ---     for n in node. +-- todo: we can better set the cell values in one go  function xtables.set_reflow_width()      local r = data.currentrow @@ -234,19 +236,29 @@ function xtables.set_reflow_width()      --      drc.list = true -- we don't need to keep the content around as we're in trial mode (no: copy_node_list(tb))      -- -    local widths, width = data.widths, getfield(tb,"width") +    local width  = getfield(tb,"width") +    local height = getfield(tb,"height") +    local depth  = getfield(tb,"depth") +    -- +    local widths  = data.widths +    local heights = data.heights +    local depths  = data.depths      if width > widths[c] then          widths[c] = width      end -    local heights, height = data.heights, getfield(tb,"height") -    if height > heights[r] then -        heights[r] = height -    end -    local depths, depth = data.depths, getfield(tb,"depth") -    if depth > depths[r] then -        depths[r] = depth +    if drc.ny < 2 then +        if height > heights[r] then +            heights[r] = height +        end +        if depth > depths[r] then +            depths[r] = depth +        end      end      -- +    drc.wd = width +    drc.ht = height +    drc.dp = depth +    --      local dimensionstate = texgetcount("frameddimensionstate")      local fixedcolumns = data.fixedcolumns      local fixedrows = data.fixedrows @@ -259,25 +271,45 @@ function xtables.set_reflow_width()      elseif dimensionstate == 3 then          fixedrows[r]    = height -- width          fixedcolumns[c] = width -- height -    elseif data.options[v_auto] then -- new per 5/5/2014 -        data.autowidths[c] = true -    else -        -- no dimensions are set in the cell -        if width <= data.criterium_h and height >= data.criterium_v then -            -- somewhat tricky branch -            if width > fixedcolumns[c] then -- how about a span here? -                -- maybe an image, so let's fix -                 fixedcolumns[c] = width -            end -        else -            -- safeguard as it could be text that can be recalculated -            -- and the previous branch could have happened in a previous -            -- row and then forces a wrong one-liner in a multiliner -            if width > fixedcolumns[c] then -                data.autowidths[c] = true -- new per 5/5/2014 -            end +    elseif width <= data.criterium_h and height >= data.criterium_v then +        -- somewhat tricky branch +        if width > fixedcolumns[c] then -- how about a span here? +            -- maybe an image, so let's fix +             fixedcolumns[c] = width          end      end +-- +-- -- this fails so not good enough predictor +-- +-- -- \startxtable +-- -- \startxrow +-- --     \startxcell knuth        \stopxcell +-- --     \startxcell \input knuth \stopxcell +-- -- \stopxrow +-- +--     else +--         local o = data.options[r][c] +--         if o and o[v_auto] then -- new per 5/5/2014 - removed per 15/07/2014 +--             data.autowidths[c] = true +--         else +--            -- no dimensions are set in the cell +--            if width <= data.criterium_h and height >= data.criterium_v then +--                -- somewhat tricky branch +--                if width > fixedcolumns[c] then -- how about a span here? +--                    -- maybe an image, so let's fix +--                     fixedcolumns[c] = width +--                end +--             else +--                 -- safeguard as it could be text that can be recalculated +--                 -- and the previous branch could have happened in a previous +--                 -- row and then forces a wrong one-liner in a multiliner +--                 if width > fixedcolumns[c] then +--                     data.autowidths[c] = true -- new per 5/5/2014 - removed per 15/07/2014 +--                 end +--             end +--         end +--     end +--      --      drc.dimensionstate = dimensionstate      -- @@ -324,7 +356,6 @@ function xtables.initialize_reflow_height()      end      texsetdimen("d_tabl_x_width",w)      local dimensionstate = drc.dimensionstate or 0 --- print(r,c,w,data.autowidths[c])      if dimensionstate == 1 or dimensionstate == 3 then          -- width was fixed so height is known          texsetcount("c_tabl_x_skip_mode",1) @@ -347,18 +378,30 @@ function xtables.set_reflow_height()   -- while row[c].span do -- we could adapt drc.nx instead   --     c = c + 1   -- end -    local tb = getbox("b_tabl_x") +    local tb  = getbox("b_tabl_x")      local drc = row[c] -    if data.fixedrows[r] == 0 then --  and drc.dimensionstate < 2 -        local heights, height = data.heights, getfield(tb,"height") -        if height > heights[r] then -            heights[r] = height -        end -        local depths, depth = data.depths, getfield(tb,"depth") -        if depth > depths[r] then -            depths[r] = depth +    -- +    local width  = getfield(tb,"width") +    local height = getfield(tb,"height") +    local depth  = getfield(tb,"depth") +    -- +    if drc.ny < 2 then +        if data.fixedrows[r] == 0 then --  and drc.dimensionstate < 2 +            local heights = data.heights +            local depths  = data.depths +            if height > heights[r] then +                heights[r] = height +            end +            if depth > depths[r] then +                depths[r] = depth +            end          end      end +    -- +    drc.wd = width +    drc.ht = height +    drc.dp = depth +    --   -- c = c + drc.nx - 1   -- data.currentcolumn = c  end @@ -372,23 +415,35 @@ function xtables.initialize_construct()          c = c + 1      end      data.currentcolumn = c -    local widths = data.widths +    local widths  = data.widths      local heights = data.heights -    local depths = data.depths -    local w = widths[c] -    local h = heights[r] -    local d = depths[r] +    local depths  = data.depths +    --      local drc = row[c] +    local wd  = drc.wd +    local ht  = drc.ht +    local dp  = drc.dp +    -- +    local width  = widths[c] +    local height = heights[r] +    local depth  = depths[r] +    --      for x=1,drc.nx-1 do -        w = w + widths[c+x] +        width = width + widths[c+x]      end -    for y=1,drc.ny-1 do -        h = h + heights[r+y] -        d = d + depths[r+y] +    -- +    local total = height + depth +    local ny = drc.ny +    if ny > 1 then +        for y=1,ny-1 do +            local nxt = r + y +            total = total + heights[nxt] + depths[nxt] +        end      end -    texsetdimen("d_tabl_x_width",w) -    texsetdimen("d_tabl_x_height",h + d) -    texsetdimen("d_tabl_x_depth",0) +    -- +    texsetdimen("d_tabl_x_width",width) +    texsetdimen("d_tabl_x_height",total) +    texsetdimen("d_tabl_x_depth",0) -- for now  end  function xtables.set_construct() @@ -401,8 +456,7 @@ function xtables.set_construct()   -- end      local drc = row[c]      -- this will change as soon as in luatex we can reset a box list without freeing ---     drc.list = copy_node_list(getbox("b_tabl_x")) -drc.list = takebox("b_tabl_x") +    drc.list = takebox("b_tabl_x")   -- c = c + drc.nx - 1   -- data.currentcolumn = c  end @@ -435,6 +489,8 @@ function xtables.reflow_width()      local maxwidth = settings.maxwidth      -- calculate width      local widths = data.widths +    local heights = data.heights +    local depths = data.depths      local distances = data.distances      local autowidths = data.autowidths      local fixedcolumns = data.fixedcolumns @@ -576,10 +632,42 @@ function xtables.reflow_height()      data.currentrow = 0      data.currentcolumn = 0      local settings = data.settings +    -- +    -- analyze ny +    -- +    local nofrows    = data.nofrows +    local nofcolumns = data.nofcolumns +    local widths     = data.widths +    local heights    = data.heights +    local depths     = data.depths +    -- +    for r=1,nofrows do +        for c=1,nofcolumns do +            local drc = data.rows[r][c] +            if drc then +                local ny = drc.ny +                if ny > 1 then +                    local height = heights[r] +                    local depth  = depths[r] +                    local total  = height + depth +                    local htdp   = drc.ht + drc.dp +                    for y=1,ny-1 do +                        local nxt = r + y +                        total = total + heights[nxt] + depths[nxt] +                    end +                    local delta = htdp - total +                    if delta > 0 then +                        delta = delta / ny +                        for y=1,ny do +                            heights[y] = heights[y] + delta +                        end +                    end +                end +            end +        end +    end +    --      if settings.options[v_height] then -        local heights = data.heights -        local depths = data.depths -        local nofrows = data.nofrows          local totalheight = 0          local totaldepth = 0          for i=1,nofrows do @@ -597,6 +685,7 @@ function xtables.reflow_height()              end          end      end +    --  end  local function showspans(data) diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 09582f980..87e016321 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@  -- merged file : luatex-fonts-merged.lua  -- parent file : luatex-fonts.lua --- merge date  : 07/14/14 19:25:59 +-- merge date  : 07/17/14 13:24:59  do -- begin closure to overcome local limits and interference @@ -7236,7 +7236,9 @@ end                  unicode=cidunicodes[index]                end                if unicode and descriptions[unicode] then -                report_otf("preventing glyph %a at index %H to overload unicode %U",name or "noname",index,unicode) +                if trace_private then +                  report_otf("preventing glyph %a at index %H to overload unicode %U",name or "noname",index,unicode) +                end                  unicode=-1                end                if not unicode or unicode==-1 then   | 
