diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv')
30 files changed, 368 insertions, 149 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv b/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv index caa9c31df7d..1c48a221dae 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2016.04.21 19:35} +\newcontextversion{2016.04.27 00:00} %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/mkiv/context-todo.tex b/Master/texmf-dist/tex/context/base/mkiv/context-todo.tex index b9591e8e06e..67204ac89e4 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/context-todo.tex +++ b/Master/texmf-dist/tex/context/base/mkiv/context-todo.tex @@ -27,6 +27,9 @@ play with par callback and properties \stopitem \startitem + get rid of components + \stopitem + \startitem play with box attributes \stopitem \startitem @@ -42,6 +45,10 @@ \stoptext +% also + +check components and pre|post|replace in math-tag + % new: <cd:command name="showgrid" file="page-grd.mkiv"> diff --git a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv index 9f4ef2327a1..ce8eceacfde 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2016.04.21 19:35} +\edef\contextversion{2016.04.27 00:00} \edef\contextkind {beta} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-afm.lua b/Master/texmf-dist/tex/context/base/mkiv/font-afm.lua index 3dedf12e1da..99b85774781 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-afm.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-afm.lua @@ -30,7 +30,7 @@ local fonts, logs, trackers, containers, resolvers = fonts, logs, trackers, cont local next, type, tonumber = next, type, tonumber local match, gmatch, lower, gsub, strip, find = string.match, string.gmatch, string.lower, string.gsub, string.strip, string.find local char, byte, sub = string.char, string.byte, string.sub -local abs, mod = math.abs, math.mod +local abs = math.abs local bxor, rshift = bit32.bxor, bit32.rshift local P, S, R, Cmt, C, Ct, Cs, lpegmatch, patterns = lpeg.P, lpeg.S, lpeg.R, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.match, lpeg.patterns local derivetable = table.derive @@ -56,7 +56,7 @@ local pfb = constructors.newhandler("pfb") local afmfeatures = constructors.newfeatures("afm") local registerafmfeature = afmfeatures.register -afm.version = 1.500 -- incrementing this number one up will force a re-cache +afm.version = 1.501 -- incrementing this number one up will force a re-cache afm.cache = containers.define("fonts", "afm", afm.version, true) afm.autoprefixed = true -- this will become false some day (catches texnansi-blabla.*) @@ -317,7 +317,7 @@ do local function step(c) local cipher = byte(c) local plain = bxor(cipher,rshift(r,8)) - r = mod((cipher + r) * c1 + c2,65536) + r = ((cipher + r) * c1 + c2) % 65536 return char(plain) end @@ -547,9 +547,10 @@ local uparser = fonts.mappings.makenameparser() unify = function(data, filename) local unicodevector = fonts.encodings.agl.unicodes -- loaded runtime in context - local unicodes, names = { }, { } - local private = constructors.privateoffset - local descriptions = data.descriptions + local unicodes = { } + local names = { } + local private = constructors.privateoffset + local descriptions = data.descriptions for name, blob in next, data.characters do local code = unicodevector[name] -- or characters.name_to_unicode[name] if not code then diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua index 14e816d5e4d..85a80bdf82c 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua @@ -525,7 +525,7 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof end end local noflookups = readushort(f) - local lookups = { } + local lookups = { } for i=1,noflookups do lookups[readushort(f)+1] = readushort(f) + 1 end diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua index aae70d1f345..ebda723d54d 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-otj.lua @@ -49,8 +49,8 @@ local attributes, nodes, node = attributes, nodes, node fonts = fonts local hashes = fonts.hashes local fontdata = hashes.identifiers -local parameters = fonts.hashes.parameters -local resources = fonts.hashes.resources +----- parameters = fonts.hashes.parameters -- not in generic +----- resources = fonts.hashes.resources -- not in generic nodes.injections = nodes.injections or { } local injections = nodes.injections @@ -1444,7 +1444,7 @@ local function injectspaces(head) -- end leftkerns = trig.left rightkerns = trig.right - local par = parameters[font] + local par = fontdata[font].parameters -- fallback for generic factor = par.factor threshold = par.spacing.width - 1 -- get rid of rounding errors lastfont = font diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua index a9ad73906c5..24f68543e85 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua @@ -69,7 +69,7 @@ local next, type, unpack = next, type, unpack local byte, lower, char, strip, gsub = string.byte, string.lower, string.char, string.strip, string.gsub local bittest = bit32.btest local concat, remove, unpack, fastcopy = table.concat, table.remov, table.unpack, table.fastcopy -local floor, mod, abs, sqrt, round = math.floor, math.mod, math.abs, math.sqrt, math.round +local floor, abs, sqrt, round = math.floor, math.abs, math.sqrt, math.round local P, R, S, C, Cs, Cc, Ct, Carg, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cc, lpeg.Ct, lpeg.Carg, lpeg.Cmt local lpegmatch = lpeg.match @@ -1270,10 +1270,10 @@ formatreaders[4] = function(f,fontdata,offset) -- bad encoding elseif offset == 0 then if trace_cmap then - report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,mod(startchar + delta,65536)) + report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,(startchar + delta) % 65536) end for unicode=startchar,endchar do - local index = mod(unicode + delta,65536) + local index = (unicode + delta) % 65536 if index and index > 0 then local glyph = glyphs[index] if glyph then @@ -1303,13 +1303,13 @@ formatreaders[4] = function(f,fontdata,offset) else local shift = (segment-nofsegments+offset/2) - startchar if trace_cmap then - report("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,mod(startchar + delta,65536)) + report("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,(startchar + delta) % 65536) end for unicode=startchar,endchar do local slot = shift + unicode local index = indices[slot] if index and index > 0 then - index = mod(index + delta,65536) + index = (index + delta) % 65536 local glyph = glyphs[index] if glyph then local gu = glyph.unicode diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua index 69118725842..57ddf907198 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-ots.lua @@ -9,6 +9,9 @@ if not modules then modules = { } end modules ['font-ots'] = { -- sequences -- to be checked: discrun doesn't seem to do something useful now (except run the -- check again) so if we need it again we'll do a zwnjrun or so +-- components will go away and be replaced by a property table which simplifies +-- code (also more efficient) + -- beware, on my development machine we test a slightly a more optimized version -- assumptions: @@ -566,7 +569,22 @@ local function toligature(head,start,stop,char,dataset,sequence,markflag,discfou local pre, post, replace, pretail, posttail, replacetail = getdisc(discfound,true) if not replace then -- todo: signal simple hyphen local prev = getprev(base) - local copied = copy_node_list(comp) +-- local copied = copy_node_list(comp) +local current = comp +local previous = nil +local copied = nil +while current do + if getid(current) == glyph_code then + local n = copy_node(current) + if copied then + setlink(previous,n) + else + copied = n + end + previous = n + end + current = getnext(current) +end setprev(discnext,nil) -- also blocks funny assignments setnext(discprev,nil) -- also blocks funny assignments if pre then @@ -2126,7 +2144,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) else local discfound = nil local n = f + 1 - last = getnext(last) + last = getnext(last) -- the second in current (first already matched) while n <= l do if not last and (sweeptype == "post" or sweeptype == "replace") then last = getnext(sweepnode) @@ -2167,7 +2185,6 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end - last = getnext(last) elseif char == false then if discfound then notmatchreplace[discfound] = true @@ -2220,6 +2237,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end match = not notmatchpre[last] end + -- maybe only if match last = getnext(last) else match = false @@ -2255,8 +2273,12 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if trace_skips then show_skip(dataset,sequence,char,ck,class) end + prev = getprev(prev) -- moved here elseif seq[n][char] then - n = n -1 + if n > 1 then -- new test + prev = getprev(prev) -- moved here + end + n = n - 1 else if discfound then notmatchreplace[discfound] = true @@ -2275,7 +2297,7 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) end break end - prev = getprev(prev) + -- prev = getprev(prev) -- moved up elseif char == false then if discfound then notmatchreplace[discfound] = true @@ -2339,21 +2361,20 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if not match then break end - else - -- skip 'm end - else - -- skip 'm end + -- maybe only if match + prev = getprev(prev) elseif seq[n][32] then n = n - 1 + prev = getprev(prev) else match = false break end - prev = getprev(prev) elseif seq[n][32] then -- somewhat special, as zapfino can have many preceding spaces n = n - 1 + prev = getprev(prev) -- was absent else match = false break @@ -2391,7 +2412,11 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) if trace_skips then show_skip(dataset,sequence,char,ck,class) end + current = getnext(current) -- was absent elseif seq[n][char] then + if n < s then -- new test + current = getnext(current) -- was absent + end n = n + 1 else if discfound then @@ -2473,10 +2498,11 @@ local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode) match = false break end + -- maybe only if match current = getnext(current) elseif seq[n][32] then n = n + 1 -current = getnext(current) + current = getnext(current) else match = false break diff --git a/Master/texmf-dist/tex/context/base/mkiv/meta-tex.mkiv b/Master/texmf-dist/tex/context/base/mkiv/meta-tex.mkiv index 35b5c133b95..8d24f687c1f 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/meta-tex.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/meta-tex.mkiv @@ -37,17 +37,20 @@ \unexpanded\def\meta_textext_indeed#1#2% {\begingroup \setbox\nextbox\hbox{#2}% - \executeifdefined{\??graphictexdepth#1}{\getvalue{\??graphictexdepth\s!depth}}% + \ifcsname\??graphictexdepth#1\endcsname + \lastnamedcs + \else + \syst_boxes_lower_nextbox_dp + \fi \box\nextbox \endgroup} \def\getTeXtext#1% - {\getvalue{\??graphictextext#1}} + {\begincsname\??graphictextext#1\endcsname} -\setvalue{\??graphictexdepth d}{\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}} % unchecked -\letvalue{\??graphictexdepth n}\donothing % unchecked - -\setvalue{\??graphictexdepth\s!depth }{\getvalue{\??graphictexdepth d}} +\letvalue{\??graphictexdepth d}\syst_boxes_lower_nextbox_dp +\letvalue{\??graphictexdepth \s!depth}\syst_boxes_lower_nextbox_dp +\letvalue{\??graphictexdepth n}\donothing \letvalue{\??graphictexdepth\s!nodepth}\donothing % \definetextext[framed]{\framed} diff --git a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-xml.tex b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-xml.tex index eeaca321340..9d0680e2a4a 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mtx-context-xml.tex +++ b/Master/texmf-dist/tex/context/base/mkiv/mtx-context-xml.tex @@ -65,6 +65,8 @@ moduledata.xml.analyzers.structure (files) context.page() moduledata.xml.analyzers.characters(files) + context.page() + moduledata.xml.analyzers.entities(files) else context("no action given") end diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua index 0d0c30c3054..99e0eb60466 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/mult-def.lua @@ -7814,7 +7814,14 @@ return { ["en"]="finalpubsep", }, ["first"]={ + ["cs"]="prvni", + ["de"]="erste", ["en"]="first", + ["fr"]="premier", + ["it"]="primo", + ["nl"]="eerste", + ["pe"]="اولی", + ["ro"]="primul", }, ["firstnamesep"]={ ["en"]="firstnamesep", @@ -13507,16 +13514,6 @@ return { ["pe"]="پیشزمینه", ["ro"]="primplan", }, - ["formeel"]={ - ["cs"]="formeel", - ["de"]="formeel", - ["en"]="formeel", - ["fr"]="formeel", - ["it"]="formeel", - ["nl"]="formeel", - ["pe"]="formeel", - ["ro"]="formeel", - }, ["formula"]={ ["cs"]="rovnice", ["de"]="formel", @@ -13877,16 +13874,6 @@ return { ["pe"]="نمایهها", ["ro"]="indexuri", }, - ["informeel"]={ - ["cs"]="informeel", - ["de"]="informeel", - ["en"]="informeel", - ["fr"]="informeel", - ["it"]="informeel", - ["nl"]="informeel", - ["pe"]="informeel", - ["ro"]="informeel", - }, ["inherit"]={ ["cs"]="inherit", ["de"]="inherit", @@ -14418,6 +14405,9 @@ return { ["pe"]="خطها", ["ro"]="linii", }, + ["linked"]={ + ["en"]="linked", + }, ["list"]={ ["cs"]="seznam", ["de"]="liste", @@ -15623,16 +15613,6 @@ return { ["pe"]="منظم", ["ro"]="regular", }, - ["rekening"]={ - ["cs"]="rekening", - ["de"]="rekening", - ["en"]="rekening", - ["fr"]="rekening", - ["it"]="rekening", - ["nl"]="rekening", - ["pe"]="rekening", - ["ro"]="rekening", - }, ["relative"]={ ["cs"]="relativni", ["de"]="relativ", @@ -17641,8 +17621,7 @@ return { ["nl"]="xmlsetup", ["ro"]="xmlsetup", }, - ["cd:sign-s"] = { en = "[-+]" }, - ["cd:sign-l"] = { en = "[-+]" }, + ["cd:sign"] = { en = "[-+]" }, ["cd:csname-s"] = { en = "\\..." }, ["cd:csname-l"] = { en = "\\..." }, ["cd:noargument-s"] = { en = "\\..." }, diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua index 409c735b7a6..76517f37ecb 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.lua @@ -412,14 +412,23 @@ implement { arguments = "string", } -implement { - name = "getsetupstring", - actions = function(s) +local function gss(s) contextsprint(vrbcatcodes,getsetupstring(s)) - end, + end + +implement { -- will b eoverloaded + name = "getsetupstring", + actions = gss, arguments = "string", } +implement { + name = "rawsetupstring", + actions = gss, + arguments = "string", +} + + local function showassignerror(namespace,key,line) local ns, instance = match(namespace,"^(%d+)[^%a]+(%a*)") if ns then diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv index 8ed147c63e4..d7dc31ec118 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/mult-ini.mkiv @@ -393,6 +393,7 @@ \unexpanded\def\displaymessage#1{\blank\inlinemessage{#1}\blank} \let\getsetupstring\clf_getsetupstring +\let\rawsetupstring\clf_rawsetupstring %D \macros %D {ifshowwarnings, ifshowmessages} diff --git a/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua b/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua index c9a13c1e8b7..d3bdc5ffda7 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/mult-low.lua @@ -263,7 +263,7 @@ return { -- "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", -- - "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "nbsp", + "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "emspace", "charspace", "nbsp", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", -- diff --git a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv index cf51b831a81..29ba543cd13 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/publ-ini.mkiv @@ -1805,7 +1805,8 @@ [\c!interaction=\v!start, \c!alternative=num, % default cite form, normally defined in the cite namespace \c!inbetween=\btxspace, - \c!range=\endash, % separator:range? + % \c!range=\endash, % separator:range? + \c!range=\directdiscretionary\endash, \c!compress=\v!yes, % was no? \c!authorconversion=normal, \c!sorttype=normal, % normal, reverse or none diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.lua b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.lua index 85cbf0b3973..c791f97183e 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.lua @@ -7,15 +7,15 @@ if not modules then modules = { } end modules ['scrn-but'] = { } local context = context -local f_two_colon = string.formatters["%s:%s"] +local f_two_colon = string.formatters["%s:%s:%s"] +local v_section = interfaces.variables.section local function registerbuttons(tag,register,language) local data = sorters.definitions[language] local orders = data and data.orders or sorters.definitions.default.orders - local tag = tag == "" and { "" } or { tag } for i=1,#orders do local order = orders[i] - context.menubutton(tag,f_two_colon(register,order),order) + context.doregistermenubutton(tag, order, f_two_colon(register,v_section,order) ) end end diff --git a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi index 1d5ffe6f3d6..98d9f2daab9 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi +++ b/Master/texmf-dist/tex/context/base/mkiv/scrn-but.mkvi @@ -150,7 +150,7 @@ \expandafter\let\csname\??buttonlocation\v!none \endcsname\plusthree \expandafter\let\csname\??buttonlocation\v!normal \endcsname\plusone % default \expandafter\let\csname\??buttonlocation\s!default\endcsname\plusone % default -\expandafter\let\csname\??buttonlocation\s!empty \endcsname\plusone % default +\expandafter\let\csname\??buttonlocation \endcsname\plusone % default \newconditional\c_scrn_button_skipped @@ -1022,15 +1022,22 @@ {\dodoubleempty\scrn_menu_register_menu_buttons} \def\scrn_menu_register_menu_buttons[#menu][#register]% - {\ifsecondargument - \clf_registerbuttons{menu}{#register}{\currentlanguage}% + {\begingroup + \ifsecondargument + \clf_registerbuttons{#menu}{#register}{\currentlanguage}% \else \clf_registerbuttons{}{#menu}{\currentlanguage}% - \fi} + \fi + \removeunwantedspaces + \endgroup} + +\def\doregistermenubutton#1#2#3% used at lua end + {\scrn_menu_menu_button_c{#1}{#2}{#3}% + \space} % or less readable: % % \def\scrn_menu_register_menu_buttons[#menu][#register]% -% {\clf_registerbuttons\ifsecondargument{menu}{#register}\else{}{#menu}\fi{\currentlanguage}} +% {\clf_registerbuttons\ifsecondargument{#menu}{#register}\else{}{#menu}\fi{\currentlanguage}} \protect \endinput diff --git a/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv b/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv index 7c5358c5135..19f2f53b3f8 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/spac-hor.mkiv @@ -603,6 +603,8 @@ \let\emspace\quad +\unexpanded\def\charspace{ } % the unexpandable \space (as space can also be delimiter for numbers) + % Suggested by GB (not the name -): \def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize} % D.A.'s value diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf Binary files differindex f5692f2c4f1..2a3cd85e758 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf +++ b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf Binary files differindex 65ec9e7c7ed..832ebd0a0a1 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf +++ b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua index d7ffd6af434..ec5dcf6f0a5 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['strc-lev'] = { } local insert, remove = table.insert, table.remove +local settings_to_array = utilities.parsers.settings_to_array local context = context local interfaces = interfaces @@ -15,6 +16,7 @@ local sections = structures.sections local implement = interfaces.implement local v_default = interfaces.variables.default +local v_auto = interfaces.variables.auto sections.levels = sections.levels or { } @@ -27,29 +29,46 @@ local f_two_colon = string.formatters["%s:%s"] storage.register("structures/sections/levels", levels, "structures.sections.levels") local function definesectionlevels(category,list) - levels[category] = utilities.parsers.settings_to_array(list) + list = settings_to_array(list) + for i=1,#list do + list[i] = settings_to_array(list[i]) + end + levels[category] = list end -local function startsectionlevel(category) +local function startsectionlevel(n,category,current) category = category ~= "" and category or v_default - level = level + 1 local lc = levels[category] + for i=1,#lc do + local lcl = lc[i] + if (lcl[n] or lcl[1]) == current then + level = i + break + end + end + level = level + 1 if not lc or level > #lc then context.nostarthead { f_two_colon(category,level) } else - context.dostarthead { lc[level] } + local lcl = lc[level] + if n > #lcl then + n = #lcl + end + context.dostarthead { lc[level][n] } end - insert(categories,category) + insert(categories,{ category, n }) end local function stopsectionlevel() - local category = remove(categories) - if category then + local top = remove(categories) + if top then + local category = top[1] + local n = top[2] local lc = levels[category] if not lc or level > #lc then context.nostophead { f_two_colon(category,level) } else - context.dostophead { lc[level] } + context.dostophead { lc[level][n] } end level = level - 1 else @@ -60,13 +79,13 @@ end implement { name = "definesectionlevels", actions = definesectionlevels, - arguments = { "string", "string" } + arguments = { "string", "string" }, } implement { name = "startsectionlevel", actions = startsectionlevel, - arguments = "string" + arguments = { "integer", "string", "string" }, } implement { diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lev.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.mkvi index dae3f28e30e..ac106f999a5 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-lev.mkvi +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.mkvi @@ -24,19 +24,25 @@ \unprotect \unexpanded\def\definesectionlevels{\dodoubleargument\strc_levels_define} -\unexpanded\def\startsectionlevel {\dosingleempty \strc_levels_start } +\unexpanded\def\startsectionlevel {\dosingleempty \strc_levels_start_section} +\unexpanded\def\startsubjectlevel {\dosingleempty \strc_levels_start_subject} \unexpanded\def\strc_levels_define[#category][#list]{\clf_definesectionlevels{#category}{#list}} -\unexpanded\def\strc_levels_start [#category]{\clf_startsectionlevel{#category}} \unexpanded\def\stopsectionlevel {\clf_stopsectionlevel} +\unexpanded\def\stopsubjectlevel {\clf_stopsectionlevel} \unexpanded\def\nostarthead{\dotripleargument\strc_levels_start_nop} % used at the lua end \unexpanded\def\nostophead {\dosingleargument\strc_levels_stop_nop } % used at the lua end -\unexpanded\def\strc_levels_start[#category]% - {\doifelseassignment{#category} - {\clf_startsectionlevel{\v!default}[#category]} - {\clf_startsectionlevel{#category}}} +\unexpanded\def\strc_levels_start_section[#category]% + {\doifelseassignment{#category}% + {\clf_startsectionlevel\plusone{\v!default}{\currentnamedsection}[#category]}% + {\clf_startsectionlevel\plusone {}{\currentnamedsection}{#category}}} + +\unexpanded\def\strc_levels_start_subject[#category]% + {\doifelseassignment{#category}% + {\clf_startsectionlevel\plustwo{\v!default}{\currentnamedsection}[#category]}% + {\clf_startsectionlevel\plustwo {#category}{\currentnamedsection}}} \unexpanded\def\strc_levels_start_nop[#category][#settings][#userdata]% {\blank @@ -50,13 +56,12 @@ \definesectionlevels [\v!default] - [\v!chapter, - \v!section, - \v!subsection, - \v!subsubsection, - \v!subsubsubsection, - \v!subsubsubsubsection] - + [{\v!chapter,\v!title}, + {\v!section,\v!subject}, + {\v!subsection,\v!subsubject}, + {\v!subsubsection,\v!subsubsubject}, + {\v!subsubsubsection,\v!subsubsubject}, + {\v!subsubsubsubsection,\v!subsubsubject}] \let\definestructurelevels\definesectionlevels \let\startstructurelevel \startsectionlevel diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi index e7ed0f1f2ff..5c2bd74e53c 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lst.mkvi @@ -82,6 +82,7 @@ \unexpanded\def\usenestedliststyleandcolor#style#color% will change {\useliststyleandcolor#style#color% + % how about style \ifx\currentcolorparameter\empty \else \resetinteractionparameter\c!color \resetinteractionparameter\c!contrastcolor diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua index 96d26e6f666..dcd35fc20b7 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-pag.lua @@ -263,12 +263,23 @@ function helpers.prefix(data,prefixspec) end end +function helpers.pageofinternal(n,prefixspec,pagespec) + local data = structures.references.internals[n] + if not data then + -- error + elseif prefixspec then + helpers.prefixpage(data,prefixspec,pagespec) + else + helpers.prefix(data,pagespec) + end +end + function pages.is_odd(n) n = n or texgetcount("realpageno") if texgetcount("pagenoshift") % 2 == 0 then - return n % 2 == 0 - else return n % 2 ~= 0 + else + return n % 2 == 0 end end @@ -277,9 +288,9 @@ function pages.on_right(n) if pagemode == 2 or pagemode == 1 then n = n or texgetcount("realpageno") if texgetcount("pagenoshift") % 2 == 0 then - return n % 2 == 0 - else return n % 2 ~= 0 + else + return n % 2 == 0 end else return true @@ -399,3 +410,9 @@ implement { -- weird place } } } + +interfaces.implement { + name = "pageofinternal", + arguments = { "integer" }, + actions = helpers.pageofinternal, +} diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua index c3b852e8917..de057742309 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.lua @@ -2421,9 +2421,7 @@ local function setreferencerealpage(actions) if not actions then actions = references.currentset end - if not actions then - return 0 - else + if type(actions) == "table" then local realpage = actions.realpage if realpage then return realpage @@ -2443,8 +2441,8 @@ local function setreferencerealpage(actions) end end actions.realpage = 0 - return 0 end + return 0 end references.setreferencerealpage = setreferencerealpage diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi index 177abd835b7..96cb61b4af1 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-ref.mkvi @@ -1593,7 +1593,7 @@ \attribute\referenceattribute\attributeunsetvalue \iflocation \setstrut % can be option - \strc_references_get_simple_reference{internal(#internal)}% + \strc_references_get_simple_reference{#internal}% \global\lastsavedreferenceattribute\currentreferenceattribute \attribute\referenceattribute\currentreferenceattribute \setlocationattributes diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua index 4efbe038b3d..66c264a49d8 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.lua @@ -40,8 +40,12 @@ local variables = interfaces.variables local v_forward = variables.forward local v_all = variables.all local v_yes = variables.yes +local v_packed = variables.packed local v_current = variables.current local v_previous = variables.previous +local v_next = variables.next +local v_first = variables.first +local v_last = variables.last local v_text = variables.text local context = context @@ -86,6 +90,7 @@ local ctx_registerentry = context.registerentry local ctx_registerseeword = context.registerseeword local ctx_registerpagerange = context.registerpagerange local ctx_registeronepage = context.registeronepage +local ctx_registerpacked = context.registerpacked -- possible export, but ugly code (overloads) -- @@ -995,6 +1000,14 @@ local function pagenumber(entry,prefixspec,pagespec) ) end +local function packed(f_entry,t_entry) + local fer, ter = f_entry.references, t_entry.references + ctx_registerpacked( + fer.internal or 0, + ter.internal or 0 + ) +end + local function collapsedpage(pages) for i=2,#pages do local first, second = pages[i-1], pages[i] @@ -1059,8 +1072,10 @@ local function collapsepages(pages) end function registers.flush(data,options,prefixspec,pagespec) - local collapse_singles = options.compress == v_yes - local collapse_ranges = options.compress == v_all + local compress = options.compress + local collapse_singles = compress == v_yes + local collapse_ranges = compress == v_all + local collapse_packed = compress == v_packed local show_page_number = options.pagenumber ~= false -- true or false local result = data.result local maxlevel = 0 @@ -1237,6 +1252,28 @@ function registers.flush(data,options,prefixspec,pagespec) else pagenumber(entry,prefixspec,pagespec) end + elseif collapse_packed then + local first = nil + local last = nil + while true do + if not first then + first = entry + end + last = entry + if d == #data then + break + else + d = d + 1 + local next = data[d] + if next.metadata.kind == "see" or not equal(entry.list,next.list) then + d = d - 1 + break + else + entry = next + end + end + end + packed(first,last) -- returns internals else while true do if entry.references.lastrealpage then @@ -1352,3 +1389,67 @@ implement { } } } + +-- linked registers + +function registers.findinternal(tag,where,n) + -- local collected = registers.collected + local current = collected[tag] + if not current then + return 0 + end + local entries = current.entries + if not entries then + return 0 + end + local entry = entries[n] + if not entry then + return 0 + end + local list = entry.list + local size = #list + -- + local start, stop, step + if where == v_previous then + start = n - 1 + stop = 1 + step = -1 + elseif where == v_first then + start = 1 + stop = #entries + step = 1 + elseif where == v_last then + start = #entries + stop = 1 + step = -1 + else + start = n + 1 + stop = #entries + step = 1 + end + -- + for i=start,stop,step do + local r = entries[i] + local l = r.list + local s = #l + if s == size then + local ok = true + for i=1,size do + if list[i][1] ~= l[i][1] then + ok = false + break + end + end + if ok then + return r.references.internal or 0 + end + end + end + return 0 +end + +interfaces.implement { + name = "findregisterinternal", + arguments = { "string", "string", "integer" }, + actions = { registers.findinternal, context }, +} diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv index 1d28db8dfed..5b32c6fc8b8 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-reg.mkiv @@ -159,6 +159,9 @@ %D Registering: +\global\let\currentregistername \empty +\global\let\currentregisternumber\!!zerocount + \def\strc_registers_register_page_entry {\iftrialtypesetting \expandafter\gobblethreearguments @@ -250,6 +253,7 @@ \setnextinternalreference % we could consider storing register entries in a list which we % could then sort + \glet\currentregistername\currentregister \xdef\currentregisternumber{\clf_storeregister % 'own' should not be in metadata metadata {% name {\currentregister}% @@ -315,6 +319,7 @@ {\begingroup \edef\currentregister{#1}% \setnextinternalreference + \glet\currentregistername\currentregister \xdef\currentregisternumber{\clf_storeregister {% metadata {% @@ -771,6 +776,16 @@ \newdimen\d_strc_registers_hangindent \newcount\c_strc_registers_hangafter +\unexpanded\def\usenestedregisterstyleandcolor#1#2% will change + {\useregisterstyleandcolor#1#2% + % how about style + \ifconditional\c_strc_registers_text_interaction + \ifx\currentcolorparameter\empty \else + \resetinteractionparameter\c!color + \resetinteractionparameter\c!contrastcolor + \fi + \fi} + \unexpanded\def\startregisterentries#1% depth {\endgraf \begingroup @@ -778,7 +793,7 @@ \dostarttagged\t!registerentries\empty \let\savedcurrentregister\currentregister \edef\currentregister{\currentregister:\number\scratchcounter}% - \useregisterstyleandcolor\c!textstyle\c!textcolor + \usenestedregisterstyleandcolor\c!textstyle\c!textcolor \ifnum\scratchcounter>\plusone \advance\leftskip\d_strc_registers_distance\relax \fi @@ -863,7 +878,7 @@ \unexpanded\def\withregisterpagecommand#1#2#3#4% {\def\currentregisterpageindex{#2}% \iflocation - \strc_references_goto_internal{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[#2]% + \strc_references_goto_internal{\applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}}[internal(#2)]% \else \applyprocessor{#1}{\registerparameter\c!pagecommand{#4}}% \fi} @@ -888,18 +903,6 @@ \dostoptagged \dostoptagged} -% \unexpanded\def\defaultregisterentry#1#2#3#4% #1:processor #2:internal #3:seeindex #4:word -% {\def\currentregisterpageindex{#2}% -% \iflocation -% \def\currentregisterseeindex{#3}% -% \doifelse{\registerparameter\c!interaction}\v!text -% {\directgoto{\setlocationcolor\doapplyregisterentrycommand{#1}{#4}}[internal(#2)]} -% {\doapplyregisterentrycommand{#1}{#4}}% -% \else -% \let\currentregisterseeindex\empty -% \doapplyregisterentrycommand{#1}{#4}% -% \fi} - \unexpanded\def\defaultregisterentry#1#2#3#4% #1:processor #2:internal #3:seeindex #4:word {\def\currentregisterpageindex{#2}% \iflocation @@ -923,14 +926,6 @@ \applyprocessor{#1}{\registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#2}}}}% \dostoptagged} -% \unexpanded\def\doapplyregisterseecommand#1#2% -% {\ifx\currentregisterseeindex\empty -% % \dontleavehmode -% \applyprocessor{#1}{#2}% -% \else -% \goto{\applyprocessor{#1}{#2}}[seeindex:\currentregisterseeindex]% -% \fi} - \unexpanded\def\doapplyregisterseecommand#1#2% {\ifx\currentregisterseeindex\empty \applyprocessor{#1}{#2}% @@ -1032,6 +1027,48 @@ %D The linked register code will be reimplemented (not that hard) when it's needed %D again and/or when I'm bored. + \def\findregisterinternal#1#2#3{\clf_findregisterinternal{#1}{#2}#3\relax} +\unexpanded\def\pageofinternal #1{\clf_pageofinternal#1\relax} + +\unexpanded\def\linkedregisterentrylink#1#2#3#4% tag where before after + {\iflocation + \scratchcounter\findregisterinternal{#1}{#2}\currentregisternumber\relax\relax + \ifcase\scratchcounter\else + #3\relax + \goto{\symbol[#2]}[internal(\the\scratchcounter)]% + #4\relax + \fi + \else + % \scratchcounter\findregisterinternal{#1}{#2}\currentregisternumber\relax\relax + % \ifcase\scratchcounter\else + % #3\relax + % \pageofinternal\scratchcounter + % #4\relax + % \fi + \fi} + +\unexpanded\def\linkedregisterentry#1% + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox{#1}% + \linkedregisterentrylink\currentregistername\v!previous\relax\nobreakspace + \unhbox\scratchbox + \linkedregisterentrylink\currentregistername\v!next\nobreakspace\relax + \endgroup} + +\unexpanded\def\registerpacked#1#2% + {\iflocation + \hskip\d_strc_registers_distance\relax + \nobreak + \ifnum#1=#2\relax + \goto{\symbol[\v!somewhere]}[internal(#1)]% + \else + \goto{\symbol[\v!first]}[internal(#1)]% + \nobreakspace + \goto{\symbol[\v!last]}[internal(#2)]% + \fi + \fi} + %D Default index: \defineregister diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv b/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv index c78cffbffaf..657e6c86644 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-sec.mkiv @@ -11,6 +11,9 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +%D In retrospect I should have gone futher and move more to the +%D \LUA\ end but here we are now. Maybe some day. + \writestatus{loading}{ConTeXt Structure Macros / Sectioning} \unprotect @@ -480,14 +483,8 @@ % todo: add grouping but where: before/after trickery .. probably inside because one can always add % grouping to the before/after settings -\unexpanded\def\strc_sectioning_start_named_section[#1]% [#2][#3] - {\pushmacro\currentnamedsection - \edef\currentnamedsection{#1}% - \normalexpanded{\strc_sectioning_start_named_section_indeed[\currentnamedsection]}} % [#2][#3] - \unexpanded\def\stopnamedsection - {\normalexpanded{\strc_sectioning_stop[\currentnamedsection]}% - \popmacro\currentnamedsection} + {\normalexpanded{\strc_sectioning_stop[\currentnamedsection]}} % structure sections (the parents of chapter etc) @@ -603,9 +600,9 @@ % head construction -\unexpanded\def\strc_sectioning_handle_own{\dodoubleempty\strc_sectioning_handle_own_indeed} % [ref] {nr} {title} -\unexpanded\def\strc_sectioning_handle_nop{\dodoubleempty\strc_sectioning_handle_nop_indeed} % [ref] {title} -\unexpanded\def\strc_sectioning_start {\dotripleempty\strc_sectioning_start_named_section_indeed} % [settings] [userdata] !!! also used at lua end +\unexpanded\def\strc_sectioning_handle_own{\dodoubleempty\strc_sectioning_handle_own_indeed} % [ref] {nr} {title} +\unexpanded\def\strc_sectioning_handle_nop{\dodoubleempty\strc_sectioning_handle_nop_indeed} % [ref] {title} +\unexpanded\def\strc_sectioning_start {\dotripleempty\strc_sectioning_start_named_section} % [settings] [userdata] !!! also used at lua end \newconditional\currentstructureown @@ -628,8 +625,10 @@ \unexpanded\def\strc_sectioning_handle_nop_indeed_nop#1#2#3% {\strc_sectioning_handle{#1}{\c!reference={#2},\c!title={#3}}{}} % name ref nr title -- -\unexpanded\def\strc_sectioning_start_named_section_indeed[#1][#2][#3]% for the moment no grouping, too annoying with page breaks - {\setfalse\currentstructureown +\unexpanded\def\strc_sectioning_start_named_section[#1][#2][#3]% for the moment no grouping, too annoying with page breaks + {\pushmacro\currentnamedsection + \edef\currentnamedsection{#1}% + \setfalse\currentstructureown %\globalpushmacro\currenthead % this does not work out well \xdef\currenthead{#1}% \setsystemmode\currenthead % new, also here now @@ -647,7 +646,8 @@ \xdef\currenthead{#1}% recover \headparameter\c!aftersection \the\everyafterhead - \resetsystemmode\currenthead} % new, also here now + \resetsystemmode\currenthead + \popmacro\currentnamedsection} % new, also here now \let\dostarthead\strc_sectioning_start % used at lua end \let\dostophead \strc_sectioning_stop % used at lua end diff --git a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv b/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv index a302076f204..9f4c58ad720 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/supp-box.mkiv @@ -285,6 +285,9 @@ \expandafter\syst_boxes_smash_process_option \fi} +\def\syst_boxes_lower_nextbox_dp + {\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}} + %D \starttabulate[|l|l|] %D \NC w \NC \ruledhbox{\smash [w]{This is some great smashing, isn't it?}} \NC \NR %D \NC h \NC \ruledhbox{\smash [h]{This is some great smashing, isn't it?}} \NC \NR |