summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-11-24 17:20:15 +0200
committerMarius <mariausol@gmail.com>2011-11-24 17:20:15 +0200
commitb0b3f63745dbcd338e4ce549c2f8c4427998ffcf (patch)
tree9bf20816667adef0f781f7a6cfccd8e61f1a7a7b
parentae4e7c1b2b58b4b089b5eff6e8f41371a309a538 (diff)
downloadcontext-b0b3f63745dbcd338e4ce549c2f8c4427998ffcf.tar.gz
beta 2011.11.24 15:52
-rw-r--r--context/data/scite/lexers/data/scite-context-data-metafun.lua2
-rw-r--r--context/data/scite/lexers/data/scite-context-data-metapost.lua4
-rw-r--r--context/data/scite/lexers/scite-context-lexer-lua-longstring.lua22
-rw-r--r--context/data/scite/lexers/scite-context-lexer-lua.lua44
-rw-r--r--context/data/scite/lexers/scite-context-lexer-mps.lua60
-rw-r--r--context/data/scite/lexers/themes/scite-context-theme.lua2
-rw-r--r--context/data/scite/scite-context-data-metafun.properties7
-rw-r--r--context/data/scite/scite-context-data-metapost.properties110
-rw-r--r--metapost/context/base/mp-base.mpiv2
-rw-r--r--metapost/context/base/mp-grph.mpiv4
-rw-r--r--metapost/context/base/mp-tool.mpiv34
-rw-r--r--scripts/context/lua/mtxrun.lua209
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua209
-rw-r--r--scripts/context/stubs/unix/mtxrun209
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4075 -> 4069 bytes
-rw-r--r--tex/context/base/context-version.pngbin106394 -> 106436 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv3
-rw-r--r--tex/context/base/lxml-lpt.lua2
-rw-r--r--tex/context/base/lxml-tex.lua447
-rw-r--r--tex/context/base/lxml-xml.lua217
-rw-r--r--tex/context/base/math-for.mkiv78
-rw-r--r--tex/context/base/math-scr.mkiv4
-rw-r--r--tex/context/base/mult-mps.lua7
-rw-r--r--tex/context/base/page-mbk.mkvi236
-rw-r--r--tex/context/base/page-mis.mkiv134
-rw-r--r--tex/context/base/status-files.pdfbin23996 -> 24020 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin167932 -> 167927 bytes
-rw-r--r--tex/context/base/strc-flt.mkvi15
-rw-r--r--tex/context/base/strc-mat.mkiv309
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
33 files changed, 1376 insertions, 1002 deletions
diff --git a/context/data/scite/lexers/data/scite-context-data-metafun.lua b/context/data/scite/lexers/data/scite-context-data-metafun.lua
index 8bca17228..f8f91d609 100644
--- a/context/data/scite/lexers/data/scite-context-data-metafun.lua
+++ b/context/data/scite/lexers/data/scite-context-data-metafun.lua
@@ -1,4 +1,4 @@
return {
- ["commands"]={ "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "acosh", "asinh", "sinh", "cosh", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", "llcircle", "lrcircle", "urcircle", "ulcircle", "tcircle", "bcircle", "lcircle", "rcircle", "lltriangle", "lrtriangle", "urtriangle", "ultriangle", "smoothed", "cornered", "superellipsed", "randomized", "squeezed", "enlonged", "shortened", "punked", "curved", "unspiked", "simplified", "blownup", "stretched", "enlarged", "leftenlarged", "topenlarged", "rightenlarged", "bottomenlarged", "crossed", "laddered", "randomshifted", "interpolated", "paralleled", "cutends", "peepholed", "llenlarged", "lrenlarged", "urenlarged", "ulenlarged", "llmoved", "lrmoved", "urmoved", "ulmoved", "rightarrow", "leftarrow", "centerarrow", "boundingbox", "innerboundingbox", "outerboundingbox", "pushboundingbox", "popboundingbox", "bottomboundary", "leftboundary", "topboundary", "rightboundary", "xsized", "ysized", "xysized", "sized", "xyscaled", "intersection_point", "intersection_found", "penpoint", "bbwidth", "bbheight", "withshade", "withlinearshading", "withcircularshading", "withfromshadecolor", "withtoshadecolor", "withshading", "shadedinto", "withcircularshade", "withlinearshade", "cmyk", "spotcolor", "multitonecolor", "namedcolor", "drawfill", "undrawfill", "inverted", "uncolored", "softened", "grayed", "greyed", "onlayer", "along", "graphictext", "loadfigure", "externalfigure", "withmask", "figure", "register", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", "textext", "thetextext", "rawtextext", "textextoffset", "verbatim", "thelabel", "label", "transparent", "withtransparency", "infont", "set_linear_vector", "linear_shade", "define_linear_shade", "define_circular_linear_shade", "define_sampled_linear_shade", "set_circular_vector", "circular_shade", "define_circular_shade", "define_circular_linear_shade", "define_sampled_circular_shade", "space", "CRLF", "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "readfile", "clearxy", "unitvector", "center", "epsed", "anchored", "originpath", "infinite", "break", "xstretched", "ystretched", "snapped", "pathconnectors", "function", "constructedpath", "constructedpairs", "punkedfunction", "curvedfunction", "tightfunction", "punkedpath", "curvedpath", "tightpath", "punkedpairs", "curvedpairs", "tightpairs", "evenly", "oddly", "drawboundary" },
+ ["commands"]={ "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "acosh", "asinh", "sinh", "cosh", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", "llcircle", "lrcircle", "urcircle", "ulcircle", "tcircle", "bcircle", "lcircle", "rcircle", "lltriangle", "lrtriangle", "urtriangle", "ultriangle", "smoothed", "cornered", "superellipsed", "randomized", "squeezed", "enlonged", "shortened", "punked", "curved", "unspiked", "simplified", "blownup", "stretched", "enlarged", "leftenlarged", "topenlarged", "rightenlarged", "bottomenlarged", "crossed", "laddered", "randomshifted", "interpolated", "paralleled", "cutends", "peepholed", "llenlarged", "lrenlarged", "urenlarged", "ulenlarged", "llmoved", "lrmoved", "urmoved", "ulmoved", "rightarrow", "leftarrow", "centerarrow", "boundingbox", "innerboundingbox", "outerboundingbox", "pushboundingbox", "popboundingbox", "bottomboundary", "leftboundary", "topboundary", "rightboundary", "xsized", "ysized", "xysized", "sized", "xyscaled", "intersection_point", "intersection_found", "penpoint", "bbwidth", "bbheight", "withshade", "withlinearshading", "withcircularshading", "withfromshadecolor", "withtoshadecolor", "withshading", "shadedinto", "withcircularshade", "withlinearshade", "cmyk", "spotcolor", "multitonecolor", "namedcolor", "drawfill", "undrawfill", "inverted", "uncolored", "softened", "grayed", "greyed", "onlayer", "along", "graphictext", "loadfigure", "externalfigure", "withmask", "figure", "register", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", "textext", "thetextext", "rawtextext", "textextoffset", "verbatim", "thelabel", "label", "transparent", "withtransparency", "infont", "set_linear_vector", "linear_shade", "define_linear_shade", "define_circular_linear_shade", "define_sampled_linear_shade", "set_circular_vector", "circular_shade", "define_circular_shade", "define_circular_linear_shade", "define_sampled_circular_shade", "space", "CRLF", "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "readfile", "clearxy", "unitvector", "center", "epsed", "anchored", "originpath", "infinite", "break", "xstretched", "ystretched", "snapped", "pathconnectors", "function", "constructedpath", "constructedpairs", "punkedfunction", "curvedfunction", "tightfunction", "punkedpath", "curvedpath", "tightpath", "punkedpairs", "curvedpairs", "tightpairs", "evenly", "oddly", "normalfill", "normaldraw", "visualizepaths", "naturalizepaths", "drawboundary", "drawwholepath", "visualizeddraw", "visualizedfill", "draworigin", "drawboundingbox", "drawpath", "drawpoint", "drawpoints", "drawcontrolpoints", "drawcontrollines", "drawpointlabels", "drawlineoptions", "drawpointoptions", "drawcontroloptions", "drawlabeloptions", "draworiginoptions", "drawboundoptions", "drawpathoptions", "resetdrawoptions" },
["internals"]={ "nocolormodel", "greycolormodel", "graycolormodel", "rgbcolormodel", "cmykcolormodel", "shadefactor", "textextoffset", "normaltransparent", "multiplytransparent", "screentransparent", "overlaytransparent", "softlighttransparent", "hardlighttransparent", "colordodgetransparent", "colorburntransparent", "darkentransparent", "lightentransparent", "differencetransparent", "exclusiontransparent", "huetransparent", "saturationtransparent", "colortransparent", "luminositytransparent" },
} \ No newline at end of file
diff --git a/context/data/scite/lexers/data/scite-context-data-metapost.lua b/context/data/scite/lexers/data/scite-context-data-metapost.lua
index 95899fa90..d3c199089 100644
--- a/context/data/scite/lexers/data/scite-context-data-metapost.lua
+++ b/context/data/scite/lexers/data/scite-context-data-metapost.lua
@@ -1,7 +1,7 @@
return {
- ["commands"]={ "arrowhead", "currentpen", "currentpicture", "cuttings", "defaultfont", "extra_beginfig", "extra_endfig", "ditto", "EOF", "down", "evenly", "fullcircle", "halfcircle", "identity", "in", "left", "origin", "pensquare", "quartercircle", "right", "unitsquare", "up", "withdots", "abs", "bbox", "ceiling", "center", "cutafter", "cutbefore", "dir", "directionpoint", "div", "dotprod", "intersectionpoint", "inverse", "mod", "round", "unitvector", "whatever", "cutdraw", "draw", "drawarrow", "drawdblarrow", "fill", "filldraw", "drawdot", "loggingall", "interact", "tracingall", "tracingnone", "pickup", "undraw", "unfill", "unfilldraw", "buildcycle", "dashpattern", "decr", "dotlabel", "dotlabels", "drawoptions", "incr", "label", "labels", "max", "min", "thelabel", "z", "beginchar", "blacker", "capsule_end", "change_width", "define_blacker_pixels", "define_corrected_pixels", "define_good_x_pixels", "define_good_y_pixels", "define_horizontal_corrected_pixels", "define_pixels", "define_whole_blacker_pixels", "define_whole_pixels", "define_whole_vertical_blacker_pixels", "define_whole_vertical_pixels", "endchar", "extra_beginchar", "extra_endchar", "extra_setup", "font_coding_scheme", "clearxy", "clearit", "clearpen", "shipit", "font_extra_space", "exitunless", "relax", "hide", "gobble", "gobbled", "stop", "blankpicture", "counterclockwise", "tensepath", "takepower", "direction", "softjoin", "makelabel", "rotatedabout", "flex", "superellipse", "erase", "image", "nullpen", "savepen", "clearpen", "penpos", "penlabels", "range", "numtok", "thru", "z", "laboff", "bye", "red", "green", "blue", "cyan", "magenta", "yellow", "black", "white", "background", "graypart", "graycolor", "mm", "pt", "dd", "bp", "cm", "pc", "cc", "in" },
+ ["commands"]={ "beginfig", "endfig", "rotatedaround", "reflectedabout", "arrowhead", "currentpen", "currentpicture", "cuttings", "defaultfont", "extra_beginfig", "extra_endfig", "ditto", "EOF", "down", "evenly", "fullcircle", "halfcircle", "identity", "in", "left", "origin", "pensquare", "quartercircle", "right", "unitsquare", "up", "withdots", "abs", "bbox", "ceiling", "center", "cutafter", "cutbefore", "dir", "directionpoint", "div", "dotprod", "intersectionpoint", "inverse", "mod", "round", "unitvector", "whatever", "cutdraw", "draw", "drawarrow", "drawdblarrow", "fill", "filldraw", "drawdot", "loggingall", "interact", "tracingall", "tracingnone", "pickup", "undraw", "unfill", "unfilldraw", "buildcycle", "dashpattern", "decr", "dotlabel", "dotlabels", "drawoptions", "incr", "label", "labels", "max", "min", "thelabel", "z", "beginchar", "blacker", "capsule_end", "change_width", "define_blacker_pixels", "define_corrected_pixels", "define_good_x_pixels", "define_good_y_pixels", "define_horizontal_corrected_pixels", "define_pixels", "define_whole_blacker_pixels", "define_whole_pixels", "define_whole_vertical_blacker_pixels", "define_whole_vertical_pixels", "endchar", "extra_beginchar", "extra_endchar", "extra_setup", "font_coding_scheme", "clearxy", "clearit", "clearpen", "shipit", "font_extra_space", "exitunless", "relax", "hide", "gobble", "gobbled", "stop", "blankpicture", "counterclockwise", "tensepath", "takepower", "direction", "softjoin", "makelabel", "rotatedabout", "flex", "superellipse", "erase", "image", "nullpen", "savepen", "clearpen", "penpos", "penlabels", "range", "numtok", "thru", "z", "laboff", "bye", "red", "green", "blue", "cyan", "magenta", "yellow", "black", "white", "background", "graypart", "graycolor", "mm", "pt", "dd", "bp", "cm", "pc", "cc", "in" },
["internals"]={ "mitered", "rounded", "beveled", "butt", "squared", "eps", "epsilon", "infinity", "bboxmargin", "ahlength", "ahangle", "labeloffset", "dotlabeldiam", "defaultpen", "defaultscale", "join_radius", "pen_lft", "pen_rt", "pen_top", "pen_bot" },
- ["primitives"]={ "charcode", "day", "linecap", "linejoin", "miterlimit", "month", "pausing", "prologues", "showstopping", "time", "tracingcapsules", "tracingchoices", "mpprocset", "tracingcommands", "tracingequations", "tracinglostchars", "tracingmacros", "tracingonline", "tracingoutput", "tracingrestores", "tracingspecs", "tracingstats", "tracingtitles", "truecorners", "warningcheck", "year", "false", "nullpicture", "pencircle", "true", "and", "angle", "arclength", "arctime", "ASCII", "boolean", "bot", "char", "color", "cosd", "cycle", "decimal", "directiontime", "floor", "fontsize", "hex", "infont", "intersectiontimes", "known", "length", "llcorner", "lrcorner", "makepath", "makepen", "mexp", "mlog", "normaldeviate", "not", "numeric", "oct", "odd", "or", "path", "pair", "pen", "penoffset", "picture", "point", "postcontrol", "precontrol", "reverse", "rotated", "scaled", "shifted", "sind", "slanted", "sqrt", "str", "string", "subpath", "substring", "transform", "transformed", "ulcorner", "uniformdeviate", "unknown", "urcorner", "xpart", "xscaled", "xxpart", "xypart", "ypart", "yscaled", "yxpart", "yypart", "zscaled", "addto", "clip", "input", "interim", "let", "newinternal", "save", "setbounds", "shipout", "show", "showdependencies", "showtoken", "showvariable", "special", "begingroup", "endgroup", "of", "curl", "tension", "and", "controls", "reflectedabout", "rotatedaround", "interpath", "on", "off", "beginfig", "endfig", "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary", "tertiary", "primarydef", "secondarydef", "tertiarydef", "randomseed", "also", "contour", "doublepath", "withcolor", "withpen", "dashed", "if", "else", "elseif", "fi", "for", "endfor", "forever", "exitif", "forsuffixes", "downto", "upto", "step", "until", "charlist", "extensible", "fontdimen", "headerbyte", "kern", "ligtable", "boundarychar", "chardp", "charext", "charht", "charic", "charwd", "designsize", "fontmaking", "charexists", "cullit", "currenttransform", "gfcorners", "grayfont", "hround", "imagerules", "lowres_fix", "nodisplays", "notransforms", "openit", "displaying", "currentwindow", "screen_rows", "screen_cols", "pixels_per_inch", "cull", "display", "openwindow", "numspecial", "totalweight", "autorounding", "fillin", "proofing", "tracingpens", "xoffset", "chardx", "granularity", "smoothing", "turningcheck", "yoffset", "chardy", "hppp", "tracingedges", "vppp", "extra_beginfig", "extra_endfig", "mpxbreak", "endinput", "message", "delimiters", "turningnumber", "errmessage", "readstring", "scantokens", "end", "outer", "inner", "write", "to", "readfrom", "withprescript", "withpostscript", "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", "redpart", "greenpart", "bluepart", "cyanpart", "magentapart", "yellowpart", "blackpart", "greypart", "rgbcolor", "cmykcolor", "greycolor", "graycolor", "colormodel", "graypart", "expandafter" },
+ ["primitives"]={ "charcode", "day", "linecap", "linejoin", "miterlimit", "month", "pausing", "prologues", "showstopping", "time", "tracingcapsules", "tracingchoices", "mpprocset", "tracingcommands", "tracingequations", "tracinglostchars", "tracingmacros", "tracingonline", "tracingoutput", "tracingrestores", "tracingspecs", "tracingstats", "tracingtitles", "truecorners", "warningcheck", "year", "false", "nullpicture", "pencircle", "true", "and", "angle", "arclength", "arctime", "ASCII", "boolean", "bot", "char", "color", "cosd", "cycle", "decimal", "directiontime", "floor", "fontsize", "hex", "infont", "intersectiontimes", "known", "length", "llcorner", "lrcorner", "makepath", "makepen", "mexp", "mlog", "normaldeviate", "not", "numeric", "oct", "odd", "or", "path", "pair", "pen", "penoffset", "picture", "point", "postcontrol", "precontrol", "reverse", "rotated", "scaled", "shifted", "sind", "slanted", "sqrt", "str", "string", "subpath", "substring", "transform", "transformed", "ulcorner", "uniformdeviate", "unknown", "urcorner", "xpart", "xscaled", "xxpart", "xypart", "ypart", "yscaled", "yxpart", "yypart", "zscaled", "addto", "clip", "input", "interim", "let", "newinternal", "save", "setbounds", "shipout", "show", "showdependencies", "showtoken", "showvariable", "special", "begingroup", "endgroup", "of", "curl", "tension", "and", "controls", "interpath", "on", "off", "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary", "tertiary", "primarydef", "secondarydef", "tertiarydef", "randomseed", "also", "contour", "doublepath", "withcolor", "withpen", "dashed", "if", "else", "elseif", "fi", "for", "endfor", "forever", "exitif", "forsuffixes", "downto", "upto", "step", "until", "charlist", "extensible", "fontdimen", "headerbyte", "kern", "ligtable", "boundarychar", "chardp", "charext", "charht", "charic", "charwd", "designsize", "fontmaking", "charexists", "cullit", "currenttransform", "gfcorners", "grayfont", "hround", "imagerules", "lowres_fix", "nodisplays", "notransforms", "openit", "displaying", "currentwindow", "screen_rows", "screen_cols", "pixels_per_inch", "cull", "display", "openwindow", "numspecial", "totalweight", "autorounding", "fillin", "proofing", "tracingpens", "xoffset", "chardx", "granularity", "smoothing", "turningcheck", "yoffset", "chardy", "hppp", "tracingedges", "vppp", "extra_beginfig", "extra_endfig", "mpxbreak", "endinput", "message", "delimiters", "turningnumber", "errmessage", "readstring", "scantokens", "end", "outer", "inner", "write", "to", "readfrom", "withprescript", "withpostscript", "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", "redpart", "greenpart", "bluepart", "cyanpart", "magentapart", "yellowpart", "blackpart", "greypart", "rgbcolor", "cmykcolor", "greycolor", "graycolor", "colormodel", "graypart", "expandafter" },
["shortcuts"]={ "..", "...", "--", "---", "&" },
["tex"]={ "btex", "etex", "verbatimtex" },
} \ No newline at end of file
diff --git a/context/data/scite/lexers/scite-context-lexer-lua-longstring.lua b/context/data/scite/lexers/scite-context-lexer-lua-longstring.lua
new file mode 100644
index 000000000..dd58dfe3b
--- /dev/null
+++ b/context/data/scite/lexers/scite-context-lexer-lua-longstring.lua
@@ -0,0 +1,22 @@
+local lexer = lexer
+local token = lexer.token
+local P = lpeg.P
+
+module(...)
+
+local stringlexer = _M
+
+local whitespace = stringlexer.WHITESPACE -- triggers states
+
+local space = lexer.space
+local nospace = 1 - space
+
+local p_spaces = token(whitespace, space ^1)
+local p_string = token("string", nospace^1)
+
+_rules = {
+ { "whitespace", p_spaces },
+ { "string", p_string },
+}
+
+_tokenstyles = lexer.context.styleset
diff --git a/context/data/scite/lexers/scite-context-lexer-lua.lua b/context/data/scite/lexers/scite-context-lexer-lua.lua
index a9006e44f..bb1a6c1d9 100644
--- a/context/data/scite/lexers/scite-context-lexer-lua.lua
+++ b/context/data/scite/lexers/scite-context-lexer-lua.lua
@@ -10,6 +10,7 @@ local lexer = lexer
local token, style, colors, exact_match, no_style = lexer.token, lexer.style, lexer.colors, lexer.exact_match, lexer.style_nothing
local P, R, S, C, Cg, Cb, Cs, Cmt = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cg, lpeg.Cb, lpeg.Cs, lpeg.Cmt
local match, find = string.match, string.find
+local setmetatable = setmetatable
local global = _G
-- beware: all multiline is messy, so even if it's no lexer, it should be an embedded lexer
@@ -61,30 +62,32 @@ local longonestring = (1-longonestop)^0
local longtwostart = P('[') * Cmt(equals,setlevel) * P('[')
local longtwostop = P(']') * equals * P(']')
+local sentinels = { } setmetatable(sentinels, { __index = function(t,k) local v = "]" .. k .. "]" t[k] = v return v end })
+
local longtwostring = P(function(input,index)
if level then
- local sentinel = ']' .. level .. ']'
+ -- local sentinel = ']' .. level .. ']'
+ local sentinel = sentinels[level]
local _, stop = find(input,sentinel,index,true)
return stop and stop + 1 - #sentinel or #input + 1
end
end)
--- local longtwostart = P("[") * Cg(equals, "init") * P("[")
--- local longtwostop = P("]") * C(equals) * P("]")
--- local longtwocheck = Cmt(longtwostop * Cb("init"), function(s,i,a,b) return a == b end)
--- local longtwostring = (P(1) - longtwocheck)^0
-
-local longcomment = Cmt(#('[[' + ('[' * P('=')^0 * '[')), function(input,index)
- local level = match(input,'^%[(=*)%[',index)
- level = "=="
- if level then
- local _, stop = find(input,']' .. level .. ']',index,true)
- return stop and stop + 1 or #input + 1
- end
-end)
-
-local longcomment = Cmt(#('[[' + ('[' * C(P('=')^0) * '[')), function(input,index,level)
- local _, stop = find(input,']' .. level .. ']',index,true)
+ local longtwostring_body = longtwostring
+
+ local longtwostring_end = P(function(input,index)
+ if level then
+ -- local sentinel = ']' .. level .. ']'
+ local sentinel = sentinels[level]
+ local _, stop = find(input,sentinel,index,true)
+ return stop and stop + 1 or #input + 1
+ end
+ end)
+
+local longcomment = Cmt(#('[[' + ('[' * C(equals) * '[')), function(input,index,level)
+ -- local sentinel = ']' .. level .. ']'
+ local sentinel = sentinels[level]
+ local _, stop = find(input,sentinel,index,true)
return stop and stop + 1 or #input + 1
end)
@@ -105,7 +108,7 @@ local shortcomment = token("comment", dashes * lexer.nonnewline^0)
local longcomment = token("comment", dashes * longcomment)
-- fails on very long string with \ at end of lines (needs embedded lexer)
--- and also on newline before " but it makes no sense to waste tiem on it
+-- and also on newline before " but it makes no sense to waste time on it
local shortstring = token("quote", dquote)
* token("string", (escaped + (1-dquote))^0)
@@ -122,7 +125,10 @@ local longstring = token("quote", longonestart)
* token("quote", longtwostop)
local string = shortstring
- + longstring
+-- + longstring
+
+ local longstringlexer = lexer.load("scite-context-lexer-lua-longstring")
+ lexer.embed_lexer(lualexer, longstringlexer, token("quote",longtwostart), token("string",longtwostring_body) * token("quote",longtwostring_end))
local integer = P('-')^-1 * (lexer.hex_num + lexer.dec_num)
local number = token("number", lexer.float + integer)
diff --git a/context/data/scite/lexers/scite-context-lexer-mps.lua b/context/data/scite/lexers/scite-context-lexer-mps.lua
index 02273ad04..22338b351 100644
--- a/context/data/scite/lexers/scite-context-lexer-mps.lua
+++ b/context/data/scite/lexers/scite-context-lexer-mps.lua
@@ -14,29 +14,53 @@ local type = type
module(...)
-local metafunlexer = _M
+local metafunlexer = _M
-local context = lexer.context
+local context = lexer.context
-local metafunhelpers = { }
-local metafunconstants = { }
-local plaincommands = { }
-local primitivecommands = { }
+local metapostprimitives = { }
+local metapostinternals = { }
+local metapostshortcuts = { }
+local metapostcommands = { }
+
+local metafuninternals = { }
+local metafunshortcuts = { }
+local metafuncommands = { }
+
+local mergedshortcuts = { }
+local mergedinternals = { }
do
local definitions = context.loaddefinitions("scite-context-data-metapost")
if definitions then
- plaincommands = definitions.plain or { }
- primitivecommands = definitions.primitives or { }
+ metapostprimitives = definitions.primitives or { }
+ metapostinternals = definitions.internals or { }
+ metapostshortcuts = definitions.shortcuts or { }
+ metapostcommands = definitions.commands or { }
end
local definitions = context.loaddefinitions("scite-context-data-metafun")
if definitions then
- metafunhelpers = definitions.helpers or { }
- metafunconstants = definitions.constants or { }
+ metafuninternals = definitions.internals or { }
+ metafunshortcuts = definitions.shortcuts or { }
+ metafuncommands = definitions.commands or { }
+ end
+
+ for i=1,#metapostshortcuts do
+ mergedshortcuts[#mergedshortcuts+1] = metapostshortcuts[i]
+ end
+ for i=1,#metafunshortcuts do
+ mergedshortcuts[#mergedshortcuts+1] = metafunshortcuts[i]
+ end
+
+ for i=1,#metapostinternals do
+ mergedinternals[#mergedinternals+1] = metapostinternals[i]
+ end
+ for i=1,#metafuninternals do
+ mergedinternals[#mergedinternals+1] = metafuninternals[i]
end
end
@@ -57,13 +81,17 @@ local cstokentex = R("az","AZ","\127\255") + S("@!?_")
local spacing = token(whitespace, space^1)
local rest = token('default', any)
local comment = token('comment', P('%') * (1-S("\n\r"))^0)
-local constant = token('data', exact_match(metafunconstants))
-local helper = token('command', exact_match(metafunhelpers))
-local plain = token('plain', exact_match(plaincommands))
+local internal = token('reserved', exact_match(mergedshortcuts,false))
+local shortcut = token('data', exact_match(mergedinternals))
+local helper = token('command', exact_match(metafuncommands))
+local plain = token('plain', exact_match(metapostcommands))
local quoted = token('quote', dquote)
* token('string', P(1-dquote)^0)
* token('quote', dquote)
-local primitive = token('primitive', exact_match(primitivecommands))
+local texstuff = token('quote', P("btex ") + P("verbatimtex "))
+ * token('string', P(1-P(" etex"))^0)
+ * token('quote', P(" etex"))
+local primitive = token('primitive', exact_match(metapostprimitives))
local identifier = token('default', cstoken^1)
local number = token('number', number)
local grouping = token('grouping', S("()[]{}")) -- can be an option
@@ -74,10 +102,12 @@ local extra = token('extra', S("`~%^&_-+*/\'|\\"))
_rules = {
{ 'whitespace', spacing },
{ 'comment', comment },
- { 'constant', constant },
+ { 'internal', internal },
+ { 'shortcut', shortcut },
{ 'helper', helper },
{ 'plain', plain },
{ 'primitive', primitive },
+ { 'texstuff', texstuff },
{ 'identifier', identifier },
{ 'number', number },
{ 'quoted', quoted },
diff --git a/context/data/scite/lexers/themes/scite-context-theme.lua b/context/data/scite/lexers/themes/scite-context-theme.lua
index f8554971d..ce959e721 100644
--- a/context/data/scite/lexers/themes/scite-context-theme.lua
+++ b/context/data/scite/lexers/themes/scite-context-theme.lua
@@ -71,6 +71,7 @@ style_string = style { fore = colors.magenta }
style_keyword = style { fore = colors.blue, bold = true }
style_char = style { fore = colors.magenta }
+style_reserved = style { fore = colors.magenta, bold = true }
style_class = style { fore = colors.black, bold = true }
style_constant = style { fore = colors.cyan, bold = true }
style_definition = style { fore = colors.black, bold = true }
@@ -104,6 +105,7 @@ lexer.context.styles = {
["comment"] = style_comment,
["keyword"] = style_keyword,
["string"] = style_string,
+ ["reserved"] = style_reserved,
["command"] = style { fore = colors.green, bold = true },
["preamble"] = style_comment,
diff --git a/context/data/scite/scite-context-data-metafun.properties b/context/data/scite/scite-context-data-metafun.properties
index b8098c9b1..4beb70265 100644
--- a/context/data/scite/scite-context-data-metafun.properties
+++ b/context/data/scite/scite-context-data-metafun.properties
@@ -42,5 +42,10 @@ center epsed anchored originpath infinite \
break xstretched ystretched snapped pathconnectors \
function constructedpath constructedpairs punkedfunction curvedfunction \
tightfunction punkedpath curvedpath tightpath punkedpairs \
-curvedpairs tightpairs evenly oddly drawboundary
+curvedpairs tightpairs evenly oddly normalfill \
+normaldraw visualizepaths naturalizepaths drawboundary drawwholepath \
+visualizeddraw visualizedfill draworigin drawboundingbox drawpath \
+drawpoint drawpoints drawcontrolpoints drawcontrollines drawpointlabels \
+drawlineoptions drawpointoptions drawcontroloptions drawlabeloptions draworiginoptions \
+drawboundoptions drawpathoptions resetdrawoptions
diff --git a/context/data/scite/scite-context-data-metapost.properties b/context/data/scite/scite-context-data-metapost.properties
index 71387bab7..d2027c956 100644
--- a/context/data/scite/scite-context-data-metapost.properties
+++ b/context/data/scite/scite-context-data-metapost.properties
@@ -22,63 +22,63 @@ yypart zscaled addto clip input \
interim let newinternal save setbounds \
shipout show showdependencies showtoken showvariable \
special begingroup endgroup of curl \
-tension and controls reflectedabout rotatedaround \
-interpath on off beginfig endfig \
-def vardef enddef expr suffix \
-text primary secondary tertiary primarydef \
-secondarydef tertiarydef randomseed also contour \
-doublepath withcolor withpen dashed if \
-else elseif fi for endfor \
-forever exitif forsuffixes downto upto \
-step until charlist extensible fontdimen \
-headerbyte kern ligtable boundarychar chardp \
-charext charht charic charwd designsize \
-fontmaking charexists cullit currenttransform gfcorners \
-grayfont hround imagerules lowres_fix nodisplays \
-notransforms openit displaying currentwindow screen_rows \
-screen_cols pixels_per_inch cull display openwindow \
-numspecial totalweight autorounding fillin proofing \
-tracingpens xoffset chardx granularity smoothing \
-turningcheck yoffset chardy hppp tracingedges \
-vppp extra_beginfig extra_endfig mpxbreak endinput \
-message delimiters turningnumber errmessage readstring \
-scantokens end outer inner write \
-to readfrom withprescript withpostscript top \
-bot lft rt ulft urt \
-llft lrt redpart greenpart bluepart \
-cyanpart magentapart yellowpart blackpart greypart \
-rgbcolor cmykcolor greycolor graycolor colormodel \
-graypart expandafter
+tension and controls interpath on \
+off def vardef enddef expr \
+suffix text primary secondary tertiary \
+primarydef secondarydef tertiarydef randomseed also \
+contour doublepath withcolor withpen dashed \
+if else elseif fi for \
+endfor forever exitif forsuffixes downto \
+upto step until charlist extensible \
+fontdimen headerbyte kern ligtable boundarychar \
+chardp charext charht charic charwd \
+designsize fontmaking charexists cullit currenttransform \
+gfcorners grayfont hround imagerules lowres_fix \
+nodisplays notransforms openit displaying currentwindow \
+screen_rows screen_cols pixels_per_inch cull display \
+openwindow numspecial totalweight autorounding fillin \
+proofing tracingpens xoffset chardx granularity \
+smoothing turningcheck yoffset chardy hppp \
+tracingedges vppp extra_beginfig extra_endfig mpxbreak \
+endinput message delimiters turningnumber errmessage \
+readstring scantokens end outer inner \
+write to readfrom withprescript withpostscript \
+top bot lft rt ulft \
+urt llft lrt redpart greenpart \
+bluepart cyanpart magentapart yellowpart blackpart \
+greypart rgbcolor cmykcolor greycolor graycolor \
+colormodel graypart expandafter
keywordclass.metapost.commands=\
-arrowhead currentpen currentpicture cuttings \
-defaultfont extra_beginfig extra_endfig ditto EOF \
-down evenly fullcircle halfcircle identity \
-in left origin pensquare quartercircle \
-right unitsquare up withdots abs \
-bbox ceiling center cutafter cutbefore \
-dir directionpoint div dotprod intersectionpoint \
-inverse mod round unitvector whatever \
-cutdraw draw drawarrow drawdblarrow fill \
-filldraw drawdot loggingall interact tracingall \
-tracingnone pickup undraw unfill unfilldraw \
-buildcycle dashpattern decr dotlabel dotlabels \
-drawoptions incr label labels max \
-min thelabel z beginchar blacker \
-capsule_end change_width define_blacker_pixels define_corrected_pixels define_good_x_pixels \
-define_good_y_pixels define_horizontal_corrected_pixels define_pixels define_whole_blacker_pixels define_whole_pixels \
-define_whole_vertical_blacker_pixels define_whole_vertical_pixels endchar extra_beginchar extra_endchar \
-extra_setup font_coding_scheme clearxy clearit clearpen \
-shipit font_extra_space exitunless relax hide \
-gobble gobbled stop blankpicture counterclockwise \
-tensepath takepower direction softjoin makelabel \
-rotatedabout flex superellipse erase image \
-nullpen savepen clearpen penpos penlabels \
-range numtok thru z laboff \
-bye red green blue cyan \
-magenta yellow black white background \
-graypart graycolor mm pt dd \
-bp cm pc cc in
+beginfig endfig rotatedaround reflectedabout \
+arrowhead currentpen currentpicture cuttings defaultfont \
+extra_beginfig extra_endfig ditto EOF down \
+evenly fullcircle halfcircle identity in \
+left origin pensquare quartercircle right \
+unitsquare up withdots abs bbox \
+ceiling center cutafter cutbefore dir \
+directionpoint div dotprod intersectionpoint inverse \
+mod round unitvector whatever cutdraw \
+draw drawarrow drawdblarrow fill filldraw \
+drawdot loggingall interact tracingall tracingnone \
+pickup undraw unfill unfilldraw buildcycle \
+dashpattern decr dotlabel dotlabels drawoptions \
+incr label labels max min \
+thelabel z beginchar blacker capsule_end \
+change_width define_blacker_pixels define_corrected_pixels define_good_x_pixels define_good_y_pixels \
+define_horizontal_corrected_pixels define_pixels define_whole_blacker_pixels define_whole_pixels define_whole_vertical_blacker_pixels \
+define_whole_vertical_pixels endchar extra_beginchar extra_endchar extra_setup \
+font_coding_scheme clearxy clearit clearpen shipit \
+font_extra_space exitunless relax hide gobble \
+gobbled stop blankpicture counterclockwise tensepath \
+takepower direction softjoin makelabel rotatedabout \
+flex superellipse erase image nullpen \
+savepen clearpen penpos penlabels range \
+numtok thru z laboff bye \
+red green blue cyan magenta \
+yellow black white background graypart \
+graycolor mm pt dd bp \
+cm pc cc in
keywordclass.metapost.tex=\
btex etex verbatimtex
diff --git a/metapost/context/base/mp-base.mpiv b/metapost/context/base/mp-base.mpiv
index 5ed6fd981..7b3a69bb0 100644
--- a/metapost/context/base/mp-base.mpiv
+++ b/metapost/context/base/mp-base.mpiv
@@ -809,7 +809,7 @@ tertiarydef m thru n =
endfor
enddef ;
-%% Overall adminstration
+%% Overall administration
string extra_beginfig, extra_endfig ;
diff --git a/metapost/context/base/mp-grph.mpiv b/metapost/context/base/mp-grph.mpiv
index 6e450a92a..5917beb17 100644
--- a/metapost/context/base/mp-grph.mpiv
+++ b/metapost/context/base/mp-grph.mpiv
@@ -23,7 +23,7 @@ numeric _fig_nesting_ ; _fig_nesting_ := 0 ;
def beginfig (expr c) =
_fig_nesting_ := _fig_nesting_ + 1 ;
- if _fig_nesting_ = 1 :
+ if _fig_nesting_ = 1 :
begingroup
charcode := c ;
resetfig ;
@@ -34,7 +34,7 @@ enddef ;
def endfig =
; % safeguard
if _fig_nesting_ = 1 :
- scantokens extra_endfig;
+ scantokens extra_endfig ;
shipit ;
endgroup ;
fi ;
diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv
index e489e7819..6c6db745a 100644
--- a/metapost/context/base/mp-tool.mpiv
+++ b/metapost/context/base/mp-tool.mpiv
@@ -957,25 +957,25 @@ enddef ;
%D PathPoints.
-def drawpoints expr c = path _c_ ; _c_ := c ; do_drawpoints enddef ;
-def drawcontrolpoints expr c = path _c_ ; _c_ := c ; do_drawcontrolpoints enddef ;
-def drawcontrollines expr c = path _c_ ; _c_ := c ; do_drawcontrollines enddef ;
-def drawpointlabels expr c = path _c_ ; _c_ := c ; do_drawpointlabels enddef ;
+def drawpoints expr c = path _c_ ; _c_ := c ; mfun_draw_points enddef ;
+def drawcontrolpoints expr c = path _c_ ; _c_ := c ; mfun_draw_controlpoints enddef ;
+def drawcontrollines expr c = path _c_ ; _c_ := c ; mfun_draw_controllines enddef ;
+def drawpointlabels expr c = path _c_ ; _c_ := c ; mdun_draw_pointlabels enddef ;
-def do_drawpoints text t =
+def mfun_draw_points text t =
for _i_=0 upto length(_c_) :
normaldraw point _i_ of _c_ _pnt_opt_ t ;
endfor ;
enddef;
-def do_drawcontrolpoints text t =
+def mfun_draw_controlpoints text t =
for _i_=0 upto length(_c_) :
normaldraw precontrol _i_ of _c_ _ctr_opt_ t ;
normaldraw postcontrol _i_ of _c_ _ctr_opt_ t ;
endfor ;
enddef;
-def do_drawcontrollines text t =
+def mfun_draw_controllines text t =
for _i_=0 upto length(_c_) :
normaldraw point _i_ of _c_ -- precontrol _i_ of _c_ _lin_opt_ t ;
normaldraw point _i_ of _c_ -- postcontrol _i_ of _c_ _lin_opt_ t ;
@@ -984,7 +984,7 @@ enddef;
boolean swappointlabels ; swappointlabels := false ;
-def do_drawpointlabels text t =
+def mfun_draw_pointlabels text t =
for _i_=0 upto length(_c_) :
pair _u_ ; _u_ := unitvector(direction _i_ of _c_) rotated if swappointlabels : - fi 90 ;
pair _p_ ; _p_ := (point _i_ of _c_) ;
@@ -1013,13 +1013,13 @@ enddef;
numeric tickstep ; tickstep := 5mm ;
numeric ticklength ; ticklength := 2mm ;
-def drawxticks expr c = path _c_ ; _c_ := c ; do_drawxticks enddef ;
-def drawyticks expr c = path _c_ ; _c_ := c ; do_drawyticks enddef ;
-def drawticks expr c = path _c_ ; _c_ := c ; do_drawticks enddef ;
+def drawxticks expr c = path _c_ ; _c_ := c ; mfun_draw_xticks enddef ;
+def drawyticks expr c = path _c_ ; _c_ := c ; mfun_draw_yticks enddef ;
+def drawticks expr c = path _c_ ; _c_ := c ; mfun_draw_ticks enddef ;
% Adding eps prevents disappearance due to rounding errors.
-def do_drawxticks text t =
+def mfun_draw_xticks text t =
for i=0 step -tickstep until xpart llcorner _c_ - eps :
if (i<=xpart lrcorner _c_) :
normaldraw (i,-ticklength)--(i,ticklength) _ori_opt_ t ;
@@ -1033,7 +1033,7 @@ def do_drawxticks text t =
normaldraw (llcorner _c_ -- ulcorner _c_) shifted (-xpart llcorner _c_,0) _ori_opt_ t ;
enddef ;
-def do_drawyticks text t =
+def mfun_draw_yticks text t =
for i=0 step -tickstep until ypart llcorner _c_ - eps :
if (i<=ypart ulcorner _c_) :
normaldraw (-ticklength,i)--(ticklength,i) _ori_opt_ t ;
@@ -1047,7 +1047,7 @@ def do_drawyticks text t =
normaldraw (llcorner _c_ -- lrcorner _c_) shifted (0,-ypart llcorner _c_) _ori_opt_ t ;
enddef ;
-def do_drawticks text t =
+def mfun_draw_ticks text t =
drawxticks _c_ t ;
drawyticks _c_ t ;
enddef ;
@@ -1936,7 +1936,7 @@ enddef ;
% under construction
-vardef straightpath(expr a, b, method) =
+vardef straightpath (expr a, b, method) =
if (method<1) or (method>6) :
(a--b)
elseif method = 1 :
@@ -2039,10 +2039,6 @@ vardef setunstringed (expr s, v) =
scantokens(cleanstring(s)) := v ;
enddef ;
-vardef setunstringed (expr s, v) =
- scantokens(cleanstring(s)) := v ;
-enddef ;
-
vardef getunstringed (expr s) =
scantokens(cleanstring(s))
enddef ;
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index ff77ef95a..261c00efd 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -8949,7 +8949,7 @@ local function profiled_apply(list,parsed,nofparsed,order)
elseif kind == "expression" then
collected = apply_expression(collected,pi.evaluator,order)
elseif kind == "finalizer" then
- collected = pi.finalizer(collected)
+ collected = pi.finalizer(collected) -- no check on # here
p.matched = p.matched + 1
p.finalized = p.finalized + 1
return collected
@@ -10070,6 +10070,21 @@ local function all(collected)
return collected
end
+-- local function reverse(collected)
+-- if collected then
+-- local nc = #collected
+-- if nc > 0 then
+-- local reversed, r = { }, 0
+-- for c=nc,1,-1 do
+-- r = r + 1
+-- reversed[r] = collected[c]
+-- end
+-- return reversed
+-- else
+-- return collected
+-- end
+-- end
+-- end
local reverse = table.reversed
@@ -10086,34 +10101,37 @@ local function att(id,name)
end
local function count(collected)
- return (collected and #collected) or 0
+ return collected and #collected or 0
end
local function position(collected,n)
- if collected then
- n = tonumber(n) or 0
- if n < 0 then
- return collected[#collected + n + 1]
- elseif n > 0 then
- return collected[n]
- else
- return collected[1].mi or 0
- end
+ if not collected then
+ return 0
+ end
+ local nc = #collected
+ if nc == 0 then
+ return 0
+ end
+ n = tonumber(n) or 0
+ if n < 0 then
+ return collected[nc + n + 1]
+ elseif n > 0 then
+ return collected[n]
+ else
+ return collected[1].mi or 0
end
end
local function match(collected)
- return (collected and collected[1].mi) or 0 -- match
+ return collected and #collected > 0 and collected[1].mi or 0 -- match
end
local function index(collected)
- if collected then
- return collected[1].ni
- end
+ return collected and #collected > 0 and collected[1].ni or 0 -- 0 is new
end
local function attributes(collected,arguments)
- if collected then
+ if collected and #collected > 0 then
local at = collected[1].at
if arguments then
return at[arguments]
@@ -10124,7 +10142,7 @@ local function attributes(collected,arguments)
end
local function chainattribute(collected,arguments) -- todo: optional levels
- if collected then
+ if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
@@ -10143,7 +10161,7 @@ local function chainattribute(collected,arguments) -- todo: optional levels
end
local function raw(collected) -- hybrid (not much different from text so it might go)
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return e and xmltostring(e) or "" -- only first as we cannot concat function
else
@@ -10186,7 +10204,7 @@ end
--
local function text(collected) -- hybrid
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return (e and xmltotext(e)) or ""
else
@@ -10195,89 +10213,114 @@ local function text(collected) -- hybrid
end
local function texts(collected)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- if e and e.dt then
- n = n + 1
- t[n] = e.dt
- end
+ if not collected then
+ return { } -- why no nil
+ end
+ local nc = #collected
+ if nc == 0 then
+ return { } -- why no nil
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ if e and e.dt then
+ n = n + 1
+ t[n] = e.dt
end
- return t
end
+ return t
end
local function tag(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- return c and c.tg
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
end
+ return c and c.tg
end
local function name(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- if c.ns == "" then
- return c.tg
- else
- return c.ns .. ":" .. c.tg
- end
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
+ end
+ if not c then
+ -- sorry
+ elseif c.ns == "" then
+ return c.tg
+ else
+ return c.ns .. ":" .. c.tg
end
end
local function tags(collected,nonamespace)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- local ns, tg = e.ns, e.tg
- n = n + 1
- if nonamespace or ns == "" then
- t[n] = tg
- else
- t[n] = ns .. ":" .. tg
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg = e.ns, e.tg
+ n = n + 1
+ if nonamespace or ns == "" then
+ t[n] = tg
+ else
+ t[n] = ns .. ":" .. tg
end
- return t
end
+ return t
end
local function empty(collected)
- if collected then
- for c=1,#collected do
- local e = collected[c]
- if e then
- local edt = e.dt
- if edt then
- local n = #edt
- if n == 1 then
- local edk = edt[1]
- local typ = type(edk)
- if typ == "table" then
- return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
- return false
- end
- elseif n > 1 then
+ if not collected then
+ return true
+ end
+ local nc = #collected
+ if nc == 0 then
+ return true
+ end
+ for c=1,nc do
+ local e = collected[c]
+ if e then
+ local edt = e.dt
+ if edt then
+ local n = #edt
+ if n == 1 then
+ local edk = edt[1]
+ local typ = type(edk)
+ if typ == "table" then
+ return false
+ elseif edk ~= "" then -- maybe an extra tester for spacing only
return false
end
+ elseif n > 1 then
+ return false
end
end
end
@@ -10336,7 +10379,7 @@ function xml.text(id,pattern)
if pattern then
-- return text(xmlfilter(id,pattern))
local collected = xmlfilter(id,pattern)
- return (collected and xmltotext(collected[1])) or ""
+ return collected and #collected > 0 and xmltotext(collected[1]) or ""
elseif id then
-- return text(id)
return xmltotext(id) or ""
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index ff77ef95a..261c00efd 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -8949,7 +8949,7 @@ local function profiled_apply(list,parsed,nofparsed,order)
elseif kind == "expression" then
collected = apply_expression(collected,pi.evaluator,order)
elseif kind == "finalizer" then
- collected = pi.finalizer(collected)
+ collected = pi.finalizer(collected) -- no check on # here
p.matched = p.matched + 1
p.finalized = p.finalized + 1
return collected
@@ -10070,6 +10070,21 @@ local function all(collected)
return collected
end
+-- local function reverse(collected)
+-- if collected then
+-- local nc = #collected
+-- if nc > 0 then
+-- local reversed, r = { }, 0
+-- for c=nc,1,-1 do
+-- r = r + 1
+-- reversed[r] = collected[c]
+-- end
+-- return reversed
+-- else
+-- return collected
+-- end
+-- end
+-- end
local reverse = table.reversed
@@ -10086,34 +10101,37 @@ local function att(id,name)
end
local function count(collected)
- return (collected and #collected) or 0
+ return collected and #collected or 0
end
local function position(collected,n)
- if collected then
- n = tonumber(n) or 0
- if n < 0 then
- return collected[#collected + n + 1]
- elseif n > 0 then
- return collected[n]
- else
- return collected[1].mi or 0
- end
+ if not collected then
+ return 0
+ end
+ local nc = #collected
+ if nc == 0 then
+ return 0
+ end
+ n = tonumber(n) or 0
+ if n < 0 then
+ return collected[nc + n + 1]
+ elseif n > 0 then
+ return collected[n]
+ else
+ return collected[1].mi or 0
end
end
local function match(collected)
- return (collected and collected[1].mi) or 0 -- match
+ return collected and #collected > 0 and collected[1].mi or 0 -- match
end
local function index(collected)
- if collected then
- return collected[1].ni
- end
+ return collected and #collected > 0 and collected[1].ni or 0 -- 0 is new
end
local function attributes(collected,arguments)
- if collected then
+ if collected and #collected > 0 then
local at = collected[1].at
if arguments then
return at[arguments]
@@ -10124,7 +10142,7 @@ local function attributes(collected,arguments)
end
local function chainattribute(collected,arguments) -- todo: optional levels
- if collected then
+ if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
@@ -10143,7 +10161,7 @@ local function chainattribute(collected,arguments) -- todo: optional levels
end
local function raw(collected) -- hybrid (not much different from text so it might go)
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return e and xmltostring(e) or "" -- only first as we cannot concat function
else
@@ -10186,7 +10204,7 @@ end
--
local function text(collected) -- hybrid
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return (e and xmltotext(e)) or ""
else
@@ -10195,89 +10213,114 @@ local function text(collected) -- hybrid
end
local function texts(collected)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- if e and e.dt then
- n = n + 1
- t[n] = e.dt
- end
+ if not collected then
+ return { } -- why no nil
+ end
+ local nc = #collected
+ if nc == 0 then
+ return { } -- why no nil
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ if e and e.dt then
+ n = n + 1
+ t[n] = e.dt
end
- return t
end
+ return t
end
local function tag(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- return c and c.tg
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
end
+ return c and c.tg
end
local function name(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- if c.ns == "" then
- return c.tg
- else
- return c.ns .. ":" .. c.tg
- end
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
+ end
+ if not c then
+ -- sorry
+ elseif c.ns == "" then
+ return c.tg
+ else
+ return c.ns .. ":" .. c.tg
end
end
local function tags(collected,nonamespace)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- local ns, tg = e.ns, e.tg
- n = n + 1
- if nonamespace or ns == "" then
- t[n] = tg
- else
- t[n] = ns .. ":" .. tg
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg = e.ns, e.tg
+ n = n + 1
+ if nonamespace or ns == "" then
+ t[n] = tg
+ else
+ t[n] = ns .. ":" .. tg
end
- return t
end
+ return t
end
local function empty(collected)
- if collected then
- for c=1,#collected do
- local e = collected[c]
- if e then
- local edt = e.dt
- if edt then
- local n = #edt
- if n == 1 then
- local edk = edt[1]
- local typ = type(edk)
- if typ == "table" then
- return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
- return false
- end
- elseif n > 1 then
+ if not collected then
+ return true
+ end
+ local nc = #collected
+ if nc == 0 then
+ return true
+ end
+ for c=1,nc do
+ local e = collected[c]
+ if e then
+ local edt = e.dt
+ if edt then
+ local n = #edt
+ if n == 1 then
+ local edk = edt[1]
+ local typ = type(edk)
+ if typ == "table" then
+ return false
+ elseif edk ~= "" then -- maybe an extra tester for spacing only
return false
end
+ elseif n > 1 then
+ return false
end
end
end
@@ -10336,7 +10379,7 @@ function xml.text(id,pattern)
if pattern then
-- return text(xmlfilter(id,pattern))
local collected = xmlfilter(id,pattern)
- return (collected and xmltotext(collected[1])) or ""
+ return collected and #collected > 0 and xmltotext(collected[1]) or ""
elseif id then
-- return text(id)
return xmltotext(id) or ""
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index ff77ef95a..261c00efd 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -8949,7 +8949,7 @@ local function profiled_apply(list,parsed,nofparsed,order)
elseif kind == "expression" then
collected = apply_expression(collected,pi.evaluator,order)
elseif kind == "finalizer" then
- collected = pi.finalizer(collected)
+ collected = pi.finalizer(collected) -- no check on # here
p.matched = p.matched + 1
p.finalized = p.finalized + 1
return collected
@@ -10070,6 +10070,21 @@ local function all(collected)
return collected
end
+-- local function reverse(collected)
+-- if collected then
+-- local nc = #collected
+-- if nc > 0 then
+-- local reversed, r = { }, 0
+-- for c=nc,1,-1 do
+-- r = r + 1
+-- reversed[r] = collected[c]
+-- end
+-- return reversed
+-- else
+-- return collected
+-- end
+-- end
+-- end
local reverse = table.reversed
@@ -10086,34 +10101,37 @@ local function att(id,name)
end
local function count(collected)
- return (collected and #collected) or 0
+ return collected and #collected or 0
end
local function position(collected,n)
- if collected then
- n = tonumber(n) or 0
- if n < 0 then
- return collected[#collected + n + 1]
- elseif n > 0 then
- return collected[n]
- else
- return collected[1].mi or 0
- end
+ if not collected then
+ return 0
+ end
+ local nc = #collected
+ if nc == 0 then
+ return 0
+ end
+ n = tonumber(n) or 0
+ if n < 0 then
+ return collected[nc + n + 1]
+ elseif n > 0 then
+ return collected[n]
+ else
+ return collected[1].mi or 0
end
end
local function match(collected)
- return (collected and collected[1].mi) or 0 -- match
+ return collected and #collected > 0 and collected[1].mi or 0 -- match
end
local function index(collected)
- if collected then
- return collected[1].ni
- end
+ return collected and #collected > 0 and collected[1].ni or 0 -- 0 is new
end
local function attributes(collected,arguments)
- if collected then
+ if collected and #collected > 0 then
local at = collected[1].at
if arguments then
return at[arguments]
@@ -10124,7 +10142,7 @@ local function attributes(collected,arguments)
end
local function chainattribute(collected,arguments) -- todo: optional levels
- if collected then
+ if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
@@ -10143,7 +10161,7 @@ local function chainattribute(collected,arguments) -- todo: optional levels
end
local function raw(collected) -- hybrid (not much different from text so it might go)
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return e and xmltostring(e) or "" -- only first as we cannot concat function
else
@@ -10186,7 +10204,7 @@ end
--
local function text(collected) -- hybrid
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return (e and xmltotext(e)) or ""
else
@@ -10195,89 +10213,114 @@ local function text(collected) -- hybrid
end
local function texts(collected)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- if e and e.dt then
- n = n + 1
- t[n] = e.dt
- end
+ if not collected then
+ return { } -- why no nil
+ end
+ local nc = #collected
+ if nc == 0 then
+ return { } -- why no nil
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ if e and e.dt then
+ n = n + 1
+ t[n] = e.dt
end
- return t
end
+ return t
end
local function tag(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- return c and c.tg
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
end
+ return c and c.tg
end
local function name(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- if c.ns == "" then
- return c.tg
- else
- return c.ns .. ":" .. c.tg
- end
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
+ end
+ if not c then
+ -- sorry
+ elseif c.ns == "" then
+ return c.tg
+ else
+ return c.ns .. ":" .. c.tg
end
end
local function tags(collected,nonamespace)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- local ns, tg = e.ns, e.tg
- n = n + 1
- if nonamespace or ns == "" then
- t[n] = tg
- else
- t[n] = ns .. ":" .. tg
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg = e.ns, e.tg
+ n = n + 1
+ if nonamespace or ns == "" then
+ t[n] = tg
+ else
+ t[n] = ns .. ":" .. tg
end
- return t
end
+ return t
end
local function empty(collected)
- if collected then
- for c=1,#collected do
- local e = collected[c]
- if e then
- local edt = e.dt
- if edt then
- local n = #edt
- if n == 1 then
- local edk = edt[1]
- local typ = type(edk)
- if typ == "table" then
- return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
- return false
- end
- elseif n > 1 then
+ if not collected then
+ return true
+ end
+ local nc = #collected
+ if nc == 0 then
+ return true
+ end
+ for c=1,nc do
+ local e = collected[c]
+ if e then
+ local edt = e.dt
+ if edt then
+ local n = #edt
+ if n == 1 then
+ local edk = edt[1]
+ local typ = type(edk)
+ if typ == "table" then
+ return false
+ elseif edk ~= "" then -- maybe an extra tester for spacing only
return false
end
+ elseif n > 1 then
+ return false
end
end
end
@@ -10336,7 +10379,7 @@ function xml.text(id,pattern)
if pattern then
-- return text(xmlfilter(id,pattern))
local collected = xmlfilter(id,pattern)
- return (collected and xmltotext(collected[1])) or ""
+ return collected and #collected > 0 and xmltotext(collected[1]) or ""
elseif id then
-- return text(id)
return xmltotext(id) or ""
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index ba80f1b11..197d60d3d 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.11.23 18:58}
+\newcontextversion{2011.11.24 15:52}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index cd0cb09b3..15f20a3ad 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{2011.11.23 18:58}
+\newcontextversion{2011.11.24 15:52}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index d62417df9..5a97ce700 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 297460688..c66071a58 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 683a629ee..4e70f3769 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.11.23 18:58}
+\edef\contextversion{2011.11.24 15:52}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 4f64155ba..32be1327a 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.11.23 18:58}
+\edef\contextversion{2011.11.24 15:52}
%D For those who want to use this:
@@ -254,6 +254,7 @@
\loadmkvifile{strc-flt}
\loadmarkfile{page-mis}
+\loadmkvifile{page-mbk}
\loadmarkfile{page-mul}
\loadmarkfile{page-set}
\loadmarkfile{pack-lyr}
diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua
index a5667ab50..11922cf18 100644
--- a/tex/context/base/lxml-lpt.lua
+++ b/tex/context/base/lxml-lpt.lua
@@ -942,7 +942,7 @@ local function profiled_apply(list,parsed,nofparsed,order)
elseif kind == "expression" then
collected = apply_expression(collected,pi.evaluator,order)
elseif kind == "finalizer" then
- collected = pi.finalizer(collected)
+ collected = pi.finalizer(collected) -- no check on # here
p.matched = p.matched + 1
p.finalized = p.finalized + 1
return collected
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 3e5522099..eb708782b 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -665,8 +665,11 @@ end
function lxml.setaction(id,pattern,action)
local collected = xmlapplylpath(getid(id),pattern)
if collected then
- for c=1,#collected do
- collected[c].command = action
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ collected[c].command = action
+ end
end
end
end
@@ -878,40 +881,45 @@ function lxml.setsetup(id,pattern,setup)
if not setup or setup == "" or setup == "*" or setup == "-" or setup == "+" then
local collected = xmlapplylpath(getid(id),pattern)
if collected then
- if trace_setups then
- for c=1, #collected do
- local e = collected[c]
- local ix = e.ix or 0
- if setup == "-" then
- e.command = false
- report_lxml("lpath matched (a) %5i: %s = %s -> skipped",c,ix,setup)
- elseif setup == "+" then
- e.command = true
- report_lxml("lpath matched (b) %5i: %s = %s -> text",c,ix,setup)
- else
- local tg = e.tg
- if tg then -- to be sure
- e.command = tg
- local ns = e.rn or e.ns
- if ns == "" then
- report_lxml("lpath matched (c) %5i: %s = %s -> %s",c,ix,tg,tg)
- else
- report_lxml("lpath matched (d) %5i: %s = %s:%s -> %s",c,ix,ns,tg,tg)
+ local nc = #collected
+ if nc > 0 then
+ if trace_setups then
+ for c=1,nc do
+ local e = collected[c]
+ local ix = e.ix or 0
+ if setup == "-" then
+ e.command = false
+ report_lxml("lpath matched (a) %5i: %s = %s -> skipped",c,ix,setup)
+ elseif setup == "+" then
+ e.command = true
+ report_lxml("lpath matched (b) %5i: %s = %s -> text",c,ix,setup)
+ else
+ local tg = e.tg
+ if tg then -- to be sure
+ e.command = tg
+ local ns = e.rn or e.ns
+ if ns == "" then
+ report_lxml("lpath matched (c) %5i: %s = %s -> %s",c,ix,tg,tg)
+ else
+ report_lxml("lpath matched (d) %5i: %s = %s:%s -> %s",c,ix,ns,tg,tg)
+ end
end
end
end
- end
- else
- for c=1, #collected do
- local e = collected[c]
- if setup == "-" then
- e.command = false
- elseif setup == "+" then
- e.command = true
- else
- e.command = e.tg
+ else
+ for c=1,nc do
+ local e = collected[c]
+ if setup == "-" then
+ e.command = false
+ elseif setup == "+" then
+ e.command = true
+ else
+ e.command = e.tg
+ end
end
end
+ elseif trace_setups then
+ report_lxml("zero lpath matches for %s",pattern)
end
elseif trace_setups then
report_lxml("no lpath matches for %s",pattern)
@@ -921,44 +929,49 @@ function lxml.setsetup(id,pattern,setup)
if a and b then
local collected = xmlapplylpath(getid(id),pattern)
if collected then
- if trace_setups then
- for c=1, #collected do
- local e = collected[c]
- local ns, tg, ix = e.rn or e.ns, e.tg, e.ix or 0
- if b == "-" then
- e.command = false
- if ns == "" then
- report_lxml("lpath matched (e) %5i: %s = %s -> skipped",c,ix,tg)
+ local nc = #collected
+ if nc > 0 then
+ if trace_setups then
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg, ix = e.rn or e.ns, e.tg, e.ix or 0
+ if b == "-" then
+ e.command = false
+ if ns == "" then
+ report_lxml("lpath matched (e) %5i: %s = %s -> skipped",c,ix,tg)
+ else
+ report_lxml("lpath matched (f) %5i: %s = %s:%s -> skipped",c,ix,ns,tg)
+ end
+ elseif b == "+" then
+ e.command = true
+ if ns == "" then
+ report_lxml("lpath matched (g) %5i: %s = %s -> text",c,ix,tg)
+ else
+ report_lxml("lpath matched (h) %5i: %s = %s:%s -> text",c,ix,ns,tg)
+ end
else
- report_lxml("lpath matched (f) %5i: %s = %s:%s -> skipped",c,ix,ns,tg)
+ e.command = a .. tg
+ if ns == "" then
+ report_lxml("lpath matched (i) %5i: %s = %s -> %s",c,ix,tg,e.command)
+ else
+ report_lxml("lpath matched (j) %5i: %s = %s:%s -> %s",c,ix,ns,tg,e.command)
+ end
end
- elseif b == "+" then
- e.command = true
- if ns == "" then
- report_lxml("lpath matched (g) %5i: %s = %s -> text",c,ix,tg)
- else
- report_lxml("lpath matched (h) %5i: %s = %s:%s -> text",c,ix,ns,tg)
- end
- else
- e.command = a .. tg
- if ns == "" then
- report_lxml("lpath matched (i) %5i: %s = %s -> %s",c,ix,tg,e.command)
+ end
+ else
+ for c=1,nc do
+ local e = collected[c]
+ if b == "-" then
+ e.command = false
+ elseif b == "+" then
+ e.command = true
else
- report_lxml("lpath matched (j) %5i: %s = %s:%s -> %s",c,ix,ns,tg,e.command)
+ e.command = a .. e.tg
end
end
end
- else
- for c=1, #collected do
- local e = collected[c]
- if b == "-" then
- e.command = false
- elseif b == "+" then
- e.command = true
- else
- e.command = a .. e.tg
- end
- end
+ elseif trace_setups then
+ report_lxml("zero lpath matches for %s",pattern)
end
elseif trace_setups then
report_lxml("no lpath matches for %s",pattern)
@@ -966,21 +979,26 @@ function lxml.setsetup(id,pattern,setup)
else
local collected = xmlapplylpath(getid(id),pattern)
if collected then
- if trace_setups then
- for c=1, #collected do
- local e = collected[c]
- e.command = setup
- local ns, tg, ix = e.rn or e.ns, e.tg, e.ix or 0
- if ns == "" then
- report_lxml("lpath matched (k) %5i: %s = %s -> %s",c,ix,tg,setup)
- else
- report_lxml("lpath matched (l) %5i: %s = %s:%s -> %s",c,ix,ns,tg,setup)
+ local nc = #collected
+ if nc > 0 then
+ if trace_setups then
+ for c=1,nc do
+ local e = collected[c]
+ e.command = setup
+ local ns, tg, ix = e.rn or e.ns, e.tg, e.ix or 0
+ if ns == "" then
+ report_lxml("lpath matched (k) %5i: %s = %s -> %s",c,ix,tg,setup)
+ else
+ report_lxml("lpath matched (l) %5i: %s = %s:%s -> %s",c,ix,ns,tg,setup)
+ end
+ end
+ else
+ for c=1,nc do
+ collected[c].command = setup
end
end
- else
- for c=1, #collected do
- collected[c].command = setup
- end
+ elseif trace_setups then
+ report_lxml("zero lpath matches for %s",pattern)
end
elseif trace_setups then
report_lxml("no lpath matches for %s",pattern)
@@ -994,65 +1012,89 @@ end
local finalizers = xml.finalizers.tex
local function first(collected)
- if collected then
+ if collected and #collected > 0 then
xmlsprint(collected[1])
end
end
local function last(collected)
if collected then
- xmlsprint(collected[#collected])
+ local nc = #collected
+ if nc > 0 then
+ xmlsprint(collected[nc])
+ end
end
end
local function all(collected)
if collected then
- for c=1,#collected do
- xmlsprint(collected[c])
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ xmlsprint(collected[c])
+ end
end
end
end
local function reverse(collected)
if collected then
- for c=#collected,1,-1 do
- xmlsprint(collected[c])
+ local nc = #collected
+ if nc >0 then
+ for c=nc,1,-1 do
+ xmlsprint(collected[c])
+ end
end
end
end
local function count(collected)
- contextsprint(ctxcatcodes,(collected and #collected) or 0)
+ contextsprint(ctxcatcodes,(collected and #collected) or 0) -- why ctxcatcodes
end
local function position(collected,n)
-- todo: if not n then == match
if collected then
- n = tonumber(n) or 0
- if n < 0 then
- n = #collected + n + 1
- end
- if n > 0 then
- xmlsprint(collected[n])
+ local nc = #collected
+ if nc > 0 then
+ n = tonumber(n) or 0
+ if n < 0 then
+ n = nc + n + 1
+ end
+ if n > 0 then
+ local cn = collected[n]
+ if cn then
+ xmlsprint(cn)
+ return
+ end
+ end
end
end
end
local function match(collected) -- is match in preceding collected, never change, see bibxml
local m = collected and collected[1]
- contextsprint(ctxcatcodes,m and m.mi or 0)
+ contextsprint(ctxcatcodes,m and m.mi or 0) -- why ctxcatcodes
end
local function index(collected,n)
if collected then
- n = tonumber(n) or 0
- if n < 0 then
- n = #collected + n + 1 -- brrr
- end
- if n > 0 then
- contextsprint(ctxcatcodes,collected[n].ni or 0)
+ local nc = #collected
+ if nc > 0 then
+ n = tonumber(n) or 0
+ if n < 0 then
+ n = nc + n + 1 -- brrr
+ end
+ if n > 0 then
+ local cn = collected[n]
+ if cn then
+ contextsprint(ctxcatcodes,cn.ni or 0) -- why ctxcatcodes
+ return
+ end
+ end
end
end
+ contextsprint(ctxcatcodes,0) -- why ctxcatcodes
end
local function command(collected,cmd,otherwise)
@@ -1091,7 +1133,7 @@ local function attribute(collected,a,default)
end
local function chainattribute(collected,arguments) -- todo: optional levels
- if collected then
+ if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
@@ -1111,7 +1153,9 @@ end
local function text(collected)
if collected then
local nc = #collected
- if nc == 1 then -- hardly any gain so this will go
+ if nc == 0 then
+ -- nothing
+ elseif nc == 1 then -- hardly any gain so this will go
cprint(collected[1])
else for c=1,nc do
cprint(collected[c])
@@ -1121,71 +1165,80 @@ end
local function ctxtext(collected)
if collected then
- for c=1,#collected do
- contextsprint(ctxcatcodes,collected[1].dt)
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ contextsprint(ctxcatcodes,collected[c].dt)
+ end
end
end
end
---~ local str = xmltext(getid(id),pattern) or ""
---~ str = gsub(str,"^%s*(.-)%s*$","%1")
---~ if nolines then
---~ str = gsub(str,"%s+"," ")
---~ end
-
local function stripped(collected) -- tricky as we strip in place
if collected then
- for c=1,#collected do
- cprint(xml.stripelement(collected[c]))
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ cprint(xml.stripelement(collected[c]))
+ end
end
end
end
local function lower(collected)
- if collected then
- for c=1,#collected do
- contextsprint(ctxcatcodes,lowerchars(collected[1].dt[1]))
+ if not collected then
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ contextsprint(ctxcatcodes,lowerchars(collected[c].dt[1]))
+ end
end
end
end
local function upper(collected)
if collected then
- for c=1,#collected do
- contextsprint(ctxcatcodes,upperchars(collected[1].dt[1]))
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ contextsprint(ctxcatcodes,upperchars(collected[c].dt[1]))
+ end
end
end
end
local function number(collected)
- if collected then
- local n = 0
- for c=1,#collected do
+ local nc = collected and #collected or 0
+ local n = 0
+ if nc > 0 then
+ for c=1,nc do
n = n + tonumber(collected[c].dt[1] or 0)
end
- contextsprint(ctxcatcodes,n)
end
+ contextsprint(ctxcatcodes,n)
end
local function concatrange(collected,start,stop,separator,lastseparator,textonly) -- test this on mml
if collected then
local nofcollected = #collected
- local separator = separator or ""
- local lastseparator = lastseparator or separator or ""
- start, stop = (start == "" and 1) or tonumber(start) or 1, (stop == "" and nofcollected) or tonumber(stop) or nofcollected
- if stop < 0 then stop = nofcollected + stop end -- -1 == last-1
- for i=start,stop do
- if textonly then
- xmlcprint(collected[i])
- else
- xmlsprint(collected[i])
- end
- if i == nofcollected then
- -- nothing
- elseif i == nofcollected-1 and lastseparator ~= "" then
- contextsprint(ctxcatcodes,lastseparator)
- elseif separator ~= "" then
- contextsprint(ctxcatcodes,separator)
+ if nofcollected > 0 then
+ local separator = separator or ""
+ local lastseparator = lastseparator or separator or ""
+ start, stop = (start == "" and 1) or tonumber(start) or 1, (stop == "" and nofcollected) or tonumber(stop) or nofcollected
+ if stop < 0 then stop = nofcollected + stop end -- -1 == last-1
+ for i=start,stop do
+ if textonly then
+ xmlcprint(collected[i])
+ else
+ xmlsprint(collected[i])
+ end
+ if i == nofcollected then
+ -- nothing
+ elseif i == nofcollected-1 and lastseparator ~= "" then
+ contextsprint(ctxcatcodes,lastseparator)
+ elseif separator ~= "" then
+ contextsprint(ctxcatcodes,separator)
+ end
end
end
end
@@ -1218,37 +1271,43 @@ finalizers.default = all -- !!
local concat = table.concat
-function finalizers.tag(collected)
+function finalizers.tag(collected,n)
if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- contextsprint(ctxcatcodes,c.tg)
+ local nc = #collected
+ if nc > 0 then
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
+ end
+ if c then
+ contextsprint(ctxcatcodes,c.tg)
+ end
end
end
end
-function finalizers.name(collected)
+function finalizers.name(collected,n)
if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- if c.ns == "" then
- contextsprint(ctxcatcodes,c.tg)
+ local nc = #collected
+ if nc > 0 then
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
else
- contextsprint(ctxcatcodes,c.ns,":",c.tg)
+ c = collected[nc-n+1]
+ end
+ if c then
+ if c.ns == "" then
+ contextsprint(ctxcatcodes,c.tg)
+ else
+ contextsprint(ctxcatcodes,c.ns,":",c.tg)
+ end
end
end
end
@@ -1256,13 +1315,16 @@ end
function finalizers.tags(collected,nonamespace)
if collected then
- for c=1,#collected do
- local e = collected[c]
- local ns, tg = e.ns, e.tg
- if nonamespace or ns == "" then
- contextsprint(ctxcatcodes,tg)
- else
- contextsprint(ctxcatcodes,ns,":",tg)
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg = e.ns, e.tg
+ if nonamespace or ns == "" then
+ contextsprint(ctxcatcodes,tg)
+ else
+ contextsprint(ctxcatcodes,ns,":",tg)
+ end
end
end
end
@@ -1327,7 +1389,7 @@ end
function lxml.raw(id,pattern) -- the content, untouched by commands
local collected = (pattern and xmlapplylpath(getid(id),pattern)) or getid(id)
- if collected then
+ if collected and #collected > 0 then
contextsprint(notcatcodes,xmltostring(collected[1].dt))
end
end
@@ -1335,7 +1397,6 @@ end
function lxml.context(id,pattern) -- the content, untouched by commands
if not pattern then
local collected = getid(id)
- -- contextsprint(ctxcatcodes,collected.dt[1])
ctx_text(collected.dt[1])
else
local collected = xmlapplylpath(getid(id),pattern) or getid(id)
@@ -1345,9 +1406,23 @@ function lxml.context(id,pattern) -- the content, untouched by commands
end
end
+function lxml.context(id,pattern) -- the content, untouched by commands
+ if pattern then
+ local collected = xmlapplylpath(getid(id),pattern) or getid(id)
+ if collected and #collected > 0 then
+ contextsprint(ctxcatcodes,collected[1].dt)
+ end
+ else
+ local collected = getid(id)
+ if collected and #collected > 0 then
+ ctx_text(collected.dt[1])
+ end
+ end
+end
+
function lxml.text(id,pattern)
local collected = (pattern and xmlapplylpath(getid(id),pattern)) or getid(id)
- if collected then
+ if collected and #collected > 0 then
text(collected)
end
end
@@ -1355,17 +1430,11 @@ end
lxml.content = text
function lxml.position(id,pattern,n)
- local collected = xmlapplylpath(getid(id),pattern)
- if collected then
- position(collected,n)
- end
+ position(xmlapplylpath(getid(id),pattern),n)
end
function lxml.chainattribute(id,pattern,a,default)
- local collected = xmlapplylpath(getid(id),pattern)
- if collected then
- chainattribute(collected,a,default)
- end
+ chainattribute(xmlapplylpath(getid(id),pattern),a,default)
end
function lxml.concatrange(id,pattern,start,stop,separator,lastseparator,textonly) -- test this on mml
@@ -1449,15 +1518,18 @@ function lxml.command(id,pattern,cmd)
local i, p = getid(id,true)
local collected = xmlapplylpath(getid(i),pattern)
if collected then
- local rootname = p or i.name
- for c=1,#collected do
- local e = collected[c]
- local ix = e.ix
- if not ix then
- addindex(rootname,false,true)
- ix = e.ix
+ local nc = #collected
+ if nc > 0 then
+ local rootname = p or i.name
+ for c=1,nc do
+ local e = collected[c]
+ local ix = e.ix
+ if not ix then
+ addindex(rootname,false,true)
+ ix = e.ix
+ end
+ contextsprint(ctxcatcodes,"\\xmlw{",cmd,"}{",rootname,"::",ix,"}")
end
- contextsprint(ctxcatcodes,"\\xmlw{",cmd,"}{",rootname,"::",ix,"}")
end
end
end
@@ -1565,8 +1637,11 @@ lxml.get_id = getid lxml.obsolete.get_id = getid
function xml.finalizers.tex.lettered(collected)
if collected then
- for c=1,#collected do
- contextsprint(ctxcatcodes,lettered(collected[1].dt[1]))
+ local nc = #collected
+ if nc > 0 then
+ for c=1,nc do
+ contextsprint(ctxcatcodes,lettered(collected[c].dt[1]))
+ end
end
end
end
@@ -1574,7 +1649,7 @@ end
--~ function xml.finalizers.tex.apply(collected,what) -- to be tested
--~ if collected then
--~ for c=1,#collected do
---~ contextsprint(ctxcatcodes,what(collected[1].dt[1]))
+--~ contextsprint(ctxcatcodes,what(collected[c].dt[1]))
--~ end
--~ end
--~ end
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua
index 05405015d..b216d7866 100644
--- a/tex/context/base/lxml-xml.lua
+++ b/tex/context/base/lxml-xml.lua
@@ -29,16 +29,21 @@ local function all(collected)
return collected
end
---~ local function reverse(collected)
---~ if collected then
---~ local reversed, r = { }, 0
---~ for c=#collected,1,-1 do
---~ r = r + 1
---~ reversed[r] = collected[c]
---~ end
---~ return reversed
---~ end
---~ end
+-- local function reverse(collected)
+-- if collected then
+-- local nc = #collected
+-- if nc > 0 then
+-- local reversed, r = { }, 0
+-- for c=nc,1,-1 do
+-- r = r + 1
+-- reversed[r] = collected[c]
+-- end
+-- return reversed
+-- else
+-- return collected
+-- end
+-- end
+-- end
local reverse = table.reversed
@@ -55,34 +60,37 @@ local function att(id,name)
end
local function count(collected)
- return (collected and #collected) or 0
+ return collected and #collected or 0
end
local function position(collected,n)
- if collected then
- n = tonumber(n) or 0
- if n < 0 then
- return collected[#collected + n + 1]
- elseif n > 0 then
- return collected[n]
- else
- return collected[1].mi or 0
- end
+ if not collected then
+ return 0
+ end
+ local nc = #collected
+ if nc == 0 then
+ return 0
+ end
+ n = tonumber(n) or 0
+ if n < 0 then
+ return collected[nc + n + 1]
+ elseif n > 0 then
+ return collected[n]
+ else
+ return collected[1].mi or 0
end
end
local function match(collected)
- return (collected and collected[1].mi) or 0 -- match
+ return collected and #collected > 0 and collected[1].mi or 0 -- match
end
local function index(collected)
- if collected then
- return collected[1].ni
- end
+ return collected and #collected > 0 and collected[1].ni or 0 -- 0 is new
end
local function attributes(collected,arguments)
- if collected then
+ if collected and #collected > 0 then
local at = collected[1].at
if arguments then
return at[arguments]
@@ -93,7 +101,7 @@ local function attributes(collected,arguments)
end
local function chainattribute(collected,arguments) -- todo: optional levels
- if collected then
+ if collected and #collected > 0 then
local e = collected[1]
while e do
local at = e.at
@@ -112,7 +120,7 @@ local function chainattribute(collected,arguments) -- todo: optional levels
end
local function raw(collected) -- hybrid (not much different from text so it might go)
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return e and xmltostring(e) or "" -- only first as we cannot concat function
else
@@ -155,7 +163,7 @@ end
--
local function text(collected) -- hybrid
- if collected then
+ if collected and #collected > 0 then
local e = collected[1] or collected
return (e and xmltotext(e)) or ""
else
@@ -164,89 +172,114 @@ local function text(collected) -- hybrid
end
local function texts(collected)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- if e and e.dt then
- n = n + 1
- t[n] = e.dt
- end
+ if not collected then
+ return { } -- why no nil
+ end
+ local nc = #collected
+ if nc == 0 then
+ return { } -- why no nil
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ if e and e.dt then
+ n = n + 1
+ t[n] = e.dt
end
- return t
end
+ return t
end
local function tag(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- return c and c.tg
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
end
+ return c and c.tg
end
local function name(collected,n)
- if collected then
- local c
- if n == 0 or not n then
- c = collected[1]
- elseif n > 1 then
- c = collected[n]
- else
- c = collected[#collected-n+1]
- end
- if c then
- if c.ns == "" then
- return c.tg
- else
- return c.ns .. ":" .. c.tg
- end
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local c
+ if n == 0 or not n then
+ c = collected[1]
+ elseif n > 1 then
+ c = collected[n]
+ else
+ c = collected[nc-n+1]
+ end
+ if not c then
+ -- sorry
+ elseif c.ns == "" then
+ return c.tg
+ else
+ return c.ns .. ":" .. c.tg
end
end
local function tags(collected,nonamespace)
- if collected then
- local t, n = { }, 0
- for c=1,#collected do
- local e = collected[c]
- local ns, tg = e.ns, e.tg
- n = n + 1
- if nonamespace or ns == "" then
- t[n] = tg
- else
- t[n] = ns .. ":" .. tg
- end
+ if not collected then
+ return
+ end
+ local nc = #collected
+ if nc == 0 then
+ return
+ end
+ local t, n = { }, 0
+ for c=1,nc do
+ local e = collected[c]
+ local ns, tg = e.ns, e.tg
+ n = n + 1
+ if nonamespace or ns == "" then
+ t[n] = tg
+ else
+ t[n] = ns .. ":" .. tg
end
- return t
end
+ return t
end
local function empty(collected)
- if collected then
- for c=1,#collected do
- local e = collected[c]
- if e then
- local edt = e.dt
- if edt then
- local n = #edt
- if n == 1 then
- local edk = edt[1]
- local typ = type(edk)
- if typ == "table" then
- return false
- elseif edk ~= "" then -- maybe an extra tester for spacing only
- return false
- end
- elseif n > 1 then
+ if not collected then
+ return true
+ end
+ local nc = #collected
+ if nc == 0 then
+ return true
+ end
+ for c=1,nc do
+ local e = collected[c]
+ if e then
+ local edt = e.dt
+ if edt then
+ local n = #edt
+ if n == 1 then
+ local edk = edt[1]
+ local typ = type(edk)
+ if typ == "table" then
+ return false
+ elseif edk ~= "" then -- maybe an extra tester for spacing only
return false
end
+ elseif n > 1 then
+ return false
end
end
end
@@ -305,7 +338,7 @@ function xml.text(id,pattern)
if pattern then
-- return text(xmlfilter(id,pattern))
local collected = xmlfilter(id,pattern)
- return (collected and xmltotext(collected[1])) or ""
+ return collected and #collected > 0 and xmltotext(collected[1]) or ""
elseif id then
-- return text(id)
return xmltotext(id) or ""
diff --git a/tex/context/base/math-for.mkiv b/tex/context/base/math-for.mkiv
index 16cab9a65..ebb5ec534 100644
--- a/tex/context/base/math-for.mkiv
+++ b/tex/context/base/math-for.mkiv
@@ -18,62 +18,28 @@
\unprotect
-\let\currentformula\s!unknown
-
-\def\formulaparameter #1{\csname\doformulaparameter{\??fm\currentformula}#1\endcsname}
-\def\formulaparameterhash#1{\doformulaparameterhash {\??fm\currentformula}#1}
-
-\def\doformulaparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\doformulaparentparameter \csname#1\s!parent\endcsname#2\fi}
-\def\doformulaparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\doformulaparentparameterhash\csname#1\s!parent\endcsname#2\fi}
-
-\def\detokenizedformulaparameter#1{\detokenize\expandafter\expandafter\expandafter{\csname\??fm\currentformula#1\endcsname}}
-
-\def\doformulaparentparameter #1#2{\ifx#1\relax\s!empty\else\doformulaparameter #1#2\fi}
-\def\doformulaparentparameterhash#1#2{\ifx#1\relax \else\doformulaparameterhash#1#2\fi}
-
-\def\dosetformulaattributes#1#2% style color
- {\edef\fontattributehash {\formulaparameterhash#1}%
- \edef\colorattributehash{\formulaparameterhash#2}%
- \ifx\fontattributehash \empty\else\dosetfontattribute \fontattributehash #1\fi
- \ifx\colorattributehash\empty\else\dosetcolorattribute\colorattributehash#2\fi}
-
-\def\getformulaparameters{\getparameters[\??fm]}
-
-%D \macros
-%D {setupformulas}
-
-\newtoks \everysetupformulas
-
-\unexpanded\def\setupformulas
- {\dodoubleempty\dosetupformulas}
-
-\def\dosetupformulas[#1][#2]%
- {\ifsecondargument
- \edef\currentformula{#1}%
- \getparameters[\??fm#1][#2]%
- \else
-% \let\currentformula\v!formula % hm
- \let\currentformula\empty
- \getparameters[\??fm][#1]%
- \fi
- \the\everysetupformulas
- \let\currentformula\empty}
-
-%D Not yet cleanup up:
-
%D \macros
-%D {setuptextformulas}
-%D
-%D This command sets up in||line math. Most features deals
-%D with grid snapping and are experimental.
-
-\newtoks \everysetuptextformulas
-
-\unexpanded\def\setuptextformulas
- {\dosingleempty\dosetuptextformulas}
-
-\def\dosetuptextformulas[#1]%
- {\getparameters[\??mt][#1]%
- \the\everysetuptextformulas}
+%D {setupformulas,setupsubformulas}
+
+\installcommandhandler \??fm {formula} \??fm
+\installcommandhandler \??fn {subformula} \??fn % maybe just setuphandler (no childs used yet)
+
+\let\setupformulas \setupformula
+\let\setupsubformulas\setupsubformula
+
+% D \macros
+% D {setuptextformulas}
+% D
+% D This command sets up in||line math. Most features deals
+% D with grid snapping and are experimental.
+
+% \newtoks \everysetuptextformulas
+%
+% \unexpanded\def\setuptextformulas
+% {\dosingleempty\dosetuptextformulas}
+%
+% \def\dosetuptextformulas[#1]%
+% {\getparameters[\??mt][#1]%
+% \the\everysetuptextformulas}
\protect \endinput
diff --git a/tex/context/base/math-scr.mkiv b/tex/context/base/math-scr.mkiv
index 280297db2..9ab61911b 100644
--- a/tex/context/base/math-scr.mkiv
+++ b/tex/context/base/math-scr.mkiv
@@ -70,7 +70,7 @@
%D How negative such a symbol looks is demonstrated in:
%D $\negative 10^{\negative 10^{\negative 10}}$.
-\setuptextformulas % why here
- [\c!size=\v!normal]
+% \setuptextformulas % why here
+% [\c!size=\v!normal]
\protect \endinput
diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua
index cb2994054..2f2c41974 100644
--- a/tex/context/base/mult-mps.lua
+++ b/tex/context/base/mult-mps.lua
@@ -27,8 +27,8 @@ return {
"shipout", "show", "showdependencies", "showtoken", "showvariable",
"special",
"begingroup", "endgroup", "of", "curl", "tension", "and", "controls",
- "reflectedabout", "rotatedaround", "interpath", "on", "off", "beginfig",
- "endfig", "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary",
+ "interpath", "on", "off",
+ "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary",
"tertiary", "primarydef", "secondarydef", "tertiarydef",
"randomseed", "also", "contour", "doublepath",
"withcolor", "withpen", "dashed", "if", "else", "elseif", "fi", "for", "endfor", "forever", "exitif",
@@ -56,6 +56,8 @@ return {
"expandafter",
},
commands = {
+ "beginfig", "endfig",
+ "rotatedaround", "reflectedabout",
"arrowhead",
"currentpen", "currentpicture", "cuttings",
"defaultfont", "extra_beginfig", "extra_endfig",
@@ -106,6 +108,5 @@ return {
"bboxmargin", "ahlength", "ahangle", "labeloffset", "dotlabeldiam", "defaultpen", "defaultscale", "join_radius",
--
"pen_lft", "pen_rt", "pen_top", "pen_bot", -- "pen_count_",
- --
},
}
diff --git a/tex/context/base/page-mbk.mkvi b/tex/context/base/page-mbk.mkvi
new file mode 100644
index 000000000..24f0913b8
--- /dev/null
+++ b/tex/context/base/page-mbk.mkvi
@@ -0,0 +1,236 @@
+%D \module
+%D [ file=page-mbk, % was part of page-mis.mkiv / 2008.11.17
+%D version=2011.11.23, % was part of page-flt.tex / 2000.10.20
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Margin Floats,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Page Macros / Margin Floats}
+
+\unprotect
+
+%D This is an old mechanism that is quite independent of other
+%D floats. There is for instance no save/restore used here. When
+%D there is need (and demand) we can use the float cache and then
+%D flush them in the text when they are left over. On the other
+%D hand, margin float are somewhat manual so it does not make too
+%D much sense to complicate the code. As an alternative users can
+%D fall back on margin texts: they do stack but don't float.
+%D
+%D \starttyping
+%D \dorecurse{9} {
+%D \placefigure[margin]{#1}{}
+%D \input ward
+%D }
+%D \page \null % will flush them
+%D \stoptyping
+
+% status=start: in margin
+% status=stop : in text
+%
+% todo: flush margin floats at end of text
+
+\installcommandhandler \??mb {marginblock} \??mb
+
+\let\setupmarginblocks\setupmarginblock
+
+\newconditional\page_margin_blocks_c % not really needed as we can check each time
+
+\appendtoks
+ \doifelse{\rootmarginblockparameter\c!state}\v!start
+ \settrue\setfalse\page_margin_blocks_c
+\to \everysetupmarginblock
+
+\setupmarginblocks
+ [\c!state=\v!start,
+ \c!location=\v!inmargin,
+ \c!width=\rightmarginwidth,
+ %\c!style=,
+ %\c!color=,
+ %\c!align=,
+ %\c!left=,
+ %\c!right=,
+ %\c!top=,
+ %\c!before=,
+ %\c!after=,
+ \c!inbetween=\blank,
+ \c!bottom=\vfill]
+
+\unexpanded\def\startmarginblock
+ {\dosingleempty\start_margin_block}
+
+\unexpanded\def\stoptmarginblock
+ {\stop_margin_block}
+
+\def\start_margin_block[#tag]%
+ {\begingroup
+ \edef\currentmarginblock{#tag}%
+ \doifelse{\marginblockparameter\c!state}\v!start
+ \start_margin_block_yes
+ \start_margin_block_nop}
+
+\def\stop_margin_block
+ {\doifelse{\marginblockparameter\c!state}\v!start
+ \stop_margin_block_yes
+ \stop_margin_block_nop
+ \endgroup}
+
+\def\start_margin_block_yes % 2 maal \vbox ivm \unvbox elders
+ {\showmessage\m!layouts4\empty
+ \global\setbox\page_margin_box\vtop\bgroup\vbox\bgroup
+ \hsize\marginblockparameter\c!width
+ \ifvoid\page_margin_box\else
+ \unvbox\page_margin_box
+ \marginblockparameter\c!inbetween
+ \fi
+ \setupalign[\marginblockparameter\c!align]%
+ \dosetfloatcaptionattributes\c!style\c!color
+ \begstrut
+ \ignorespaces}
+
+\def\stop_margin_block_yes
+ {\removeunwantedspaces
+ \endstrut
+ \egroup
+ \egroup}
+
+\def\start_margin_block_nop
+ {\showmessage\m!layouts5\empty
+ \marginblockparameter\c!before
+ \bgroup
+ \dosetfloatcaptionattributes\c!style\c!color}
+
+\def\stop_margin_block_nop
+ {\egroup
+ \marginblockparameter\c!after}
+
+\newbox\page_margin_box
+\newbox\page_margin_prepared_box
+
+\def\page_margin_reshape
+ {\ifdim\ht\page_margin_prepared_box>\zeropoint
+ \beginofshapebox
+ \unvbox\page_margin_prepared_box
+ \endofshapebox
+ \reshapebox
+ {\box\shapebox}%
+ \setbox\page_margin_prepared_box\vbox to \textheight
+ {\marginblockparameter\c!top
+ \flushshapebox
+ \marginblockparameter\c!bottom}%
+ \fi}
+
+\unexpanded\def\checkmarginblocks
+ {\ifvoid\page_margin_box \else
+ \page_margin_check_indeed
+ \fi}
+
+\def\page_margin_check_indeed
+ {\ifcsname\??mb::\c!location::\marginblockparameter\c!location\endcsname
+ \page_margin_prepare_box
+ \csname\??mb::\c!location::\marginblockparameter\c!location\endcsname
+ \else
+ \global\page_margin_box\emptybox
+ \fi}
+
+\def\page_margin_prepare_box
+ {\setbox\page_margin_prepared_box\vbox
+ {\forgetall
+ \splittopskip\topskip
+ \ifvoid\page_margin_box\else
+ \ifdim\ht\page_margin_box>\textheight
+ \vsplit\page_margin_box to \textheight
+ \else
+ \unvbox\page_margin_box
+ \fi
+ \fi}%
+ \page_margin_reshape
+ \setbox\page_margin_prepared_box\vbox
+ {\marginblockparameter\c!before
+ \box\page_margin_prepared_box
+ \marginblockparameter\c!after}}
+
+\setvalue{\??mb::\c!location::\v!left }{\page_margin_set_l_box}
+\setvalue{\??mb::\c!location::\v!right }{\page_margin_set_r_box}
+\setvalue{\??mb::\c!location::\v!inmargin}{\doifbothsidesoverruled
+ \page_margin_set_r_box
+ \page_margin_set_r_box
+ \page_margin_set_l_box}
+\setvalue{\??mb::\c!location::\v!middle }{\doifbothsidesoverruled
+ \page_margin_set_r_box
+ \page_margin_set_l_box
+ \page_margin_set_r_box}
+
+\unexpanded\def\place_r_margin_block_yes
+ {\setbox\page_margin_prepared_box\hbox to \rightmarginwidth
+ {\marginblockparameter\c!left
+ \box\page_margin_prepared_box
+ \marginblockparameter\c!right}%
+ \vsmashbox\page_margin_prepared_box
+ \box\page_margin_prepared_box}
+
+\unexpanded\def\place_l_margin_block_yes
+ {\setbox\page_margin_prepared_box\hbox to \leftmarginwidth
+ {\marginblockparameter\c!right
+ \box\page_margin_prepared_box
+ \marginblockparameter\c!left}%
+ \vsmashbox\page_margin_prepared_box
+ \box\page_margin_prepared_box}
+
+\unexpanded\def\place_r_margin_block_nop{\hskip\rightmarginwidth}
+\unexpanded\def\place_l_margin_block_nop{\hskip\leftmarginwidth}
+
+\let\placerightmarginblock\place_r_margin_block_nop
+\let\placeleftmarginblock \place_l_margin_block_nop
+
+\def\page_margin_set_r_box{\let\placerightmarginblock\place_r_margin_block_yes}
+\def\page_margin_set_l_box{\let\placeleftmarginblock \place_l_margin_block_yes}
+
+% margin floats (keyword 'margin' in option list)
+
+\unexpanded\def\page_margin_process_float
+ {\doifelse{\marginblockparameter\c!state}\v!start
+ \page_margin_process_float_yes
+ \page_margin_process_float_nop}
+
+\def\page_margin_process_float_yes#options%
+ {\global\setbox\page_margin_box\vbox
+ {\hsize\marginblockparameter\c!width
+ \unvcopy\page_margin_box
+ \ifvoid\page_margin_box\else
+ \expandafter\marginblockparameter\expandafter\c!inbetween
+ \fi
+ \box\floatbox
+ \filbreak}%
+ \ifdim\ht\page_margin_box>\textheight
+ % \dosavefloatinfo % no saving done anyway
+ \else
+ \doinsertfloatinfo
+ \fi}
+
+\def\page_margin_process_float_nop#options%
+ {\someelsefloat[#options,\v!here]} % still an old name
+
+\def\page_margin_float_before
+ {\ifconditional\page_margin_blocks_c
+ \doifinset\v!margin\floatlocation\endgraf
+ \fi}
+
+\def\page_margin_float_set_hsize
+ {\ifconditional\page_margin_blocks_c
+ \doifinset\v!margin\floatlocation{\hsize\rootmarginblockparameter\c!width}%
+ \fi}
+
+\appendtoks
+ \ifvoid\page_margin_box \else
+ \writestatus\m!layouts{beware: there are left-over margin floats!}%
+ \fi
+\to \everystoptext
+
+\protect \endinput
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv
index d3c1e5051..5ab96f0f8 100644
--- a/tex/context/base/page-mis.mkiv
+++ b/tex/context/base/page-mis.mkiv
@@ -17,140 +17,6 @@
\unprotect
-\newif\ifmarginblocks
-
-\def\dosetupmarginblocks[#1]%
- {\getparameters[\??mb][#1]%
- \doifelse\@@mbstate\v!start
- {\showmessage\m!layouts4\empty
- \marginblockstrue
- \let\somenextfloat\dosomenextfloat
- \let\startmarginblock\dostartmarginblock
- \let\stopmarginblock\dostopmarginblock}%
- {\showmessage\m!layouts5\empty
- \marginblocksfalse
- \def\somenextfloat[##1]%
- {\someelsefloat[##1,\v!here]}%
- \let\startmarginblock\dontstartmargeblok
- \let\stopmarginblock\dontstopmargeblok}}
-
-\unexpanded\def\setupmarginblocks
- {\dosingleargument\dosetupmarginblocks}
-
-\newbox\marginbox
-
-\def\dosomenextfloat[#1]%
- {\global\setbox\marginbox\vbox
- {\hsize\@@mbwidth
- \unvcopy\marginbox
- \ifvoid\marginbox\else\expandafter\@@mbinbetween\fi
- \box\floatbox\filbreak}%
- \ifdim\ht\marginbox>\textheight
- % \dosavefloatinfo
- \else
- \doinsertfloatinfo
- \fi}
-
-\newbox\preparedmarginbox
-
-\def\reshapemargin
- {\ifdim\ht\preparedmarginbox>\zeropoint
- \beginofshapebox
- \unvbox\preparedmarginbox
- \endofshapebox
- \reshapebox
- {\box\shapebox}%
- \setbox\preparedmarginbox\vbox to \textheight
- {\@@mbtop
- \flushshapebox
- \@@mbbottom}%
- \fi}
-
-\unexpanded\def\placerightmarginblock
- {\hskip\rightmarginwidth}
-
-\unexpanded\def\placeleftmarginblock
- {\hskip\leftmarginwidth}
-
-\def\checkmarginblocks
- {\ifvoid\marginbox\else\docheckmarginblocks\fi}
-
-\def\docheckmarginblocks % erg inefficient
- {\setbox\preparedmarginbox\vbox
- {\forgetall
- \splittopskip\topskip
- \ifvoid\marginbox\else
- \ifdim\ht\marginbox>\textheight
- \vsplit\marginbox to \textheight
- \else
- \unvbox\marginbox
- \fi
- \fi}%
- \reshapemargin
- \setbox\preparedmarginbox\vbox
- {\@@mbbefore\box\preparedmarginbox\@@mbafter}%
- \def\rightmarginbox
- {\unexpanded\def\placerightmarginblock
- {\setbox\preparedmarginbox\hbox to \rightmarginwidth
- {\@@mbleft\box\preparedmarginbox\@@mbright}%
- \vsmashbox\preparedmarginbox
- \box\preparedmarginbox}}%
- \def\leftmarginbox
- {\unexpanded\def\placeleftmarginblock
- {\setbox\preparedmarginbox\hbox to \leftmarginwidth
- {\@@mbright\box\preparedmarginbox\@@mbleft}%
- \vsmashbox\preparedmarginbox
- \box\preparedmarginbox}}%
- \processaction % traag
- [\@@mblocation]
- [ \v!inmargin=>\doifbothsidesoverruled\rightmarginbox\rightmarginbox\leftmarginbox,
- \v!middle=>\doifbothsidesoverruled\rightmarginbox\leftmarginbox\rightmarginbox,
- \v!left=>\leftmarginbox,
- \v!right=>\rightmarginbox,
- \s!unknown=>\setbox\preparedmarginbox\emptyhbox]}
-
-\def\dostartmarginblock % 2 maal \vbox ivm \unvbox elders
- {\global\setbox\marginbox\vtop\bgroup\vbox\bgroup
- \hsize\@@mbwidth
- \ifvoid\marginbox\else
- \unvbox\marginbox
- \@@mbinbetween
- \fi
- \setupalign[\@@mbalign]%
- \dostartattributes\??mb\c!style\c!color{}%
- \begstrut\ignorespaces}
-
-\def\dostopmarginblock
- {\unskip\endstrut
- \dostopattributes
- \egroup
- \egroup}
-
-\def\dontstartmargeblok
- {\@@mbbefore
- \bgroup
- \dostartattributes\??mb\c!style\c!color\empty}
-
-\def\dontstopmargeblok
- {\dostopattributes
- \egroup
- \@@mbafter}
-
-\setupmarginblocks
- [\c!state=\v!start,
- \c!location=\v!inmargin,
- \c!width=\rightmarginwidth,
- \c!style=,
- \c!color=,
- \c!align=,
- \c!left=,
- \c!right=,
- \c!top=,
- \c!inbetween=\blank,
- \c!bottom=\vfill,
- \c!before=,
- \c!after=]
-
% postponing
\newevery\everytopofpage\relax
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 4d659188f..14972afff 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 915145f56..129f122ed 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index ed5215dce..22585b465 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -514,7 +514,10 @@
\def\float_begin_text_group {\begingroup\let\float_end_group\relax}
\def\float_end_text_group {\endgroup}
-% implemenation
+% implementation
+
+\ifdefined\page_margin_float_before \else \let\page_margin_float_before \relax \fi
+\ifdefined\page_margin_float_set_hsize \else \let\page_margin_float_set_hsize\relax \fi
\def\flushfloatslist
{\v!left,\v!right,\v!inner,\v!outer,%
@@ -537,14 +540,10 @@
{\doifcommonelse\floatlocation\flushfloatslist\doflushfloats\donothing}%
% but which should be done before using box \floatbox
\fi
- \ifmarginblocks
- \doifinset\v!margin\floatlocation\endgraf
- \fi
+ \page_margin_float_before % todo: each float handler gets a before
\global\insidefloattrue
\dostarttagged\t!float\currentfloat
- \ifmarginblocks
- \doifinset\v!margin\floatlocation{\hsize\@@mbwidth}%
- \fi
+ \page_margin_float_set_hsize % todo: each float handler gets a set_hsize
\the\everyinsidefloat
\float_analyze_variables_one
\dostarttagged\t!floatcontent\empty
@@ -1878,7 +1877,7 @@
\def\sometopfloat [#1]{\someelsefloat[#1]\nonoindentation}
\def\somebottomfloat [#1]{\someelsefloat[#1]}
\def\someautofloat [#1]{\someelsefloat[#1]}
-\def\somemarginfloat [#1]{\somenextfloat[#1]\nonoindentation}
+\def\somemarginfloat [#1]{\page_margin_process_float{#1}\nonoindentation}
\def\someinleftmarginfloat [#1]{\somesidefloat[#1]}
\def\someinrightmarginfloat[#1]{\somesidefloat[#1]}
\def\someinleftedgefloat [#1]{\somesidefloat[#1]}
diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv
index 97c2e7581..a782e292f 100644
--- a/tex/context/base/strc-mat.mkiv
+++ b/tex/context/base/strc-mat.mkiv
@@ -21,52 +21,116 @@
\unprotect
-\definestructureconversionset[\v!formula][numbers,characters]
-
\setupformulas
- [%\c!way=\@@nrway,
+ [%\c!way=,
%\c!blockway=,
- %\c!sectionnumber=\@@nrsectionnumber,
+ %\c!sectionnumber=,
%\c!conversion=\v!numbers,
+ %\c!numberstyle=,
+ %\c!numbercolor=,
+ %\c!numbercommand=,
+ %\c!margin=,
+ %\c!align=,
+ %\c!separator=,
+ %\c!grid=,
\c!location=\v!right,
\c!left=(,
\c!right=),
\c!expansion=\v!yes, % maybe automatically
- %\c!numberstyle=,
- %\c!numbercolor=,
- %\c!numbercommand=,
\c!spacebefore=\v!big,
\c!spaceafter=\formulaparameter\c!spacebefore,
\c!leftmargin=\!!zeropoint,
\c!rightmargin=\!!zeropoint,
- %\c!margin=,
\c!indentnext=\v!no,
\c!alternative=\s!default,
- %\c!align=,
\c!strut=\v!no,
- %\c!separator=\@@koseparator,
- %\c!grid=,
\c!distance=1em]
+\setupsubformulas % subformulas could be last in chain
+ [\c!indentnext=\formulaparameter\c!indentnext]
+
\definestructurecounter
[\v!formula]
-\presetstructurecountersetup\setupformulas\sharedstructurecounterparameter
+\definestructureconversionset
+ [\v!formula]
+ [numbers,characters]
+\presetstructurecountersetup\setupformulas\sharedstructurecounterparameter
\appendtoks
\dostructurecountersetup\v!formula\formulaparameter
\docheckstructurecountersetup\v!formula % yes or no
-\to \everysetupformulas
+\to \everysetupformula
\setupformulas
[\c!numberconversionset=\v!formula] % why forgotten
+\appendtoks
+ \normalexpanded{\definelist[\currentformula]}% is expansion needed?
+ \setuevalue{\e!start\currentformula\v!formula}{\dostartformula{\currentformula}}%
+ \setuevalue{\e!stop \currentformula\v!formula}{\dostopformula}%
+\to \everydefineformula
+
+\definelist[\v!formula]
+
+\setuvalue{\e!start\v!formula}{\dostartformula{}}
+\setuvalue{\e!stop \v!formula}{\dostopformula}
+
+\let\dostartformula\relax % defined later
+\let\dostopformula \relax % defined later
+
+\unexpanded\def\defineformulaalternative % this might change ... start and stop can become keys
+ {\dotripleargument\dodefineformulaalternative} % to the general define .. s!startcommand
+
+\def\dodefineformulaalternative[#1][#2][#3]%
+ {\setvalue{\e!start#1\v!formula}{#2}%
+ \setvalue{\e!stop #1\v!formula}{#3}}
+
+% sp = single line paragraph sd = single line display
+% mp = multi line paragraph md = multy line display
+
+\defineformulaalternative[\s!default][\startdisplaymath][\stopdisplaymath]
+\defineformulaalternative[\s!single] [\startdisplaymath][\stopdisplaymath]
+\defineformulaalternative[\s!multi] [\startdisplaymath][\stopdisplaymath]
+
+\defineformula
+ [sp]
+ [\c!spacebefore=\v!none,
+ \c!spaceafter=\v!none,
+ \c!indentnext=\v!no,
+ \c!alternative=\s!single]
+
+\defineformula
+ [sd]
+ [\c!spacebefore=\v!none,
+ \c!spaceafter=\v!none,
+ \c!indentnext=\v!yes,
+ \c!alternative=\s!single]
+
+\defineformula
+ [mp]
+ [\c!indentnext=\v!no,
+ \c!alternative=\s!multi]
+
+\defineformula
+ [md]
+ [\c!indentnext=\v!yes,
+ \c!alternative=\s!multi]
+
+\newtoks\everyresetformulas
+
+\appendtoks
+ \let\currentformula\empty % to be checked:
+\to \everyresetformulas
+
+% implementation
+
\def\storecurrentformulanumber#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float)
{\settrue\handleformulanumber
\dostructurecountercomponent
{formula}%
- \getformulaparameters \formulaparameter \detokenizedformulaparameter
+ \setupcurrentformula \formulaparameter \detokenizedformulaparameter
\relax \relax \relax
[\c!name=\v!formula,\s!counter=\v!formula,%
\s!hascaption=\v!yes,\s!hastitle=\v!yes,\s!hasnumber=\v!yes,%\s!haslevel=#6,%
@@ -77,26 +141,32 @@
\globallet#4\laststructurecountersynchronize
\globallet#5\laststructurecounterattribute}
-\newif\ifnoformulanumber
-
-\newconditional\handleformulanumber
-\newconditional\incrementformulanumber
-
-\newtoks\everyresetformulas
-
-% 0=unset, 1=forced, 2=none, 3=reference
+% modes: 0=unset, 1=forced, 2=none, 3=reference
\newconstant\placeformulanumbermode
\newconstant\formulasnumbermode
\newconstant\subformulasnumbermode
\newconstant\nestedformulanumbermode
+\appendtoks
+ \placeformulanumbermode \zerocount
+ \formulasnumbermode \zerocount
+ \subformulasnumbermode \zerocount
+ \nestedformulanumbermode\zerocount
+\to \everyresetformulas
+
+\newconditional\handleformulanumber
+\newconditional\incrementformulanumber
+
\newconditional\insideplaceformula
\newconditional\insideplacesubformula
\newconditional\insideformulas
\newconditional\insidesubformulas
-% 0=unset, 1=forced, 2=none, 3=reference
+\appendtoks
+ \global\setfalse\insideplaceformula
+ \global\setfalse\insideplacesubformula
+\to \everyresetformulas
\def\handleplaceformulanumbering % place formula
{\settrue\handleformulanumber
@@ -118,8 +188,23 @@
\currentsubformulasattribute
}
-\def\tracedformulamode
- {\hbox{\quad\tt\txx[\number\placeformulanumbermode,\number\formulasnumbermode,\number\subformulasnumbermode,\number\nestedformulanumbermode]}}
+\let\dotraceformulareferencestate\relax
+\let\doshowformulareferencestate \relax
+
+% \def\dotraceformulareferencestate
+% {\rlap{\hbox{\quad\tt\txx[%
+% \number\placeformulanumbermode,%
+% \number\formulasnumbermode,%
+% \number\subformulasnumbermode,%
+% \number\nestedformulanumbermode
+% ]}}}
+
+% \def\doshowformulareferencestate
+% {\writestatus{\v!formula}%
+% {place: \number\placeformulanumbermode,\space
+% formula: \number\formulasnumbermode,\space
+% subformula: \number\subformulasnumbermode,\space
+% nested: \number\nestedformulanumbermode]}}
\unexpanded\def\placecurrentformulanumber
{\rm % nodig ?
@@ -148,25 +233,54 @@
\glet#1\relax
\fi\fi\fi}
+\let\currentplaceformulaattribute\relax
+\let\currentformulaattribute \relax
+\let\currentsubformulaattribute \relax
+\let\currentformulasattribute \relax
+
+\let\currentplaceformulanumber\relax
+\let\currentformulanumber \relax
+\let\currentsubformulanumber \relax
+\let\currentformulasnumber \relax
+
+\let\currentformulasreference \empty
+\let\currentformulareference \empty
+\let\currentsubformulareference \empty
+\let\currentnestedformulareference\empty
+
+\appendtoks
+ \glet\currentformulasreference \empty
+ \glet\currentformulareference \empty
+ \glet\currentsubformulareference \empty
+ \glet\currentnestedformulareference\empty
+\to \everyresetformulas
+
+\let\currentformulassuffix \empty
+\let\currentformulasuffix \empty
+\let\currentsubformulasuffix \empty
+\let\currentnestedformulasuffix\empty
+
+\appendtoks
+ \glet\currentformulassuffix \empty
+ \glet\currentformulasuffix \empty
+ \glet\currentsubformulasuffix \empty
+ \glet\currentnestedformulasuffix\empty
+\to \everyresetformulas
+
+\let\currentplaceformulasynchronize\relax
+\let\currentformulasynchronize \relax
+\let\currentsubformulasynchronize \relax
+\let\currentformulassynchronize \relax
+
\appendtoks
\glet\currentplaceformulasynchronize \relax
\glet\currentformulassynchronize \relax
\glet\currentsubformulassynchronize \relax
\glet\currentnestedformulasynchronize\relax
- \let\currentformula\empty
\to \everyresetformulas
% currently we do the number, some day we will do the (sub) formula
-\let\doshowformulareferencestate\relax
-
-% \def\doshowformulareferencestate
-% {\writestatus{\v!formula}%
-% {place: \number\placeformulanumbermode,\space
-% formula: \number\formulasnumbermode,\space
-% subformula: \number\subformulasnumbermode,\space
-% nested: \number\nestedformulanumbermode]}}
-
\def\dohandlecurrentformulareferences
{\doshowformulareferencestate
\ifnum\placeformulanumbermode=\plusthree
@@ -209,16 +323,6 @@
% needs checking ... too many:
-\let\currentplaceformulaattribute\relax \let\currentplaceformulasynchronize\relax \let\currentplaceformulanumber\relax
-\let\currentformulaattribute \relax \let\currentformulasynchronize \relax \let\currentformulanumber \relax
-\let\currentsubformulaattribute \relax \let\currentsubformulasynchronize \relax \let\currentsubformulanumber \relax
-\let\currentformulasattribute \relax \let\currentformulassynchronize \relax \let\currentformulasnumber \relax
-
-\let\currentformulasreference \empty \let\currentformulassuffix \empty
-\let\currentformulareference \empty \let\currentformulasuffix \empty
-\let\currentsubformulareference \empty \let\currentsubformulasuffix \empty
-\let\currentnestedformulareference\empty \let\currentnestedformulasuffix\empty
-
\def\dohandleformulanumbering
{\doincrementsubstructurecounter[\v!formula][1]%
\doiftext\currentplaceformulasuffix{\setsubstructurecounterown[\v!formula][2]{\currentplaceformulasuffix}}%
@@ -267,12 +371,10 @@
\dohandlesubformulanumbering
\fi
\fi
- %\rlap{\tracedformulamode}%
+ \dotraceformulareferencestate
\egroup
\fi}
-\definelist[\v!formula]
-
\installstructurelistprocessor\v!formula % to be checked ...
{\dodolistelement
\currentlist
@@ -282,35 +384,6 @@
\structurelistpagenumber
\structurelistrealpagenumber}
-\appendtoks
- \global\setfalse\insideplaceformula
- \global\setfalse\insideplacesubformula
-\to \everyresetformulas
-
-\appendtoks
- \placeformulanumbermode \zerocount
- \formulasnumbermode \zerocount
- \subformulasnumbermode \zerocount
- \nestedformulanumbermode \zerocount
- \glet\currentformulasreference \empty
- \glet\currentformulareference \empty
- \glet\currentsubformulareference \empty
- \glet\currentnestedformulareference\empty
- \glet\currentformulassuffix \empty
- \glet\currentformulasuffix \empty
- \glet\currentsubformulasuffix \empty
- \glet\currentnestedformulasuffix \empty
-\to \everyresetformulas
-
-\let\currentformulasreference \empty
-\let\currentformulareference \empty
-\let\currentsubformulareference \empty
-\let\currentnestedformulareference\empty
-\let\currentformulassuffix \empty
-\let\currentformulasuffix \empty
-\let\currentsubformulasuffix \empty
-\let\currentnestedformulasuffix \empty
-
\newif\ifinformula
%D We need a hook into the plain math alignment macros
@@ -328,69 +401,9 @@
\let\normalreqno\gobbleoneargument \let\eqno \gobbleoneargument
\let\doplaceformulanumber\empty}
-%D
-
-\unexpanded\def\defineformula
- {\dodoubleempty\dodefineformula}
-
-\def\dodefineformula[#1][#2]%
- {\doifsomething{#1}
- {\getparameters[\??fm#1][\s!parent=\??fm,#2]%
- \definelist[#1]%
- \setvalue{\e!start#1\v!formula}{\dostartformula{#1}}%
- \setvalue{\e!stop #1\v!formula}{\dostopformula}}}
-
-\unexpanded\def\defineformulaalternative
- {\dotripleargument\dodefineformulaalternative}
-
-\def\dodefineformulaalternative[#1][#2][#3]%
- {\setvalue{\e!start#1\v!formula}{#2}%
- \setvalue{\e!stop #1\v!formula}{#3}}
-
-% sp = single line paragraph sd = single line display
-% mp = multi line paragraph md = multy line display
-
-\defineformulaalternative[\s!default][\startdisplaymath][\stopdisplaymath]
-\defineformulaalternative[\s!single] [\startdisplaymath][\stopdisplaymath]
-\defineformulaalternative[\s!multi] [\startdisplaymath][\stopdisplaymath]
-
-\defineformula
- [sp]
- [\c!spacebefore=\v!none,
- \c!spaceafter=\v!none,
- \c!indentnext=\v!no,
- \c!alternative=\s!single]
-
-\defineformula
- [sd]
- [\c!spacebefore=\v!none,
- \c!spaceafter=\v!none,
- \c!indentnext=\v!yes,
- \c!alternative=\s!single]
-
-\defineformula
- [mp]
- [\c!indentnext=\v!no,
- \c!alternative=\s!multi]
-
-\defineformula
- [md]
- [\c!indentnext=\v!yes,
- \c!alternative=\s!multi]
-
%D \macros
-%D {setupsubformulas, startsubformulas}
-
-\def\subformulaparameter#1{\ifcsname\??fn#1\endcsname\csname\??fn#1\endcsname\fi}
-
-\unexpanded\def\setupsubformulas
- {\dodoubleargument\getparameters[\??fn]}
+%D {startsubformulas}
-\setupsubformulas
- [\c!indentnext=\formulaparameter\c!indentnext]
-
-% \setupsubformulas[conversion=romannumerals]
-%
% \placeformula
% \startsubformulas[Maxwell]
% \startformulas
@@ -427,9 +440,6 @@
\abovedisplayshortskip\zeropoint
\belowdisplayshortskip\zeropoint}
-\setvalue{\e!start\v!formula}{\dostartformula{}}
-\setvalue{\e!stop \v!formula}{\dostopformula}
-
\def\predisplaysizethreshhold{2em} % was 3em
\def\leftdisplayskip {\leftskip}
@@ -457,7 +467,7 @@
\advance\displaywidth\dimexpr-\displayindent-\rightdisplayskip-\rightdisplaymargin\relax
\hsize\displaywidth} % new, else overfull in itemize
-\def\dostartformula#1%
+\unexpanded\def\dostartformula#1%
{\dodoubleempty\dodostartformula[#1]}
\newskip\formulaparskip
@@ -500,7 +510,7 @@
% tagging of formulanumbers is not ok (we get two display maths blobs)
-\def\dostopformula
+\unexpanded\def\dostopformula
{\dostarttagged\t!formulacaption\empty
\doplaceformulanumber
\dostoptagged
@@ -528,7 +538,7 @@
\def\switchtoformulabodyfont{\switchtobodyfont}
-\setvalue{\v!formula}{\dosingleempty\doformula}
+\setuvalue{\v!formula}{\dosingleempty\doformula}
\def\doformula[#1]#2% todo: tagged
{\begingroup
@@ -567,9 +577,6 @@
\par
\egroup}
-\newif\ifclipdisplaymath \clipdisplaymathtrue
-\def\displaymathclipfactor{1.1}
-
% already defined
%
% \let\startinnermath\empty
@@ -735,8 +742,8 @@
% to be checked
-\glet\doplaceformulanumber \relax
-\glet\donestedformulanumber\gobbletwoarguments
+\let\doplaceformulanumber \relax
+\let\donestedformulanumber\gobbletwoarguments
\def\donestedformulanumberindeed#1#2%
{\def\currentnestedformulareference{#1}%
@@ -773,9 +780,9 @@
\setformulalistentry{#2}%
\next}
-\glet\namedformulaentry\empty % \relax % this will become a key/value so that we can do bookmarks
+\let\namedformulaentry\empty % \relax % this will become a key/value so that we can do bookmarks
-\def\setformulalistentry#1%
+\unexpanded\def\setformulalistentry#1%
{\gdef\namedformulaentry{#1}}
\protect \endinput
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 2be7de33c..78855b32b 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 : 11/23/11 18:58:55
+-- merge date : 11/24/11 15:52:09
do -- begin closure to overcome local limits and interference