From 6f8440fd75c76e40620c2110ac445ab92635460c Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Thu, 18 Sep 2014 13:15:05 +0200 Subject: 2014-09-18 11:19:00 --- tex/context/base/back-exp.lua | 191 +++++++---- tex/context/base/back-exp.mkiv | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4441 -> 4385 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/core-con.lua | 2 +- tex/context/base/export-example.css | 22 +- tex/context/base/grph-inc.lua | 2 +- tex/context/base/l-url.lua | 3 +- tex/context/base/lpdf-epa.lua | 7 + tex/context/base/lpdf-ini.lua | 41 ++- tex/context/base/lxml-css.lua | 14 +- tex/context/base/lxml-tex.lua | 2 + tex/context/base/page-sid.mkiv | 2 +- tex/context/base/publ-fnd.lua | 29 +- tex/context/base/publ-imp-aps.mkvi | 40 +-- tex/context/base/status-files.pdf | Bin 25043 -> 24768 bytes tex/context/base/status-lua.pdf | Bin 327160 -> 324988 bytes tex/context/base/strc-def.mkiv | 16 +- tex/context/base/trac-log.lua | 365 +++++++++++++-------- tex/context/base/util-str.lua | 2 +- tex/context/base/x-cals.lua | 6 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 4 +- 23 files changed, 500 insertions(+), 254 deletions(-) (limited to 'tex') diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 223f492c1..74640ad08 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -38,6 +38,7 @@ local fromunicode16 = fonts.mappings.fromunicode16 local sortedhash = table.sortedhash local formatters = string.formatters local todimen = number.todimen +local replacetemplate = utilities.templates.replace local trace_export = false trackers.register ("export.trace", function(v) trace_export = v end) local trace_spacing = false trackers.register ("export.trace.spacing", function(v) trace_spacing = v end) @@ -336,23 +337,24 @@ do -- /* padding : ; */ -- /* text-justify : inter-word ; */ -local f_document = formatters [ [[ +local documenttemplate = [[ document { - font-size : %s !important ; - max-width : %s !important ; - text-align : %s !important ; - hyphens : %s !important ; + font-size : %size% !important ; + max-width : %width% !important ; + text-width : %align% !important ; + hyphens : %hyphens% !important ; } -]] ] +]] -local f_style = formatters [ [[ -%s[detail="%s"] { - font-style : %s ; - font-variant : %s ; - font-weight : %s ; - font-family : %s ; - color : %s ; -}]] ] +local styletemplate = [[ +%element%[detail="%detail%"], div.%element%.detail-%detail% { + display : inline ; + font-style : %style% ; + font-variant : %variant% ; + font-weight : %weight% ; + font-family : %family% ; + color : %color% ; +}]] function wrapups.allusedstyles(xmlfile) local result = { formatters["/* %s for file %s */"]("styles",xmlfile) } @@ -384,7 +386,12 @@ local f_style = formatters [ [[ align = hyphens and "justify" or "inherited" end -- - result[#result+1] = f_document(bodyfont,width,align,hyphen) + result[#result+1] = replacetemplate(documenttemplate,{ + size = bodyfont, + width = width, + align = align, + hyphens = hyphen + }) -- local colorspecification = xml.css.colorspecification local fontspecification = xml.css.fontspecification @@ -392,12 +399,15 @@ local f_style = formatters [ [[ for detail, data in sortedhash(details) do local s = fontspecification(data.style) local c = colorspecification(data.color) - result[#result+1] = f_style(element,detail, - s.style or "inherit", - s.variant or "inherit", - s.weight or "inherit", - s.family or "inherit", - c or "inherit") + result[#result+1] = replacetemplate(styletemplate,{ + element = element, + detail = detail, + style = s.style or "inherit", + variant = s.variant or "inherit", + weight = s.weight or "inherit", + family = s.family or "inherit", + color = c or "inherit", + }) end end return concat(result,"\n\n") @@ -409,44 +419,56 @@ local usedimages = { } do -local f_image = formatters [ [[ -%s[id="%s"] { +local imagetemplate = [[ +%element%[id="%detail%"], div.%element%[id="%detail%"] { display : block ; - background-image : url(%s) ; + background-image : url(%name%) ; background-size : 100%% auto ; background-repeat : no-repeat ; - width : %s ; - height : %s ; -}]] ] + width : %width% ; + height : %height% ; +}]] + + + local function substitute(name) + if file.suffix(name) == "pdf" then + -- temp hack .. we will have a remapper + return file.replacesuffix(name,"svg") + else + return name + end + end + + local f_images = formatters["/* %s for file %s */"] + local collected = { } function wrapups.allusedimages(xmlfile) - local result = { formatters["/* %s for file %s */"]("images",xmlfile) } + local result = { f_images("images",xmlfile) } for element, details in sortedhash(usedimages) do for detail, data in sortedhash(details) do local name = data.name - if file.suffix(name) == "pdf" then - -- temp hack .. we will have a remapper - name = file.replacesuffix(name,"svg") - end - result[#result+1] = f_image(element,detail,name,data.width,data.height) + local full = url.addscheme(substitute(name)) + result[#result+1] = replacetemplate(imagetemplate,{ + element = element, + detail = detail, + name = full, + width = data.width, + height = data.height, + }) + collected[detail] = { + name = full, + width = data.width, + height = data.height, + page = data.page, + used = data.used, + } end end return concat(result,"\n\n") end - function wrapups.uniqueusedimages() - local unique = { } - for element, details in next, usedimages do - for detail, data in next, details do - local name = data.name - if file.suffix(name) == "pdf" then - unique[file.replacesuffix(name,"svg")] = name - else - unique[name] = name - end - end - end - return unique + function wrapups.uniqueusedimages() -- todo: combine these two + return collected end end @@ -710,9 +732,10 @@ do local f_imagespec = formatters[' id="%s" width="%s" height="%s"'] local f_imagepage = formatters[' page="%s"'] - function structurestags.setfigure(name,page,width,height) + function structurestags.setfigure(name,used,page,width,height) image[detailedtag("image")] = { name = name, + used = used, page = page, width = todimen(width, "cm","%0.3Fcm"), height = todimen(height,"cm","%0.3Fcm"), @@ -1026,6 +1049,12 @@ do return v end) + local dummy_nucleus = { + element = "mtext", + data = { content = "" }, + nature = "inline", + } + local function checkmath(root) -- we can provide utf.toentities as an option local data = root.data if data then @@ -1055,6 +1084,14 @@ do -- sub.__o__, sup.__o__ = subscript, superscript sub.__i__, sup.__i__ = superscript, subscript end +-- elseif roottg == "msup" or roottg == "msub" then +-- -- m$^2$ +-- if ndata == 1 then +-- local d = data[1] +-- data[2] = d +-- d.__i__ = 2 +-- data[1] = dummy_nucleus +-- end elseif roottg == "mfenced" then local new, n = { }, 0 local attributes = { } @@ -1272,7 +1309,8 @@ do } -- can be option if needed: if mode == "inline" then - di.nature = "mixed" -- else spacing problem (maybe inline) + -- di.nature = "mixed" -- else spacing problem (maybe inline) + di.nature = "inline" -- we need to catch x$X$x and x $X$ x else di.nature = "display" end @@ -1300,6 +1338,19 @@ do end end + function extras.msub(result,element,detail,n,fulltag,di) + -- m$^2$ + local data = di.data + if #data == 1 then + local d = data[1] + data[2] = d + d.__i__ = 2 + data[1] = dummy_nucleus + end + end + + extras.msup = extras.msub + end do @@ -2545,15 +2596,15 @@ local f_cssheadlink = formatters [ [[ return concat(result), concat(extras) end -local f_e_template = formatters [ [[ -%s { - display: %s ; -}]] ] +local f_e_template = [[ +%element% { + display: %display% ; +}]] -local f_d_template = formatters [ [[ -%s[detail=%s] { - display: %s ; -}]] ] +local f_d_template = [[ +%element%[detail=%detail%], div.detail-%detail% { + display: %display% ; +}]] local f_category = formatters["/* category: %s */"] @@ -2575,6 +2626,8 @@ local htmltemplate = [[ +
Rendering can be suboptimal because there is no default/fallback css loaded.
+ %body% @@ -2592,11 +2645,18 @@ local htmltemplate = [[ for element, details in sortedhash(used) do result[#result+1] = f_category(element) for detail, nature in sortedhash(details) do - local d = displaymapping[nature or "display"] or "block" + local display = displaymapping[nature or "display"] or "block" if detail == "" then - result[#result+1] = f_e_template(element,d) + result[#result+1] = replacetemplate(f_e_template, { + element = element, + display = display, + }) else - result[#result+1] = f_d_template(element,detail,d) + result[#result+1] = replacetemplate(f_d_template, { + element = element, + detail = detail, + display = display, + }) end end end @@ -2685,6 +2745,8 @@ local htmltemplate = [[ end end + -- maybe the reverse: be explicit about what is permitted + local private = { destination = true, prefix = true, @@ -2700,6 +2762,13 @@ local htmltemplate = [[ file = true, internal = true, location = true, + -- + name = true, -- image name + used = true, -- image name + page = true, -- image name + width = true, + height = true, + -- } local addclicks = true @@ -2872,6 +2941,8 @@ local htmltemplate = [[ name = file.removesuffix(v), identifier = os.uuid(), images = wrapups.uniqueusedimages(), + imagefile = imagefilename, + stylefile = stylefilename, root = xhtmlfile, files = files, language = languagenames[texgetcount("mainlanguagenumber")], @@ -2893,7 +2964,7 @@ local htmltemplate = [[ preamble = wholepreamble(false), title = specification.title, } - io.savedata(resultfile,utilities.templates.replace(htmltemplate,variables,"xml")) + io.savedata(resultfile,replacetemplate(htmltemplate,variables,"xml")) report_export("") report_export([[create epub with: mtxrun --script epub --make "%s"]],file.nameonly(resultfile)) report_export("") diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index 7cae68f0e..bda056fac 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -98,7 +98,7 @@ \to \everyenableelements \appendtoks % we can have differently scaled images - \unexpanded\def\dotagfigure{\taggedctxcommand{settagfigure("\figurefileoriginal","\figurefilepage",\number\dimexpr\figurewidth,\number\dimexpr\figureheight)}}% + \unexpanded\def\dotagfigure{\taggedctxcommand{settagfigure("\figurefileoriginal","\figurefullname","\figurefilepage",\number\dimexpr\figurewidth,\number\dimexpr\figureheight)}}% \to \everyenableelements \appendtoks diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 5b27eb60b..37a9ead0f 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.09.06 20:59} +\newcontextversion{2014.09.18 11:17} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index e6d7ad599..e0c719446 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 79b273b0a..f060a710b 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.09.06 20:59} +\edef\contextversion{2014.09.18 11:17} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua index 343485ed2..dd9f50dc8 100644 --- a/tex/context/base/core-con.lua +++ b/tex/context/base/core-con.lua @@ -983,7 +983,7 @@ end local whitespace = lpeg.patterns.whitespace local word = lpeg.patterns.utf8uppercharacter^-1 * (1-whitespace)^1 -local pattern_one = Cs(whitespace^0 * word^-1 * P(1)^1) +local pattern_one = Cs( whitespace^0 * word^-1 * P(1)^0) local pattern_all = Cs((whitespace^1 + word)^1) function converters.word (s) return s end -- dummies for typos diff --git a/tex/context/base/export-example.css b/tex/context/base/export-example.css index 10db21982..f78014a5d 100644 --- a/tex/context/base/export-example.css +++ b/tex/context/base/export-example.css @@ -50,7 +50,7 @@ document, div.document { } document>metadata, div.document div.metadata { - font-family : "Lucida Console", "DejaVu Sans Mono", monospace ; + font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; margin-bottom : 2em ; } @@ -312,7 +312,7 @@ verbatimblock, div.verbatimblock { padding : 1em ; margin-bottom : 1em ; margin-top : 1em ; - font-family : "Lucida Console", "DejaVu Sans Mono", monospace ; + font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; } verbatimlines+verbatimlines, div.verbatimlines+div.verbatimlines { @@ -329,7 +329,7 @@ verbatim, div.verbatim { display : inline ; white-space : pre-wrap ; color : rgb(60%,60%,0%) ; - font-family : "Lucida Console", "DejaVu Sans Mono", monospace ; + font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; } /* lines : display */ @@ -773,7 +773,17 @@ comment, div.comment { background-color : rgb(50%,75%,100%) ; display : block ; padding : 1em ; - margin-bottom : 1em ; - margin-top : 1em ; - font-family : "Lucida Console", "DejaVu Sans Mono", monospace ; + margin-bottom : 2ex ; + margin-top : 2ex ; + font-family : "DejaVu Sans Mono", "Lucida Console", monospace ; +} + +/* special */ + +c, div.c { + display : inline ; +} + +warning, div.warning { + display : none ; } diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index 7e3ed6e69..d3b13a680 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -725,7 +725,7 @@ local function register(askedname,specification) report_inclusion("format %a natively supported by backend",format) end else - specification.found = false + -- specification.found = false -- needs checking if trace_figures then report_inclusion("format %a supported by output file format",format) end diff --git a/tex/context/base/l-url.lua b/tex/context/base/l-url.lua index 8e96b4525..b189ec5bb 100644 --- a/tex/context/base/l-url.lua +++ b/tex/context/base/l-url.lua @@ -256,7 +256,7 @@ function url.construct(hash) -- dodo: we need to escape ! return lpegmatch(escaper,concat(fullurl)) end -local pattern = Cs(noslash * R("az","AZ") * (S(":|")/":") * noslash * P(1)^0) +local pattern = Cs(slash^-1/"" * R("az","AZ") * ((S(":|")/":") + P(":")) * slash * P(1)^0) function url.filename(filename) local spec = hashed(filename) @@ -266,6 +266,7 @@ end -- print(url.filename("/c|/test")) -- print(url.filename("/c/test")) +-- print(url.filename("file:///t:/sources/cow.svg")) local function escapestring(str) return lpegmatch(escaper,str) diff --git a/tex/context/base/lpdf-epa.lua b/tex/context/base/lpdf-epa.lua index 61d57b8d3..fd4d9eb7e 100644 --- a/tex/context/base/lpdf-epa.lua +++ b/tex/context/base/lpdf-epa.lua @@ -94,10 +94,17 @@ local function link_uri(x,y,w,h,document,annotation) end end +-- The rules in PDF on what a 'file specification' is, is in fact quite elaborate +-- (see section 3.10 in the 1.7 reference) so we need to test for string as well +-- as a table. TH/20140916 + local function link_file(x,y,w,h,document,annotation) local a = annotation.A if a then local filename = a.F + if type(filename) == "table" then + filename = filename.F + end if filename then filename = escapetex(filename) local destination = a.D diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index e8bd82cb9..b58008e7f 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -12,6 +12,7 @@ local utfchar, utfvalues = utf.char, utf.values local sind, cosd, floor, max, min = math.sind, math.cosd, math.floor, math.max, math.min local lpegmatch, P, C, R, S, Cc, Cs = lpeg.match, lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc, lpeg.Cs local formatters = string.formatters +local isboolean = string.is_boolean local report_objects = logs.reporter("backend","objects") local report_finalizing = logs.reporter("backend","finalizing") @@ -941,39 +942,59 @@ function lpdf.id() return format("%s.%s",tex.jobname,timestamp) end +-- return nil is nicer in test prints + function lpdf.checkedkey(t,key,variant) local pn = t and t[key] - if pn then + if pn ~= nil then local tn = type(pn) if tn == variant then if variant == "string" then - return pn ~= "" and pn or nil + if pn ~= "" then + return pn + end elseif variant == "table" then - return next(pn) and pn or nil + if next(pn) then + return pn + end else return pn end - elseif tn == "string" and variant == "number" then - return tonumber(pn) + elseif tn == "string" then + if variant == "number" then + return tonumber(pn) + elseif variant == "boolean" then + return isboolean(pn,nil,true) + end end end + -- return nil end function lpdf.checkedvalue(value,variant) -- code not shared - if value then + if value ~= nil then local tv = type(value) if tv == variant then if variant == "string" then - return value ~= "" and value + if value ~= "" then + return value + end elseif variant == "table" then - return next(value) and value + if next(value) then + return value + end else return value end - elseif tv == "string" and variant == "number" then - return tonumber(value) + elseif tv == "string" then + if variant == "number" then + return tonumber(value) + elseif variant == "boolean" then + return isboolean(value,nil,true) + end end end + -- return nil end function lpdf.limited(n,min,max,default) diff --git a/tex/context/base/lxml-css.lua b/tex/context/base/lxml-css.lua index 0deaea4d3..fa921b24f 100644 --- a/tex/context/base/lxml-css.lua +++ b/tex/context/base/lxml-css.lua @@ -146,7 +146,19 @@ local pattern = Cf( Ct("") * ( + (C("sansserif") + C("sans")) / "sans-serif" -- match before serif + C("serif") ) - ) + P(1) + ) +--+ P("\\") * ( +-- P("bf") * ( Cg ( Cc("weight") * Cc("bold") ) ) +-- + P("bi") * ( Cg ( Cc("weight") * Cc("bold") ) +-- * Cg ( Cc("style") * Cc("italic") ) ) +-- + P("bs") * ( Cg ( Cc("weight") * Cc("bold") ) +-- * Cg ( Cc("style") * Cc("oblique") ) ) +-- + P("it") * ( Cg ( Cc("style") * Cc("italic") ) ) +-- + P("sl") * ( Cg ( Cc("style") * Cc("oblique") ) ) +-- + P("sc") * ( Cg ( Cc("variant") * Cc("small-caps") ) ) +-- + P("tt") * ( Cg ( Cc("family") * Cc("monospace") ) ) +--) + + P(1) )^0 , rawset) function css.fontspecification(str) diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index c27d4ed40..31381b0ca 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -1543,6 +1543,8 @@ function lxml.att(id,a,default) end elseif str ~= "" then contextsprint(notcatcodes,str) + else + -- explicit empty is valid end elseif default and default ~= "" then contextsprint(notcatcodes,default) diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv index f7a2357bf..c85565703 100644 --- a/tex/context/base/page-sid.mkiv +++ b/tex/context/base/page-sid.mkiv @@ -764,7 +764,7 @@ \def\checksidefloat {\page_sides_check_floats} \def\flushsidefloats {\page_sides_flush_floats} \def\flushsidefloatsafterpar{\page_sides_flush_floats_after_par} -%def\forgetsidefloats {\page_sides_forget_floats} +\def\forgetsidefloats {\page_sides_forget_floats} %def\synchronizesidefloats {\page_sides_synchronize_floats} \protect \endinput diff --git a/tex/context/base/publ-fnd.lua b/tex/context/base/publ-fnd.lua index f9afd5fd0..ba60bdca0 100644 --- a/tex/context/base/publ-fnd.lua +++ b/tex/context/base/publ-fnd.lua @@ -11,6 +11,10 @@ if not characters then dofile(resolvers.findfile("char-utf.lua")) end +-- this tracker is only for real debugging and not for the average user + +local trace_match = false trackers.register("publications.cite.match", function(v) trace_match = v end) + if not publications then publications = { } end @@ -23,7 +27,7 @@ local concat = table.concat local formatters = string.formatters local lowercase = characters.lower -local report = logs.reporter("publications") +local report = logs.reporter("publications","match") local colon = P(":") local dash = P("-") @@ -67,9 +71,9 @@ end ----- pattern = Cs(b_match * ((field + range + match + space + P(1))-e_match)^1 * e_match) local b_match = lparent -local e_match = rparent * space^0 * (P(-1) + P(",")/" or ") +local e_match = rparent * space^0 * (#P(-1) + P(",")/" or ") -- maybe also + -> and local p_match = b_match * ((field + range + match + space + P(1))-e_match)^1 * e_match -local pattern = Cs(Cc("(") * (P("match")/"" * p_match)^1 * Cc(")")) +local pattern = Cs(Cc("(") * (P("match")/"" * space^0 * p_match)^1 * Cc(")")) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -93,7 +97,7 @@ local find = string.find local lower = characters.lower return function(entry) %s -return %s and true or false + return %s and true or false end ]] ] @@ -102,14 +106,25 @@ local function compile(expr) local keys = { } -- local expression = lpegmatch(pattern,expr,start,keys) local expression = lpegmatch(pattern,expr,1,keys) - -- report("compiling expression: %s",expr) + if trace_match then + report("compiling expression: %s",expr) + end local definitions = { } for k, v in next, keys do definitions[#definitions+1] = v end + if #definitions == 0 then + report("invalid expression: %s",expr) + elseif trace_match then + for i=1,#definitions do + report("% 3i : %s",i,definitions[i]) + end + end definitions = concat(definitions,"\n") local code = f_template(definitions,expression) - -- report("generated code: %s",code) + if trace_match then + report("generated code: %s",code) + end code = loadstring(code) if type(code) == "function" then code = code() @@ -121,6 +136,8 @@ local function compile(expr) return false end +-- print(lpegmatch(pattern,"match ( author:cleveland and year:1993 ) "),1,{}) + -- compile([[match(key:"foo bar")]]) -- compile([[match(key:'foo bar')]]) -- compile([[match(key:{foo bar})]]) diff --git a/tex/context/base/publ-imp-aps.mkvi b/tex/context/base/publ-imp-aps.mkvi index 7af8efead..49f5eaf73 100644 --- a/tex/context/base/publ-imp-aps.mkvi +++ b/tex/context/base/publ-imp-aps.mkvi @@ -153,7 +153,7 @@ \stoptexdefinition \starttexdefinition btx:aps:pages - \btxif {pages} { + \btxdoif {pages} { \btxcomma \btxoneorrange {pages} { \btxlabeltext{aps:p} @@ -319,7 +319,7 @@ \btxflush{series} } } - \btxif {chapter} { + \btxdoif {chapter} { \btxcomma \btxflush{chapter} } @@ -376,7 +376,7 @@ \texdefinition{btx:aps:publisher} \btxflush{year} \btxrparent - \btxif {edition} { + \btxdoif {edition} { \btxcomma \btxflush{edition} \btxspace @@ -410,7 +410,7 @@ } } { \btxdoifelse {crossref} { - \btxif {chapter} { + \btxdoif {chapter} { \btxcomma \btxflush{chapter} } @@ -432,7 +432,7 @@ \btxlabeltext{aps:volume}% vol. \btxnbsp \btxflush{volume} - \btxif {series} { + \btxdoif {series} { \btxnbsp \btxlabeltext{aps:of} \btxnbsp @@ -499,11 +499,11 @@ \stopsetups \startsetups btx:aps:manual - \btxif {title} { + \btxdoif {title} { \texdefinition {btx:aps:italic} { \btxflush{title} } - \btxif {series} { + \btxdoif {series} { \btxlparent \btxflush{series} \btxrparent @@ -512,18 +512,18 @@ } \btxdoifelse {year} { \btxlparent - \btxif {organization} { + \btxdoif {organization} { \btxflush{organization} \btxcomma } - \btxif {city} { + \btxdoif {city} { \btxflush{organization} \btxcomma } \btxflush{year} \btxrparent % st\or nd\or rd\else th\fi - \btxif {edition} { + \btxdoif {edition} { \btxcomma \btxflush{edition} \btxspace @@ -543,7 +543,7 @@ \btxdoifelse {author} { \btxflushauthor {author} } { - \btxif {key} { + \btxdoif {key} { \btxsetup{ntx:format:key} \btxcomma } @@ -573,17 +573,17 @@ \btxflush{series} } } - \btxif {chapter} { + \btxdoif {chapter} { \btxcomma \btxflush{chapter} } \btxspace - \btxif {year} { + \btxdoif {year} { \btxlparent \btxflush{year} \btxrparent \texdefinition{btx:aps:publisher} - \btxif {edition} { + \btxdoif {edition} { \btxcomma \btxflush{edition} \btxlabeltext{aps:edition}% ed. @@ -593,10 +593,10 @@ \btxperiod } { \btxlabeltext{aps:In} - \btxif {crossref} { + \btxdoif {crossref} { \btxflush{crossref} } - \btxif {chapter} { + \btxdoif {chapter} { \btxcomma \btxflush{chapter} \btxspace @@ -719,7 +719,7 @@ \btxrparent } \texdefinition{btx:aps:pages} - \btxif {city} { + \btxdoif {city} { \btxcomma \btxflush{city} } @@ -835,16 +835,16 @@ \btxflush{year} \btxrparent } { - \btxif {published} { + \btxdoif {published} { \btxcomma \btxflush{published} } } - \btxif {pages} { + \btxdoif {pages} { \btxcomma \btxflush{pages} } - \btxif {print} { + \btxdoif {print} { % eprint \btxcomma \btxflush{print} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index e75a657d3..9dc680772 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 564b9ee68..3936e2e7c 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-def.mkiv b/tex/context/base/strc-def.mkiv index 0738bdf29..2f5116459 100644 --- a/tex/context/base/strc-def.mkiv +++ b/tex/context/base/strc-def.mkiv @@ -220,19 +220,19 @@ [\c!before={\blank[\v!preference,\v!big]}, % sort of mkii compatible, watch columns \c!after=\blank, \c!label=\v!yes, - \c!distance=1em] + \c!distance=\emwidth] \setuplist [\v!chapter] [\c!before={\blank[\v!preference,\v!big]}, % sort of mkii compatible, watch columns \c!after=] -\setuplist [\v!part] [\c!width=0em] -\setuplist [\v!chapter] [\c!width=2em] -\setuplist [\v!section] [\c!width=3em] -\setuplist [\v!subsection] [\c!width=4em] -\setuplist [\v!subsubsection] [\c!width=5em] -\setuplist [\v!subsubsubsection] [\c!width=6em] -\setuplist [\v!subsubsubsubsection] [\c!width=7em] +\setuplist [\v!part] [\c!width=0\emwidth] +\setuplist [\v!chapter] [\c!width=2\emwidth] +\setuplist [\v!section] [\c!width=3\emwidth] +\setuplist [\v!subsection] [\c!width=4\emwidth] +\setuplist [\v!subsubsection] [\c!width=5\emwidth] +\setuplist [\v!subsubsubsection] [\c!width=6\emwidth] +\setuplist [\v!subsubsubsubsection] [\c!width=7\emwidth] \protect \endinput diff --git a/tex/context/base/trac-log.lua b/tex/context/base/trac-log.lua index 8e83bbafa..90da5cfe4 100644 --- a/tex/context/base/trac-log.lua +++ b/tex/context/base/trac-log.lua @@ -9,69 +9,11 @@ if not modules then modules = { } end modules ['trac-log'] = { -- In fact all writes could go through lua and we could write the console and -- terminal handler in lua then. Ok, maybe it's slower then, so a no-go. --- if tex and (tex.jobname or tex.formatname) then --- --- -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2) --- -- still needed for luajittex --- --- local texio_write_nl = texio.write_nl --- local texio_write = texio.write --- local io_write = io.write --- --- local write_nl = function(target,...) --- if not io_write then --- io_write = io.write --- end --- if target == "term and log" then --- texio_write_nl("log",...) --- texio_write_nl("term","") --- io_write(...) --- elseif target == "log" then --- texio_write_nl("log",...) --- elseif target == "term" then --- texio_write_nl("term","") --- io_write(...) --- else --- texio_write_nl("log",target,...) --- texio_write_nl("term","") --- io_write(target,...) --- end --- end --- --- local write = function(target,...) --- if not io_write then --- io_write = io.write --- end --- if target == "term and log" then --- texio_write("log",...) --- io_write(...) --- elseif target == "log" then --- texio_write("log",...) --- elseif target == "term" then --- io_write(...) --- else --- texio_write("log",target,...) --- io_write(target,...) --- end --- end --- --- texio.write = write --- texio.write_nl = write_nl --- --- else --- --- -- texlua or just lua --- --- end - --- todo: less categories, more subcategories (e.g. nodes) --- todo: split into basics and ctx specific - +local next, type, select, print = next, type, select, print local write_nl, write = texio and texio.write_nl or print, texio and texio.write or io.write local format, gmatch, find = string.format, string.gmatch, string.find local concat, insert, remove = table.concat, table.insert, table.remove local topattern = string.topattern -local next, type, select = next, type, select local utfchar = utf.char local datetime = os.date local openfile = io.open @@ -81,6 +23,14 @@ local formatters = string.formatters local texgetcount = tex and tex.getcount +-- variant is set now + +local variant = "default" +-- local variant = "ansi" + +-- todo: less categories, more subcategories (e.g. nodes) +-- todo: split into basics and ctx specific + --[[ldx--

This is a prelude to a more extensive logging module. We no longer provide based logging as parsing is relatively easy anyway.

@@ -114,12 +64,12 @@ wiki : http://contextgarden.net -- [[local chruni = utilities.strings.chruni]] -- ) -utilities.strings.formatters.add ( +formatters.add ( formatters, "unichr", [["U+" .. format("%%05X",%s) .. " (" .. utfchar(%s) .. ")"]] ) -utilities.strings.formatters.add ( +formatters.add ( formatters, "chruni", [[utfchar(%s) .. " (U+" .. format("%%05X",%s) .. ")"]] ) @@ -154,18 +104,125 @@ local report, subreport, status, settarget, setformats, settranslations local direct, subdirect, writer, pushtarget, poptarget, setlogfile, settimedlog, setprocessor, setformatters +-- we use formatters but best check for % then because for simple messages but +-- we don't want this overhead for single messages (not that there are that +-- many; we could have a special weak table) + if tex and (tex.jobname or tex.formatname) then - -- local format = string.formatter + local function useluawrites() + + -- quick hack, awaiting speedup in engine (8 -> 6.4 sec for --make with console2) + -- still needed for luajittex .. luatex should not have that ^^ mess + + local texio_write_nl = texio.write_nl + local texio_write = texio.write + local io_write = io.write + + write_nl = function(target,...) + if not io_write then + io_write = io.write + end + if target == "term and log" then + texio_write_nl("log",...) + texio_write_nl("term","") + io_write(...) + elseif target == "log" then + texio_write_nl("log",...) + elseif target == "term" then + texio_write_nl("term","") + io_write(...) + elseif target ~= "none" then + texio_write_nl("log",target,...) + texio_write_nl("term","") + io_write(target,...) + end + end + + write = function(target,...) + if not io_write then + io_write = io.write + end + if target == "term and log" then + texio_write("log",...) + io_write(...) + elseif target == "log" then + texio_write("log",...) + elseif target == "term" then + io_write(...) + elseif target ~= "none" then + texio_write("log",target,...) + io_write(target,...) + end + end - local valueiskey = { __index = function(t,k) t[k] = k return k end } -- will be helper + texio.write = write + texio.write_nl = write_nl - local target = "term and log" + useluawrites = ignore - logs.flush = io.flush + end + + -- local format = string.formatter + + local whereto = "both" + local target = nil + local targets = nil + + local formats = table.setmetatableindex("self") + local translations = table.setmetatableindex("self") + + local report_yes, subreport_yes, direct_yes, subdirect_yes, status_yes + local report_nop, subreport_nop, direct_nop, subdirect_nop, status_nop + + local variants = { + default = { + formats = { + report_yes = formatters["%-15s > %s\n"], + report_nop = formatters["%-15s >\n"], + direct_yes = formatters["%-15s > %s"], + direct_nop = formatters["%-15s >"], + subreport_yes = formatters["%-15s > %s > %s\n"], + subreport_nop = formatters["%-15s > %s >\n"], + subdirect_yes = formatters["%-15s > %s > %s"], + subdirect_nop = formatters["%-15s > %s >"], + status_yes = formatters["%-15s : %s\n"], + status_nop = formatters["%-15s :\n"], + }, + targets = { + logfile = "log", + log = "log", + file = "log", + console = "term", + terminal = "term", + both = "term and log", + }, + }, + ansi = { + formats = { + report_yes = formatters["%-15s > %s\n"], + report_nop = formatters["%-15s >\n"], + direct_yes = formatters["%-15s > %s"], + direct_nop = formatters["%-15s >"], + subreport_yes = formatters["%-15s > %s > %s\n"], + subreport_nop = formatters["%-15s > %s >\n"], + subdirect_yes = formatters["%-15s > %s > %s"], + subdirect_nop = formatters["%-15s > %s >"], + status_yes = formatters["%-15s : %s\n"], + status_nop = formatters["%-15s :\n"], + }, + targets = { + logfile = "none", + log = "none", + file = "none", + console = "term", + terminal = "term", + both = "term", + }, + } + } - local formats = { } setmetatable(formats, valueiskey) - local translations = { } setmetatable(translations,valueiskey) + logs.flush = io.flush writer = function(...) write_nl(target,...) @@ -175,13 +232,6 @@ if tex and (tex.jobname or tex.formatname) then write_nl(target,"\n") end - local report_yes = formatters["%-15s > %s\n"] - local report_nop = formatters["%-15s >\n"] - - -- we can use formatters but best check for % then because for simple messages - -- we con't want this overhead for single messages (not that there are that - -- many; we could have a special weak table) - report = function(a,b,c,...) if c then write_nl(target,report_yes(translations[a],formatters[formats[b]](c,...))) @@ -194,9 +244,6 @@ if tex and (tex.jobname or tex.formatname) then end end - local direct_yes = formatters["%-15s > %s"] - local direct_nop = formatters["%-15s >"] - direct = function(a,b,c,...) if c then return direct_yes(translations[a],formatters[formats[b]](c,...)) @@ -209,9 +256,6 @@ if tex and (tex.jobname or tex.formatname) then end end - local subreport_yes = formatters["%-15s > %s > %s\n"] - local subreport_nop = formatters["%-15s > %s >\n"] - subreport = function(a,s,b,c,...) if c then write_nl(target,subreport_yes(translations[a],translations[s],formatters[formats[b]](c,...))) @@ -224,9 +268,6 @@ if tex and (tex.jobname or tex.formatname) then end end - local subdirect_yes = formatters["%-15s > %s > %s"] - local subdirect_nop = formatters["%-15s > %s >"] - subdirect = function(a,s,b,c,...) if c then return subdirect_yes(translations[a],translations[s],formatters[formats[b]](c,...)) @@ -239,9 +280,6 @@ if tex and (tex.jobname or tex.formatname) then end end - local status_yes = formatters["%-15s : %s\n"] - local status_nop = formatters["%-15s :\n"] - status = function(a,b,c,...) if c then write_nl(target,status_yes(translations[a],formatters[formats[b]](c,...))) @@ -254,17 +292,13 @@ if tex and (tex.jobname or tex.formatname) then end end - local targets = { - logfile = "log", - log = "log", - file = "log", - console = "term", - terminal = "term", - both = "term and log", - } - - settarget = function(whereto) - target = targets[whereto or "both"] or targets.both + settarget = function(askedwhereto) + whereto = askedwhereto or whereto or "both" + target = targets[whereto] + if not target then + whereto = "both" + target = targets[whereto] + end if target == "term" or target == "term and log" then logs.flush = io.flush else @@ -300,24 +334,81 @@ if tex and (tex.jobname or tex.formatname) then end end - setformatters = function(f) - report_yes = f.report_yes or report_yes - report_nop = f.report_nop or report_nop - subreport_yes = f.subreport_yes or subreport_yes - subreport_nop = f.subreport_nop or subreport_nop - direct_yes = f.direct_yes or direct_yes - direct_nop = f.direct_nop or direct_nop - subdirect_yes = f.subdirect_yes or subdirect_yes - subdirect_nop = f.subdirect_nop or subdirect_nop - status_yes = f.status_yes or status_yes - status_nop = f.status_nop or status_nop + setformatters = function(specification) + local t = nil + local f = nil + local d = variants.default + if not specification then + -- + elseif type(specification) == "table" then + t = specification.targets + f = specification.formats or specification + else + local v = variants[specification] + if v then + t = v.targets + f = v.formats + variant = specification + end + end + targets = t or d.targets + target = targets[whereto] or target + if f then + d = d.formats + else + f = d.formats + d = f + end + setmetatableindex(f,d) + report_yes = f.report_yes + report_nop = f.report_nop + subreport_yes = f.subreport_yes + subreport_nop = f.subreport_nop + direct_yes = f.direct_yes + direct_nop = f.direct_nop + subdirect_yes = f.subdirect_yes + subdirect_nop = f.subdirect_nop + status_yes = f.status_yes + status_nop = f.status_nop + if variant == "ansi" then + useluawrites() -- because tex escapes ^^ + end + settarget(whereto) end + setformatters(variant) + setlogfile = ignore settimedlog = ignore else + local report_yes, subreport_yes, status_yes + local report_nop, subreport_nop, status_nop + + local variants = { + default = { + formats = { + report_yes = formatters["%-15s | %s"], + report_nop = formatters["%-15s |"], + subreport_yes = formatters["%-15s | %s | %s"], + subreport_nop = formatters["%-15s | %s |"], + status_yes = formatters["%-15s : %s\n"], + status_nop = formatters["%-15s :\n"], + }, + }, + ansi = { + formats = { + report_yes = formatters["%-15s | %s"], + report_nop = formatters["%-15s |"], + subreport_yes = formatters["%-15s | %s | %s"], + subreport_nop = formatters["%-15s | %s |"], + status_yes = formatters["%-15s : %s\n"], + status_nop = formatters["%-15s :\n"], + }, + }, + } + logs.flush = ignore writer = function(s) @@ -328,9 +419,6 @@ else write_nl("\n") end - local report_yes = formatters["%-15s | %s"] - local report_nop = formatters["%-15s |"] - report = function(a,b,c,...) if c then write_nl(report_yes(a,formatters[b](c,...))) @@ -343,9 +431,6 @@ else end end - local subreport_yes = formatters["%-15s | %s | %s"] - local subreport_nop = formatters["%-15s | %s |"] - subreport = function(a,sub,b,c,...) if c then write_nl(subreport_yes(a,sub,formatters[b](c,...))) @@ -358,9 +443,6 @@ else end end - local status_yes = formatters["%-15s : %s\n"] - local status_nop = formatters["%-15s :\n"] - status = function(a,b,c,...) -- not to be used in lua anyway if c then write_nl(status_yes(a,formatters[b](c,...))) @@ -389,15 +471,36 @@ else end end - setformatters = function(f) - report_yes = f.report_yes or report_yes - report_nop = f.report_nop or report_nop - subreport_yes = f.subreport_yes or subreport_yes - subreport_nop = f.subreport_nop or subreport_nop - status_yes = f.status_yes or status_yes - status_nop = f.status_nop or status_nop + setformatters = function(specification) + local f = nil + local d = variants.default + if specification then + if type(specification) == "table" then + f = specification.formats or specification + else + local v = variants[specification] + if v then + f = v.formats + end + end + end + if f then + d = d.formats + else + f = d.formats + d = f + end + setmetatableindex(f,d) + report_yes = f.report_yes + report_nop = f.report_nop + subreport_yes = f.subreport_yes + subreport_nop = f.subreport_nop + status_yes = f.status_yes + status_nop = f.status_nop end + setformatters(variant) + setlogfile = function(name,keepopen) if name and name ~= "" then local localtime = os.localtime @@ -728,13 +831,13 @@ logs.simpleline = simple -- obsolete -function logs.setprogram () end -- obsolete -function logs.extendbanner() end -- obsolete -function logs.reportlines () end -- obsolete -function logs.reportbanner() end -- obsolete -function logs.reportline () end -- obsolete -function logs.simplelines () end -- obsolete -function logs.help () end -- obsolete +logs.setprogram = ignore -- obsolete +logs.extendbanner = ignore -- obsolete +logs.reportlines = ignore -- obsolete +logs.reportbanner = ignore -- obsolete +logs.reportline = ignore -- obsolete +logs.simplelines = ignore -- obsolete +logs.help = ignore -- obsolete -- applications diff --git a/tex/context/base/util-str.lua b/tex/context/base/util-str.lua index fd6fc4d91..8529c3ad0 100644 --- a/tex/context/base/util-str.lua +++ b/tex/context/base/util-str.lua @@ -537,7 +537,7 @@ end -- We could probably use just %s with integers but who knows what Lua 5.3 will do? So let's -- for the moment use %i. -local format_F = function() -- beware, no cast to number +local format_F = function(f) -- beware, no cast to number n = n + 1 if not f or f == "" then return format("(((a%s > -0.0000000005 and a%s < 0.0000000005) and '0') or format((a%s %% 1 == 0) and '%%i' or '%%.9f',a%s))",n,n,n,n) diff --git a/tex/context/base/x-cals.lua b/tex/context/base/x-cals.lua index 36bc1aaba..13f0e2bbe 100644 --- a/tex/context/base/x-cals.lua +++ b/tex/context/base/x-cals.lua @@ -65,8 +65,10 @@ end local function getspecs(root, pattern, names, widths) -- here, but actually we need this in core-ntb.tex -- but ideally we need an mkiv enhanced core-ntb.tex - local ignore_widths = cals.ignore_widths - local shrink_widths = cals.shrink_widths + local ignore_widths = cals.ignore_widths +-- local shrink_widths = at.option == "shrink" or cals.shrink_widths +-- local stretch_widths = at.option == "stretch" or cals.stretch_widths + local shrink_widths = cals.shrink_widths local stretch_widths = cals.stretch_widths for e in xmlcollected(root,pattern) do local at = e.at diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 5f4d5c1dd..d58fa5f1c 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 : 09/06/14 20:59:58 +-- merge date : 09/18/14 11:17:09 do -- begin closure to overcome local limits and interference @@ -2940,7 +2940,7 @@ local format_f=function(f) n=n+1 return format("format('%%%sf',a%s)",f,n) end -local format_F=function() +local format_F=function(f) n=n+1 if not f or f=="" then return format("(((a%s > -0.0000000005 and a%s < 0.0000000005) and '0') or format((a%s %% 1 == 0) and '%%i' or '%%.9f',a%s))",n,n,n,n) -- cgit v1.2.3