From dc98ffdc842271d05903846b460fab90d4d83739 Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Mon, 9 Mar 2015 20:15:05 +0100 Subject: 2015-03-09 19:29:00 --- .../lexers/data/scite-context-data-context.lua | 2 +- .../lexers/data/scite-context-data-metafun.lua | 2 +- .../context/scite-context-data-context.properties | 237 +-- .../context/scite-context-data-metafun.properties | 88 +- .../documents/general/manuals/workflows-mkiv.pdf | Bin 68961 -> 71319 bytes doc/context/scripts/mkiv/mtx-bibtex.html | 55 + doc/context/scripts/mkiv/mtx-bibtex.man | 33 + doc/context/scripts/mkiv/mtx-bibtex.xml | 28 + .../general/manuals/workflows/workflows-mkiv.tex | 1 + .../general/manuals/workflows/workflows-setups.tex | 72 + .../general/manuals/workflows/workflows-style.tex | 1 - metapost/context/base/mp-chem.mpiv | 32 +- metapost/context/base/mp-mlib.mpiv | 26 +- metapost/context/base/mp-tool.mpii | 2 +- metapost/context/base/mp-tool.mpiv | 9 +- scripts/context/lua/mtx-context.lua | 22 +- scripts/context/lua/mtx-epub.lua | 54 +- scripts/context/lua/mtx-interface.lua | 8 +- scripts/context/lua/mtxrun.lua | 75 +- scripts/context/stubs/mswin/mtxrun.lua | 75 +- scripts/context/stubs/unix/mtxrun | 75 +- scripts/context/stubs/win64/mtxrun.lua | 75 +- tex/context/base/anch-bck.mkvi | 6 +- tex/context/base/anch-pgr.lua | 12 +- tex/context/base/anch-pos.mkiv | 3 + tex/context/base/back-exp.lua | 49 +- tex/context/base/blob-ini.lua | 11 - tex/context/base/buff-ini.lua | 2 + tex/context/base/buff-ver.lua | 11 +- tex/context/base/buff-ver.mkiv | 5 +- tex/context/base/char-fio.lua | 46 +- tex/context/base/char-ini.lua | 6 +- tex/context/base/char-tex.lua | 10 + tex/context/base/chem-str.lua | 10 +- tex/context/base/chem-str.mkiv | 4 +- tex/context/base/cldf-ini.lua | 329 +++-- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4386 -> 4394 bytes tex/context/base/context.mkiv | 5 +- tex/context/base/core-env.lua | 287 ++-- tex/context/base/core-env.mkiv | 6 +- tex/context/base/data-tre.lua | 20 +- tex/context/base/enco-ini.mkiv | 100 +- tex/context/base/export-example.css | 1 + tex/context/base/export-example.tex | 4 +- tex/context/base/file-job.lua | 6 + tex/context/base/font-ctx.lua | 31 +- tex/context/base/font-fil.mkvi | 94 +- tex/context/base/font-ini.mkvi | 10 +- tex/context/base/font-inj.lua | 63 +- tex/context/base/font-nod.lua | 38 +- tex/context/base/font-otn.lua | 12 +- tex/context/base/font-pre.mkiv | 29 + tex/context/base/font-tfm.lua | 6 +- tex/context/base/lang-ini.lua | 2 +- tex/context/base/lang-ini.mkiv | 38 + tex/context/base/lang-lab.lua | 1 + tex/context/base/lang-lab.mkiv | 5 +- tex/context/base/lpdf-ano.lua | 33 +- tex/context/base/lpdf-mis.lua | 85 +- tex/context/base/luat-ini.mkiv | 18 + tex/context/base/luat-mac.lua | 5 +- tex/context/base/lxml-ini.mkiv | 20 +- tex/context/base/lxml-tab.lua | 8 +- tex/context/base/lxml-tex.lua | 15 + tex/context/base/m-chart.lua | 53 +- tex/context/base/m-chart.mkvi | 7 +- tex/context/base/m-scite.mkiv | 2 + tex/context/base/math-ini.mkiv | 36 +- tex/context/base/math-noa.lua | 13 +- tex/context/base/mtx-context-arrange.tex | 2 +- tex/context/base/mtx-context-listing.tex | 7 + tex/context/base/mult-aux.mkiv | 79 + tex/context/base/mult-def.lua | 8 +- tex/context/base/mult-def.mkiv | 4 +- tex/context/base/mult-fun.lua | 1 + tex/context/base/mult-it.mkii | 2 +- tex/context/base/mult-low.lua | 4 +- tex/context/base/mult-nl.mkii | 8 +- tex/context/base/node-fnt.lua | 36 +- tex/context/base/node-nut.lua | 32 + tex/context/base/node-ref.lua | 1 - tex/context/base/node-res.lua | 12 + tex/context/base/node-tex.lua | 4 +- tex/context/base/node-tra.lua | 216 ++- tex/context/base/pack-lyr.mkiv | 5 +- tex/context/base/page-ini.mkiv | 8 +- tex/context/base/page-lay.mkiv | 10 +- tex/context/base/page-mak.mkvi | 3 +- tex/context/base/page-run.mkiv | 10 +- tex/context/base/publ-aut.lua | 10 +- tex/context/base/publ-dat.lua | 214 +-- tex/context/base/publ-fnd.lua | 370 +++-- tex/context/base/publ-imp-apa.lua | 146 +- tex/context/base/publ-imp-apa.mkvi | 1512 ++++++++++++-------- tex/context/base/publ-imp-aps.mkvi | 30 +- tex/context/base/publ-imp-author.mkvi | 140 +- tex/context/base/publ-imp-cite.mkvi | 281 ++-- tex/context/base/publ-imp-commands.mkiv | 15 - tex/context/base/publ-imp-commands.mkvi | 15 + tex/context/base/publ-imp-default.lua | 124 ++ tex/context/base/publ-imp-default.mkvi | 597 ++++++++ tex/context/base/publ-imp-definitions.mkiv | 77 - tex/context/base/publ-imp-definitions.mkvi | 123 ++ tex/context/base/publ-imp-list.mkvi | 22 +- tex/context/base/publ-imp-page.mkvi | 51 +- tex/context/base/publ-imp-replacements.lua | 13 + tex/context/base/publ-ini.lua | 984 ++++++++----- tex/context/base/publ-ini.mkiv | 1318 ++++++++--------- tex/context/base/publ-reg.lua | 1 - tex/context/base/publ-sor.lua | 7 +- tex/context/base/publ-tra.lua | 102 +- tex/context/base/publ-tra.mkiv | 12 +- tex/context/base/publ-xml.mkiv | 2 +- tex/context/base/status-files.pdf | Bin 24590 -> 24658 bytes tex/context/base/status-lua.pdf | Bin 333384 -> 343151 bytes tex/context/base/strc-bkm.lua | 54 +- tex/context/base/strc-bkm.mkiv | 6 +- tex/context/base/strc-def.mkiv | 4 + tex/context/base/strc-doc.lua | 28 +- tex/context/base/strc-ini.lua | 5 +- tex/context/base/strc-itm.lua | 5 +- tex/context/base/strc-lst.lua | 4 +- tex/context/base/strc-lst.mkvi | 107 +- tex/context/base/strc-not.mkvi | 20 + tex/context/base/strc-num.mkiv | 4 +- tex/context/base/strc-ref.lua | 4 +- tex/context/base/strc-ref.mkvi | 21 + tex/context/base/strc-reg.lua | 28 +- tex/context/base/strc-sec.mkiv | 2 +- tex/context/base/syst-aux.lua | 2 +- tex/context/base/syst-aux.mkiv | 35 +- tex/context/base/syst-ini.mkiv | 5 +- tex/context/base/syst-lua.lua | 23 +- tex/context/base/syst-lua.mkiv | 27 +- tex/context/base/syst-rtp.mkiv | 2 +- tex/context/base/tabl-xtb.mkvi | 2 + tex/context/base/toks-ini.lua | 509 +++---- tex/context/base/toks-ini.mkiv | 50 +- tex/context/base/toks-map.lua | 70 + tex/context/base/toks-map.mkiv | 63 + tex/context/base/toks-tra.lua | 298 ++++ tex/context/base/toks-tra.mkiv | 31 + tex/context/base/trac-tex.lua | 77 +- tex/context/base/typo-chr.lua | 104 ++ tex/context/base/typo-chr.mkiv | 27 + tex/context/base/typo-del.mkiv | 43 +- tex/context/base/typo-mar.lua | 4 +- tex/context/base/util-dim.lua | 4 +- tex/context/base/util-prs.lua | 4 +- tex/context/base/x-asciimath.lua | 97 +- tex/context/base/x-asciimath.mkiv | 28 +- tex/context/base/x-cals.lua | 1 + tex/context/base/x-html.mkiv | 12 +- tex/context/base/x-set-11.mkiv | 73 +- tex/context/interface/keys-it.xml | 2 +- tex/context/interface/keys-nl.xml | 8 +- tex/generic/context/luatex/luatex-basics-gen.lua | 9 +- tex/generic/context/luatex/luatex-fonts-cbk.lua | 13 +- tex/generic/context/luatex/luatex-fonts-inj.lua | 384 ++--- tex/generic/context/luatex/luatex-fonts-merged.lua | 399 +++--- tex/generic/context/luatex/luatex-fonts-otn.lua | 12 +- 162 files changed, 7819 insertions(+), 4040 deletions(-) create mode 100644 doc/context/scripts/mkiv/mtx-bibtex.html create mode 100644 doc/context/scripts/mkiv/mtx-bibtex.man create mode 100644 doc/context/scripts/mkiv/mtx-bibtex.xml create mode 100644 doc/context/sources/general/manuals/workflows/workflows-setups.tex delete mode 100644 tex/context/base/publ-imp-commands.mkiv create mode 100644 tex/context/base/publ-imp-commands.mkvi create mode 100644 tex/context/base/publ-imp-default.lua create mode 100644 tex/context/base/publ-imp-default.mkvi delete mode 100644 tex/context/base/publ-imp-definitions.mkiv create mode 100644 tex/context/base/publ-imp-definitions.mkvi create mode 100644 tex/context/base/publ-imp-replacements.lua create mode 100644 tex/context/base/toks-map.lua create mode 100644 tex/context/base/toks-map.mkiv create mode 100644 tex/context/base/toks-tra.lua create mode 100644 tex/context/base/toks-tra.mkiv create mode 100644 tex/context/base/typo-chr.lua create mode 100644 tex/context/base/typo-chr.mkiv diff --git a/context/data/scite/context/lexers/data/scite-context-data-context.lua b/context/data/scite/context/lexers/data/scite-context-data-context.lua index c117428b3..88eea6b5d 100644 --- a/context/data/scite/context/lexers/data/scite-context-data-context.lua +++ b/context/data/scite/context/lexers/data/scite-context-data-context.lua @@ -1,4 +1,4 @@ return { ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "maxcardminusone", "zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "halfpoint", "zeroskip", "zeromuskip", "onemuskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "normalpagebox", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "conditionaltrue", "conditionalfalse", "attributeunsetvalue", "uprotationangle", "rightrotationangle", "downrotationangle", "leftrotationangle", "inicatcodes", "ctxcatcodes", "texcatcodes", "notcatcodes", "txtcatcodes", "vrbcatcodes", "prtcatcodes", "nilcatcodes", "luacatcodes", "tpacatcodes", "tpbcatcodes", "xmlcatcodes", "ctdcatcodes", "escapecatcode", "begingroupcatcode", "endgroupcatcode", "mathshiftcatcode", "alignmentcatcode", "endoflinecatcode", "parametercatcode", "superscriptcatcode", "subscriptcatcode", "ignorecatcode", "spacecatcode", "lettercatcode", "othercatcode", "activecatcode", "commentcatcode", "invalidcatcode", "tabasciicode", "newlineasciicode", "formfeedasciicode", "endoflineasciicode", "endoffileasciicode", "spaceasciicode", "hashasciicode", "dollarasciicode", "commentasciicode", "ampersandasciicode", "colonasciicode", "backslashasciicode", "circumflexasciicode", "underscoreasciicode", "leftbraceasciicode", "barasciicode", "rightbraceasciicode", "tildeasciicode", "delasciicode", "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", "primeasciicode", "hyphenasciicode", "activemathcharcode", "activetabtoken", "activeformfeedtoken", "activeendoflinetoken", "batchmodecode", "nonstopmodecode", "scrollmodecode", "errorstopmodecode", "bottomlevelgroupcode", "simplegroupcode", "hboxgroupcode", "adjustedhboxgroupcode", "vboxgroupcode", "vtopgroupcode", "aligngroupcode", "noaligngroupcode", "outputgroupcode", "mathgroupcode", "discretionarygroupcode", "insertgroupcode", "vcentergroupcode", "mathchoicegroupcode", "semisimplegroupcode", "mathshiftgroupcode", "mathleftgroupcode", "vadjustgroupcode", "charnodecode", "hlistnodecode", "vlistnodecode", "rulenodecode", "insertnodecode", "marknodecode", "adjustnodecode", "ligaturenodecode", "discretionarynodecode", "whatsitnodecode", "mathnodecode", "gluenodecode", "kernnodecode", "penaltynodecode", "unsetnodecode", "mathsnodecode", "charifcode", "catifcode", "numifcode", "dimifcode", "oddifcode", "vmodeifcode", "hmodeifcode", "mmodeifcode", "innerifcode", "voidifcode", "hboxifcode", "vboxifcode", "xifcode", "eofifcode", "trueifcode", "falseifcode", "caseifcode", "definedifcode", "csnameifcode", "fontcharifcode", "fontslantperpoint", "fontinterwordspace", "fontinterwordstretch", "fontinterwordshrink", "fontexheight", "fontemwidth", "fontextraspace", "slantperpoint", "interwordspace", "interwordstretch", "interwordshrink", "exheight", "emwidth", "extraspace", "mathsupdisplay", "mathsupnormal", "mathsupcramped", "mathsubnormal", "mathsubcombined", "mathaxisheight", "muquad", "startmode", "stopmode", "startnotmode", "stopnotmode", "startmodeset", "stopmodeset", "doifmode", "doifmodeelse", "doifnotmode", "startmodeset", "stopmodeset", "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startnotext", "stopnotext", "startdocument", "stopdocument", "documentvariable", "setupdocument", "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule", "setupmodule", "currentmoduleparameter", "moduleparameter", "everystarttext", "startTEXpage", "stopTEXpage", "enablemode", "disablemode", "preventmode", "definemode", "globalenablemode", "globaldisablemode", "globalpreventmode", "pushmode", "popmode", "typescriptone", "typescripttwo", "typescriptthree", "mathsizesuffix", "mathordcode", "mathopcode", "mathbincode", "mathrelcode", "mathopencode", "mathclosecode", "mathpunctcode", "mathalphacode", "mathinnercode", "mathnothingcode", "mathlimopcode", "mathnolopcode", "mathboxcode", "mathchoicecode", "mathaccentcode", "mathradicalcode", "constantnumber", "constantnumberargument", "constantdimen", "constantdimenargument", "constantemptyargument", "continueifinputfile", "luastringsep", "!!bs", "!!es", "lefttorightmark", "righttoleftmark", "breakablethinspace", "nobreakspace", "nonbreakablespace", "narrownobreakspace", "zerowidthnobreakspace", "ideographicspace", "ideographichalffillspace", "twoperemspace", "threeperemspace", "fourperemspace", "fiveperemspace", "sixperemspace", "figurespace", "punctuationspace", "hairspace", "zerowidthspace", "zerowidthnonjoiner", "zerowidthjoiner", "zwnj", "zwj", "optionalspace", "asciispacechar" }, - ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "doifelsecommandhandler", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "strippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthsargumenttrue", "sixthargumentfalse", "sixtsargumenttrue", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "reqno", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextoptionalcselse", "doiffastoptionalcheckelse", "doifnextbgroupelse", "doifnextbgroupcselse", "doifnextparenthesiselse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifnumber", "doifnotnumber", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "docheckassignment", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "nbsp", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "begstrut", "endstrut", "lineheight", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expdoifelse", "expdoif", "expdoifnot", "expdoifcommonelse", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "carryoverpar", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "lefttoright", "righttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath" }, + ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "startluasetups", "stopluasetups", "starttexsetups", "stoptexsetups", "startrawsetups", "stoprawsetups", "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "startcontextcode", "stopcontextcode", "startcontextdefinitioncode", "stopcontextdefinitioncode", "texdefinition", "doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup", "fastsetup", "doifelsecommandhandler", "doifnotcommandhandler", "doifcommandhandler", "newmode", "setmode", "resetmode", "newsystemmode", "setsystemmode", "resetsystemmode", "pushsystemmode", "popsystemmode", "booleanmodevalue", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "then", "begcsname", "strippedcsname", "checkedstrippedcsname", "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", "thirdargumentfalse", "thirdargumenttrue", "fourthargumentfalse", "fourthargumenttrue", "fifthargumentfalse", "fifthsargumenttrue", "sixthargumentfalse", "sixtsargumenttrue", "doglobal", "dodoglobal", "redoglobal", "resetglobal", "donothing", "dontcomplain", "forgetall", "donetrue", "donefalse", "inlineordisplaymath", "indisplaymath", "forcedisplaymath", "startforceddisplaymath", "stopforceddisplaymath", "reqno", "htdp", "unvoidbox", "hfilll", "vfilll", "mathbox", "mathlimop", "mathnolop", "mathnothing", "mathalpha", "currentcatcodetable", "defaultcatcodetable", "catcodetablename", "newcatcodetable", "startcatcodetable", "stopcatcodetable", "startextendcatcodetable", "stopextendcatcodetable", "pushcatcodetable", "popcatcodetable", "restorecatcodes", "setcatcodetable", "letcatcodecommand", "defcatcodecommand", "uedcatcodecommand", "hglue", "vglue", "hfillneg", "vfillneg", "hfilllneg", "vfilllneg", "ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg", "ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg", "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox", "ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern", "ruledhglue", "ruledvglue", "normalhglue", "normalvglue", "ruledpenalty", "filledhboxb", "filledhboxr", "filledhboxg", "filledhboxc", "filledhboxm", "filledhboxy", "filledhboxk", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "normalbaselineskip", "normallineskip", "normallineskiplimit", "availablehsize", "localhsize", "setlocalhsize", "distributedhsize", "hsizefraction", "nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs", "scratchwidth", "scratchheight", "scratchdepth", "scratchoffset", "scratchdistance", "scratchhsize", "scratchvsize", "scratchxoffset", "scratchyoffset", "scratchhoffset", "scratchvoffset", "scratchxposition", "scratchyposition", "scratchtopoffset", "scratchbottomoffset", "scratchleftoffset", "scratchrightoffset", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "scratchnx", "scratchny", "scratchmx", "scratchmy", "scratchunicode", "scratchleftskip", "scratchrightskip", "scratchtopskip", "scratchbottomskip", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextoptionalcselse", "doiffastoptionalcheckelse", "doifnextbgroupelse", "doifnextbgroupcselse", "doifnextparenthesiselse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifnumber", "doifnotnumber", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "doifassignmentelse", "docheckassignment", "tracingall", "tracingnone", "loggingall", "removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "endpar", "everyendpar", "reseteverypar", "finishpar", "empty", "null", "space", "quad", "enspace", "nbsp", "obeyspaces", "obeylines", "obeyedspace", "obeyedline", "obeyedtab", "obeyedpage", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "removelastspace", "removeunwantedspaces", "keepunwantedspaces", "wait", "writestatus", "define", "defineexpandable", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "freezemeasure", "measure", "measured", "installcorenamespace", "getvalue", "getuvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "udef", "ugdef", "uedef", "uxdef", "checked", "unique", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "firstofoneunexpanded", "firstoftwounexpanded", "secondoftwounexpanded", "firstofthreeunexpanded", "secondofthreeunexpanded", "thirdofthreeunexpanded", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "dofastloopcs", "dowith", "newconstant", "setnewconstant", "setconstant", "setconstantvalue", "newconditional", "settrue", "setfalse", "settruevalue", "setfalsevalue", "newmacro", "setnewmacro", "newfraction", "newsignal", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "doquintupleargument", "dosixtupleargument", "doseventupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "permitspacesbetweengroups", "dontpermitspacesbetweengroups", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference", "twodigits", "threedigits", "leftorright", "offinterlineskip", "oninterlineskip", "nointerlineskip", "strut", "halfstrut", "quarterstrut", "depthstrut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "begstrut", "endstrut", "lineheight", "ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing", "ordopenspacing", "ordclosespacing", "ordpunctspacing", "ordinnerspacing", "opordspacing", "opopspacing", "opbinspacing", "oprelspacing", "opopenspacing", "opclosespacing", "oppunctspacing", "opinnerspacing", "binordspacing", "binopspacing", "binbinspacing", "binrelspacing", "binopenspacing", "binclosespacing", "binpunctspacing", "bininnerspacing", "relordspacing", "relopspacing", "relbinspacing", "relrelspacing", "relopenspacing", "relclosespacing", "relpunctspacing", "relinnerspacing", "openordspacing", "openopspacing", "openbinspacing", "openrelspacing", "openopenspacing", "openclosespacing", "openpunctspacing", "openinnerspacing", "closeordspacing", "closeopspacing", "closebinspacing", "closerelspacing", "closeopenspacing", "closeclosespacing", "closepunctspacing", "closeinnerspacing", "punctordspacing", "punctopspacing", "punctbinspacing", "punctrelspacing", "punctopenspacing", "punctclosespacing", "punctpunctspacing", "punctinnerspacing", "innerordspacing", "inneropspacing", "innerbinspacing", "innerrelspacing", "inneropenspacing", "innerclosespacing", "innerpunctspacing", "innerinnerspacing", "normalreqno", "startimath", "stopimath", "normalstartimath", "normalstopimath", "startdmath", "stopdmath", "normalstartdmath", "normalstopdmath", "uncramped", "cramped", "triggermathstyle", "mathstylefont", "mathsmallstylefont", "mathstyleface", "mathsmallstyleface", "mathstylecommand", "mathpalette", "mathstylehbox", "mathstylevbox", "mathstylevcenter", "mathstylevcenteredhbox", "mathstylevcenteredvbox", "mathtext", "setmathsmalltextbox", "setmathtextbox", "pushmathstyle", "popmathstyle", "triggerdisplaystyle", "triggertextstyle", "triggerscriptstyle", "triggerscriptscriptstyle", "triggeruncrampedstyle", "triggercrampedstyle", "triggersmallstyle", "triggeruncrampedsmallstyle", "triggercrampedsmallstyle", "triggerbigstyle", "triggeruncrampedbigstyle", "triggercrampedbigstyle", "luaexpr", "expdoifelse", "expdoif", "expdoifnot", "expdoifcommonelse", "expdoifinsetelse", "ctxdirectlua", "ctxlatelua", "ctxsprint", "ctxwrite", "ctxcommand", "ctxdirectcommand", "ctxlatecommand", "ctxreport", "ctxlua", "luacode", "lateluacode", "directluacode", "registerctxluafile", "ctxloadluafile", "luaversion", "luamajorversion", "luaminorversion", "ctxluacode", "luaconditional", "luaexpanded", "startluaparameterset", "stopluaparameterset", "luaparameterset", "definenamedlua", "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction", "stopctxfunction", "ctxfunction", "startctxfunctiondefinition", "stopctxfunctiondefinition", "installctxfunction", "carryoverpar", "assumelongusagecs", "Umathbotaccent", "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop", "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop", "autodirhbox", "autodirvbox", "autodirvtop", "lefttoright", "righttoleft", "synchronizelayoutdirection", "synchronizedisplaydirection", "synchronizeinlinedirection", "lesshyphens", "morehyphens", "nohyphens", "dohyphens", "Ucheckedstartdisplaymath", "Ucheckedstopdisplaymath" }, } \ No newline at end of file diff --git a/context/data/scite/context/lexers/data/scite-context-data-metafun.lua b/context/data/scite/context/lexers/data/scite-context-data-metafun.lua index 38c46afad..547b8c145 100644 --- a/context/data/scite/context/lexers/data/scite-context-data-metafun.lua +++ b/context/data/scite/context/lexers/data/scite-context-data-metafun.lua @@ -1,4 +1,4 @@ return { - ["commands"]={ "transparency", "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "invtan", "acosh", "asinh", "sinh", "cosh", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", "llcircle", "lrcircle", "urcircle", "ulcircle", "tcircle", "bcircle", "lcircle", "rcircle", "lltriangle", "lrtriangle", "urtriangle", "ultriangle", "uptriangle", "downtriangle", "lefttriangle", "righttriangle", "triangle", "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", "withcircularshade", "withlinearshade", "defineshade", "shaded", "shadedinto", "withshadecolors", "withshadedomain", "withshademethod", "withshadefactor", "withshadevector", "withshadecenter", "cmyk", "spotcolor", "multitonecolor", "namedcolor", "drawfill", "undrawfill", "inverted", "uncolored", "softened", "grayed", "greyed", "onlayer", "along", "graphictext", "loadfigure", "externalfigure", "figure", "register", "withmask", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", "textext", "thetextext", "rawtextext", "textextoffset", "verbatim", "thelabel", "label", "autoalign", "transparent", "withtransparency", "property", "properties", "withproperties", "asgroup", "infont", "space", "crlf", "dquote", "percent", "SPACE", "CRLF", "DQUOTE", "PERCENT", "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "readfile", "clearxy", "unitvector", "center", "epsed", "anchored", "originpath", "infinite", "break", "xstretched", "ystretched", "snapped", "pathconnectors", "function", "constructedfunction", "constructedpath", "constructedpairs", "straightfunction", "straightpath", "straightpairs", "curvedfunction", "curvedpath", "curvedpairs", "evenly", "oddly", "condition", "pushcurrentpicture", "popcurrentpicture", "arrowpath", "tensecircle", "roundedsquare", "colortype", "whitecolor", "blackcolor", "basiccolors", "normalfill", "normaldraw", "visualizepaths", "naturalizepaths", "drawboundary", "drawwholepath", "visualizeddraw", "visualizedfill", "draworigin", "drawboundingbox", "drawpath", "drawpoint", "drawpoints", "drawcontrolpoints", "drawcontrollines", "drawpointlabels", "drawlineoptions", "drawpointoptions", "drawcontroloptions", "drawlabeloptions", "draworiginoptions", "drawboundoptions", "drawpathoptions", "resetdrawoptions", "undashed", "decorated", "redecorated", "undecorated", "passvariable", "passarrayvariable", "tostring", "format", "formatted", "startpassingvariable", "stoppassingvariable", "eofill", "eoclip", "area" }, + ["commands"]={ "transparency", "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "invtan", "acosh", "asinh", "sinh", "cosh", "zmod", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", "llcircle", "lrcircle", "urcircle", "ulcircle", "tcircle", "bcircle", "lcircle", "rcircle", "lltriangle", "lrtriangle", "urtriangle", "ultriangle", "uptriangle", "downtriangle", "lefttriangle", "righttriangle", "triangle", "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", "withcircularshade", "withlinearshade", "defineshade", "shaded", "shadedinto", "withshadecolors", "withshadedomain", "withshademethod", "withshadefactor", "withshadevector", "withshadecenter", "cmyk", "spotcolor", "multitonecolor", "namedcolor", "drawfill", "undrawfill", "inverted", "uncolored", "softened", "grayed", "greyed", "onlayer", "along", "graphictext", "loadfigure", "externalfigure", "figure", "register", "withmask", "bitmapimage", "colordecimals", "ddecimal", "dddecimal", "ddddecimal", "textext", "thetextext", "rawtextext", "textextoffset", "verbatim", "thelabel", "label", "autoalign", "transparent", "withtransparency", "property", "properties", "withproperties", "asgroup", "infont", "space", "crlf", "dquote", "percent", "SPACE", "CRLF", "DQUOTE", "PERCENT", "grayscale", "greyscale", "withgray", "withgrey", "colorpart", "readfile", "clearxy", "unitvector", "center", "epsed", "anchored", "originpath", "infinite", "break", "xstretched", "ystretched", "snapped", "pathconnectors", "function", "constructedfunction", "constructedpath", "constructedpairs", "straightfunction", "straightpath", "straightpairs", "curvedfunction", "curvedpath", "curvedpairs", "evenly", "oddly", "condition", "pushcurrentpicture", "popcurrentpicture", "arrowpath", "tensecircle", "roundedsquare", "colortype", "whitecolor", "blackcolor", "basiccolors", "normalfill", "normaldraw", "visualizepaths", "naturalizepaths", "drawboundary", "drawwholepath", "visualizeddraw", "visualizedfill", "draworigin", "drawboundingbox", "drawpath", "drawpoint", "drawpoints", "drawcontrolpoints", "drawcontrollines", "drawpointlabels", "drawlineoptions", "drawpointoptions", "drawcontroloptions", "drawlabeloptions", "draworiginoptions", "drawboundoptions", "drawpathoptions", "resetdrawoptions", "undashed", "decorated", "redecorated", "undecorated", "passvariable", "passarrayvariable", "tostring", "format", "formatted", "startpassingvariable", "stoppassingvariable", "eofill", "eoclip", "area" }, ["internals"]={ "nocolormodel", "greycolormodel", "graycolormodel", "rgbcolormodel", "cmykcolormodel", "shadefactor", "textextoffset", "normaltransparent", "multiplytransparent", "screentransparent", "overlaytransparent", "softlighttransparent", "hardlighttransparent", "colordodgetransparent", "colorburntransparent", "darkentransparent", "lightentransparent", "differencetransparent", "exclusiontransparent", "huetransparent", "saturationtransparent", "colortransparent", "luminositytransparent", "metapostversion", "maxdimensions" }, } \ No newline at end of file diff --git a/context/data/scite/context/scite-context-data-context.properties b/context/data/scite/context/scite-context-data-context.properties index ab2d9f2cd..584f5d7e0 100644 --- a/context/data/scite/context/scite-context-data-context.properties +++ b/context/data/scite/context/scite-context-data-context.properties @@ -79,122 +79,123 @@ resetsystemmode pushsystemmode popsystemmode booleanmodevalue newcount \ newdimen newskip newmuskip newbox newtoks \ newread newwrite newmarks newinsert newattribute \ newif newlanguage newfamily newfam newhelp \ -then begcsname strippedcsname firstargumentfalse firstargumenttrue \ -secondargumentfalse secondargumenttrue thirdargumentfalse thirdargumenttrue fourthargumentfalse \ -fourthargumenttrue fifthargumentfalse fifthsargumenttrue sixthargumentfalse sixtsargumenttrue \ -doglobal dodoglobal redoglobal resetglobal donothing \ -dontcomplain forgetall donetrue donefalse inlineordisplaymath \ -indisplaymath forcedisplaymath startforceddisplaymath stopforceddisplaymath reqno \ -htdp unvoidbox hfilll vfilll mathbox \ -mathlimop mathnolop mathnothing mathalpha currentcatcodetable \ -defaultcatcodetable catcodetablename newcatcodetable startcatcodetable stopcatcodetable \ -startextendcatcodetable stopextendcatcodetable pushcatcodetable popcatcodetable restorecatcodes \ -setcatcodetable letcatcodecommand defcatcodecommand uedcatcodecommand hglue \ -vglue hfillneg vfillneg hfilllneg vfilllneg \ -ruledhss ruledhfil ruledhfill ruledhfilneg ruledhfillneg \ -normalhfillneg ruledvss ruledvfil ruledvfill ruledvfilneg \ -ruledvfillneg normalvfillneg ruledhbox ruledvbox ruledvtop \ -ruledvcenter ruledmbox ruledhskip ruledvskip ruledkern \ -ruledmskip ruledmkern ruledhglue ruledvglue normalhglue \ -normalvglue ruledpenalty filledhboxb filledhboxr filledhboxg \ -filledhboxc filledhboxm filledhboxy filledhboxk scratchcounter \ -globalscratchcounter scratchdimen globalscratchdimen scratchskip globalscratchskip \ -scratchmuskip globalscratchmuskip scratchtoks globalscratchtoks scratchbox \ -globalscratchbox normalbaselineskip normallineskip normallineskiplimit availablehsize \ -localhsize setlocalhsize distributedhsize hsizefraction nextbox \ -dowithnextbox dowithnextboxcs dowithnextboxcontent dowithnextboxcontentcs scratchwidth \ -scratchheight scratchdepth scratchoffset scratchdistance scratchhsize \ -scratchvsize scratchxoffset scratchyoffset scratchhoffset scratchvoffset \ -scratchxposition scratchyposition scratchtopoffset scratchbottomoffset scratchleftoffset \ -scratchrightoffset scratchcounterone scratchcountertwo scratchcounterthree scratchdimenone \ -scratchdimentwo scratchdimenthree scratchskipone scratchskiptwo scratchskipthree \ -scratchmuskipone scratchmuskiptwo scratchmuskipthree scratchtoksone scratchtokstwo \ -scratchtoksthree scratchboxone scratchboxtwo scratchboxthree scratchnx \ -scratchny scratchmx scratchmy scratchunicode scratchleftskip \ -scratchrightskip scratchtopskip scratchbottomskip doif doifnot \ -doifelse doifinset doifnotinset doifinsetelse doifnextcharelse \ -doifnextoptionalelse doifnextoptionalcselse doiffastoptionalcheckelse doifnextbgroupelse doifnextbgroupcselse \ -doifnextparenthesiselse doifundefinedelse doifdefinedelse doifundefined doifdefined \ -doifelsevalue doifvalue doifnotvalue doifnothing doifsomething \ -doifelsenothing doifsomethingelse doifvaluenothing doifvaluesomething doifelsevaluenothing \ -doifdimensionelse doifnumberelse doifnumber doifnotnumber doifcommonelse \ -doifcommon doifnotcommon doifinstring doifnotinstring doifinstringelse \ -doifassignmentelse docheckassignment tracingall tracingnone loggingall \ -removetoks appendtoks prependtoks appendtotoks prependtotoks \ -to endgraf endpar everyendpar reseteverypar \ -finishpar empty null space quad \ -enspace nbsp obeyspaces obeylines obeyedspace \ -obeyedline obeyedtab obeyedpage normalspace executeifdefined \ -singleexpandafter doubleexpandafter tripleexpandafter dontleavehmode removelastspace \ -removeunwantedspaces keepunwantedspaces wait writestatus define \ -defineexpandable redefine setmeasure setemeasure setgmeasure \ -setxmeasure definemeasure freezemeasure measure measured \ -installcorenamespace getvalue getuvalue setvalue setevalue \ -setgvalue setxvalue letvalue letgvalue resetvalue \ -undefinevalue ignorevalue setuvalue setuevalue setugvalue \ -setuxvalue globallet glet udef ugdef \ -uedef uxdef checked unique getparameters \ -geteparameters getgparameters getxparameters forgetparameters copyparameters \ -getdummyparameters dummyparameter directdummyparameter setdummyparameter letdummyparameter \ -usedummystyleandcolor usedummystyleparameter usedummycolorparameter processcommalist processcommacommand \ -quitcommalist quitprevcommalist processaction processallactions processfirstactioninset \ -processallactionsinset unexpanded expanded startexpanded stopexpanded \ -protected protect unprotect firstofoneargument firstoftwoarguments \ -secondoftwoarguments firstofthreearguments secondofthreearguments thirdofthreearguments firstoffourarguments \ -secondoffourarguments thirdoffourarguments fourthoffourarguments firstoffivearguments secondoffivearguments \ -thirdoffivearguments fourthoffivearguments fifthoffivearguments firstofsixarguments secondofsixarguments \ -thirdofsixarguments fourthofsixarguments fifthofsixarguments sixthofsixarguments firstofoneunexpanded \ -firstoftwounexpanded secondoftwounexpanded firstofthreeunexpanded secondofthreeunexpanded thirdofthreeunexpanded \ -gobbleoneargument gobbletwoarguments gobblethreearguments gobblefourarguments gobblefivearguments \ -gobblesixarguments gobblesevenarguments gobbleeightarguments gobbleninearguments gobbletenarguments \ -gobbleoneoptional gobbletwooptionals gobblethreeoptionals gobblefouroptionals gobblefiveoptionals \ -dorecurse doloop exitloop dostepwiserecurse recurselevel \ -recursedepth dofastloopcs dowith newconstant setnewconstant \ -setconstant setconstantvalue newconditional settrue setfalse \ -settruevalue setfalsevalue newmacro setnewmacro newfraction \ -newsignal dosingleempty dodoubleempty dotripleempty doquadrupleempty \ -doquintupleempty dosixtupleempty doseventupleempty dosingleargument dodoubleargument \ -dotripleargument doquadrupleargument doquintupleargument dosixtupleargument doseventupleargument \ -dosinglegroupempty dodoublegroupempty dotriplegroupempty doquadruplegroupempty doquintuplegroupempty \ -permitspacesbetweengroups dontpermitspacesbetweengroups nopdfcompression maximumpdfcompression normalpdfcompression \ -modulonumber dividenumber getfirstcharacter doiffirstcharelse startnointerference \ -stopnointerference twodigits threedigits leftorright offinterlineskip \ -oninterlineskip nointerlineskip strut halfstrut quarterstrut \ -depthstrut setstrut strutbox strutht strutdp \ -strutwd struthtdp begstrut endstrut lineheight \ -ordordspacing ordopspacing ordbinspacing ordrelspacing ordopenspacing \ -ordclosespacing ordpunctspacing ordinnerspacing opordspacing opopspacing \ -opbinspacing oprelspacing opopenspacing opclosespacing oppunctspacing \ -opinnerspacing binordspacing binopspacing binbinspacing binrelspacing \ -binopenspacing binclosespacing binpunctspacing bininnerspacing relordspacing \ -relopspacing relbinspacing relrelspacing relopenspacing relclosespacing \ -relpunctspacing relinnerspacing openordspacing openopspacing openbinspacing \ -openrelspacing openopenspacing openclosespacing openpunctspacing openinnerspacing \ -closeordspacing closeopspacing closebinspacing closerelspacing closeopenspacing \ -closeclosespacing closepunctspacing closeinnerspacing punctordspacing punctopspacing \ -punctbinspacing punctrelspacing punctopenspacing punctclosespacing punctpunctspacing \ -punctinnerspacing innerordspacing inneropspacing innerbinspacing innerrelspacing \ -inneropenspacing innerclosespacing innerpunctspacing innerinnerspacing normalreqno \ -startimath stopimath normalstartimath normalstopimath startdmath \ -stopdmath normalstartdmath normalstopdmath uncramped cramped \ -triggermathstyle mathstylefont mathsmallstylefont mathstyleface mathsmallstyleface \ -mathstylecommand mathpalette mathstylehbox mathstylevbox mathstylevcenter \ -mathstylevcenteredhbox mathstylevcenteredvbox mathtext setmathsmalltextbox setmathtextbox \ -pushmathstyle popmathstyle triggerdisplaystyle triggertextstyle triggerscriptstyle \ -triggerscriptscriptstyle triggeruncrampedstyle triggercrampedstyle triggersmallstyle triggeruncrampedsmallstyle \ -triggercrampedsmallstyle triggerbigstyle triggeruncrampedbigstyle triggercrampedbigstyle luaexpr \ -expdoifelse expdoif expdoifnot expdoifcommonelse expdoifinsetelse \ -ctxdirectlua ctxlatelua ctxsprint ctxwrite ctxcommand \ -ctxdirectcommand ctxlatecommand ctxreport ctxlua luacode \ -lateluacode directluacode registerctxluafile ctxloadluafile luaversion \ -luamajorversion luaminorversion ctxluacode luaconditional luaexpanded \ -startluaparameterset stopluaparameterset luaparameterset definenamedlua obeylualines \ -obeyluatokens startluacode stopluacode startlua stoplua \ -startctxfunction stopctxfunction ctxfunction startctxfunctiondefinition stopctxfunctiondefinition \ -carryoverpar assumelongusagecs Umathbotaccent righttolefthbox lefttorighthbox \ -righttoleftvbox lefttorightvbox righttoleftvtop lefttorightvtop rtlhbox \ -ltrhbox rtlvbox ltrvbox rtlvtop ltrvtop \ -autodirhbox autodirvbox autodirvtop lefttoright righttoleft \ -synchronizelayoutdirection synchronizedisplaydirection synchronizeinlinedirection lesshyphens morehyphens \ -nohyphens dohyphens Ucheckedstartdisplaymath Ucheckedstopdisplaymath +then begcsname strippedcsname checkedstrippedcsname firstargumentfalse \ +firstargumenttrue secondargumentfalse secondargumenttrue thirdargumentfalse thirdargumenttrue \ +fourthargumentfalse fourthargumenttrue fifthargumentfalse fifthsargumenttrue sixthargumentfalse \ +sixtsargumenttrue doglobal dodoglobal redoglobal resetglobal \ +donothing dontcomplain forgetall donetrue donefalse \ +inlineordisplaymath indisplaymath forcedisplaymath startforceddisplaymath stopforceddisplaymath \ +reqno htdp unvoidbox hfilll vfilll \ +mathbox mathlimop mathnolop mathnothing mathalpha \ +currentcatcodetable defaultcatcodetable catcodetablename newcatcodetable startcatcodetable \ +stopcatcodetable startextendcatcodetable stopextendcatcodetable pushcatcodetable popcatcodetable \ +restorecatcodes setcatcodetable letcatcodecommand defcatcodecommand uedcatcodecommand \ +hglue vglue hfillneg vfillneg hfilllneg \ +vfilllneg ruledhss ruledhfil ruledhfill ruledhfilneg \ +ruledhfillneg normalhfillneg ruledvss ruledvfil ruledvfill \ +ruledvfilneg ruledvfillneg normalvfillneg ruledhbox ruledvbox \ +ruledvtop ruledvcenter ruledmbox ruledhskip ruledvskip \ +ruledkern ruledmskip ruledmkern ruledhglue ruledvglue \ +normalhglue normalvglue ruledpenalty filledhboxb filledhboxr \ +filledhboxg filledhboxc filledhboxm filledhboxy filledhboxk \ +scratchcounter globalscratchcounter scratchdimen globalscratchdimen scratchskip \ +globalscratchskip scratchmuskip globalscratchmuskip scratchtoks globalscratchtoks \ +scratchbox globalscratchbox normalbaselineskip normallineskip normallineskiplimit \ +availablehsize localhsize setlocalhsize distributedhsize hsizefraction \ +nextbox dowithnextbox dowithnextboxcs dowithnextboxcontent dowithnextboxcontentcs \ +scratchwidth scratchheight scratchdepth scratchoffset scratchdistance \ +scratchhsize scratchvsize scratchxoffset scratchyoffset scratchhoffset \ +scratchvoffset scratchxposition scratchyposition scratchtopoffset scratchbottomoffset \ +scratchleftoffset scratchrightoffset scratchcounterone scratchcountertwo scratchcounterthree \ +scratchdimenone scratchdimentwo scratchdimenthree scratchskipone scratchskiptwo \ +scratchskipthree scratchmuskipone scratchmuskiptwo scratchmuskipthree scratchtoksone \ +scratchtokstwo scratchtoksthree scratchboxone scratchboxtwo scratchboxthree \ +scratchnx scratchny scratchmx scratchmy scratchunicode \ +scratchleftskip scratchrightskip scratchtopskip scratchbottomskip doif \ +doifnot doifelse doifinset doifnotinset doifinsetelse \ +doifnextcharelse doifnextoptionalelse doifnextoptionalcselse doiffastoptionalcheckelse doifnextbgroupelse \ +doifnextbgroupcselse doifnextparenthesiselse doifundefinedelse doifdefinedelse doifundefined \ +doifdefined doifelsevalue doifvalue doifnotvalue doifnothing \ +doifsomething doifelsenothing doifsomethingelse doifvaluenothing doifvaluesomething \ +doifelsevaluenothing doifdimensionelse doifnumberelse doifnumber doifnotnumber \ +doifcommonelse doifcommon doifnotcommon doifinstring doifnotinstring \ +doifinstringelse doifassignmentelse docheckassignment tracingall tracingnone \ +loggingall removetoks appendtoks prependtoks appendtotoks \ +prependtotoks to endgraf endpar everyendpar \ +reseteverypar finishpar empty null space \ +quad enspace nbsp obeyspaces obeylines \ +obeyedspace obeyedline obeyedtab obeyedpage normalspace \ +executeifdefined singleexpandafter doubleexpandafter tripleexpandafter dontleavehmode \ +removelastspace removeunwantedspaces keepunwantedspaces wait writestatus \ +define defineexpandable redefine setmeasure setemeasure \ +setgmeasure setxmeasure definemeasure freezemeasure measure \ +measured installcorenamespace getvalue getuvalue setvalue \ +setevalue setgvalue setxvalue letvalue letgvalue \ +resetvalue undefinevalue ignorevalue setuvalue setuevalue \ +setugvalue setuxvalue globallet glet udef \ +ugdef uedef uxdef checked unique \ +getparameters geteparameters getgparameters getxparameters forgetparameters \ +copyparameters getdummyparameters dummyparameter directdummyparameter setdummyparameter \ +letdummyparameter usedummystyleandcolor usedummystyleparameter usedummycolorparameter processcommalist \ +processcommacommand quitcommalist quitprevcommalist processaction processallactions \ +processfirstactioninset processallactionsinset unexpanded expanded startexpanded \ +stopexpanded protected protect unprotect firstofoneargument \ +firstoftwoarguments secondoftwoarguments firstofthreearguments secondofthreearguments thirdofthreearguments \ +firstoffourarguments secondoffourarguments thirdoffourarguments fourthoffourarguments firstoffivearguments \ +secondoffivearguments thirdoffivearguments fourthoffivearguments fifthoffivearguments firstofsixarguments \ +secondofsixarguments thirdofsixarguments fourthofsixarguments fifthofsixarguments sixthofsixarguments \ +firstofoneunexpanded firstoftwounexpanded secondoftwounexpanded firstofthreeunexpanded secondofthreeunexpanded \ +thirdofthreeunexpanded gobbleoneargument gobbletwoarguments gobblethreearguments gobblefourarguments \ +gobblefivearguments gobblesixarguments gobblesevenarguments gobbleeightarguments gobbleninearguments \ +gobbletenarguments gobbleoneoptional gobbletwooptionals gobblethreeoptionals gobblefouroptionals \ +gobblefiveoptionals dorecurse doloop exitloop dostepwiserecurse \ +recurselevel recursedepth dofastloopcs dowith newconstant \ +setnewconstant setconstant setconstantvalue newconditional settrue \ +setfalse settruevalue setfalsevalue newmacro setnewmacro \ +newfraction newsignal dosingleempty dodoubleempty dotripleempty \ +doquadrupleempty doquintupleempty dosixtupleempty doseventupleempty dosingleargument \ +dodoubleargument dotripleargument doquadrupleargument doquintupleargument dosixtupleargument \ +doseventupleargument dosinglegroupempty dodoublegroupempty dotriplegroupempty doquadruplegroupempty \ +doquintuplegroupempty permitspacesbetweengroups dontpermitspacesbetweengroups nopdfcompression maximumpdfcompression \ +normalpdfcompression modulonumber dividenumber getfirstcharacter doiffirstcharelse \ +startnointerference stopnointerference twodigits threedigits leftorright \ +offinterlineskip oninterlineskip nointerlineskip strut halfstrut \ +quarterstrut depthstrut setstrut strutbox strutht \ +strutdp strutwd struthtdp begstrut endstrut \ +lineheight ordordspacing ordopspacing ordbinspacing ordrelspacing \ +ordopenspacing ordclosespacing ordpunctspacing ordinnerspacing opordspacing \ +opopspacing opbinspacing oprelspacing opopenspacing opclosespacing \ +oppunctspacing opinnerspacing binordspacing binopspacing binbinspacing \ +binrelspacing binopenspacing binclosespacing binpunctspacing bininnerspacing \ +relordspacing relopspacing relbinspacing relrelspacing relopenspacing \ +relclosespacing relpunctspacing relinnerspacing openordspacing openopspacing \ +openbinspacing openrelspacing openopenspacing openclosespacing openpunctspacing \ +openinnerspacing closeordspacing closeopspacing closebinspacing closerelspacing \ +closeopenspacing closeclosespacing closepunctspacing closeinnerspacing punctordspacing \ +punctopspacing punctbinspacing punctrelspacing punctopenspacing punctclosespacing \ +punctpunctspacing punctinnerspacing innerordspacing inneropspacing innerbinspacing \ +innerrelspacing inneropenspacing innerclosespacing innerpunctspacing innerinnerspacing \ +normalreqno startimath stopimath normalstartimath normalstopimath \ +startdmath stopdmath normalstartdmath normalstopdmath uncramped \ +cramped triggermathstyle mathstylefont mathsmallstylefont mathstyleface \ +mathsmallstyleface mathstylecommand mathpalette mathstylehbox mathstylevbox \ +mathstylevcenter mathstylevcenteredhbox mathstylevcenteredvbox mathtext setmathsmalltextbox \ +setmathtextbox pushmathstyle popmathstyle triggerdisplaystyle triggertextstyle \ +triggerscriptstyle triggerscriptscriptstyle triggeruncrampedstyle triggercrampedstyle triggersmallstyle \ +triggeruncrampedsmallstyle triggercrampedsmallstyle triggerbigstyle triggeruncrampedbigstyle triggercrampedbigstyle \ +luaexpr expdoifelse expdoif expdoifnot expdoifcommonelse \ +expdoifinsetelse ctxdirectlua ctxlatelua ctxsprint ctxwrite \ +ctxcommand ctxdirectcommand ctxlatecommand ctxreport ctxlua \ +luacode lateluacode directluacode registerctxluafile ctxloadluafile \ +luaversion luamajorversion luaminorversion ctxluacode luaconditional \ +luaexpanded startluaparameterset stopluaparameterset luaparameterset definenamedlua \ +obeylualines obeyluatokens startluacode stopluacode startlua \ +stoplua startctxfunction stopctxfunction ctxfunction startctxfunctiondefinition \ +stopctxfunctiondefinition installctxfunction carryoverpar assumelongusagecs Umathbotaccent \ +righttolefthbox lefttorighthbox righttoleftvbox lefttorightvbox righttoleftvtop \ +lefttorightvtop rtlhbox ltrhbox rtlvbox ltrvbox \ +rtlvtop ltrvtop autodirhbox autodirvbox autodirvtop \ +lefttoright righttoleft synchronizelayoutdirection synchronizedisplaydirection synchronizeinlinedirection \ +lesshyphens morehyphens nohyphens dohyphens Ucheckedstartdisplaymath \ +Ucheckedstopdisplaymath diff --git a/context/data/scite/context/scite-context-data-metafun.properties b/context/data/scite/context/scite-context-data-metafun.properties index 4e82474f8..977ca9dfd 100644 --- a/context/data/scite/context/scite-context-data-metafun.properties +++ b/context/data/scite/context/scite-context-data-metafun.properties @@ -4,50 +4,50 @@ exp inv pow pi radian \ tand cotd sin cos tan \ cot atan asin acos invsin \ invcos invtan acosh asinh sinh \ -cosh paired tripled unitcircle fulldiamond \ -unitdiamond fullsquare llcircle lrcircle urcircle \ -ulcircle tcircle bcircle lcircle rcircle \ -lltriangle lrtriangle urtriangle ultriangle uptriangle \ -downtriangle lefttriangle righttriangle triangle 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 \ -withcircularshade withlinearshade defineshade shaded shadedinto \ -withshadecolors withshadedomain withshademethod withshadefactor withshadevector \ -withshadecenter cmyk spotcolor multitonecolor namedcolor \ -drawfill undrawfill inverted uncolored softened \ -grayed greyed onlayer along graphictext \ -loadfigure externalfigure figure register withmask \ -bitmapimage colordecimals ddecimal dddecimal ddddecimal \ -textext thetextext rawtextext textextoffset verbatim \ -thelabel label autoalign transparent withtransparency \ -property properties withproperties asgroup infont \ -space crlf dquote percent SPACE \ -CRLF DQUOTE PERCENT grayscale greyscale \ -withgray withgrey colorpart readfile clearxy \ -unitvector center epsed anchored originpath \ -infinite break xstretched ystretched snapped \ -pathconnectors function constructedfunction constructedpath constructedpairs \ -straightfunction straightpath straightpairs curvedfunction curvedpath \ -curvedpairs evenly oddly condition pushcurrentpicture \ -popcurrentpicture arrowpath tensecircle roundedsquare colortype \ -whitecolor blackcolor basiccolors normalfill normaldraw \ -visualizepaths naturalizepaths drawboundary drawwholepath visualizeddraw \ -visualizedfill draworigin drawboundingbox drawpath drawpoint \ -drawpoints drawcontrolpoints drawcontrollines drawpointlabels drawlineoptions \ -drawpointoptions drawcontroloptions drawlabeloptions draworiginoptions drawboundoptions \ -drawpathoptions resetdrawoptions undashed decorated redecorated \ -undecorated passvariable passarrayvariable tostring format \ -formatted startpassingvariable stoppassingvariable eofill eoclip \ -area +cosh zmod paired tripled unitcircle \ +fulldiamond unitdiamond fullsquare llcircle lrcircle \ +urcircle ulcircle tcircle bcircle lcircle \ +rcircle lltriangle lrtriangle urtriangle ultriangle \ +uptriangle downtriangle lefttriangle righttriangle triangle \ +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 withcircularshade withlinearshade defineshade shaded \ +shadedinto withshadecolors withshadedomain withshademethod withshadefactor \ +withshadevector withshadecenter cmyk spotcolor multitonecolor \ +namedcolor drawfill undrawfill inverted uncolored \ +softened grayed greyed onlayer along \ +graphictext loadfigure externalfigure figure register \ +withmask bitmapimage colordecimals ddecimal dddecimal \ +ddddecimal textext thetextext rawtextext textextoffset \ +verbatim thelabel label autoalign transparent \ +withtransparency property properties withproperties asgroup \ +infont space crlf dquote percent \ +SPACE CRLF DQUOTE PERCENT grayscale \ +greyscale withgray withgrey colorpart readfile \ +clearxy unitvector center epsed anchored \ +originpath infinite break xstretched ystretched \ +snapped pathconnectors function constructedfunction constructedpath \ +constructedpairs straightfunction straightpath straightpairs curvedfunction \ +curvedpath curvedpairs evenly oddly condition \ +pushcurrentpicture popcurrentpicture arrowpath tensecircle roundedsquare \ +colortype whitecolor blackcolor basiccolors normalfill \ +normaldraw visualizepaths naturalizepaths drawboundary drawwholepath \ +visualizeddraw visualizedfill draworigin drawboundingbox drawpath \ +drawpoint drawpoints drawcontrolpoints drawcontrollines drawpointlabels \ +drawlineoptions drawpointoptions drawcontroloptions drawlabeloptions draworiginoptions \ +drawboundoptions drawpathoptions resetdrawoptions undashed decorated \ +redecorated undecorated passvariable passarrayvariable tostring \ +format formatted startpassingvariable stoppassingvariable eofill \ +eoclip area keywordclass.metafun.internals=\ nocolormodel greycolormodel graycolormodel rgbcolormodel \ diff --git a/doc/context/documents/general/manuals/workflows-mkiv.pdf b/doc/context/documents/general/manuals/workflows-mkiv.pdf index 8d9ee5cd6..7cdd669cc 100644 Binary files a/doc/context/documents/general/manuals/workflows-mkiv.pdf and b/doc/context/documents/general/manuals/workflows-mkiv.pdf differ diff --git a/doc/context/scripts/mkiv/mtx-bibtex.html b/doc/context/scripts/mkiv/mtx-bibtex.html new file mode 100644 index 000000000..61a679716 --- /dev/null +++ b/doc/context/scripts/mkiv/mtx-bibtex.html @@ -0,0 +1,55 @@ + + + + + + + + + + + bibtex helpers + + + + + +
+
bibtex helpers
+
+
+
+
wiki: http://contextgarden.net | mail: ntg-context@ntg.nl | website: http://www.pragma-ade.nl
+
+
+
+ +
+
+

Command line options

+ + + + + + +
flagvaluedescription
--toxmlconvert bibtex database(s) to xml
--toluaconvert bibtex database(s) to lua
--searchseatch bibtex database(s)
+
+

Example

+mtxrun --script bibtex --tolua bibl-001.bib +
mtxrun --script bibtex --tolua --simple bibl-001.bib +
mtxrun --script bibtex --toxml bibl-001.bib bibl-002.bib bibl-003.bib biblio.xml +
mtxrun --script bibtex --search --list --pattern=match(author:foo) bar.bib +

+
+ + diff --git a/doc/context/scripts/mkiv/mtx-bibtex.man b/doc/context/scripts/mkiv/mtx-bibtex.man new file mode 100644 index 000000000..ddd3cfbc5 --- /dev/null +++ b/doc/context/scripts/mkiv/mtx-bibtex.man @@ -0,0 +1,33 @@ +.TH "mtx-bibtex" "1" "01-01-2015" "version 1.00" "bibtex helpers" +.SH NAME +.B mtx-bibtex +.SH SYNOPSIS +.B mtxrun --script bibtex [ +.I OPTIONS ... +.B ] [ +.I FILENAMES +.B ] +.SH DESCRIPTION +.B bibtex helpers +.SH OPTIONS +.TP +.B --toxml +convert bibtex database(s) to xml +.TP +.B --tolua +convert bibtex database(s) to lua +.TP +.B --search +seatch bibtex database(s) +.SH AUTHOR +More information about ConTeXt and the tools that come with it can be found at: + + +.B "maillist:" +ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context + +.B "webpage:" +http://www.pragma-ade.nl / http://tex.aanhet.net + +.B "wiki:" +http://contextgarden.net diff --git a/doc/context/scripts/mkiv/mtx-bibtex.xml b/doc/context/scripts/mkiv/mtx-bibtex.xml new file mode 100644 index 000000000..5c28b946a --- /dev/null +++ b/doc/context/scripts/mkiv/mtx-bibtex.xml @@ -0,0 +1,28 @@ + + + + mtx-bibtex + bibtex helpers + 1.00 + + + + + convert bibtex database(s) to xml + convert bibtex database(s) to lua + seatch bibtex database(s) + + + + + + Example + + mtxrun --script bibtex --tolua bibl-001.bib + mtxrun --script bibtex --tolua --simple bibl-001.bib + mtxrun --script bibtex --toxml bibl-001.bib bibl-002.bib bibl-003.bib biblio.xml + mtxrun --script bibtex --search --list --pattern=match(author:foo) bar.bib + + + + diff --git a/doc/context/sources/general/manuals/workflows/workflows-mkiv.tex b/doc/context/sources/general/manuals/workflows/workflows-mkiv.tex index 3070a5be6..919b5cc74 100644 --- a/doc/context/sources/general/manuals/workflows/workflows-mkiv.tex +++ b/doc/context/sources/general/manuals/workflows/workflows-mkiv.tex @@ -24,6 +24,7 @@ \component workflows-suspects \component workflows-injectors \component workflows-xml + \component workflows-setups \stopbodymatter \stopdocument diff --git a/doc/context/sources/general/manuals/workflows/workflows-setups.tex b/doc/context/sources/general/manuals/workflows/workflows-setups.tex new file mode 100644 index 000000000..e9d120f7b --- /dev/null +++ b/doc/context/sources/general/manuals/workflows/workflows-setups.tex @@ -0,0 +1,72 @@ +% language=uk + +\environment workflows-style + +\startcomponent workflows-setups + +\startchapter[title={Setups}] + +Setups are a powerful way to organize styles. They are basically macros but live +in their own namespace. One advantage is that spaces in a setup are ignored so +you can code without bothering about spurious spaces. Here is a trick that you +can use when one style contains directives for multiple products: + +\startbuffer +\startsetups tex:whatever + \fastsetup{tex:whatever:\documentvariable{stylevariant}} +\stopsetups + +\startsetups tex:whatever:foo + FOO +\stopsetups + +\startsetups tex:whatever:bar + BAR +\stopsetups +\stopbuffer + +\typebuffer \getbuffer + +Here we define a main setup \type {tex:whatever} that gets expanded in one of two +variants, controlled by a document variable. + +\startbuffer +\setups{tex:whatever} + +\setupdocument + [stylevariant=foo] + +\setups{tex:whatever} + +\setupdocument + [stylevariant=bar] + +\setups{tex:whatever} +\stopbuffer + +\typebuffer + +These lines result in: + +\getbuffer + +In a similar fashion you can define \XML\ setups that are used to render +elements: + +\starttyping +\startxmlsetups xml:whatever + \xmlsetup{#1}{xml:whatever:\documentvariable{stylevariant}} +\stopxmlsetups + +\startxmlsetups xml:whatever:foo + FOO: \xmlflush{#1} +\stopxmlsetups + +\startxmlsetups xml:whatever:bar + BAR: \xmlflush{#1} +\stopxmlsetups +\stoptyping + +\stopchapter + +\stopcomponent diff --git a/doc/context/sources/general/manuals/workflows/workflows-style.tex b/doc/context/sources/general/manuals/workflows/workflows-style.tex index ed64da6b2..9d46aaad8 100644 --- a/doc/context/sources/general/manuals/workflows/workflows-style.tex +++ b/doc/context/sources/general/manuals/workflows/workflows-style.tex @@ -35,7 +35,6 @@ \setuptype [color=maincolor] - \setupdocument [metadata:author=, metadata:title=, diff --git a/metapost/context/base/mp-chem.mpiv b/metapost/context/base/mp-chem.mpiv index a316a1a30..7ca40bbea 100644 --- a/metapost/context/base/mp-chem.mpiv +++ b/metapost/context/base/mp-chem.mpiv @@ -11,7 +11,8 @@ %C therefore copyrighted by \PRAGMA. See licen-en.pdf for %C details. -%D This module is incomplete and experimental. +%D This module is incomplete and experimental. Okay, it's not that bad but we do need +%D some disclaimer. % either consistent setting or not @@ -300,7 +301,6 @@ enddef ; chem_init_all ; % WHY does this not work unless defined and then called? - % Like most often in ConTeXt, we will trap but then silently ignore mistaken use, % unless of course the error be too harmful... @@ -529,6 +529,17 @@ vardef chem_set (suffix $) = % This is a fairly complicated optimization and ajustement. It took some % thinking to get right, so beware! + % And then even more time fixing a bug of a rotation +- half the symmetry + % angle of a structure depending on the scale and/or the font size + % (through chem_b_length). + + % first save the symmetry angle of the structure (as in chem_rot): + chem_num0 := if chem_stacked[$] : 3 else : 0 fi ; + chem_num9 := if chem_tetra[$] : 360 else : + abs(angle(point 0+chem_num0 of chem_b_path[$]) - + angle(point 1+chem_num0 of chem_b_path[$])) + fi ; + if (chem_adjacent<>0) and chem_star[P] and chem_star[$] : % nop chem_adjacent := 0 ; @@ -581,7 +592,8 @@ vardef chem_set (suffix $) = -((point (chem_adjacent-1) of chem_b_path[P]) chem_transformed(P)) ; fi % adjust the bond angles - chem_rotation := (chem_rotation + angle(chem_pair1)-angle(chem_pair3)) mod 360 ; + chem_num4 := (angle(chem_pair1)-angle(chem_pair3)) zmod chem_num9 ; + chem_rotation := chem_rotation + chem_num4 ; if not chem_star[$] : chem_pair4 := if chem_star[P] : @@ -666,7 +678,8 @@ vardef chem_set (suffix $) = fi endfor if not chem_front[$] : % adjust rotation - chem_rotation := (chem_rotation + angle(chem_pair1)-angle(chem_pair3)) mod 360 ; + chem_num4 := angle(chem_pair1)-angle(chem_pair3) ; + chem_rotation := (chem_rotation + chem_num4) mod 360 ; fi ; chem_t := identity chem_transformed($) ; chem_pair4 := (point chem_num3 of chem_b_path[$]) transformed chem_t ; @@ -674,6 +687,9 @@ vardef chem_set (suffix $) = currentpicture := currentpicture shifted chem_pair4 ; chem_origin := chem_origin shifted chem_pair4 ; fi + if not chem_front[$] : % adjust rotation + chem_rotation := chem_rotation zmod chem_num9 ; + fi fi chem_substituent := 0 ; fi ; @@ -1571,9 +1587,9 @@ vardef chem_rot (suffix $) (expr d, s) = % ROT chem_rotation := 0 else : chem_num0 := if chem_stacked[$] : 3 else : 0 fi ; - chem_num1 := .5(angle(point d+chem_num0 of chem_b_path[$]) - + chem_num1 := .5(angle(point d+chem_num0 of chem_b_path[$]) - angle(point d+chem_num0-1 of chem_b_path[$])) ; - chem_rotation := (chem_rotation + s*chem_num1) mod 360 ; + chem_rotation := (chem_rotation + s*chem_num1) zmod 360 ; fi fi enddef ; @@ -1584,7 +1600,7 @@ vardef chem_mir (suffix $) (expr d, s) = % MIR if not chem_front[$] : if d=0 : % inversion if chem_mirror=origin : - chem_rotation := (chem_rotation + 180*s) mod 360 ; + chem_rotation := (chem_rotation + 180*s) zmod 360 ; else : chem_mirror := chem_mirror rotated 90 ; fi @@ -1600,7 +1616,7 @@ vardef chem_mir (suffix $) (expr d, s) = % MIR chem_num0 := -360 - chem_num0 ; fi chem_num0 := chem_num0 * s ; - chem_rotation := (chem_rotation + 2chem_num0) mod 360 ; + chem_rotation := (chem_rotation + 2chem_num0) zmod 360 ; chem_mirror := origin ; fi fi diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index 1140673ab..907c0c4b7 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -390,11 +390,11 @@ string mfun_prescript_separator ; mfun_prescript_separator := char(13) ; % Shades % for while we had this: -% -% newinternal shadefactor ; shadefactor := 1 ; -% pair shadeoffset ; shadeoffset := origin ; -% boolean trace_shades ; trace_shades := false ; -% + +newinternal shadefactor ; shadefactor := 1 ; % currently obsolete +pair shadeoffset ; shadeoffset := origin ; % currently obsolete +boolean trace_shades ; trace_shades := false ; % still there + % def withlinearshading (expr a, b) = % withprescript "sh_type=linear" % withprescript "sh_domain=0 1" @@ -523,8 +523,8 @@ def withcircularshade (expr a, b, ra, rb, ca, cb) = withprescript "sh_factor=1" withprescript "sh_color_a=" & colordecimals ca withprescript "sh_color_b=" & colordecimals cb - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) + withprescript "sh_center_a=" & ddecimal a % (a shifted shadeoffset) + withprescript "sh_center_b=" & ddecimal b % (b shifted shadeoffset) withprescript "sh_radius_a=" & decimal ra withprescript "sh_radius_b=" & decimal rb enddef ; @@ -535,8 +535,8 @@ def withlinearshade (expr a, b, ca, cb) = withprescript "sh_factor=1" withprescript "sh_color_a=" & colordecimals ca withprescript "sh_color_b=" & colordecimals cb - withprescript "sh_center_a=" & ddecimal (a shifted shadeoffset) - withprescript "sh_center_b=" & ddecimal (b shifted shadeoffset) + withprescript "sh_center_a=" & ddecimal a % (a shifted shadeoffset) + withprescript "sh_center_b=" & ddecimal b % (b shifted shadeoffset) enddef ; % replaced (obsolete): @@ -595,8 +595,8 @@ vardef define_circular_shade (expr a, b, ra, rb, ca, cb) = & mfun_prescript_separator & "sh_factor=1" & mfun_prescript_separator & "sh_color_a=" & colordecimals ca & mfun_prescript_separator & "sh_color_b=" & colordecimals cb - & mfun_prescript_separator & "sh_center_a=" & ddecimal (a shifted shadeoffset) - & mfun_prescript_separator & "sh_center_b=" & ddecimal (b shifted shadeoffset) + & mfun_prescript_separator & "sh_center_a=" & ddecimal a % (a shifted shadeoffset) + & mfun_prescript_separator & "sh_center_b=" & ddecimal b % (b shifted shadeoffset) & mfun_prescript_separator & "sh_radius_a=" & decimal ra & mfun_prescript_separator & "sh_radius_b=" & decimal rb ; @@ -610,8 +610,8 @@ vardef define_linear_shade (expr a, b, ca, cb) = & mfun_prescript_separator & "sh_factor=1" & mfun_prescript_separator & "sh_color_a=" & colordecimals ca & mfun_prescript_separator & "sh_color_b=" & colordecimals cb - & mfun_prescript_separator & "sh_center_a=" & ddecimal (a shifted shadeoffset) - & mfun_prescript_separator & "sh_center_b=" & ddecimal (b shifted shadeoffset) + & mfun_prescript_separator & "sh_center_a=" & ddecimal a % (a shifted shadeoffset) + & mfun_prescript_separator & "sh_center_b=" & ddecimal b % (b shifted shadeoffset) ; mfun_defined_cs enddef ; diff --git a/metapost/context/base/mp-tool.mpii b/metapost/context/base/mp-tool.mpii index 62bd122f5..a5bb345a1 100644 --- a/metapost/context/base/mp-tool.mpii +++ b/metapost/context/base/mp-tool.mpii @@ -1407,7 +1407,7 @@ primarydef pct along pat = % also negative enddef ; primarydef len on pat = % no outer ( ) .. somehow fails - (arctime if len>0 : len else : (arclength(pat)+len) fi of pat) of pat + (arctime if len>=0 : len else : (arclength(pat)+len) fi of pat) of pat enddef ; % this cuts of a piece from both ends diff --git a/metapost/context/base/mp-tool.mpiv b/metapost/context/base/mp-tool.mpiv index dda8e84a1..30c3f0f50 100644 --- a/metapost/context/base/mp-tool.mpiv +++ b/metapost/context/base/mp-tool.mpiv @@ -368,6 +368,11 @@ vardef asinh primary x = ln(x+(x++1)) enddef ; vardef sinh primary x = save xx ; xx = exp x ; (xx-1/xx)/2 enddef ; vardef cosh primary x = save xx ; xx = exp x ; (xx+1/xx)/2 enddef ; +%D Like mod, but useful for anglesl it returns (-.5d,+.5d] and is used +%D in for instance mp-chem. + +primarydef a zmod b = (-((b/2 - a) mod b) + b/2) enddef ; + %D Sometimes this is handy: def undashed = @@ -1364,7 +1369,7 @@ primarydef pct along pat = % also negative enddef ; primarydef len on pat = % no outer ( ) .. somehow fails - (arctime if len>0 : len else : (arclength(pat)+len) fi of pat) of pat + (arctime if len>=0 : len else : (arclength(pat)+len) fi of pat) of pat enddef ; % this cuts of a piece from both ends @@ -2315,7 +2320,7 @@ enddef ; %D Handy: def break = - exitif true fi ; + exitif true ; % fi enddef ; %D New too: diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 8a18cab39..ac93145be 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -644,6 +644,22 @@ function scripts.context.run(ctxdata,filename) scripts.context.make(formatname,a_engine) formatfile, scriptfile = resolvers.locateformat(formatname) end + -- + local function combine(key) + local flag = validstring(environment[key]) + local plus = analysis[key] + if flag and plus then + return plus .. "," .. flag -- flag wins + else + return flag or plus -- flag wins + end + end + local a_trackers = analysis.trackers + local a_experiments = analysis.experiments + local directives = combine("directives") + local trackers = combine("trackers") + local experiments = combine("experiments") + -- if formatfile and scriptfile then local suffix = validstring(getargument("suffix")) local resultname = validstring(getargument("result")) @@ -691,9 +707,9 @@ function scripts.context.run(ctxdata,filename) local maxnofruns = once and 1 or multipass_nofruns -- local c_flags = { - directives = validstring(environment.directives), -- gets passed via mtxrun - trackers = validstring(environment.trackers), -- gets passed via mtxrun - experiments = validstring(environment.experiments), -- gets passed via mtxrun + directives = directives, -- gets passed via mtxrun + trackers = trackers, -- gets passed via mtxrun + experiments = experiments, -- gets passed via mtxrun -- result = validstring(resultname), input = validstring(getargument("input") or filename), -- alternative input diff --git a/scripts/context/lua/mtx-epub.lua b/scripts/context/lua/mtx-epub.lua index a383cfd90..69d9bb72c 100644 --- a/scripts/context/lua/mtx-epub.lua +++ b/scripts/context/lua/mtx-epub.lua @@ -34,6 +34,46 @@ if not modules then modules = { } end modules ['mtx-epub'] = { -- coverpage tests -- split up +-- todo: automated cover page: +-- +-- \startMPpage +-- StartPage ; +-- fill Page withcolor .5red ; +-- numeric n ; +-- for i=10 downto 1 : +-- n := i * PaperWidth/40 ; +-- draw +-- lrcorner Page shifted (0,n) +-- % -- lrcorner Page +-- -- lrcorner Page shifted (-n,0) +-- % -- cycle +-- withpen pencircle scaled 1mm +-- withcolor white ; +-- endfor ; +-- picture p ; p := image ( +-- draw +-- anchored.top( +-- textext.bot("\tttf Some Title") +-- xsized .8PaperWidth +-- ,center topboundary Page +-- ) +-- withcolor white ; +-- ) ; +-- picture q ; q := image ( +-- draw +-- anchored.top( +-- textext.bot("\tttf An Author") +-- xsized .4PaperWidth +-- shifted (0,-PaperHeight/40) +-- ,center bottomboundary p +-- ) +-- withcolor white ; +-- ) ; +-- draw p ; +-- draw q ; +-- StopPage ; +-- \stopMPpage + local format, gsub, find = string.format, string.gsub, string.find local concat, sortedhash = table.concat, table.sortedhash @@ -389,7 +429,7 @@ function scripts.epub.make(purge,rename,svgmath,svgstyle) end if not specfull or not isfile(specfull) then - report("unknown specificaton file for %a",filename) + report("unknown specificaton file %a for %a",specfull or "?",filename) return end @@ -459,7 +499,8 @@ function scripts.epub.make(purge,rename,svgmath,svgstyle) local pdftosvg = os.which("mudraw") and formatters[ [[mudraw -o "%s" "%s" %s]] ] - local f_svgname = formatters["%s-page-%s.svg"] + local f_svgpage = formatters["%s-page-%s.svg"] + local f_svgname = formatters["%s.svg"] local notupdated = 0 local updated = 0 @@ -521,10 +562,15 @@ function scripts.epub.make(purge,rename,svgmath,svgstyle) local name = url.filename(data.name) local used = url.filename(data.used) local base = basename(used) - local page = data.page or "1" + local page = tonumber(data.page) or 1 -- todo : check timestamp and prefix, rename to image-* if suffix(used) == "pdf" then - name = f_svgname(nameonly(name),page) + -- todo: pass svg name + if page > 1 then + name = f_svgpage(nameonly(name),page) + else + name = f_svgname(nameonly(name)) + end local source = used local target = joinfile(imagesource,name) if needsupdating(source,target) then diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua index 82cefd638..1640f0891 100644 --- a/scripts/context/lua/mtx-interface.lua +++ b/scripts/context/lua/mtx-interface.lua @@ -248,7 +248,7 @@ function scripts.interface.editor(editor,split,forcedinterfaces) local mappings = { } local environments = { } local x = xml.load(keyfile) - for e, d, k in xml.elements(x,"cd:command") do + for e, d, k in xml.elements(x,"/cd:interface/cd:commands/cd:command") do -- somehow this was variable local at = d[k].at local name, value = at.name, at.value if name and value then @@ -256,7 +256,7 @@ function scripts.interface.editor(editor,split,forcedinterfaces) end end local x = xml.load(xmlfile) - for e, d, k in xml.elements(x,"cd:command") do + for e, d, k in xml.elements(x,"/cd:interface/cd:command") do local at = d[k].at local name, type = at.name, at["type"] if name and name ~= "" then @@ -322,7 +322,7 @@ function scripts.interface.check() if f then f:write("\\starttext\n") local x = xml.load(xmlfile) - for e, d, k in xml.elements(x,"cd:command") do + for e, d, k in xml.elements(x,"/cd:interface/cd:command") do local dk = d[k] local at = dk.at if at then @@ -384,6 +384,7 @@ function scripts.interface.interfaces() return a .. b .. c .. b end) end + -- we could just replace attributes for language, _ in next, commands.setuplayout do local texresult, xmlresult = { }, { } texresult[#texresult+1] = format("%% this file is auto-generated, don't edit this file\n%%") @@ -403,6 +404,7 @@ function scripts.interface.interfaces() report("saving interface translations '%s'",xmlfilename) if language ~= "en" and xmldata ~= "" then local newdata = xmldata:gsub("(<cd:interface.*language=.)en(.)","%1"..language.."%2",1) +-- newdata = replace(newdata, 'cd:command', 'name', interface.commands, interface.elements, language) newdata = replace(newdata, 'cd:string', 'value', interface.commands, interface.elements, language) newdata = replace(newdata, 'cd:variable' , 'value', interface.variables, nil, language) newdata = replace(newdata, 'cd:parameter', 'name', interface.constants, nil, language) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 0ac7e5013..c9096d81e 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -6558,7 +6558,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 21550, stripped down to: 14916 +-- original size: 21610, stripped down to: 14974 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -6813,7 +6813,7 @@ function parsers.simple_hash_to_string(h,separator) end return concat(t,separator or ",") end -local str=C((1-whitespace-equal)^1) +local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1) local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset) local splitter=setting^1 function utilities.parsers.options_to_hash(str,target) @@ -6940,7 +6940,7 @@ function parsers.rfc4180splitter(specification) local field=escaped+non_escaped+Cc("") local record=Ct(field*(separator*field)^1) local headerline=record*Cp() - local wholeblob=Ct((newline^-1*record)^0) + local wholeblob=Ct((newline^(specification.strict and -1 or 1)*record)^0) return function(data,getheader) if getheader then local header,position=lpegmatch(headerline,data) @@ -9478,7 +9478,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 43805, stripped down to: 26812 +-- original size: 43882, stripped down to: 26870 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -10115,14 +10115,17 @@ function xml.checkbom(root) insert(dt,2,"\n" ) end end -local function verbose_element(e,handlers) +local f_attribute=formatters['%s=%q'] +local function verbose_element(e,handlers,escape) local handle=handlers.handle local serialize=handlers.serialize local ens,etg,eat,edt,ern=e.ns,e.tg,e.at,e.dt,e.rn local ats=eat and next(eat) and {} if ats then + local n=0 for k,v in next,eat do - ats[#ats+1]=formatters['%s=%q'](k,escaped(v)) + n=n+1 + ats[n]=f_attribute(k,escaped(v)) end end if ern and trace_entities and ern~=ens then @@ -16666,7 +16669,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-tre"] = package.loaded["data-tre"] or true --- original size: 7987, stripped down to: 5309 +-- original size: 8479, stripped down to: 5580 if not modules then modules={} end modules ['data-tre']={ version=1.001, @@ -16711,6 +16714,18 @@ function resolvers.finders.tree(specification) return fullname end end + local pattern=lower(pattern) + for i=1,#names do + local fullname=lower(names[i]) + if find(fullname,pattern) then + if isfile(fullname) then + found[spec]=fullname + return fullname + else + break + end + end + end end okay=notfound() found[spec]=okay @@ -16731,9 +16746,7 @@ function resolvers.locators.tree(specification) end function resolvers.hashers.tree(specification) local name=specification.filename - if trace_locating then - report_trees("analysing %a",name) - end + report_trees("analyzing %a",name) resolvers.methodhandler("hashers",name) resolvers.generators.file(specification) end @@ -17761,8 +17774,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 744704 --- stripped bytes : 272130 +-- original bytes : 745333 +-- stripped bytes : 272372 -- end library merge @@ -17988,6 +18001,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="script"><short>run an mtx script (lua prefered method) (<ref name="noquotes"/>), no script gives list</short></flag> + <flag name="evaluate"><short>run code passed on the commandline (between quotes)</short></flag> <flag name="execute"><short>run a script or program (texmfstart method) (<ref name="noquotes"/>)</short></flag> <flag name="resolve"><short>resolve prefixed arguments</short></flag> <flag name="ctxlua"><short>run internally (using preloaded libs)</short></flag> @@ -18643,6 +18657,39 @@ function runners.associate(filename) os.launch(filename) end +function runners.evaluate(code,filename) -- for Luigi + if code == "loop" then + while true do + io.write("> ") + local code = io.read() + if code ~= "" then + local temp = string.match(code,"^= (.*)$") + if temp then + code = "print("..temp..")" + end + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("! " .. (message or code).."\n") + else + io.write(compiled()) + end + end + end + else + if type(code) ~= "string" or code == "" then + code = filename + end + if code ~= "" then + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("invalid lua code: " .. (message or code)) + return + end + io.write(compiled()) + end + end +end + function runners.gethelp(filename) local url = environment.argument("url") if url and url ~= "" then @@ -18803,6 +18850,10 @@ if e_argument("script") or e_argument("scripts") then ok = runners.execute_ctx_script(filename) end +elseif e_argument("evaluate") then + + runners.evaluate(e_argument("evaluate"),filename) + elseif e_argument("selfmerge") then -- embed used libraries diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 0ac7e5013..c9096d81e 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -6558,7 +6558,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 21550, stripped down to: 14916 +-- original size: 21610, stripped down to: 14974 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -6813,7 +6813,7 @@ function parsers.simple_hash_to_string(h,separator) end return concat(t,separator or ",") end -local str=C((1-whitespace-equal)^1) +local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1) local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset) local splitter=setting^1 function utilities.parsers.options_to_hash(str,target) @@ -6940,7 +6940,7 @@ function parsers.rfc4180splitter(specification) local field=escaped+non_escaped+Cc("") local record=Ct(field*(separator*field)^1) local headerline=record*Cp() - local wholeblob=Ct((newline^-1*record)^0) + local wholeblob=Ct((newline^(specification.strict and -1 or 1)*record)^0) return function(data,getheader) if getheader then local header,position=lpegmatch(headerline,data) @@ -9478,7 +9478,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 43805, stripped down to: 26812 +-- original size: 43882, stripped down to: 26870 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -10115,14 +10115,17 @@ function xml.checkbom(root) insert(dt,2,"\n" ) end end -local function verbose_element(e,handlers) +local f_attribute=formatters['%s=%q'] +local function verbose_element(e,handlers,escape) local handle=handlers.handle local serialize=handlers.serialize local ens,etg,eat,edt,ern=e.ns,e.tg,e.at,e.dt,e.rn local ats=eat and next(eat) and {} if ats then + local n=0 for k,v in next,eat do - ats[#ats+1]=formatters['%s=%q'](k,escaped(v)) + n=n+1 + ats[n]=f_attribute(k,escaped(v)) end end if ern and trace_entities and ern~=ens then @@ -16666,7 +16669,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-tre"] = package.loaded["data-tre"] or true --- original size: 7987, stripped down to: 5309 +-- original size: 8479, stripped down to: 5580 if not modules then modules={} end modules ['data-tre']={ version=1.001, @@ -16711,6 +16714,18 @@ function resolvers.finders.tree(specification) return fullname end end + local pattern=lower(pattern) + for i=1,#names do + local fullname=lower(names[i]) + if find(fullname,pattern) then + if isfile(fullname) then + found[spec]=fullname + return fullname + else + break + end + end + end end okay=notfound() found[spec]=okay @@ -16731,9 +16746,7 @@ function resolvers.locators.tree(specification) end function resolvers.hashers.tree(specification) local name=specification.filename - if trace_locating then - report_trees("analysing %a",name) - end + report_trees("analyzing %a",name) resolvers.methodhandler("hashers",name) resolvers.generators.file(specification) end @@ -17761,8 +17774,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 744704 --- stripped bytes : 272130 +-- original bytes : 745333 +-- stripped bytes : 272372 -- end library merge @@ -17988,6 +18001,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="script"><short>run an mtx script (lua prefered method) (<ref name="noquotes"/>), no script gives list</short></flag> + <flag name="evaluate"><short>run code passed on the commandline (between quotes)</short></flag> <flag name="execute"><short>run a script or program (texmfstart method) (<ref name="noquotes"/>)</short></flag> <flag name="resolve"><short>resolve prefixed arguments</short></flag> <flag name="ctxlua"><short>run internally (using preloaded libs)</short></flag> @@ -18643,6 +18657,39 @@ function runners.associate(filename) os.launch(filename) end +function runners.evaluate(code,filename) -- for Luigi + if code == "loop" then + while true do + io.write("> ") + local code = io.read() + if code ~= "" then + local temp = string.match(code,"^= (.*)$") + if temp then + code = "print("..temp..")" + end + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("! " .. (message or code).."\n") + else + io.write(compiled()) + end + end + end + else + if type(code) ~= "string" or code == "" then + code = filename + end + if code ~= "" then + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("invalid lua code: " .. (message or code)) + return + end + io.write(compiled()) + end + end +end + function runners.gethelp(filename) local url = environment.argument("url") if url and url ~= "" then @@ -18803,6 +18850,10 @@ if e_argument("script") or e_argument("scripts") then ok = runners.execute_ctx_script(filename) end +elseif e_argument("evaluate") then + + runners.evaluate(e_argument("evaluate"),filename) + elseif e_argument("selfmerge") then -- embed used libraries diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 0ac7e5013..c9096d81e 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -6558,7 +6558,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 21550, stripped down to: 14916 +-- original size: 21610, stripped down to: 14974 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -6813,7 +6813,7 @@ function parsers.simple_hash_to_string(h,separator) end return concat(t,separator or ",") end -local str=C((1-whitespace-equal)^1) +local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1) local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset) local splitter=setting^1 function utilities.parsers.options_to_hash(str,target) @@ -6940,7 +6940,7 @@ function parsers.rfc4180splitter(specification) local field=escaped+non_escaped+Cc("") local record=Ct(field*(separator*field)^1) local headerline=record*Cp() - local wholeblob=Ct((newline^-1*record)^0) + local wholeblob=Ct((newline^(specification.strict and -1 or 1)*record)^0) return function(data,getheader) if getheader then local header,position=lpegmatch(headerline,data) @@ -9478,7 +9478,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 43805, stripped down to: 26812 +-- original size: 43882, stripped down to: 26870 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -10115,14 +10115,17 @@ function xml.checkbom(root) insert(dt,2,"\n" ) end end -local function verbose_element(e,handlers) +local f_attribute=formatters['%s=%q'] +local function verbose_element(e,handlers,escape) local handle=handlers.handle local serialize=handlers.serialize local ens,etg,eat,edt,ern=e.ns,e.tg,e.at,e.dt,e.rn local ats=eat and next(eat) and {} if ats then + local n=0 for k,v in next,eat do - ats[#ats+1]=formatters['%s=%q'](k,escaped(v)) + n=n+1 + ats[n]=f_attribute(k,escaped(v)) end end if ern and trace_entities and ern~=ens then @@ -16666,7 +16669,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-tre"] = package.loaded["data-tre"] or true --- original size: 7987, stripped down to: 5309 +-- original size: 8479, stripped down to: 5580 if not modules then modules={} end modules ['data-tre']={ version=1.001, @@ -16711,6 +16714,18 @@ function resolvers.finders.tree(specification) return fullname end end + local pattern=lower(pattern) + for i=1,#names do + local fullname=lower(names[i]) + if find(fullname,pattern) then + if isfile(fullname) then + found[spec]=fullname + return fullname + else + break + end + end + end end okay=notfound() found[spec]=okay @@ -16731,9 +16746,7 @@ function resolvers.locators.tree(specification) end function resolvers.hashers.tree(specification) local name=specification.filename - if trace_locating then - report_trees("analysing %a",name) - end + report_trees("analyzing %a",name) resolvers.methodhandler("hashers",name) resolvers.generators.file(specification) end @@ -17761,8 +17774,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 744704 --- stripped bytes : 272130 +-- original bytes : 745333 +-- stripped bytes : 272372 -- end library merge @@ -17988,6 +18001,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="script"><short>run an mtx script (lua prefered method) (<ref name="noquotes"/>), no script gives list</short></flag> + <flag name="evaluate"><short>run code passed on the commandline (between quotes)</short></flag> <flag name="execute"><short>run a script or program (texmfstart method) (<ref name="noquotes"/>)</short></flag> <flag name="resolve"><short>resolve prefixed arguments</short></flag> <flag name="ctxlua"><short>run internally (using preloaded libs)</short></flag> @@ -18643,6 +18657,39 @@ function runners.associate(filename) os.launch(filename) end +function runners.evaluate(code,filename) -- for Luigi + if code == "loop" then + while true do + io.write("> ") + local code = io.read() + if code ~= "" then + local temp = string.match(code,"^= (.*)$") + if temp then + code = "print("..temp..")" + end + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("! " .. (message or code).."\n") + else + io.write(compiled()) + end + end + end + else + if type(code) ~= "string" or code == "" then + code = filename + end + if code ~= "" then + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("invalid lua code: " .. (message or code)) + return + end + io.write(compiled()) + end + end +end + function runners.gethelp(filename) local url = environment.argument("url") if url and url ~= "" then @@ -18803,6 +18850,10 @@ if e_argument("script") or e_argument("scripts") then ok = runners.execute_ctx_script(filename) end +elseif e_argument("evaluate") then + + runners.evaluate(e_argument("evaluate"),filename) + elseif e_argument("selfmerge") then -- embed used libraries diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua index 0ac7e5013..c9096d81e 100644 --- a/scripts/context/stubs/win64/mtxrun.lua +++ b/scripts/context/stubs/win64/mtxrun.lua @@ -6558,7 +6558,7 @@ do -- create closure to overcome 200 locals limit package.loaded["util-prs"] = package.loaded["util-prs"] or true --- original size: 21550, stripped down to: 14916 +-- original size: 21610, stripped down to: 14974 if not modules then modules={} end modules ['util-prs']={ version=1.001, @@ -6813,7 +6813,7 @@ function parsers.simple_hash_to_string(h,separator) end return concat(t,separator or ",") end -local str=C((1-whitespace-equal)^1) +local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1) local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset) local splitter=setting^1 function utilities.parsers.options_to_hash(str,target) @@ -6940,7 +6940,7 @@ function parsers.rfc4180splitter(specification) local field=escaped+non_escaped+Cc("") local record=Ct(field*(separator*field)^1) local headerline=record*Cp() - local wholeblob=Ct((newline^-1*record)^0) + local wholeblob=Ct((newline^(specification.strict and -1 or 1)*record)^0) return function(data,getheader) if getheader then local header,position=lpegmatch(headerline,data) @@ -9478,7 +9478,7 @@ do -- create closure to overcome 200 locals limit package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true --- original size: 43805, stripped down to: 26812 +-- original size: 43882, stripped down to: 26870 if not modules then modules={} end modules ['lxml-tab']={ version=1.001, @@ -10115,14 +10115,17 @@ function xml.checkbom(root) insert(dt,2,"\n" ) end end -local function verbose_element(e,handlers) +local f_attribute=formatters['%s=%q'] +local function verbose_element(e,handlers,escape) local handle=handlers.handle local serialize=handlers.serialize local ens,etg,eat,edt,ern=e.ns,e.tg,e.at,e.dt,e.rn local ats=eat and next(eat) and {} if ats then + local n=0 for k,v in next,eat do - ats[#ats+1]=formatters['%s=%q'](k,escaped(v)) + n=n+1 + ats[n]=f_attribute(k,escaped(v)) end end if ern and trace_entities and ern~=ens then @@ -16666,7 +16669,7 @@ do -- create closure to overcome 200 locals limit package.loaded["data-tre"] = package.loaded["data-tre"] or true --- original size: 7987, stripped down to: 5309 +-- original size: 8479, stripped down to: 5580 if not modules then modules={} end modules ['data-tre']={ version=1.001, @@ -16711,6 +16714,18 @@ function resolvers.finders.tree(specification) return fullname end end + local pattern=lower(pattern) + for i=1,#names do + local fullname=lower(names[i]) + if find(fullname,pattern) then + if isfile(fullname) then + found[spec]=fullname + return fullname + else + break + end + end + end end okay=notfound() found[spec]=okay @@ -16731,9 +16746,7 @@ function resolvers.locators.tree(specification) end function resolvers.hashers.tree(specification) local name=specification.filename - if trace_locating then - report_trees("analysing %a",name) - end + report_trees("analyzing %a",name) resolvers.methodhandler("hashers",name) resolvers.generators.file(specification) end @@ -17761,8 +17774,8 @@ end -- of closure -- used libraries : l-lua.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-sto.lua util-prs.lua util-fmt.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-mrg.lua util-tpl.lua util-env.lua luat-env.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua util-lib.lua luat-sta.lua luat-fmt.lua -- skipped libraries : - --- original bytes : 744704 --- stripped bytes : 272130 +-- original bytes : 745333 +-- stripped bytes : 272372 -- end library merge @@ -17988,6 +18001,7 @@ local helpinfo = [[ <category name="basic"> <subcategory> <flag name="script"><short>run an mtx script (lua prefered method) (<ref name="noquotes"/>), no script gives list</short></flag> + <flag name="evaluate"><short>run code passed on the commandline (between quotes)</short></flag> <flag name="execute"><short>run a script or program (texmfstart method) (<ref name="noquotes"/>)</short></flag> <flag name="resolve"><short>resolve prefixed arguments</short></flag> <flag name="ctxlua"><short>run internally (using preloaded libs)</short></flag> @@ -18643,6 +18657,39 @@ function runners.associate(filename) os.launch(filename) end +function runners.evaluate(code,filename) -- for Luigi + if code == "loop" then + while true do + io.write("> ") + local code = io.read() + if code ~= "" then + local temp = string.match(code,"^= (.*)$") + if temp then + code = "print("..temp..")" + end + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("! " .. (message or code).."\n") + else + io.write(compiled()) + end + end + end + else + if type(code) ~= "string" or code == "" then + code = filename + end + if code ~= "" then + local compiled, message = loadstring(code) + if type(compiled) ~= "function" then + io.write("invalid lua code: " .. (message or code)) + return + end + io.write(compiled()) + end + end +end + function runners.gethelp(filename) local url = environment.argument("url") if url and url ~= "" then @@ -18803,6 +18850,10 @@ if e_argument("script") or e_argument("scripts") then ok = runners.execute_ctx_script(filename) end +elseif e_argument("evaluate") then + + runners.evaluate(e_argument("evaluate"),filename) + elseif e_argument("selfmerge") then -- embed used libraries diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index cccf14ee4..273cf0159 100644 --- a/tex/context/base/anch-bck.mkvi +++ b/tex/context/base/anch-bck.mkvi @@ -20,10 +20,6 @@ \unprotect -% we can flush 5 in one call (saved 4 lua calls) .. brrr wself .. will change - -\def\MPposset#1{\ctxcommand{MPposset("#1")}} % will go - % This might be overloaded later on: % \defineoverlay[\v!text-2][\positionoverlay{\v!text-2}] @@ -50,7 +46,7 @@ % tricky: we need to catch newly set! otherwise an old run can have positions \unexpanded\def\anch_backgrounds_text_initialize - {\ctxcommand{doifelsepositionsused()}\enableparpositions\donothing + {\doifelsepositionsused\enableparpositions\donothing \global\let\anch_backgrounds_text_initialize\relax} \appendtoks diff --git a/tex/context/base/anch-pgr.lua b/tex/context/base/anch-pgr.lua index 7c8c4545f..198e8a499 100644 --- a/tex/context/base/anch-pgr.lua +++ b/tex/context/base/anch-pgr.lua @@ -19,6 +19,10 @@ local lpegmatch = lpeg.match local jobpositions = job.positions local formatters = string.formatters +local scanstring = tokens.scanstring +local scannumber = tokens.scannumber +local scandimen = tokens.scandimen + local report_graphics = logs.reporter("graphics") local f_b_tag = formatters["b:%s"] @@ -552,7 +556,7 @@ f_template_b = formatters[f_template_b] f_template_c = formatters[f_template_c] f_template_d = formatters[f_template_d] -function backgrounds.fetchmultipar(n,anchor,page,obeyhang) +local function fetchmultipar(n,anchor,page,obeyhang) local data = pbg[n] if not data then data = calculatemultipar(n,obeyhang) @@ -596,16 +600,18 @@ function backgrounds.fetchmultipar(n,anchor,page,obeyhang) return f_template_a(0,"origin",0,0,0) end +backgrounds.fetchmultipar = fetchmultipar + backgrounds.point = f_point backgrounds.pair = f_pair backgrounds.path = f_path function commands.fetchmultipar(n,anchor,page) - context(backgrounds.fetchmultipar(n,anchor,page)) + context(fetchmultipar(n,anchor,page)) end function commands.fetchmultishape(n,anchor,page) - context(backgrounds.fetchmultipar(n,anchor,page,true)) + context(fetchmultipar(n,anchor,page,true)) end local f_template_a = [[ diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index a87a32c06..f91dfb0f9 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -281,6 +281,9 @@ \unexpanded\def\anch_mark_text_box#1% {\ctxcommand{markregionbox(\number#1,"\textanchor")}} % needs an hbox +\unexpanded\def\anch_mark_tagged_box#1#2% + {\ctxcommand{markregionbox(\number#1,"#2")}} % needs an hbox + %D We can copy a position with: %D %D \starttyping diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 0c99a6fd5..d4c252384 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -364,15 +364,15 @@ local styletemplate = [[ local hyphen = finetuning.hyphen local align = finetuning.align -- - if not bodyfont or bodyfont == "" then + if type(bodyfont) == "number" then + bodyfont = todimen(bodyfont) + else bodyfont = "12pt" - elseif type(bodyfont) == "number" then - bodyfont = todimen(bodyfont,"pt","%ipt") or "12pt" end - if not width or width == "" then + if type(width) == "number" then + width = todimen(width) or "50em" + else width = "50em" - elseif type(width) == "number" then - width = todimen(width,"pt","%ipt") or "50em" end if hyphen == v_yes then hyphen = "manual" @@ -422,39 +422,50 @@ do local imagetemplate = [[ %element%[id="%id%"], div.%element%[id="%id%"] { display : block ; - background-image : url(%url%) ; + background-image : url('%url%') ; background-size : 100%% auto ; background-repeat : no-repeat ; width : %width% ; height : %height% ; }]] + local f_svgname = formatters["%s.svg"] + local f_svgpage = formatters["%s-page-%s.svg"] + local collected = { } - local function substitute(name) + local function usedname(name,page) if file.suffix(name) == "pdf" then -- temp hack .. we will have a remapper - return file.replacesuffix(name,"svg") + if page and page > 1 then + name = f_svgpage(file.nameonly(name),page) + else + name = f_svgname(file.nameonly(name)) + end + end + local scheme = url.hasscheme(name) + if not scheme or scheme == "file" then + -- or can we just use the name ? + return file.join("../images",file.basename(url.filename(name))) else return name end end - local collected = { } - function wrapups.allusedimages(basename) local result = { formatters["/* %s for file %s */"]("images",basename) } for element, details in sortedhash(usedimages) do for detail, data in sortedhash(details) do local name = data.name + local page = tonumber(data.page) or 1 local spec = { element = element, id = data.id, name = name, - url = url.addscheme(substitute(name)), + page = page, + url = usedname(name,page), width = data.width, height = data.height, used = data.used, - page = data.page, } result[#result+1] = replacetemplate(imagetemplate,spec) collected[detail] = spec @@ -725,8 +736,8 @@ do name = name, used = used, page = page and page > 1 and page or nil, - width = todimen(width, "cm","%0.3Fcm"), - height = todimen(height,"cm","%0.3Fcm"), + width = todimen(width, "cm","%0.3F%s"), + height = todimen(height,"cm","%0.3F%s"), } end @@ -2511,13 +2522,17 @@ local function collectresults(head,list,pat,pap) -- is last used (we also have c nofcurrentcontent = nofcurrentcontent + 1 currentcontent[nofcurrentcontent] = utfchar(u) end - else -- weird, happens in hz (we really need to get rid of the pseudo fonts) + elseif c > 0 then nofcurrentcontent = nofcurrentcontent + 1 currentcontent[nofcurrentcontent] = utfchar(c) + else + -- we can have -1 as side effect of an explicit hyphen (unless we expand) end - else + elseif c > 0 then nofcurrentcontent = nofcurrentcontent + 1 currentcontent[nofcurrentcontent] = utfchar(c) + else + -- we can have -1 as side effect of an explicit hyphen (unless we expand) end end end diff --git a/tex/context/base/blob-ini.lua b/tex/context/base/blob-ini.lua index 32fac7662..7c30131bc 100644 --- a/tex/context/base/blob-ini.lua +++ b/tex/context/base/blob-ini.lua @@ -199,14 +199,3 @@ function commands.strwd(str) context(strwd(str)) end function commands.strht(str) context(strht(str)) end function commands.strdp(str) context(strdp(str)) end function commands.strhd(str) context(strhd(str)) end - --- less efficient: --- --- function commands.widthof(str) --- local b = blobs.new() --- blobs.append(b,str) --- blobs.pack(b) --- local w = blobs.dimensions(b) --- context(number.todimen(w)) --- blobs.dispose(b) --- end diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index 040aa731e..9954ad39f 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -257,6 +257,8 @@ local function undent(str) -- new version, needs testing: todo: not always neede return lpegmatch(stripper,str) or str end +buffers.undent = undent + function commands.grabbuffer(name,begintag,endtag,bufferdata,catcodes,doundent) -- maybe move \\ to call local dn = getcontent(name) if dn == "" then diff --git a/tex/context/base/buff-ver.lua b/tex/context/base/buff-ver.lua index 832c14122..7e7120eae 100644 --- a/tex/context/base/buff-ver.lua +++ b/tex/context/base/buff-ver.lua @@ -624,14 +624,16 @@ end local function getrange(lines,first,last,range) -- 1,3 1,+3 fromhere,tothere local noflines = #lines - local first, last = first or 1, last or noflines + local first = first or 1 + local last = last or noflines if last < 0 then last = noflines + last end - local range = settings.range local what = settings_to_array(range) - local r_first, r_last = what[1], what[2] - local f, l = tonumber(r_first), tonumber(r_last) + local r_first = what[1] + local r_last = what[2] + local f = tonumber(r_first) + local l = tonumber(r_last) if r_first then if f then if f > first then @@ -688,6 +690,7 @@ local function filter(lines,settings) -- todo: inline or display in settings end local line, n = 0, 0 local first, last, m = getstrip(lines) + local range = settings.range if range then first, last = getrange(lines,first,last,range) first, last = getstrip(lines,first,last) diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 019e645c4..1e5a9e690 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -332,8 +332,9 @@ tab = "\typeparameter\c!tab", method = "\typeparameter\c!option", nature = "inline", - compact = "\typeparameter\c!compact", % none | all | last (all needed in tabulate etc for manuals) - }}% + compact = "\typeparameter\c!compact", % none | all | last (all needed in tabulate etc for manuals) + escape = \!!bs\typeparameter\c!escape\!!es, % new but rather useless imo (escaping in general is not used much) + }}% \dostoptagged \buff_verbatim_right_of_type \egroup} diff --git a/tex/context/base/char-fio.lua b/tex/context/base/char-fio.lua index 766ea7123..4f091ebec 100644 --- a/tex/context/base/char-fio.lua +++ b/tex/context/base/char-fio.lua @@ -6,6 +6,11 @@ if not modules then modules = { } end modules ['char-fio'] = { license = "see context related readme files" } +-- % directives="filters.utf.reorder=false" + + +local next = next + -- -- local sequencers = utilities.sequencers @@ -30,19 +35,46 @@ disableaction(textfileactions, "characters.filters.utf.collapse") appendaction (textfileactions,"system","characters.filters.utf.decompose") disableaction(textfileactions, "characters.filters.utf.decompose") +local report = logs.reporter("unicode filter") +local reporting = "no" + +-- this is messy as for performance reasons i don't want this to happen +-- per line by default + +local enforced = { + ["characters.filters.utf.reorder"] = true, + ["characters.filters.utf.collapse"] = true, + ["characters.filters.utf.decompose"] = true, +} + function characters.filters.utf.enable() - enableaction(textfileactions,"characters.filters.utf.reorder") - enableaction(textfileactions,"characters.filters.utf.collapse") - enableaction(textfileactions,"characters.filters.utf.decompose") + for k, v in next, enforced do + if v then + if reporting == "yes" then + report("%a enabled",k) + end + enableaction(textfileactions,v) + else + if reporting == "yes" then + report("%a not enabled",k) + end + end + end + reporting = "never" end local function configure(what,v) - if not v then - disableaction(textfileactions,what) - disableaction(textlineactions,what) - elseif v == "line" then + if v == "line" then disableaction(textfileactions,what) enableaction (textlineactions,what) + elseif not toboolean(v) then + if reporting ~= "never" then + report("%a disabled",k) + reporting = "yes" + end + enforced[what] = false + disableaction(textfileactions,what) + disableaction(textlineactions,what) else -- true or text enableaction (textfileactions,what) disableaction(textlineactions,what) diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua index 267b51b46..0f632935d 100644 --- a/tex/context/base/char-ini.lua +++ b/tex/context/base/char-ini.lua @@ -945,6 +945,7 @@ if not characters.lhash then -- if k < 0x11000 then local l = v.lccode if l then + -- we have an uppercase if type(l) == "number" then lhash[utfchar(k)] = utfchar(l) elseif #l == 2 then @@ -955,6 +956,7 @@ if not characters.lhash then else local u = v.uccode if u then + -- we have an lowercase if type(u) == "number" then uhash[utfchar(k)] = utfchar(u) elseif #u == 2 then @@ -979,8 +981,8 @@ if not characters.lhash then if storage then storage.register("characters/lhash", lhash, "characters.lhash") - storage.register("characters/uhash", lhash, "characters.uhash") - storage.register("characters/shash", lhash, "characters.shash") + storage.register("characters/uhash", uhash, "characters.uhash") + storage.register("characters/shash", shash, "characters.shash") end end diff --git a/tex/context/base/char-tex.lua b/tex/context/base/char-tex.lua index 5ca8eea05..e03307cc3 100644 --- a/tex/context/base/char-tex.lua +++ b/tex/context/base/char-tex.lua @@ -225,6 +225,16 @@ local accentmapping = allocate { O = "Õ", o = "õ", U = "Ũ", u = "ũ", }, + ["o"] = { [""] = "ø", + }, + ["O"] = { [""] = "Ø", + }, + ["a"] = { + ["a"] = "å", + }, + ["A"] = { + ["A"] = "Å", + }, } texcharacters.accentmapping = accentmapping diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index cd7a2db06..6c1d3b837 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -60,6 +60,8 @@ local mpnamedcolor = attributes.colors.mpnamedcolor local topoints = number.topoints local todimen = string.todimen +local trialtypesetting = context.trialtypesetting + chemistry = chemistry or { } local chemistry = chemistry @@ -422,7 +424,11 @@ local function process(level,spec,text,n,rulethickness,rulecolor,offset,default_ insert(sstack,variant) m = m + 1 ; metacode[m] = syntax.save.direct elseif operation == "restore" then - variant = remove(sstack) + if #sstack > 0 then + variant = remove(sstack) + else + report_chemistry("restore without save") + end local ss = syntax[variant] keys, max = ss.keys, ss.max m = m + 1 ; metacode[m] = syntax.restore.direct @@ -721,7 +727,7 @@ function chemistry.start(settings) width, left, right, sp_width = calculated(width, left, right,bondlength,unit,scale) height, bottom, top, sp_height = calculated(height,bottom,top, bondlength,unit,scale) -- - if width ~= "true" and height ~= "true" and texgetcount("@@trialtypesetting") ~= 0 then + if width ~= "true" and height ~= "true" and trialtypesetting() then if trace_structure then report_chemistry("skipping trial run") end diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index 6aec16f9e..801683cfd 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -67,7 +67,7 @@ [\s!format=metafun, %\s!extensions=\v!yes, % Should we add extensions and initializations? %\s!initializations=\v!yes, % Would this give EmWidth, etc.? - ] + \c!method=\s!double] \startMPdefinitions{chemistry} input mp-chem.mpiv ; @@ -720,7 +720,7 @@ \c!rotation=0, % unitless number (interpreted as degrees) \c!symalign=\v!auto, \c!location=, % not yet used (was interaction related in mkii) - \c!offset=.25em, + \c!offset=.25\emwidth, \c!unit=\emwidth, \c!factor=3, \c!color=, diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index ff466586f..62158e08b 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -32,19 +32,23 @@ if not modules then modules = { } end modules ['cldf-ini'] = { -- context(string.formatters["%!tex!"]("${}")) -- context("%!tex!","${}") -local tex = tex - -context = context or { } -local context = context - -local format, gsub, validstring, stripstring = string.format, string.gsub, string.valid, string.strip -local next, type, tostring, tonumber, setmetatable, unpack, select = next, type, tostring, tonumber, setmetatable, unpack, select +local format, validstring, stripstring = string.format, string.valid, string.strip +local next, type, tostring, tonumber, setmetatable, unpack, select, rawset = next, type, tostring, tonumber, setmetatable, unpack, select, rawset local insert, remove, concat = table.insert, table.remove, table.concat local lpegmatch, lpegC, lpegS, lpegP, lpegV, lpegCc, lpegCs, patterns = lpeg.match, lpeg.C, lpeg.S, lpeg.P, lpeg.V, lpeg.Cc, lpeg.Cs, lpeg.patterns -local formatters = string.formatters -- using formatteds is slower in this case +local formatters = string.formatters -- using formatters is slower in this case + +context = context or { } +commands = commands or { } +interfaces = interfaces or { } + +local context = context +local commands = commands +local interfaces = interfaces local loaddata = io.loaddata +local tex = tex local texsprint = tex.sprint local texprint = tex.print local texwrite = tex.write @@ -87,7 +91,7 @@ local storefunction, flushfunction local storenode, flushnode local registerfunction, unregisterfunction, reservefunction, knownfunctions, callfunctiononce -if luafunctions then +-- if luafunctions then local freed, nofused, noffreed = { }, 0, 0 -- maybe use the number of @@trialtypesetting @@ -148,26 +152,123 @@ if luafunctions then end end - registerfunction = function(f) - if type(f) == "string" then - f = loadstring(f) + -- registerfunction = function(f) + -- if type(f) == "string" then + -- f = loadstring(f) + -- end + -- if type(f) ~= "function" then + -- f = function() report_cld("invalid function %A",f) end + -- end + -- if noffreed > 0 then + -- local n = freed[noffreed] + -- freed[noffreed] = nil + -- noffreed = noffreed - 1 + -- luafunctions[n] = f + -- return n + -- else + -- nofused = nofused + 1 + -- luafunctions[nofused] = f + -- return nofused + -- end + -- end + + storage.storedfunctions = storage.storedfunctions or { } + local storedfunctions = storage.storedfunctions + local initex = environment.initex + + storage.register("storage/storedfunctions", storedfunctions, "storage.storedfunctions") + + local f_resolve = nil + local p_resolve = ((1-lpegP("."))^1 / function(s) f_resolve = f_resolve[s] end * lpegP(".")^0)^1 + + function resolvestoredfunction(str) + f_resolve = global + lpegmatch(p_resolve,str) + return f_resolve + end + + local function expose(slot,f,...) -- so we can register yet undefined functions + local func = resolvestoredfunction(f) + if not func then + func = function() report_cld("beware: unknown function %i called: %s",slot,f) end end - if type(f) ~= "function" then - f = function() report_cld("invalid function %A",f) end + luafunctions[slot] = func + return func(...) + end + + if initex then + -- todo: log stored functions + else + local slots = table.sortedkeys(storedfunctions) + local last = #slots + if last > 0 then + -- we restore the references + for i=1,last do + local slot = slots[i] + local data = storedfunctions[slot] + luafunctions[slot] = function(...) + return expose(slot,data,...) + end + end + -- we now know how many are defined + nofused = slots[last] + -- normally there are no holes in the list yet + for i=1,nofused do + if not luafunctions[i] then + noffreed = noffreed + 1 + freed[noffreed] = i + end + end + -- report_cld("%s registered functions, %s freed slots",last,noffreed) end + end + + registerfunction = function(f,direct) -- either f=code or f=namespace,direct=name + local slot, func if noffreed > 0 then - local n = freed[noffreed] + slot = freed[noffreed] freed[noffreed] = nil noffreed = noffreed - 1 - luafunctions[n] = f - return n else nofused = nofused + 1 - luafunctions[nofused] = f - return nofused + slot = nofused end + if direct then + if initex then + func = function(...) + expose(slot,f,...) + end + if initex then + storedfunctions[slot] = f + end + else + func = resolvestoredfunction(f) + end + if type(func) ~= "function" then + func = function() report_cld("invalid resolve %A",f) end + end + elseif type(f) == "string" then + func = loadstring(f) + if type(func) ~= "function" then + func = function() report_cld("invalid code %A",f) end + end + elseif type(f) == "function" then + func = f + else + func = function() report_cld("invalid function %A",f) end + end + luafunctions[slot] = func + return slot end + -- do + -- commands.test = function(str) report_cld("test function: %s", str) end + -- if initex then + -- registerfunction("commands.test") -- number 1 + -- end + -- luafunctions[1]("okay") + -- end + unregisterfunction = function(slot) if luafunctions[slot] then noffreed = noffreed + 1 @@ -201,92 +302,116 @@ if luafunctions then knownfunctions = luafunctions -else - - local luafunctions, noffunctions = { }, 0 - local luanodes, nofnodes = { }, 0 - - usedstack = function() - return noffunctions + nofnodes, 0 - end + -- The next hack is a convenient way to define scanners at the Lua end and + -- get them available at the TeX end. There is some dirty magic needed to + -- prevent overload during format loading. - flushfunction = function(n) - local sn = luafunctions[n] - if not sn then - report_cld("data with id %a cannot be found on stack",n) - elseif not sn() and texgetcount("@@trialtypesetting") == 0 then -- @@trialtypesetting is private! - luafunctions[n] = nil - end - end + -- interfaces.scanners.foo = function() context("[%s]",tokens.scanners.string()) end : \scan_foo - storefunction = function(ti) - noffunctions = noffunctions + 1 - luafunctions[noffunctions] = ti - return noffunctions - end + interfaces.storedscanners = interfaces.storedscanners or { } + local storedscanners = interfaces.storedscanners - -- freefunction = function(n) - -- luafunctions[n] = nil - -- end + storage.register("interfaces/storedscanners", storedscanners, "interfaces.storedscanners") - flushnode = function(n) - local sn = luanodes[n] - if not sn then - report_cld("data with id %a cannot be found on stack",n) - elseif texgetcount("@@trialtypesetting") == 0 then -- @@trialtypesetting is private! - writenode(sn) - luanodes[n] = nil + interfaces.scanners = table.setmetatablenewindex(function(t,k,v) + if storedscanners[k] then + -- \scan_<k> is already in the format + -- report_cld("using interface scanner: %s",k) else - writenode(copynodelist(sn)) + -- todo: allocate slot here and pass it + storedscanners[k] = true + -- report_cld("installing interface scanner: %s",k) + context("\\installctxfunction{scan_%s}{interfaces.scanners.%s}",k,k) end - end + rawset(t,k,v) + end) - storenode = function(ti) - nofnodes = nofnodes + 1 - luanodes[nofnodes] = ti - return nofnodes - end - - _cldf_ = flushfunction -- global - _cldn_ = flushnode -- global - -- _cldl_ = function(n) return luafunctions[n]() end -- luafunctions(n) - _cldl_ = luafunctions - - registerfunction = function(f) - if type(f) == "string" then - f = loadstring(f) - end - if type(f) ~= "function" then - f = function() report_cld("invalid function %A",f) end - end - noffunctions = noffunctions + 1 - luafunctions[noffunctions] = f - return noffunctions - end - - unregisterfunction = function(slot) - if luafunctions[slot] then - luafunctions[slot] = nil - else - report_cld("invalid function slot %A",slot) - end - end - - reservefunction = function() - noffunctions = noffunctions + 1 - return noffunctions - end - - callfunctiononce = function(slot) - luafunctions[slot](slot) - luafunctions[slot] = nil - end - - table.setmetatablecall(luafunctions,function(t,n) return luafunctions[n](n) end) - - knownfunctions = luafunctions - -end +-- else -- by now this is obsolete +-- +-- local luafunctions, noffunctions = { }, 0 +-- local luanodes, nofnodes = { }, 0 +-- +-- usedstack = function() +-- return noffunctions + nofnodes, 0 +-- end +-- +-- flushfunction = function(n) +-- local sn = luafunctions[n] +-- if not sn then +-- report_cld("data with id %a cannot be found on stack",n) +-- elseif not sn() and texgetcount("@@trialtypesetting") == 0 then -- @@trialtypesetting is private! +-- luafunctions[n] = nil +-- end +-- end +-- +-- storefunction = function(ti) +-- noffunctions = noffunctions + 1 +-- luafunctions[noffunctions] = ti +-- return noffunctions +-- end +-- +-- -- freefunction = function(n) +-- -- luafunctions[n] = nil +-- -- end +-- +-- flushnode = function(n) +-- local sn = luanodes[n] +-- if not sn then +-- report_cld("data with id %a cannot be found on stack",n) +-- elseif texgetcount("@@trialtypesetting") == 0 then -- @@trialtypesetting is private! +-- writenode(sn) +-- luanodes[n] = nil +-- else +-- writenode(copynodelist(sn)) +-- end +-- end +-- +-- storenode = function(ti) +-- nofnodes = nofnodes + 1 +-- luanodes[nofnodes] = ti +-- return nofnodes +-- end +-- +-- _cldf_ = flushfunction -- global +-- _cldn_ = flushnode -- global +-- -- _cldl_ = function(n) return luafunctions[n]() end -- luafunctions(n) +-- _cldl_ = luafunctions +-- +-- registerfunction = function(f) +-- if type(f) == "string" then +-- f = loadstring(f) +-- end +-- if type(f) ~= "function" then +-- f = function() report_cld("invalid function %A",f) end +-- end +-- noffunctions = noffunctions + 1 +-- luafunctions[noffunctions] = f +-- return noffunctions +-- end +-- +-- unregisterfunction = function(slot) +-- if luafunctions[slot] then +-- luafunctions[slot] = nil +-- else +-- report_cld("invalid function slot %A",slot) +-- end +-- end +-- +-- reservefunction = function() +-- noffunctions = noffunctions + 1 +-- return noffunctions +-- end +-- +-- callfunctiononce = function(slot) +-- luafunctions[slot](slot) +-- luafunctions[slot] = nil +-- end +-- +-- table.setmetatablecall(luafunctions,function(t,n) return luafunctions[n](n) end) +-- +-- knownfunctions = luafunctions +-- +-- end context.registerfunction = registerfunction context.unregisterfunction = unregisterfunction @@ -295,8 +420,12 @@ context.knownfunctions = knownfunctions context.callfunctiononce = callfunctiononce _cldo_ = callfunctiononce context.storenode = storenode -- private helper -function commands.ctxfunction(code) - context(registerfunction(code)) +function commands.ctxfunction(code,namespace) + context(registerfunction(code,namespace)) +end + +function context.trialtypesetting() + return texgetcount("@@trialtypesetting") ~= 0 end -- local f_cldo = formatters["_cldo_(%i)"] diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 2d0f07dad..d38507d34 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{2015.02.03 23:55} +\newcontextversion{2015.03.09 19:27} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 31c5d44c1..1907d4063 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index d6522da7e..9e66e2f65 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2015.02.03 23:55} +\edef\contextversion{2015.03.09 19:27} \edef\contextkind {beta} %D For those who want to use this: @@ -129,6 +129,8 @@ \loadmarkfile{luat-ini} \loadmarkfile{toks-ini} +\loadmarkfile{toks-tra} +%loadmarkfile{toks-map} % obsolete, never used \loadmarkfile{attr-ini} @@ -405,6 +407,7 @@ \loadmarkfile{typo-fln} \loadmarkfile{typo-sus} \loadmarkfile{typo-lig} +\loadmarkfile{typo-chr} \loadmkvifile{type-ini} \loadmarkfile{type-set} diff --git a/tex/context/base/core-env.lua b/tex/context/base/core-env.lua index 94f237c2e..75cbbb607 100644 --- a/tex/context/base/core-env.lua +++ b/tex/context/base/core-env.lua @@ -13,19 +13,15 @@ if not modules then modules = { } end modules ['core-env'] = { local P, C, S, Cc, lpegmatch, patterns = lpeg.P, lpeg.C, lpeg.S, lpeg.Cc, lpeg.match, lpeg.patterns -local csname_id = token.csname_id -local create = token.create local texgetcount = tex.getcount local texsetcount = tex.setcount local allocate = utilities.storage.allocate local setmetatableindex = table.setmetatableindex +local setmetatablecall = table.setmetatablecall local context = context -local undefined = csname_id("*undefined*crap*") -local iftrue = create("iftrue")[2] -- inefficient hack - tex.modes = allocate { } tex.systemmodes = allocate { } tex.constants = allocate { } @@ -36,52 +32,204 @@ tex.isdefined = allocate { } local modes = { } local systemmodes = { } -setmetatableindex(tex.modes, function(t,k) - local m = modes[k] - if m then - return m() - else - local n = "mode>" .. k - if csname_id(n) == undefined then - return false +if newtoken then + + -- undefined: mode == 0 or cmdname = "undefined_cs" + + local create = newtoken.create + + local cache = table.setmetatableindex(function(t,k) + local v = create(k) + t[k] = v + return v + end) + + -- we can have a modes cache too + + local iftrue = cache["iftrue"].mode + local undefined = cache["*undefined*crap*"].mode -- is this ok? + + setmetatableindex(tex.modes, function(t,k) + local m = modes[k] + if m then + return m() + else + local n = "mode>" .. k + if cache[n].mode == 0 then + return false + else + modes[k] = function() return texgetcount(n) == 1 end + return texgetcount(n) == 1 -- 2 is prevented + end + end + end) + + setmetatableindex(tex.systemmodes, function(t,k) + local m = systemmodes[k] + if m then + return m() else - modes[k] = function() return texgetcount(n) == 1 end - return texgetcount(n) == 1 -- 2 is prevented + local n = "mode>*" .. k + if cache[n].mode == 0 then + return false + else + systemmodes[k] = function() return texgetcount(n) == 1 end + return texgetcount(n) == 1 -- 2 is prevented + end end + end) + + setmetatableindex(tex.constants, function(t,k) + return cache[k].mode ~= 0 and texgetcount(k) or 0 + end) + + setmetatableindex(tex.conditionals, function(t,k) -- 0 == true + return cache[k].mode ~= 0 and texgetcount(k) == 0 + end) + + table.setmetatableindex(tex.ifs, function(t,k) + -- local mode = cache[k].mode + -- if mode == 0 then + -- return nil + -- else + -- return mode == iftrue + -- end + return cache[k].mode == iftrue + end) + + setmetatableindex(tex.isdefined, function(t,k) + return k and cache[k].mode ~= 0 + end) + + setmetatablecall(tex.isdefined, function(t,k) + return k and cache[k].mode ~= 0 + end) + + local dimencode = cache["scratchdimen" ].command + local countcode = cache["scratchcounter"].command + local tokencode = cache["scratchtoken" ].command + local skipcode = cache["scratchskip" ].command + + local types = { + [dimencode] = "dimen", + [countcode] = "count", + [tokencode] = "token", + [skipcode ] = "skip", + } + + function tex.isdimen(name) + return cache[name].command == dimencode end -end) -setmetatableindex(tex.systemmodes, function(t,k) - local m = systemmodes[k] - if m then - return m() - else - local n = "mode>*" .. k - if csname_id(n) == undefined then - return false + function tex.iscount(name) + return cache[name].command == countcode + end + + function tex.istoken(name) + return cache[name].command == tokencode + end + + function tex.isskip(name) + return cache[name].command == skipcode + end + + function tex.type(name) + return types[cache[name].command] or "macro" + end + +else + + local csname_id = token.csname_id + local create = token.create + + local undefined = csname_id("*undefined*crap*") + local iftrue = create("iftrue")[2] -- inefficient hack + + setmetatableindex(tex.modes, function(t,k) + local m = modes[k] + if m then + return m() + else + local n = "mode>" .. k + if csname_id(n) == undefined then + return false + else + modes[k] = function() return texgetcount(n) == 1 end + return texgetcount(n) == 1 -- 2 is prevented + end + end + end) + + setmetatableindex(tex.systemmodes, function(t,k) + local m = systemmodes[k] + if m then + return m() else - systemmodes[k] = function() return texgetcount(n) == 1 end - return texgetcount(n) == 1 -- 2 is prevented + local n = "mode>*" .. k + if csname_id(n) == undefined then + return false + else + systemmodes[k] = function() return texgetcount(n) == 1 end + return texgetcount(n) == 1 -- 2 is prevented + end end + end) + + setmetatableindex(tex.constants, function(t,k) + return csname_id(k) ~= undefined and texgetcount(k) or 0 + end) + + setmetatableindex(tex.conditionals, function(t,k) -- 0 == true + return csname_id(k) ~= undefined and texgetcount(k) == 0 + end) + + setmetatableindex(tex.ifs, function(t,k) + -- k = "if" .. k -- better not + return csname_id(k) ~= undefined and create(k)[2] == iftrue -- inefficient, this create, we need a helper + end) + + setmetatableindex(tex.isdefined, function(t,k) + return k and csname_id(k) ~= undefined + end) + setmetatablecall(tex.isdefined, function(t,k) + return k and csname_id(k) ~= undefined + end) + + local lookuptoken = token.lookup + + local dimencode = lookuptoken("scratchdimen" )[1] + local countcode = lookuptoken("scratchcounter")[1] + local tokencode = lookuptoken("scratchtoken" )[1] + local skipcode = lookuptoken("scratchskip" )[1] + + local types = { + [dimencode] = "dimen", + [countcode] = "count", + [tokencode] = "token", + [skipcode ] = "skip", + } + + function tex.isdimen(name) + return lookuptoken(name)[1] == dimencode end -end) -setmetatableindex(tex.constants, function(t,k) - return csname_id(k) ~= undefined and texgetcount(k) or 0 -end) + function tex.iscount(name) + return lookuptoken(name)[1] == countcode + end -setmetatableindex(tex.conditionals, function(t,k) -- 0 == true - return csname_id(k) ~= undefined and texgetcount(k) == 0 -end) + function tex.istoken(name) + return lookuptoken(name)[1] == tokencode + end -setmetatableindex(tex.ifs, function(t,k) - -- k = "if" .. k -- better not - return csname_id(k) ~= undefined and create(k)[2] == iftrue -- inefficient, this create, we need a helper -end) + function tex.isskip(name) + return lookuptoken(name)[1] == skipcode + end -setmetatableindex(tex.isdefined, function(t,k) - return csname_id(k) ~= undefined -end) + function tex.type(name) + return types[lookuptoken(name)[1]] or "macro" + end + +end function context.setconditional(name,value) if value then @@ -91,27 +239,6 @@ function context.setconditional(name,value) end end - --- todo : global - --- not possible as we let at the tex end to zerocount and plusone --- --- function tex.settrue(name,glob) --- if glob then --- texsetcount("global",name,0) --- else --- texsetcount(name,0) --- end --- end --- --- function tex.setfalse(name,glob) --- if glob then --- texsetcount("global",name,1) --- else --- texsetcount(name,1) --- end --- end - ---- arg = P("{") * C(patterns.nested) * P("}") + Cc("") local sep = S("), ") @@ -130,41 +257,3 @@ function commands.autosetups(str) lpegmatch(pattern,str) end --- new (inefficient) - -local lookuptoken = token.lookup - -local dimencode = lookuptoken("scratchdimen" )[1] -local countcode = lookuptoken("scratchcounter")[1] -local tokencode = lookuptoken("scratchtoken" )[1] -local skipcode = lookuptoken("scratchskip" )[1] - -local types = { - [dimencode] = "dimen", - [countcode] = "count", - [tokencode] = "token", - [skipcode ] = "skip", -} - -function tex.isdimen(name) - return lookuptoken(name)[1] == dimencode -end - -function tex.iscount(name) - return lookuptoken(name)[1] == countcode -end - -function tex.istoken(name) - return lookuptoken(name)[1] == tokencode -end - -function tex.isskip(name) - return lookuptoken(name)[1] == skipcode -end - -function tex.type(name) - return types[lookuptoken(name)[1]] or "macro" -end - --- inspect(tex.isdimen("xxxxxxxxxxxxxxx")) --- inspect(tex.isdimen("textwidth")) diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index 1e47ac517..0ee5a0fb3 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -467,7 +467,11 @@ % but it won't work out well with multiple setups (intercepted at the % lua end) that then get only one argument. -\def\fastsetup#1{\csname\??setup:#1\endcsname\empty} % no checking and we assume it being defined (at least for now) +% no checking and we assume it being defined: + +\def\fastsetup #1{\csname\??setup:#1\endcsname\empty} +\def\fastsetupwithargument #1#2{\csname\??setup:#2\endcsname{#1}} +\def\fastsetupwithargumentswapped #1{\csname\??setup:#1\endcsname} % the next one is meant for \c!setups situations, hence the check for % a shortcut diff --git a/tex/context/base/data-tre.lua b/tex/context/base/data-tre.lua index 4aca21b68..4388731f9 100644 --- a/tex/context/base/data-tre.lua +++ b/tex/context/base/data-tre.lua @@ -64,6 +64,20 @@ function resolvers.finders.tree(specification) -- to be adapted to new formats return fullname end end + -- let's be nice: + local pattern = lower(pattern) + for i=1,#names do + local fullname = lower(names[i]) + if find(fullname,pattern) then + if isfile(fullname) then + found[spec] = fullname + return fullname + else + -- no os name mapping + break + end + end + end end okay = notfound() -- false found[spec] = okay @@ -86,9 +100,9 @@ end function resolvers.hashers.tree(specification) local name = specification.filename - if trace_locating then - report_trees("analysing %a",name) - end + -- if trace_locating then + report_trees("analyzing %a",name) + -- end resolvers.methodhandler("hashers",name) resolvers.generators.file(specification) diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index 07bdaebd9..29b0542da 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -401,37 +401,105 @@ \unexpanded\def\inch {\mathematics{\prime\prime}} % was: \hbox{\rm\char125\relax} \unexpanded\def\fraction#1#2{\mathematics{#1\over#2}} -\def\periodswidth {.5em} -\def\periodsdefault{3} % was 5, but now it's like \unknown - -\unexpanded\def\periods - {\dosingleempty\enco_periods} - +% \def\periodswidth {.5em} +% \def\periodsdefault{3} % was 5, but now it's like \unknown +% +% \unexpanded\def\periods +% {\dosingleempty\enco_periods} +% % \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 % {\dontleavehmode % \begingroup % \scratchdimen\periodswidth % \hbox to \iffirstargument#1\else\periodsdefault\fi \scratchdimen -% {\leaders\hbox to \scratchdimen{\hss.\hss}\hss}% +% {\leaders\hbox to \scratchdimen{\hss\periodsymbol\hss}\hss}% % \endgroup} % % better for export: +% +% \unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 +% {\dontleavehmode +% \hbox\bgroup +% \setbox\scratchbox\hbox to \periodswidth{\hss\periodsymbol\hss}% +% \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% +% \egroup} +% +% \unexpanded\def\unknown +% {\periods\relax} % relax prevents lookahead for [] +% +% per request: + +%D \startbuffer +%D \startlines +%D x\periods x +%D x\periods[10]x +%D x\periods[n=10,symbol={,}]x +%D x\periods[n=4,symbol={!!},width=1em]x +%D x\periods[n=4,symbol={!!},width=fit]x +%D x\periods[n=4,symbol={!!},width=fit,distance=1em]x +%D x\unknown x +%D \stoplines +%D \stopbuffer +%D +%D \typbuffer \getbuffer + +\def\periodswidth {.5\emwidth} % downward compatible +\def\periodsdefault{3} % downward compatible + +\installcorenamespace {periods} + +\installsetuponlycommandhandler \??periods {periods} + +\setupperiods + [\c!n=\periodsdefault, + \c!width=\periodswidth, % can also be \v!fit + \c!distance=.25\emwidth, + \c!symbol=.] -\unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 +\unexpanded\def\periods {\dontleavehmode \hbox\bgroup - \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% - \dorecurse{\iffirstargument#1\else\periodsdefault\fi}{\copy\scratchbox}% + \doifnextoptionalelse\enco_periods_yes\enco_periods_nop} + +\unexpanded\def\enco_periods_yes[#1]% + {\doifassignmentelse{#1} + {\setupcurrentperiods[#1]% + \scratchcounter\periodsparameter\c!n} + {\doifelsenothing{#1} + {\scratchcounter\periodsparameter\c!n}% + {\scratchcounter#1}}% + \enco_periods_finish} + +\unexpanded\def\enco_periods_nop + {\scratchcounter\periodsparameter\c!n + \enco_periods_finish} + +\unexpanded\def\enco_periods_finish + {\edef\p_width{\periodsparameter\c!width}% + \ifx\p_width\v!fit + \enco_periods_finish_fit + \else + \enco_periods_finish_width + \fi \egroup} +\unexpanded\def\enco_periods_finish_width + {\setbox\scratchbox\hbox to \p_width + {\hss\periodsparameter\c!symbol\hss}% + \dorecurse\scratchcounter{\copy\scratchbox}} + +\unexpanded\def\enco_periods_finish_fit + {\edef\p_symbol{\periodsparameter\c!symbol}% + \scratchdistance\periodsparameter\c!distance + \hskip\scratchdistance + \dorecurse\scratchcounter{\p_symbol\hskip\scratchdistance}} + \unexpanded\def\unknown - {\periods\relax} % relax prevents lookahead for [] + {\dontleavehmode + \hbox\bgroup + \enco_periods_nop} -% Example by Wolfgang Schuster on the context list: -% -% \unexpanded\def\fourdots{{\def\periodswidth{.3em}\periods[4]}} -% -% Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. +%D Left-overs: \appendtoks \let\buildtextaccent\secondoftwoarguments diff --git a/tex/context/base/export-example.css b/tex/context/base/export-example.css index cbe4ccf4e..41321ead4 100644 --- a/tex/context/base/export-example.css +++ b/tex/context/base/export-example.css @@ -122,6 +122,7 @@ construct[detail="important"], div.construct.important { } highlight, div.highlight { /* todo: style and color */ + display : inline ; } /* section : display */ diff --git a/tex/context/base/export-example.tex b/tex/context/base/export-example.tex index 3a70b92fd..32cb79c5e 100644 --- a/tex/context/base/export-example.tex +++ b/tex/context/base/export-example.tex @@ -9,9 +9,7 @@ hyphen=yes] \setupbackend - [export=export-example.xml, - xhtml=export-example.xhtml, - css=export-example.css] + [export=yes] % \setupalign % [flushleft] diff --git a/tex/context/base/file-job.lua b/tex/context/base/file-job.lua index 0d1986463..ff99aa651 100644 --- a/tex/context/base/file-job.lua +++ b/tex/context/base/file-job.lua @@ -88,10 +88,12 @@ function commands.locatefilepath(name) end function commands.usepath(paths) + report_jobfiles("using path: %s",paths) registerextrapath(paths) end function commands.usesubpath(subpaths) + report_jobfiles("using subpath: %s",subpaths) registerextrapath(nil,subpaths) end @@ -773,6 +775,10 @@ function document.getargument(key,default) -- commands context(v or default or "") end +function document.setargument(key,value) + document.arguments[key] = value -- only strings +end + function document.getfilename(i) -- commands context(document.files[tonumber(i)] or "") end diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index ee2a71ac5..a7f915023 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -1004,8 +1004,34 @@ do -- else too many locals return (gsub(cs,".->", "")) end +-- local scan_string = newtoken.scan_string +-- local scan_dimen = newtoken.scan_dimen +-- local scan_number = newtoken.scan_number +-- local scan_boolean = newtoken.scan_boolean + +-- function commands.definefont_two() + +-- local global = scan_boolean() +-- local cs = scan_string() +-- local str = scan_string() +-- local size = scan_number() +-- local inheritancemode = scan_number() +-- local classfeatures = scan_string() +-- local fontfeatures = scan_string() +-- local classfallbacks = scan_string() +-- local fontfallbacks = scan_string() +-- local mathsize = scan_number() +-- local textsize = scan_number() +-- local relativeid = scan_string() +-- local classgoodies = scan_string() +-- local goodies = scan_string() +-- local classdesignsize = scan_string() +-- local fontdesignsize = scan_string() +-- local scaledfontmode = scan_number() + function commands.definefont_two(global,cs,str,size,inheritancemode,classfeatures,fontfeatures,classfallbacks,fontfallbacks, mathsize,textsize,relativeid,classgoodies,goodies,classdesignsize,fontdesignsize,scaledfontmode) + if trace_defining then report_defining("start stage two: %s (size %s)",str,size) end @@ -1242,9 +1268,12 @@ do function definers.internal(specification,cs) specification = specification or { } local name = specification.name - local size = specification.size and number.todimen(specification.size) or texgetdimen("bodyfontsize") + local size = tonumber(specification.size) local number = tonumber(specification.number) local id = nil + if not size then + size = texgetdimen("bodyfontsize") + end if number then id = number elseif name and name ~= "" then diff --git a/tex/context/base/font-fil.mkvi b/tex/context/base/font-fil.mkvi index 158bcda71..0f1d27564 100644 --- a/tex/context/base/font-fil.mkvi +++ b/tex/context/base/font-fil.mkvi @@ -290,75 +290,75 @@ % resolve \def\font_helpers_set_features_yes#name% - {\ifcsname\??fontfile\fontclass#name\s!features \endcsname\expandafter\let\expandafter\m_font_features % class + symbolic_name - \csname\??fontfile\fontclass#name\s!features \endcsname\else - \ifcsname\??fontfile #name\s!features \endcsname\expandafter\let\expandafter\m_font_features % symbolic_name - \csname\??fontfile #name\s!features \endcsname\else + {\ifcsname\??fontfile\fontclass#name\s!features \endcsname \edef\m_font_features % class + symbolic_name + {\csname\??fontfile\fontclass#name\s!features \endcsname}\else + \ifcsname\??fontfile #name\s!features \endcsname \edef\m_font_features % symbolic_name + {\csname\??fontfile #name\s!features \endcsname}\else \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_features_yes % class + parent_name - \csname\??fontfile\fontclass #name\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_yes % parent_name - \csname\??fontfile #name\endcsname\else + \csname\??fontfile\fontclass #name\endcsname \else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_features_yes % parent_name + \csname\??fontfile #name\endcsname \else \let\m_font_features\empty\fi\fi\fi\fi} \def\font_helpers_set_fallbacks_yes#name% - {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks - \csname\??fontfile\fontclass#name\s!fallbacks\endcsname\else - \ifcsname\??fontfile #name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks - \csname\??fontfile #name\s!fallbacks\endcsname\else - \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_fallbacks_yes - \csname\??fontfile\fontclass #name\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_yes - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile\fontclass#name\s!fallbacks\endcsname \edef\m_font_fallbacks + {\csname\??fontfile\fontclass#name\s!fallbacks\endcsname}\else + \ifcsname\??fontfile #name\s!fallbacks\endcsname \edef\m_font_fallbacks + {\csname\??fontfile #name\s!fallbacks\endcsname}\else + \ifcsname\??fontfile\fontclass #name\endcsname \expandafter\font_helpers_set_fallbacks_yes + \csname\??fontfile\fontclass #name\endcsname \else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_fallbacks_yes + \csname\??fontfile #name\endcsname \else \let\m_font_fallbacks\empty\fi\fi\fi\fi} \def\font_helpers_set_goodies_yes#name% - {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies - \csname\??fontfile\fontclass#name\s!goodies \endcsname\else - \ifcsname\??fontfile #name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies - \csname\??fontfile #name\s!goodies \endcsname\else - \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_goodies_yes - \csname\??fontfile\fontclass #name\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_yes - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile\fontclass#name\s!goodies \endcsname \edef\m_font_goodies + {\csname\??fontfile\fontclass#name\s!goodies \endcsname}\else + \ifcsname\??fontfile #name\s!goodies \endcsname \edef\m_font_goodies + {\csname\??fontfile #name\s!goodies \endcsname}\else + \ifcsname\??fontfile\fontclass #name\endcsname \expandafter\font_helpers_set_goodies_yes + \csname\??fontfile\fontclass #name\endcsname \else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_goodies_yes + \csname\??fontfile #name\endcsname \else \let\m_font_goodies\empty\fi\fi\fi\fi} \def\font_helpers_set_designsize_yes#name% - {\ifcsname\??fontfile\fontclass#name\s!designsize\endcsname\expandafter\let\expandafter\m_font_designsize - \csname\??fontfile\fontclass#name\s!designsize\endcsname\else - \ifcsname\??fontfile #name\s!designsize\endcsname\expandafter\let\expandafter\m_font_designsize - \csname\??fontfile #name\s!designsize\endcsname\else - \ifcsname\??fontfile\fontclass #name\endcsname\expandafter\font_helpers_set_designsize_yes - \csname\??fontfile\fontclass #name\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_designsize_yes - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile\fontclass#name\s!designsize\endcsname \edef\m_font_designsize + {\csname\??fontfile\fontclass#name\s!designsize\endcsname}\else + \ifcsname\??fontfile #name\s!designsize\endcsname \edef\m_font_designsize + {\csname\??fontfile #name\s!designsize\endcsname}\else + \ifcsname\??fontfile\fontclass #name\endcsname \expandafter\font_helpers_set_designsize_yes + \csname\??fontfile\fontclass #name\endcsname \else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_designsize_yes + \csname\??fontfile #name\endcsname \else \let\m_font_designsize\empty\fi\fi\fi\fi} \def\font_helpers_set_features_nop#name% - {\ifcsname\??fontfile#name\s!features \endcsname\expandafter\let\expandafter\m_font_features - \csname\??fontfile#name\s!features \endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_features_nop - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile#name\s!features \endcsname \edef\m_font_features + {\csname\??fontfile#name\s!features \endcsname}\else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_features_nop + \csname\??fontfile #name\endcsname \else \let\m_font_features\empty\fi\fi} \def\font_helpers_set_fallbacks_nop#name% - {\ifcsname\??fontfile#name\s!fallbacks\endcsname\expandafter\let\expandafter\m_font_fallbacks - \csname\??fontfile#name\s!fallbacks\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_fallbacks_nop - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile#name\s!fallbacks\endcsname \edef\m_font_fallbacks + {\csname\??fontfile#name\s!fallbacks\endcsname}\else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_fallbacks_nop + \csname\??fontfile #name\endcsname \else \let\m_font_fallbacks\empty\fi\fi} \def\font_helpers_set_goodies_nop#name% - {\ifcsname\??fontfile#name\s!goodies \endcsname\expandafter\let\expandafter\m_font_goodies - \csname\??fontfile#name\s!goodies \endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_goodies_nop - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile#name\s!goodies \endcsname \edef\m_font_goodies + {\csname\??fontfile#name\s!goodies \endcsname}\else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_goodies_nop + \csname\??fontfile #name\endcsname \else \let\m_font_goodies\empty\fi\fi} \def\font_helpers_set_designsize_nop#name% - {\ifcsname\??fontfile#name\s!designsize\endcsname\expandafter\let\expandafter\m_font_designsize - \csname\??fontfile#name\s!designsize\endcsname\else - \ifcsname\??fontfile #name\endcsname\expandafter\font_helpers_set_designsize_nop - \csname\??fontfile #name\endcsname\else + {\ifcsname\??fontfile#name\s!designsize\endcsname \edef\m_font_designsize + {\csname\??fontfile#name\s!designsize\endcsname}\else + \ifcsname\??fontfile #name\endcsname \expandafter\font_helpers_set_designsize_nop + \csname\??fontfile #name\endcsname \else \let\m_font_designsize\empty\fi\fi} \def\font_helpers_update_font_parameters_yes diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi index 03e08affc..60104f31a 100644 --- a/tex/context/base/font-ini.mkvi +++ b/tex/context/base/font-ini.mkvi @@ -900,11 +900,19 @@ \unexpanded\def\definefrozenfont {\dotripleempty\font_basics_define_frozen_font} +% \def\font_basics_define_frozen_font[#name][#specification][#settings]% +% {\begingroup +% \font_basics_define_font[#name][#specification][#settings]% +% \csname#name\endcsname +% \expandafter\expandafter\expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall} + \def\font_basics_define_frozen_font[#name][#specification][#settings]% {\begingroup \font_basics_define_font[#name][#specification][#settings]% \csname#name\endcsname - \expandafter\endgroup\expandafter\let\csname#name\endcsname\lastrawfontcall} + \global\let\lastglobalrawfontcall\lastrawfontcall + \endgroup + \expandafter\let\csname#name\endcsname\lastglobalrawfontcall} %D The instance namespace protection makes the switch local so that we can redefine a %D logical name and/or change the size in between. diff --git a/tex/context/base/font-inj.lua b/tex/context/base/font-inj.lua index 87d3f9b27..cb9ed891c 100644 --- a/tex/context/base/font-inj.lua +++ b/tex/context/base/font-inj.lua @@ -14,6 +14,7 @@ if not nodes.properties then return end local next, rawget = next, rawget local utfchar = utf.char +local fastcopy = table.fastcopy local trace_injections = false trackers.register("fonts.injections", function(v) trace_injections = v end) @@ -89,6 +90,28 @@ function injections.reset(n) end end +function injections.copy(target,source) + local sp = rawget(properties,source) + if sp then + local tp = rawget(properties,target) + local si = rawget(sp,"injections") + if si then + si = fastcopy(si) + if tp then + tp.injections = si + else + propertydata[target] = { + injections = si, + } + end + else + if tp then + tp.injections = nil + end + end + end +end + function injections.setligaindex(n,index) local p = rawget(properties,n) if p then @@ -114,7 +137,7 @@ function injections.getligaindex(n,default) if p then local i = rawget(p,"injections") if i then - return p.ligaindex or default + return i.ligaindex or default end end return default @@ -186,12 +209,14 @@ function injections.setpair(current,factor,rlmode,r2lflag,spec,injection) -- r2l if p then local i = rawget(p,"injections") if i then - if leftkern ~= 0 or rightkern ~= 0 then - i.leftkern = i.leftkern or 0 + leftkern - i.rightkern = i.rightkern or 0 + rightkern + if leftkern ~= 0 then + i.leftkern = (i.leftkern or 0) + leftkern + end + if rightkern ~= 0 then + i.rightkern = (i.rightkern or 0) + rightkern end if yoffset ~= 0 then - i.yoffset = i.yoffset or 0 + yoffset + i.yoffset = (i.yoffset or 0) + yoffset end elseif leftkern ~= 0 or rightkern ~= 0 then p.injections = { @@ -241,7 +266,7 @@ function injections.setkern(current,factor,rlmode,x,injection) if p then local i = rawget(p,injection) if i then - i.leftkern = dx + i.leftkern or 0 + i.leftkern = dx + (i.leftkern or 0) else p[injection] = { leftkern = dx, @@ -312,7 +337,7 @@ local function show(n,what,nested,symbol) if n then local p = rawget(properties,n) if p then - local i = p[what] + local i = rawget(p,what) if i then local leftkern = i.leftkern or 0 local rightkern = i.rightkern or 0 @@ -354,9 +379,9 @@ local function showsub(n,what,where) report_injections("end subrun") end -local function trace(head) - report_injections("begin run: %s kerns, %s pairs, %s marks and %s cursives registered", - nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) +local function trace(head,where) + report_injections("begin run %s: %s kerns, %s pairs, %s marks and %s cursives registered", + where or "",nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) local n = head while n do local id = getid(n) @@ -479,7 +504,9 @@ local function inject_marks(marks,nofmarks) local pp = rawget(properties,p) if pp then pp = rawget(pp,"injections") - rightkern = pp.rightkern + if pp then + rightkern = pp.rightkern + end end if rightkern then -- x and w ~= 0 if pn.markdir < 0 then @@ -495,7 +522,7 @@ local function inject_marks(marks,nofmarks) else ox = px - pn.markx - leftkern end - -- report_injections("l2r case 1: %p",ox) +-- report_injections("l2r case 1: %p",ox) end else -- we need to deal with fonts that have marks with width @@ -529,7 +556,7 @@ local function inject_marks(marks,nofmarks) end setfield(n,"yoffset",oy) else - -- normally this can't happen (only when in trace mode which is a special case anyway) + -- normally this can't happen (only when in trace mode which is a special case anyway) -- report_injections("missing mark anchor %i",pn.markbase or 0) end end @@ -551,7 +578,7 @@ local function inject_cursives(glyphs,nofglyphs) if cursivex then if cursiveanchor then if cursivex ~= 0 then - pn.leftkern = pn.leftkern or 0 + cursivex + pn.leftkern = (pn.leftkern or 0) + cursivex end if lastanchor then if maxc == 0 then @@ -644,7 +671,7 @@ end local function inject_everything(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"everything") end local glyphs, nofglyphs, marks, nofmarks if nofregisteredpairs > 0 then @@ -656,7 +683,7 @@ local function inject_everything(head,where) if nofregisteredcursives > 0 then inject_cursives(glyphs,nofglyphs) end - if nofregisteredmarks > 0 then + if nofregisteredmarks > 0 then -- and nofmarks > 0 inject_marks(marks,nofmarks) end inject_kerns(head,glyphs,nofglyphs) @@ -675,7 +702,7 @@ end local function inject_kerns_only(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"kerns") end local n = head local p = nil @@ -818,7 +845,7 @@ end local function inject_pairs_only(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"pairs") end -- local n = head diff --git a/tex/context/base/font-nod.lua b/tex/context/base/font-nod.lua index 636a668bc..26c736582 100644 --- a/tex/context/base/font-nod.lua +++ b/tex/context/base/font-nod.lua @@ -11,10 +11,10 @@ if not modules then modules = { } end modules ['font-nod'] = { might become a runtime module instead. This module will be cleaned up!</p> --ldx]]-- -local tonumber, tostring = tonumber, tostring +local tonumber, tostring, rawget = tonumber, tostring, rawget local utfchar = utf.char -local concat = table.concat -local match, gmatch, concat, rep = string.match, string.gmatch, table.concat, string.rep +local concat, fastcopy = table.concat, table.fastcopy +local match, rep = string.match, string.rep local report_nodes = logs.reporter("fonts","tracing") @@ -92,6 +92,25 @@ local fontcharacters = hashes.characters local fontproperties = hashes.properties local fontparameters = hashes.parameters +local properties = nodes.properties.data + +-- direct.set_properties_mode(true,false) +-- direct.set_properties_mode(true,true) -- default + +local function freeze(h,where) + -- report_nodes("freezing %s",where) + for n in traverse_nodes(tonut(h)) do -- todo: disc but not traced anyway + local p = properties[n] + if p then + local i = p.injections if i then p.injections = fastcopy(i) end + -- local i = r.preinjections if i then p.preinjections = fastcopy(i) end + -- local i = r.postinjections if i then p.postinjections = fastcopy(i) end + -- local i = r.replaceinjections if i then p.replaceinjections = fastcopy(i) end + -- only injections + end + end +end + function char_tracers.collect(head,list,tag,n) head = tonut(head) n = n or 0 @@ -269,7 +288,8 @@ end function step_tracers.glyphs(n,i) local c = collection[i] if c then - local b = hpack_node_list(copy_node_list(c)) -- multiple arguments + local c = copy_node_list(c) + local b = hpack_node_list(c) -- multiple arguments setbox(n,b) end end @@ -414,10 +434,11 @@ end function step_tracers.check(head) if collecting then step_tracers.reset() - local n = copy_node_list(tonut(head)) + local h = tonut(head) + local n = copy_node_list(h) + freeze(n,"check") injections.keepcounts(n) -- one-time injections.handler(n,"trace") - -- handlers.protectglyphs(n) -- can be option protect_glyphs(n) collection[1] = n end @@ -427,10 +448,11 @@ function step_tracers.register(head) if collecting then local nc = #collection+1 if messages[nc] then - local n = copy_node_list(tonut(head)) + local h = tonut(head) + local n = copy_node_list(h) + freeze(n,"register") injections.keepcounts(n) -- one-time injections.handler(n,"trace") - -- handlers.protectglyph s(n) -- can be option protect_glyphs(n) collection[nc] = n end diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua index e1be424b1..52fcbcbd6 100644 --- a/tex/context/base/font-otn.lua +++ b/tex/context/base/font-otn.lua @@ -42,7 +42,7 @@ if not modules then modules = { } end modules ['font-otn'] = { -- -- beware: -- --- we do some disc juglling where we need to keep in mind that the +-- we do some disc jugling where we need to keep in mind that the -- pre, post and replace fields can have prev pointers to a nesting -- node ... i wonder if that is still needed -- @@ -274,6 +274,7 @@ local setcursive = injections.setcursive local setkern = injections.setkern local setpair = injections.setpair local resetinjection = injections.reset +local copyinjection = injections.copy local setligaindex = injections.setligaindex local getligaindex = injections.getligaindex @@ -385,10 +386,13 @@ local function copy_glyph(g) -- next and prev are untouched ! if components then setfield(g,"components",nil) local n = copy_node(g) + copyinjection(n,g) -- we need to preserve the lig indices setfield(g,"components",components) return n else - return copy_node(g) + local n = copy_node(g) + copyinjection(n,g) -- we need to preserve the lig indices + return n end end @@ -613,7 +617,9 @@ local function toligature(kind,lookupname,head,start,stop,char,markflag,discfoun if trace_marks then logwarning("%s: keep mark %s, gets index %s",pref(kind,lookupname),gref(char),getligaindex(start)) end - head, current = insert_node_after(head,current,copy_node(start)) -- unlikely that mark has components + local n = copy_node(start) + copyinjection(n,start) + head, current = insert_node_after(head,current,n) -- unlikely that mark has components elseif trace_marks then logwarning("%s: delete mark %s",pref(kind,lookupname),gref(char)) end diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv index 6176c33ab..c184a2118 100644 --- a/tex/context/base/font-pre.mkiv +++ b/tex/context/base/font-pre.mkiv @@ -585,6 +585,7 @@ \definefontfeature[f:smallcaps][smcp=yes] \definefontfeature[f:oldstyle] [onum=yes] \definefontfeature[f:tabular] [tnum=yes] +\definefontfeature[f:superiors][sups=yes] \definealternativestyle [\v!smallcaps] [\setsmallcaps] [\setsmallcaps] \definealternativestyle [\v!oldstyle] [\setoldstyle ] [\setoldstyle ] @@ -592,6 +593,7 @@ \unexpanded\def\setsmallcaps{\doaddfeature{f:smallcaps}} \unexpanded\def\setoldstyle {\doaddfeature{f:oldstyle}} \unexpanded\def\settabular {\doaddfeature{f:tabular}} +\unexpanded\def\setsuperiors{\doaddfeature{f:superiors}} %D \macros %D {tinyfont} @@ -669,3 +671,30 @@ % % /lessorequalslant % /greaterorequalslant + +% \unprotect +% +% \definehighlight[\v!italic ][\c!command=\v!no,\c!style=\v!italic] +% \definehighlight[\v!bold ][\c!command=\v!no,\c!style=\v!bold] +% \definehighlight[\v!bolditalic][\c!command=\v!no,\c!style=\v!bolditalic] +% \definehighlight[\v!mono] [\c!command=\v!no,\c!style=\v!mono] +% \definehighlight[\v!monobold] [\c!command=\v!no,\c!style=\v!monobold] +% +% \definehighlight[important] [\c!command=\v!no,\c!style=\v!bold] +% \definehighlight[unimportant] [\c!command=\v!no,\c!color=darkgray] +% \definehighlight[warning] [\c!command=\v!no,\c!style=\v!bold,\c!color=darkblue] +% \definehighlight[error] [\c!command=\v!no,\c!style=\v!bold,\c!color=darkred] +% +% \protect +% +% \starttext +% \highlight[italic] {italic} +% \highlight[bolditalic] {bolditalic} +% \highlight[bold] {bold} +% \highlight[mono] {mono} +% \highlight[monobold] {monobold} +% \highlight[important] {important} +% \highlight[unimportant]{unimportant} +% \highlight[warning] {warning} +% \highlight[error] {error} +% \stoptext diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua index 49df94e68..ab0378851 100644 --- a/tex/context/base/font-tfm.lua +++ b/tex/context/base/font-tfm.lua @@ -72,15 +72,15 @@ local function read_from_tfm(specification) properties.filename = specification.filename properties.format = fonts.formats.tfm -- better than nothing parameters.size = size - shared.rawdata = { } - shared.features = features - shared.processes = next(features) and tfm.setfeatures(tfmdata,features) or nil -- tfmdata.properties = properties tfmdata.resources = resources tfmdata.parameters = parameters tfmdata.shared = shared -- + shared.rawdata = { } + shared.features = features + shared.processes = next(features) and tfm.setfeatures(tfmdata,features) or nil parameters.slant = parameters.slant or parameters[1] or 0 parameters.space = parameters.space or parameters[2] or 0 parameters.space_stretch = parameters.space_stretch or parameters[3] or 0 diff --git a/tex/context/base/lang-ini.lua b/tex/context/base/lang-ini.lua index 27c4f774e..0c3d9d80b 100644 --- a/tex/context/base/lang-ini.lua +++ b/tex/context/base/lang-ini.lua @@ -58,9 +58,9 @@ local numbers = languages.numbers languages.data = languages.data or { } local data = languages.data -storage.register("languages/numbers", numbers, "languages.numbers") storage.register("languages/registered",registered,"languages.registered") storage.register("languages/associated",associated,"languages.associated") +storage.register("languages/numbers", numbers, "languages.numbers") storage.register("languages/data", data, "languages.data") local nofloaded = 0 diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv index a55c4665a..71b631be9 100644 --- a/tex/context/base/lang-ini.mkiv +++ b/tex/context/base/lang-ini.mkiv @@ -111,6 +111,44 @@ \csname\??language\s!default#2\endcsname \fi\fi\fi} +\def\mainlanguageparameter#1% + {\ifcsname\??language\currentmainlanguage#1\endcsname + \csname\??language\currentmainlanguage#1\endcsname + \else\ifcsname\??language\currentmainlanguage\s!default\endcsname + \expandafter\specificlanguageparameter\csname\??language\currentmainlanguage\s!default\endcsname{#1}% + \else\ifcsname\??language\s!default#1\endcsname + \csname\??language\s!default#1\endcsname + \fi\fi\fi} + +\def\currentusedlanguage{\currentlanguage} + +\let\usedlanguageparameter\languageparameter + +\def\askedlanguageparameter#1% assumes \currentusedlanguage being set + {\ifcsname\??language\currentusedlanguage#1\endcsname + \csname\??language\currentusedlanguage#1\endcsname + \else\ifcsname\??language\currentusedlanguage\s!default\endcsname + \expandafter\specificlanguageparameter\csname\??language\currentusedlanguage\s!default\endcsname{#1}% + \else\ifcsname\??language\s!default#1\endcsname + \csname\??language\s!default#1\endcsname + \fi\fi\fi} + +\unexpanded\def\setlanguageparameter#1% + {\edef\currentusedlanguage{\reallanguagetag{#1\c!language}}% + %\let\setlanguageparameter\gobbleoneargument + \ifx\currentusedlanguage\empty + \let\currentusedlanguage \currentlanguage + \let\usedlanguageparameter\languageparameter + \else\ifx\currentusedlanguage\v!global + \let\currentusedlanguage \currentmainlanguage + \let\usedlanguageparameter\mainlanguageparameter + \else\ifx\currentusedlanguage\v!local + \let\currentusedlanguage \currentlanguage + \let\usedlanguageparameter\languageparameter + \else + \let\usedlanguageparameter\askedlanguageparameter + \fi\fi\fi} + \unexpanded\def\setupcurrentlanguage[#1]% {\setcurrentlanguage\currentmainlanguage{#1}} diff --git a/tex/context/base/lang-lab.lua b/tex/context/base/lang-lab.lua index 1540bc04e..1675146be 100644 --- a/tex/context/base/lang-lab.lua +++ b/tex/context/base/lang-lab.lua @@ -63,6 +63,7 @@ function labels.define(class,name,prefixed) if list then report_labels("defining label set %a",name) for tag, data in next, list do + tag = variables[tag] or tag if data.hidden then -- skip elseif prefixed then diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index 27d35776d..c5c2adc01 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -237,7 +237,8 @@ {\expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}} \unexpanded\def\setlabeltextpair#1#2#3#4#5% a fast one for usage at the Lua end - {\expandafter\def\csname\??label#1:\reallanguagetag{#2}:#3\endcsname{{#4}{#5}}} % class tag key left right + {%\writestatus{!!!!}{#1:\reallanguagetag{#2}:#3}% + \expandafter\def\csname\??label#1:\reallanguagetag{#2}:#3\endcsname{{#4}{#5}}} % class tag key left right \def\lang_labels_text_prefix_copy[#1][#2]% {\ifsecondargument @@ -319,7 +320,7 @@ %D \assigntranslation[en=something,nl=iets]\to\command %D \stoptyping -\def\assigntranslation[#1]\to#2% +\unexpanded\def\assigntranslation[#1]\to#2% bad, this \to {\getparameters[\??translation][#1]% \edef#2{\csname\??translation\currentlanguage\endcsname}} diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua index dd83a44db..ac608baa4 100644 --- a/tex/context/base/lpdf-ano.lua +++ b/tex/context/base/lpdf-ano.lua @@ -331,7 +331,7 @@ local f_fith = formatters["<< /D [ %i 0 R /FitH %0.3F ] >>"] local f_fitv = formatters["<< /D [ %i 0 R /FitV %0.3F ] >>"] local f_fitbh = formatters["<< /D [ %i 0 R /FitBH %0.3F ] >>"] local f_fitbv = formatters["<< /D [ %i 0 R /FitBV %0.3F ] >>"] -local f_fitr = formatters["<< /D [ %i 0 R /FitR [ %0.3F %0.3F %0.3F %0.3F ] ] >>"] +local f_fitr = formatters["<< /D [ %i 0 R /FitR %0.3F %0.3F %0.3F %0.3F ] >>"] local v_standard = variables.standard local v_frame = variables.frame @@ -344,15 +344,28 @@ local v_tight = variables.tight -- nicer is to create dictionaries and set properties but it's a bit overkill +-- The problem with the following settings is that they are guesses: we never know +-- if a box is part of something larger that needs to be in view, or that we are +-- dealing with a vbox or vtop so the used h/d values cannot be trusted in a tight +-- view. Of course some decent additional offset would be nice so maybe i'll add +-- that some day. I never use anything else than 'fit' anyway as I think that the +-- document should fit the device (and vice versa). In fact, with todays swipe +-- and finger zooming this whole view is rather useless and as with any zooming +-- one looses the overview and keeps zooming. + local destinationactions = { - [v_standard] = function(r,w,h,d) return f_xyz (r,pdfrectangle(w,h,d)) end, -- local left,top with zoom (0 in our case) - [v_frame] = function(r,w,h,d) return f_fitr (r,pdfrectangle(w,h,d)) end, -- fit rectangle in window - [v_width] = function(r,w,h,d) return f_fith (r, gethpos() *factor) end, -- top coordinate, fit width of page in window - [v_minwidth] = function(r,w,h,d) return f_fitbh(r, gethpos() *factor) end, -- top coordinate, fit width of content in window - [v_height] = function(r,w,h,d) return f_fitv (r,(getvpos()+h)*factor) end, -- left coordinate, fit height of page in window - [v_minheight] = function(r,w,h,d) return f_fitbv(r,(getvpos()+h)*factor) end, -- left coordinate, fit height of content in window - [v_fit] = f_fit, -- fit page in window - [v_tight] = f_fitb, -- fit content in window + -- [v_standard] = function(r,w,h,d) return f_xyz (r,pdfrectangle(w,h,d)) end, -- local left,top with zoom (0 in our case) + [v_standard] = function(r,w,h,d) return f_xyz (r,gethpos()*factor,(getvpos()+h)*factor) end, -- local left,top with no zoom + [v_frame] = function(r,w,h,d) return f_fitr (r,pdfrectangle(w,h,d)) end, -- fit rectangle in window + -- [v_width] = function(r,w,h,d) return f_fith (r,gethpos()*factor) end, -- top coordinate, fit width of page in window + [v_width] = function(r,w,h,d) return f_fith (r,(getvpos()+h)*factor) end, -- top coordinate, fit width of page in window + -- [v_minwidth] = function(r,w,h,d) return f_fitbh(r,gethpos()*factor) end, -- top coordinate, fit width of content in window + [v_minwidth] = function(r,w,h,d) return f_fitbh(r,(getvpos()+h)*factor) end, -- top coordinate, fit width of content in window + -- [v_height] = function(r,w,h,d) return f_fitv (r,(getvpos()+h)*factor) end, -- left coordinate, fit height of page in window + [v_height] = function(r,w,h,d) return f_fitv (r,gethpos()*factor) end, -- left coordinate, fit height of page in window + -- [v_minheight] = function(r,w,h,d) return f_fitbv(r,(getvpos()+h)*factor) end, -- left coordinate, fit height of content in window + [v_minheight] = function(r,w,h,d) return f_fitbv(r,gethpos()*factor) end, -- left coordinate, fit height of content in window [v_fit] = f_fit, -- fit page in window + [v_tight] = f_fitb, -- fit content in window } local mapping = { @@ -383,7 +396,7 @@ end) local function flushdestination(width,height,depth,names,view) local r = pdfpagereference(texgetcount("realpageno")) - if view == defaultview then + if view == defaultview or not view or view == "" then r = pagedestinations[r] else local action = view and destinationactions[view] or defaultaction diff --git a/tex/context/base/lpdf-mis.lua b/tex/context/base/lpdf-mis.lua index 748567125..a1b12d8c0 100644 --- a/tex/context/base/lpdf-mis.lua +++ b/tex/context/base/lpdf-mis.lua @@ -241,14 +241,19 @@ lpdf.registerdocumentfinalizer(flushjavascripts,"javascripts") -- -- -- local pagespecs = { - [variables.max] = { "FullScreen", false, false }, - [variables.bookmark] = { "UseOutlines", false, false }, - [variables.fit] = { "UseNone", false, true }, - [variables.doublesided] = { "UseNone", "TwoColumnRight", true }, - [variables.singlesided] = { "UseNone", false, false }, - [variables.default] = { "UseNone", "auto", false }, - [variables.auto] = { "UseNone", "auto", false }, - [variables.none] = { false, false, false }, + [variables.max] = { mode = "FullScreen", layout = false, fit = false, fixed = false, duplex = false }, + [variables.bookmark] = { mode = "UseOutlines", layout = false, fit = false, fixed = false, duplex = false }, + [variables.fit] = { mode = "UseNone", layout = false, fit = true, fixed = false, duplex = false }, + [variables.doublesided] = { mode = "UseNone", layout = "TwoColumnRight", fit = true, fixed = false, duplex = false }, + [variables.singlesided] = { mode = "UseNone", layout = false, fit = false, fixed = false, duplex = false }, + [variables.default] = { mode = "UseNone", layout = "auto", fit = false, fixed = false, duplex = false }, + [variables.auto] = { mode = "UseNone", layout = "auto", fit = false, fixed = false, duplex = false }, + [variables.none] = { mode = false, layout = false, fit = false, fixed = false, duplex = false }, + -- new + [variables.fixed] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = false }, -- noscale + [variables.landscape] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = "DuplexFlipShortEdge" }, + [variables.portrait] = { mode = "UseNone", layout = "auto", fit = false, fixed = true, duplex = "DuplexFlipLongEdge" }, + } local pagespec, topoffset, leftoffset, height, width, doublesided = "default", 0, 0, 0, 0, false @@ -279,34 +284,50 @@ function codeinjections.setupcanvas(specification) end local function documentspecification() + if not pagespec or pagespec == "" then + pagespec = variables.default + end + -- local settings = utilities.parsers.settings_to_array(pagespec) + -- local spec = pagespecs[variables.default] + -- for i=1,#settings do + -- local s = pagespecs[settings[i]] + -- if s then + -- for k, v in next, s do + -- spec[k] = v + -- end + -- end + -- end local spec = pagespecs[pagespec] or pagespecs[variables.default] - if spec then - local mode, layout, fit = spec[1], spec[2], spec[3] - if layout == variables.auto then - if doublesided then - spec = pagespecs[variables.doublesided] -- to be checked voor interfaces - if spec then - mode, layout, fit = spec[1], spec[2], spec[3] - end - else - layout = false + if spec.layout == "auto" then + if doublesided then + local s = pagespecs[variables.doublesided] -- to be checked voor interfaces + for k, v in next, s do + spec[k] = v end + else + spec.layout = false end - mode = mode and pdfconstant(mode) - layout = layout and pdfconstant(layout) - fit = fit and pdfdictionary { FitWindow = true } - if layout then - addtocatalog("PageLayout",layout) - end - if mode then - addtocatalog("PageMode",mode) - end - if fit then - addtocatalog("ViewerPreferences",fit) - end - addtoinfo ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP - addtocatalog("Version", pdfconstant(format("1.%s",tex.pdfminorversion))) end + local layout = spec.layout + local mode = spec.mode + local fit = spec.fit + local fixed = spec.fixed + local duplex = spec.duplex + if layout then + addtocatalog("PageLayout",pdfconstant(layout)) + end + if mode then + addtocatalog("PageMode",pdfconstant(mode)) + end + if fit or fixed or duplex then + addtocatalog("ViewerPreferences",pdfdictionary { + FitWindow = fit and true or nil, + PrintScaling = fixed and pdfconstant("None") or nil, + Duplex = duplex and pdfconstant(duplex) or nil, + }) + end + addtoinfo ("Trapped", pdfconstant("False")) -- '/Trapped' in /Info, 'Trapped' in XMP + addtocatalog("Version", pdfconstant(format("1.%s",tex.pdfminorversion))) end -- temp hack: the mediabox is not under our control and has a precision of 4 digits diff --git a/tex/context/base/luat-ini.mkiv b/tex/context/base/luat-ini.mkiv index e47e8f74b..168b52095 100644 --- a/tex/context/base/luat-ini.mkiv +++ b/tex/context/base/luat-ini.mkiv @@ -204,6 +204,7 @@ \def\setdocumentargumentdefault#1#2{\ctxlua{document.setdefaultargument("#1","#2")}} \def\getdocumentfilename #1{\ctxlua{document.getfilename("#1")}} \def\getdocumentargument #1{\ctxlua{document.getargument("#1")}} +\def\setdocumentargument #1#2{\ctxlua{document.setargument("#1","#2")}} \def\getdocumentargumentdefault#1#2{\ctxlua{document.getargument("#1","#2")}} \def\doifdocumentargumentelse #1{\doifsomethingelse{\getdocumentargument{#1}}} \def\doifdocumentargument #1{\doifsomething {\getdocumentargument{#1}}} @@ -323,4 +324,21 @@ \def\ctxfunction#1% {\csname\??ctxfunction#1\endcsname} +% In theory this is faster due to the call not being wrapped in a function but in +% practice the speedup can't be noticed. The actions called for often have lots of +% lookups so an extra one doesn't matter much. The kind of calls differs a lot per +% document and often there are other ways to optimize a style. For instance we can +% gain a lot when defining a font, but when a frozen definition is used that gain +% gets completely lost. For some calls (take list writers) it can get worse if only +% because readability gets worse and passing is already efficient due to selective +% flushing, while with the token scanners one has to scan all of them. + +% \startctxfunctiondefinition foo commands.foo() \stopctxfunctiondefinition +% +% \installctxfunction\foo{commands.foo} + +\normalprotected\def\installctxfunction#1#2% + {\expandafter\chardef\csname\??luafunction\checkedstrippedcsname#1\endcsname\ctxcommand{ctxfunction("#2",true)}\relax + \expandafter\edef\csname\checkedstrippedcsname#1\endcsname{\noexpand\luafunction\csname\??luafunction\checkedstrippedcsname#1\endcsname}} + \protect \endinput diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua index 9c3f792dd..15bc14132 100644 --- a/tex/context/base/luat-mac.lua +++ b/tex/context/base/luat-mac.lua @@ -144,7 +144,10 @@ local grammar = { "converter", * V("texbody") * stopcode * poplocal, - texbody = ( V("definition") + texbody = ( +leadingcomment -- new per 2015-03-03 (ugly) ++ + V("definition") + identifier + V("braced") + (1 - stopcode) diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 0092ea4f4..a7cdff862 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -56,7 +56,7 @@ %def\xmlcontent #1{\ctxlxml{content("#1")}} %def\xmlflushstripped #1{\ctxlxml{strip("#1",true)}} \def\xmldirect #1{\ctxlxml{direct("#1")}} % in loops, not dt but root -\def\xmlidx #1#2#3{\ctxlxml{idx("#1","#2",\number#3)}} +\def\xmlidx #1#2#3{\ctxlxml{idx("#1","#2",\number#3)}} % not ok \def\xmlinclude #1#2#3{\ctxlxml{include("#1","#2","#3",true)}} \def\xmlincludeoptions#1#2#3#4{\ctxlxml{include("#1","#2","#3","#4")}} \def\xmlinclusion #1{\ctxlxml{inclusion("#1")}} @@ -100,7 +100,19 @@ \def\xmltoparameters #1{\ctxlxml{toparameters("#1")}} -\def\xmltofile #1#2#3{\ctxlxml{tofile("#1","#2","#3")}} % id pattern filename +\def\xmltofile #1#2#3{\ctxlxml{tofile("#1","#2","#3")}} % id pattern filename +\def\xmltobuffer #1#2#3{\ctxlxml{tobuffer("#1","#2","#3")}} % id pattern name +\def\xmltobufferverbose #1#2#3{\ctxlxml{tobuffer("#1","#2","#3",true)}} % id pattern name + +% goodie: + +\unexpanded\def\xmlprettyprint#1#2% + {\xmltobufferverbose{#1}{.}{xml-temp}% + \ifdefined\scitebuffer + \scitebuffer[#2][xml-temp]% + \else + \typebuffer[xml-temp][\c!option=#2]% + \fi} % kind of special: @@ -135,8 +147,8 @@ %\ef\xmlsetup#1#2{\setupwithargument{#2}{#1}} \let\xmlsetup\setupwithargumentswapped -\let\xmls\setupwithargumentswapped -\let\xmlw\setupwithargument +\let\xmls\setupwithargumentswapped % hardly any faster +\let\xmlw\setupwithargument % hardly any faster \newtoks \registeredxmlsetups diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 6ab12c898..0a72640d0 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -951,14 +951,18 @@ and then handle the lot.</p> -- new experimental reorganized serialize -local function verbose_element(e,handlers) -- options +local f_attribute = formatters['%s=%q'] + +local function verbose_element(e,handlers,escape) -- options local handle = handlers.handle local serialize = handlers.serialize local ens, etg, eat, edt, ern = e.ns, e.tg, e.at, e.dt, e.rn local ats = eat and next(eat) and { } if ats then + local n = 0 for k,v in next, eat do - ats[#ats+1] = formatters['%s=%q'](k,escaped(v)) + n = n + 1 + ats[n] = f_attribute(k,escaped(v)) end end if ern and trace_entities and ern ~= ens then diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua index c33fdbc49..3e2ce82c5 100644 --- a/tex/context/base/lxml-tex.lua +++ b/tex/context/base/lxml-tex.lua @@ -39,6 +39,7 @@ local xmlapplylpath = xml.applylpath local xmlunprivatized, xmlprivatetoken, xmlprivatecodes = xml.unprivatized, xml.privatetoken, xml.privatecodes local xmlstripelement = xml.stripelement local xmlinclusion, xmlinclusions = xml.inclusion, xml.inclusions +local xmlcontent = xml.content local variables = interfaces and interfaces.variables or { } @@ -1811,3 +1812,17 @@ end texfinalizers.upperall = xmlfinalizers.upperall texfinalizers.lowerall = xmlfinalizers.lowerall + +function lxml.tobuffer(id,pattern,name,unescaped) + local collected = xmlapplylpath(getid(id),pattern) + if collected then + if unescaped then + collected = xmlcontent(collected[1]) -- expanded entities ! + else + collected = tostring(collected[1]) + end + buffers.assign(name,collected) + else + buffers.erase(name) + end +end diff --git a/tex/context/base/m-chart.lua b/tex/context/base/m-chart.lua index 2b9869379..92b079b8d 100644 --- a/tex/context/base/m-chart.lua +++ b/tex/context/base/m-chart.lua @@ -229,6 +229,8 @@ function commands.flow_start_cell(settings) settings = settings, x = 1, y = 1, + realx = 1, + realy = 1, name = "", } end @@ -325,9 +327,13 @@ local function inject(includedata,data,hash) if si.include then inject(si,data,hash) else + local x = si.x + xoffset + local y = si.y + yoffset local t = { - x = si.x + xoffset, - y = si.y + yoffset, + x = x, + y = y, + realx = x, + realy = y, settings = settings, } setmetatableindex(t,si) @@ -451,10 +457,12 @@ function commands.flow_set_location(x,y) else y = tonumber(y) end - temp.x = x or 1 - temp.y = y or 1 - last_x = x or last_x - last_y = y or last_y + temp.x = x or 1 + temp.y = y or 1 + temp.realx = x or 1 + temp.realy = y or 1 + last_x = x or last_x + last_y = y or last_y end function commands.flow_set_connection(location,displacement,name) @@ -686,6 +694,7 @@ local function getchart(settings,forced_x,forced_y,forced_nx,forced_ny) print("no such chart",chartname) return end +-- chart = table.copy(chart) chart = expanded(chart,settings) local chartsettings = chart.settings.chart local autofocus = chart.settings.chart.autofocus @@ -746,8 +755,8 @@ local function getchart(settings,forced_x,forced_y,forced_nx,forced_ny) -- relocate cells for i=1,#data do local cell = data[i] - cell.x = cell.x - minx + 1 - cell.y = cell.y - miny + 1 + cell.x = cell.realx - minx + 1 + cell.y = cell.realy - miny + 1 end chart.from_x = 1 chart.from_y = 1 @@ -756,7 +765,9 @@ local function getchart(settings,forced_x,forced_y,forced_nx,forced_ny) chart.nx = nx chart.ny = ny -- - -- inspect(chart) + chart.shift_x = minx + 1 + chart.shift_y = miny + 1 + -- return chart end @@ -854,7 +865,7 @@ local function splitchart(chart) local delta_x = splitsettings.dx or 0 local delta_y = splitsettings.dy or 0 -- - report_chart("spliting %a from (%s,%s) upto (%s,%s) into (%s,%s) with overlap (%s,%s)", + report_chart("spliting %a from (%s,%s) upto (%s,%s) with steps (%s,%s) and overlap (%s,%s)", name,from_x,from_y,to_x,to_y,step_x,step_y,delta_x,delta_y) -- local part_x = 0 @@ -866,6 +877,9 @@ local function splitchart(chart) if done then last_x = to_x end +-- if first_x >= to_x then +-- break +-- end local part_y = 0 local first_y = from_y while true do @@ -875,14 +889,31 @@ local function splitchart(chart) if done then last_y = to_y end +-- if first_y >= to_y then +-- break +-- end -- +local data = chart.data +for i=1,#data do + local cell = data[i] +-- inspect(cell) + local cx, cy = cell.x, cell.y + if cx >= first_x and cx <= last_x then + if cy >= first_y and cy <= last_y then report_chart("part (%s,%s) of %a is split from (%s,%s) -> (%s,%s)",part_x,part_y,name,first_x,first_y,last_x,last_y) - local x, y, nx, ny = first_x, first_y, last_x - first_x + 1,last_y - first_y + 1 + local x = first_x + local y = first_y + local nx = last_x - first_x + 1 + local ny = last_y - first_y + 1 context.beforeFLOWsplit() context.handleFLOWsplit(function() makechart(getchart(settings,x,y,nx,ny)) -- we need to pass frozen settings ! end) context.afterFLOWsplit() + break + end + end +end -- if done then break diff --git a/tex/context/base/m-chart.mkvi b/tex/context/base/m-chart.mkvi index 2b1a7447c..f910b88eb 100644 --- a/tex/context/base/m-chart.mkvi +++ b/tex/context/base/m-chart.mkvi @@ -177,7 +177,7 @@ corner = "\FLOWlineparameter\c!corner", dash = "\FLOWlineparameter\c!dash", arrow = "\FLOWlineparameter\c!arrow", - offset = "\FLOWlineparameter\c!offset", + offset = \number\dimexpr\FLOWlineparameter\c!offset, }, } }% \endgroup} @@ -259,8 +259,9 @@ \def\FLOW_charts[#name][#settings] {\begingroup - \setupFLOWsplit[\c!state=\v!start,#settings]% - \FLOW_chart[#name][]% + \setupFLOWchart[\c!split=\v!yes]% + \setupFLOWsplit[#settings]% + \module_charts_process[#name][]% \FLOWchart... \endgroup} \appendtoks diff --git a/tex/context/base/m-scite.mkiv b/tex/context/base/m-scite.mkiv index 93349122d..7a8e8b06e 100644 --- a/tex/context/base/m-scite.mkiv +++ b/tex/context/base/m-scite.mkiv @@ -199,6 +199,7 @@ end \installscitecommands \tt \dontcomplain + \setcatcodetable\ctxcatcodes % needed in xml \startscite \getbuffer[lex]% \stopscite @@ -217,6 +218,7 @@ end \installscitecommands \tt \dontcomplain + \setcatcodetable\ctxcatcodes % needed in xml \startscite \getbuffer[lex]% \stopscite diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index 7cee9fb31..4ee7c6826 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -199,7 +199,7 @@ \installcorenamespace{mathstylealternate} % might become a setuphandler -\unexpanded\def\math_set_font_style_alterternate#1% +\unexpanded\def\math_set_font_style_alternate#1% {\ifcsname\??mathstylealternate\fontclass:#1\endcsname \expandafter\math_set_font_alternate\csname\??mathstylealternate\fontclass:#1\endcsname \else\ifcsname\??mathstylealternate#1\endcsname @@ -222,27 +222,27 @@ \let\setmathalphabet \math_set_alphabet \let\setmathfontstyle \math_set_font_style \let\setmathfontalternate \math_set_font_alternate -\let\setmathfontstylealterternate\math_set_font_style_alterternate +\let\setmathfontstylealternate\math_set_font_style_alternate \let\mathalternate \math_set_font_alternate % obsolete -\unexpanded\def\mathupright {\math_set_attribute\s!regular\s!tf\math_set_font_style_alterternate\s!tf} -\unexpanded\def\mathdefault {\math_set_attribute\s!regular\s!it\math_set_font_style_alterternate\s!it} -\unexpanded\def\mathscript {\math_set_alphabet \s!script \math_set_font_style_alterternate\s!script} -\unexpanded\def\mathfraktur {\math_set_alphabet \s!fraktur \math_set_font_style_alterternate\s!fraktur} -\unexpanded\def\mathblackboard{\math_set_alphabet \s!blackboard \math_set_font_style_alterternate\s!blackboard} +\unexpanded\def\mathupright {\math_set_attribute\s!regular\s!tf\math_set_font_style_alternate\s!tf} +\unexpanded\def\mathdefault {\math_set_attribute\s!regular\s!it\math_set_font_style_alternate\s!it} +\unexpanded\def\mathscript {\math_set_alphabet \s!script \math_set_font_style_alternate\s!script} +\unexpanded\def\mathfraktur {\math_set_alphabet \s!fraktur \math_set_font_style_alternate\s!fraktur} +\unexpanded\def\mathblackboard{\math_set_alphabet \s!blackboard \math_set_font_style_alternate\s!blackboard} -\unexpanded\def\mathrm {\math_set_attribute\s!rm\s!tf \math_set_font_style_alterternate\s!tf} -\unexpanded\def\mathss {\math_set_attribute\s!ss\s!tf \math_set_font_style_alterternate\s!tf} -\unexpanded\def\mathtt {\math_set_attribute\s!tt\s!tf \math_set_font_style_alterternate\s!tf} +\unexpanded\def\mathrm {\math_set_attribute\s!rm\s!tf \math_set_font_style_alternate\s!tf} +\unexpanded\def\mathss {\math_set_attribute\s!ss\s!tf \math_set_font_style_alternate\s!tf} +\unexpanded\def\mathtt {\math_set_attribute\s!tt\s!tf \math_set_font_style_alternate\s!tf} -\unexpanded\def\mathtf {\math_set_font_style\s!tf \math_set_font_style_alterternate\s!tf} -\unexpanded\def\mathsl {\math_set_font_style\s!it \math_set_font_style_alterternate\s!it} % no sl -\unexpanded\def\mathit {\math_set_font_style\s!it \math_set_font_style_alterternate\s!it} +\unexpanded\def\mathtf {\math_set_font_style\s!tf \math_set_font_style_alternate\s!tf} +\unexpanded\def\mathsl {\math_set_font_style\s!it \math_set_font_style_alternate\s!it} % no sl +\unexpanded\def\mathit {\math_set_font_style\s!it \math_set_font_style_alternate\s!it} -\unexpanded\def\mathbf {\math_set_font_style\s!bf \math_set_font_style_alterternate\s!bf} -\unexpanded\def\mathbs {\math_set_font_style\s!bi \math_set_font_style_alterternate\s!bi} % no sl -\unexpanded\def\mathbi {\math_set_font_style\s!bi \math_set_font_style_alterternate\s!bi} +\unexpanded\def\mathbf {\math_set_font_style\s!bf \math_set_font_style_alternate\s!bf} +\unexpanded\def\mathbs {\math_set_font_style\s!bi \math_set_font_style_alternate\s!bi} % no sl +\unexpanded\def\mathbi {\math_set_font_style\s!bi \math_set_font_style_alternate\s!bi} \let\tfmath\mathtf % maybe a grouped command \let\slmath\mathsl @@ -280,9 +280,9 @@ \ifdefined\mb \else \let\mb\relax \fi % 1: $\setmathattribute{ss}{bf}3$ -% 2: $\setmathattribute{ss}{bf}\setmathfontstylealterternate{bf}3$ +% 2: $\setmathattribute{ss}{bf}\setmathfontstylealternate{bf}3$ % 3: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}3$ -% 4: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}\setmathfontstylealterternate{bf}3$ +% 4: $\setmathattribute{ss}{bf}\setmathfontstyle{bf}\setmathfontstylealternate{bf}3$ % 5: $e=mc^2 \quad \mb e=mc^2$ \prependtoks diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua index 0dec3a7b2..be1f4a9b5 100644 --- a/tex/context/base/math-noa.lua +++ b/tex/context/base/math-noa.lua @@ -715,6 +715,11 @@ end -- = we check for correction first because accessing nodes is slower -- = the actual glyph is not that important (we can control it with numbers) +-- Italic correction in luatex math is a mess. There are all kind of assumptions based on +-- old fonts and new font. Eventually there should be a flag that can signal to ignore all +-- those heuristics. We want to deal with it ourselves also in the perspective of mxed math +-- and text. + local a_mathitalics = privateattribute("mathitalics") local italics = { } @@ -798,7 +803,7 @@ local function insert_kern(current,kern) return sub end -registertracker("math.italics", function(v) +registertracker("math.italics.visualize", function(v) if v then italic_kern = function(k,font) local ex = 1.5 * fontexheights[font] @@ -843,12 +848,14 @@ italics[math_char] = function(pointer,what,n,parent) report_italics("method %a, adding %p italic correction for lower limit of %C",method,correction,char) end end - else - if sup then + elseif sup then + if pointer ~= sub then setfield(parent,"sup",insert_kern(sup,italic_kern(correction,font))) if trace_italics then report_italics("method %a, adding %p italic correction before superscript after %C",method,correction,char) end + else + -- otherwise we inject twice end end else diff --git a/tex/context/base/mtx-context-arrange.tex b/tex/context/base/mtx-context-arrange.tex index 49920293f..39373f0e2 100644 --- a/tex/context/base/mtx-context-arrange.tex +++ b/tex/context/base/mtx-context-arrange.tex @@ -27,7 +27,7 @@ % --printformat : 2UP, etc % --paperformat=spec : paper*print or paperxprint % -% example: context --extra=arrange --printformat=2UP --paperformat=A4,A3,landscape myfile +% example: context --extra=arrange --printformat=2UP --paperformat=A4*A3,landscape myfile % % end help diff --git a/tex/context/base/mtx-context-listing.tex b/tex/context/base/mtx-context-listing.tex index 8b7efd8a5..a38fc60a9 100644 --- a/tex/context/base/mtx-context-listing.tex +++ b/tex/context/base/mtx-context-listing.tex @@ -24,11 +24,18 @@ % --scite : pretty print comform suffix using scite lexer % --bodyfont=list : additional bodyfont settings % --paperformat=spec : paper*print or paperxprint +% --compact : small margins, small font % % end help \input mtx-context-common.tex +\doifdocumentargument {compact} { + \setdocumentargument{topspace} {5mm} + \setdocumentargument{backspace}{5mm} + \setdocumentargument{bodyfont} {8pt} +} + \setupbodyfont [dejavu,11pt,tt,\getdocumentargument{bodyfont}] % dejavu is more complete diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 11414f38b..1fb951048 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -1125,6 +1125,85 @@ % % \syst_helpers_do_do_process_comma_item##1,]\relax % \global\advance\commalevel \minusone +% The next one is experimental (and used in publications): + +\let\c_mult_set\relax + +\unexpanded\def\mult_interfaces_install_definition_set#1#2#3#4#5#6#7% + {\newcount#3% + \let#6\empty + \unexpanded\def#2% + {\expandafter\let\expandafter\c_mult_set\csname #1_t_#6\endcsname + \ifx\c_mult_set\relax + \expandafter\newtoks\c_mult_set + \expandafter\let\csname #1_t_#6\endcsname\c_mult_set + \fi} + \unexpanded\def#4##1% + {\pushmacro#6% + \advance#3\plusone + \edef#6{##1}% + \unprotect}% + \unexpanded\def#5% + {\protect + \advance#3\minusone + \popmacro#6}% + \unexpanded\def#7##1% + {\edef#6{##1}% + #2% + \the\c_mult_set\relax}} + +\unexpanded\def\installdefinitionset#1#2% + {\normalexpanded + {\mult_interfaces_install_definition_set + {\noexpand#1}% \??aa + \expandafter\noexpand\csname set_#2_toks\endcsname + \expandafter\noexpand\csname #2_nesting_depth\endcsname + \expandafter\noexpand\csname push#2\endcsname + \expandafter\noexpand\csname pop#2\endcsname + \expandafter\noexpand\csname current#2\endcsname + \expandafter\noexpand\csname use#2\endcsname}} + +\unexpanded\def\mult_interfaces_install_definition_set_member#1#2#3#4#5#6#7#8#9% no everysetups etc + {\let#5#2% + \unexpanded\def#2% + {\ifcase#4\relax\expandafter#5\else\expandafter#6\fi}% + \unexpanded\def#6% + {\dodoubleempty#7}% + \unexpanded\def#7[##1][##2]% + {\ifsecondargument + #3\c_mult_set\expandafter{\the\c_mult_set#9[##1][##2]}% + \else\iffirstargument + #3\c_mult_set\expandafter{\the\c_mult_set#8[##1]}% + \fi\fi}} + +\unexpanded\def\installdefinitionsetmember#1#2#3#4% + {\normalexpanded + {\mult_interfaces_install_definition_set_member + {\noexpand#3}% \??aa + \expandafter\noexpand\csname setup#4\endcsname + \expandafter\noexpand\csname set_#2_toks\endcsname + \expandafter\noexpand\csname #2_nesting_depth\endcsname + \expandafter\noexpand\csname normal_setup_#4\endcsname + \expandafter\noexpand\csname delayed_setup_#4\endcsname + \expandafter\noexpand\csname do_delayed_setup_#4\endcsname + \expandafter\noexpand\csname setup#4_\s!single\endcsname + \expandafter\noexpand\csname setup#4_\s!double\endcsname}} + +%D Another experiment: + +\unexpanded\def\mult_interfaces_install_parent_injector#1#2#3#4% + {\unexpanded\def#4##1% + {\ifx#3\empty + \expandafter\def\csname#1#2:\s!parent\endcsname{#1##1}% + \fi}} + +\unexpanded\def\installparentinjector#1#2% + {\normalexpanded{\mult_interfaces_install_parent_injector + {\noexpand#1}% + \expandafter\noexpand\csname current#2\endcsname + \expandafter\noexpand\csname current#2parent\endcsname + \expandafter\noexpand\csname inject#2parent\endcsname}} + \protect %\unprotect diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index d1c340c1e..c3d50d83d 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -8969,7 +8969,7 @@ return { ["de"]="mindepth", ["en"]="mindepth", ["fr"]="profondeurmin", - ["it"]="mindeoth", + ["it"]="mindepth", ["nl"]="mindiepte", ["pe"]="کمترین‌عمق", ["ro"]="mindepth", @@ -11545,21 +11545,27 @@ return { }, ["maxheight"]={ ["en"]="maxheight", + ["nl"]="maxhoogte", }, ["maxdepth"]={ ["en"]="maxdepth", + ["nl"]="maxdiepte", }, ["maxwidth"]={ ["en"]="maxwidth", + ["nl"]="maxbreedte", }, ["minheight"]={ ["en"]="minheight", + ["nl"]="minhoogte", }, ["mindepth"]={ ["en"]="mindepth", + ["nl"]="mindiepte", }, ["minwidth"]={ ["en"]="minwidth", + ["nl"]="minbreedte", }, ["short"]={ ["nl"]="kort", diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index e456d1568..438df2308 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -32,13 +32,15 @@ \ctxlua{interfaces.setuserinterface("\userinterfacetag","\userresponsestag")} -% start todo in muld-def.lua: +% start todo in mult-def.lua: \def\v!alphabetic {alphabetic} \def\v!Alphabetic {Alphabetic} \def\c!svgstyle {svgstyle} +\def\c!translate {translate} + \def\c!nextleft {nextleft} \def\c!nextright {nextright} \def\c!nextleftquotation {nextleftquotation} diff --git a/tex/context/base/mult-fun.lua b/tex/context/base/mult-fun.lua index 280d6bd5b..27aa32055 100644 --- a/tex/context/base/mult-fun.lua +++ b/tex/context/base/mult-fun.lua @@ -20,6 +20,7 @@ return { "sqr", "log", "ln", "exp", "inv", "pow", "pi", "radian", "tand", "cotd", "sin", "cos", "tan", "cot", "atan", "asin", "acos", "invsin", "invcos", "invtan", "acosh", "asinh", "sinh", "cosh", + "zmod", "paired", "tripled", "unitcircle", "fulldiamond", "unitdiamond", "fullsquare", -- "halfcircle", "quartercircle", diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii index e31245549..9b0ea7b15 100644 --- a/tex/context/base/mult-it.mkii +++ b/tex/context/base/mult-it.mkii @@ -838,7 +838,7 @@ \setinterfaceconstant{middletext}{testocentro} \setinterfaceconstant{midsentence}{midsentence} \setinterfaceconstant{min}{min} -\setinterfaceconstant{mindepth}{mindeoth} +\setinterfaceconstant{mindepth}{mindepth} \setinterfaceconstant{minheight}{altezzamin} \setinterfaceconstant{minwidth}{ampiezzamin} \setinterfaceconstant{moffset}{moffset} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index 460128d96..22bab6f32 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -156,7 +156,7 @@ return { "then", "begcsname", -- - "strippedcsname", + "strippedcsname","checkedstrippedcsname", -- "firstargumentfalse", "firstargumenttrue", "secondargumentfalse", "secondargumenttrue", @@ -369,7 +369,7 @@ return { "obeylualines", "obeyluatokens", "startluacode", "stopluacode", "startlua", "stoplua", "startctxfunction","stopctxfunction","ctxfunction", - "startctxfunctiondefinition","stopctxfunctiondefinition", + "startctxfunctiondefinition","stopctxfunctiondefinition", "installctxfunction", -- "carryoverpar", -- diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii index 07a16f67a..a84494cfb 100644 --- a/tex/context/base/mult-nl.mkii +++ b/tex/context/base/mult-nl.mkii @@ -288,15 +288,15 @@ \setinterfacevariable{mathematics}{wiskunde} \setinterfacevariable{mathmatrix}{wiskundematrix} \setinterfacevariable{max}{max} -\setinterfacevariable{maxdepth}{maxdepth} -\setinterfacevariable{maxheight}{maxheight} -\setinterfacevariable{maxwidth}{maxwidth} +\setinterfacevariable{maxdepth}{maxdiepte} +\setinterfacevariable{maxheight}{maxhoogte} +\setinterfacevariable{maxwidth}{maxbreedte} \setinterfacevariable{may}{mei} \setinterfacevariable{mediaeval}{mediaeval} \setinterfacevariable{medium}{middel} \setinterfacevariable{middle}{midden} \setinterfacevariable{min}{min} -\setinterfacevariable{mindepth}{mindepth} +\setinterfacevariable{mindepth}{mindiepte} \setinterfacevariable{minheight}{minhoogte} \setinterfacevariable{minwidth}{minbreedte} \setinterfacevariable{mirrored}{gespiegeld} diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua index 1dd944403..774a68718 100644 --- a/tex/context/base/node-fnt.lua +++ b/tex/context/base/node-fnt.lua @@ -319,28 +319,44 @@ function handlers.characters(head) -- skip elseif b == 1 then -- only one font + local front = head == start local range = basefonts[1] - local start, stop = range[1], range[2] + local start = range[1] + local stop = range[2] if stop then - ligaturing(start,stop) - kerning(start,stop) + start, stop = ligaturing(start,stop) + start, stop = kerning(start,stop) + elseif start then -- safeguard + start = ligaturing(start) + start = kerning(start) else - ligaturing(start) - kerning(start) + -- something bad happened + end + if front then + -- shouldn't happen + head = start end else -- multiple fonts + local front = head == start for i=1,b do local range = basefonts[i] - local start, stop = range[1], range[2] + local start = range[1] + local stop = range[2] if stop then - ligaturing(start,stop) - kerning(start,stop) + start, stop = ligaturing(start,stop) + start, stop = kerning(start,stop) + elseif start then -- safeguard + start = ligaturing(start) + start = kerning(start) else - ligaturing(start) - kerning(start) + -- something bad happened end end + if front then + -- shouldn't happen + head = start + end end stoptiming(nodes) if trace_characters then diff --git a/tex/context/base/node-nut.lua b/tex/context/base/node-nut.lua index cbf1c686c..32f2d57ec 100644 --- a/tex/context/base/node-nut.lua +++ b/tex/context/base/node-nut.lua @@ -86,10 +86,14 @@ if not modules then modules = { } end modules ['node-met'] = { -- luatex 3.9 sec / 54 pps -- luajittex 2.3 sec / 93 pps +local type, rawget = type, rawget + local nodes = nodes local gonuts = nodes.gonuts local direct = node.direct +local fastcopy = table.fastcopy + if type(direct) ~= "table" then return elseif gonuts then @@ -720,3 +724,31 @@ else nodes.getprop = setattr end + +function nuts.copy_properties(source,target,what) + local newprops = propertydata[source] + if not newprops then + -- nothing to copy + return + end + if what then + -- copy one category + newprops = rawget(source,what) + if newprops then + newprops = fastcopy(newprops) + local p = rawget(propertydata,target) + if p then + p[what] = newprops + else + propertydata[target] = { + [what] = newprops, + } + end + end + else + -- copy all properties + newprops = fastcopy(newprops) + propertydata[target] = newprops + end + return newprops -- for checking +end diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua index 4c04e5ea7..9527cc2e8 100644 --- a/tex/context/base/node-ref.lua +++ b/tex/context/base/node-ref.lua @@ -314,7 +314,6 @@ local function inject_areas(head,attribute,make,stack,done,skip,parent,pardir,tx -- see dimensions: this is tricky with split off boxes like inserts -- where we can end up with a first and last spanning lines - local r = getattr(current,attribute) -- test \goto{test}[page(2)] test \gotobox{test}[page(2)] -- test \goto{\TeX}[page(2)] test \gotobox{\hbox {x} \hbox {x}}[page(2)] diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua index 1a9d6f02e..43dd3895e 100644 --- a/tex/context/base/node-res.lua +++ b/tex/context/base/node-res.lua @@ -146,6 +146,7 @@ local user_n = register_nut(new_nut("whatsit",whatsitcodes.userdefine local user_l = register_nut(new_nut("whatsit",whatsitcodes.userdefined)) setfield(user_l,"type",110) -- 44 local user_s = register_nut(new_nut("whatsit",whatsitcodes.userdefined)) setfield(user_s,"type",115) -- 44 local user_t = register_nut(new_nut("whatsit",whatsitcodes.userdefined)) setfield(user_t,"type",116) -- 44 +----- user_c = register_nut(new_nut("whatsit",whatsitcodes.userdefined)) setfield(user_c,"type",108) -- 44 local left_margin_kern = register_nut(new_nut("margin_kern",0)) local right_margin_kern = register_nut(new_nut("margin_kern",1)) local lineskip = register_nut(new_nut("glue",skipcodes.lineskip)) @@ -504,6 +505,17 @@ function nutpool.usertokens(id,tokens) return n end +-- function nutpool.usercode(id,code) +-- local n = copy_nut(user_c) +-- if code then +-- setfield(n,"user_id",id) +-- setfield(n,"value",code) +-- else +-- setfield(n,"value",id) +-- end +-- return n +-- end + function nutpool.special(str) local n = copy_nut(special) setfield(n,"data",str) diff --git a/tex/context/base/node-tex.lua b/tex/context/base/node-tex.lua index 8f4a65450..c9d3091df 100644 --- a/tex/context/base/node-tex.lua +++ b/tex/context/base/node-tex.lua @@ -26,12 +26,12 @@ function kernel.hyphenation(head) end function kernel.ligaturing(head) - local head, tail, done = ligaturing(head) + local head, tail, done = ligaturing(head) -- we return 3 values indeed return head, done end function kernel.kerning(head) - local head, tail, done = kerning(head) + local head, tail, done = kerning(head) -- we return 3 values indeed return head, done end diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index 5f060e4f3..4d5ae5aca 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -78,6 +78,7 @@ local localpar_code = whatcodes.localpar local dir_code = whatcodes.dir local dimenfactors = number.dimenfactors +local fillorders = nodes.fillcodes local formatters = string.formatters -- this will be reorganized: @@ -358,82 +359,175 @@ local stripper = lpeg.patterns.stripzeros -- -- redefined: -local dimenfactors = number.dimenfactors +-- local function nodetodimen(d,unit,fmt,strip) +-- d = tonut(d) -- tricky: direct nuts are an issue +-- if unit == true then +-- unit = "pt" +-- fmt = "%0.5f%s" +-- else +-- unit = unit or 'pt' +-- if not fmt then +-- fmt = "%s%s" +-- elseif fmt == true then +-- fmt = "%0.5f%s" +-- end +-- end +-- local id = getid(d) +-- if id == kern_code then +-- local str = formatters[fmt](getfield(d,"width")*dimenfactors[unit],unit) +-- return strip and lpegmatch(stripper,str) or str +-- end +-- if id == glue_code then +-- d = getfield(d,"spec") +-- end +-- if not d or not getid(d) == gluespec_code then +-- local str = formatters[fmt](0,unit) +-- return strip and lpegmatch(stripper,str) or str +-- end +-- local width = getfield(d,"width") +-- local plus = getfield(d,"stretch_order") +-- local minus = getfield(d,"shrink_order") +-- local stretch = getfield(d,"stretch") +-- local shrink = getfield(d,"shrink") +-- if plus ~= 0 then +-- plus = " plus " .. stretch/65536 .. fillcodes[plus] +-- elseif stretch ~= 0 then +-- plus = formatters[fmt](stretch*dimenfactors[unit],unit) +-- plus = " plus " .. (strip and lpegmatch(stripper,plus) or plus) +-- else +-- plus = "" +-- end +-- if minus ~= 0 then +-- minus = " minus " .. shrink/65536 .. fillcodes[minus] +-- elseif shrink ~= 0 then +-- minus = formatters[fmt](shrink*dimenfactors[unit],unit) +-- minus = " minus " .. (strip and lpegmatch(stripper,minus) or minus) +-- else +-- minus = "" +-- end +-- local str = formatters[fmt](getfield(d,"width")*dimenfactors[unit],unit) +-- return (strip and lpegmatch(stripper,str) or str) .. plus .. minus +-- end +-- +-- local function numbertodimen(d,unit,fmt,strip) +-- if not d then +-- local str = formatters[fmt](0,unit) +-- return strip and lpegmatch(stripper,str) or str +-- end +-- local t = type(d) +-- if t == 'string' then +-- return d +-- elseif t == "number" then +-- if unit == true then +-- unit = "pt" +-- fmt = "%0.5f%s" +-- else +-- unit = unit or 'pt' +-- if not fmt then +-- fmt = "%s%s" +-- elseif fmt == true then +-- fmt = "%0.5f%s" +-- end +-- end +-- local str = formatters[fmt](d*dimenfactors[unit],unit) +-- return strip and lpegmatch(stripper,str) or str +-- else +-- return nodetodimen(d,unit,fmt,strip) -- real node +-- end +-- end -local function nodetodimen(d,unit,fmt,strip) - d = tonut(d) -- tricky: direct nuts are an issue - if unit == true then - unit = "pt" - fmt = "%0.5f%s" - else - unit = unit or 'pt' - if not fmt then - fmt = "%s%s" - elseif fmt == true then - fmt = "%0.5f%s" - end - end - local id = getid(d) +local f_f_f = formatters["%0.5Fpt plus %0.5F%s minus %0.5F%s"] +local f_f_m = formatters["%0.5Fpt plus %0.5F%s minus %0.5Fpt"] +local f_p_f = formatters["%0.5Fpt plus %0.5Fpt minus %0.5F%s"] +local f_p_m = formatters["%0.5Fpt plus %0.5Fpt minus %0.5Fpt"] +local f_f_z = formatters["%0.5Fpt plus %0.5F%s"] +local f_p_z = formatters["%0.5Fpt plus %0.5Fpt"] +local f_z_f = formatters["%0.5Fpt minus %0.5F%s"] +local f_z_m = formatters["%0.5Fpt minus %0.5Fpt"] +local f_z_z = formatters["%0.5Fpt"] + +local tonut = nodes.tonut +local getfield = nodes.nuts.getfield + +local function nodetodimen(n) + n = tonut(n) + local id = getid(n) if id == kern_code then - local str = formatters[fmt](getfield(d,"width")*dimenfactors[unit],unit) - return strip and lpegmatch(stripper,str) or str + local width = getfield(n,"width") + if width == 0 then + return "0pt" + else + return f_z_z(width) + end end if id == glue_code then - d = getfield(d,"spec") + n = getfield(n,"spec") end - if not d or not getid(d) == gluespec_code then - local str = formatters[fmt](0,unit) - return strip and lpegmatch(stripper,str) or str + if not n or not getid(n) == gluespec_code then + return "0pt" end - local width = getfield(d,"width") - local plus = getfield(d,"stretch_order") - local minus = getfield(d,"shrink_order") - local stretch = getfield(d,"stretch") - local shrink = getfield(d,"shrink") - if plus ~= 0 then - plus = " plus " .. stretch/65536 .. fillcodes[plus] + local stretch_order = getfield(n,"stretch_order") + local shrink_order = getfield(n,"shrink_order") + local stretch = getfield(n,"stretch") / 65536 + local shrink = getfield(n,"shrink") / 65536 + local width = getfield(n,"width") / 65536 + if stretch_order ~= 0 then + if shrink_order ~= 0 then + return f_f_f(width,stretch,fillorders[stretch_order],shrink,fillorders[shrink_order]) + elseif shrink ~= 0 then + return f_f_m(width,stretch,fillorders[stretch_order],shrink) + else + return f_f_z(width,stretch,fillorders[stretch_order]) + end + elseif shrink_order ~= 0 then + if stretch ~= 0 then + return f_p_f(width,stretch,shrink,fillorders[shrink_order]) + else + return f_z_f(width,shrink,fillorders[shrink_order]) + end elseif stretch ~= 0 then - plus = formatters[fmt](stretch*dimenfactors[unit],unit) - plus = " plus " .. (strip and lpegmatch(stripper,plus) or plus) - else - plus = "" - end - if minus ~= 0 then - minus = " minus " .. shrink/65536 .. fillcodes[minus] + if shrink ~= 0 then + return f_p_m(width,stretch,shrink) + else + return f_p_z(width,stretch) + end elseif shrink ~= 0 then - minus = formatters[fmt](shrink*dimenfactors[unit],unit) - minus = " minus " .. (strip and lpegmatch(stripper,minus) or minus) + return f_z_m(width,shrink) + elseif width == 0 then + return "0pt" else - minus = "" + return f_z_z(width) end - local str = formatters[fmt](getfield(d,"width")*dimenfactors[unit],unit) - return (strip and lpegmatch(stripper,str) or str) .. plus .. minus end -local function numbertodimen(d,unit,fmt,strip) - if not d then - local str = formatters[fmt](0,unit) - return strip and lpegmatch(stripper,str) or str - end - local t = type(d) - if t == 'string' then - return d - elseif t == "number" then - if unit == true then - unit = "pt" - fmt = "%0.5f%s" + +-- number.todimen(123) +-- number.todimen(123,"cm") +-- number.todimen(123,false,"%F)) + +local f_pt = formatters["%p"] +local f_un = formatters["%F%s"] + +dimenfactors[""] = dimenfactors.pt + +local function numbertodimen(d,unit,fmt) + if not d or d == 0 then + if not unit or unit == "pt" then + return "0pt" + elseif fmt then + return formatters[fmt](0,unit) else - unit = unit or 'pt' - if not fmt then - fmt = "%s%s" - elseif fmt == true then - fmt = "%0.5f%s" - end + return 0 .. unit + end + elseif fmt then + if not unit then + unit = "pt" end - local str = formatters[fmt](d*dimenfactors[unit],unit) - return strip and lpegmatch(stripper,str) or str + return formatters[fmt](d*dimenfactors[unit],unit) + elseif not unit or unit == "pt" then + return f_pt(d) else - return nodetodimen(d,unit,fmt,strip) -- real node + return f_un(d*dimenfactors[unit],unit) end end diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv index a891c998d..e7954931c 100644 --- a/tex/context/base/pack-lyr.mkiv +++ b/tex/context/base/pack-lyr.mkiv @@ -101,9 +101,6 @@ \def\layeranchor{\currentlayer:\the\realpageno} -\unexpanded\def\anch_mark_anchor_box#1% - {\ctxcommand{markregionbox(\number#1,"\layeranchor")}} % needs an hbox - \let\p_pack_layers_doublesided\empty \let\p_pack_layers_state \empty \let\p_pack_layers_option \empty @@ -687,7 +684,7 @@ \ifx\p_pack_layers_position\v!yes \edef\p_pack_layers_region{\layerparameter\c!region}% \ifx\p_pack_layers_region\empty \else - \anch_mark_anchor_box\nextbox + \anch_mark_tagged_box\nextbox\layeranchor \fi \fi \box\nextbox diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index fdffa552d..08fc6b33a 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -143,9 +143,15 @@ \newconstant\pageornamentstate % 0=on 1=one-off 2=always-off +% \appendtoks +% \ifcase\pageornamentstate \or +% \pageornamentstate\zerocount +% \fi +% \to \everyaftershipout + \appendtoks \ifcase\pageornamentstate \or - \pageornamentstate\zerocount + \global\pageornamentstate\zerocount \fi \to \everyaftershipout diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index 716967f27..fc864719b 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -1,4 +1,4 @@ - %D \module +%D \module %D [ file=page-lay, %D version=2000.10.20, % copied from main-001 %D title=\CONTEXT\ Page Macros, @@ -1377,6 +1377,9 @@ \definepapersize [A9] [\c!width=37mm,\c!height=52mm] \definepapersize [A10] [\c!width=26mm,\c!height=37mm] +\definepapersize [A4/2][\c!width=\dimexpr297mm/2\relax,\c!height=210mm] % 148.5mm +%definepapersize [2A5] [\c!width=296mm,\c!height=210mm] % doublewide + \definepapersize [B0] [\c!width=1000mm,\c!height=1414mm] \definepapersize [B1] [\c!width=707mm,\c!height=1000mm] \definepapersize [B2] [\c!width=500mm,\c!height=707mm] @@ -1534,6 +1537,11 @@ [ \c!width=\dimexpr \paperheight+\layouttargetparameter\c!distance\relax, \c!height=\dimexpr2\paperwidth +\layouttargetparameter\c!distance\relax] +\definepapersize + [doublewide] + [ \c!width=\dimexpr2\paperwidth \relax, + \c!height=\dimexpr \paperheight\relax] + % \setuppapersize % [A4][A4] diff --git a/tex/context/base/page-mak.mkvi b/tex/context/base/page-mak.mkvi index c910f281d..9b596b9e5 100644 --- a/tex/context/base/page-mak.mkvi +++ b/tex/context/base/page-mak.mkvi @@ -126,8 +126,7 @@ % nothing \endgroup \else - \endgroup - \page[\p_page]% + \normalexpanded{\endgroup\page[\p_page]}% \fi\fi % some dirty trickery (sorry) for determining if we have % - a layout definition at all diff --git a/tex/context/base/page-run.mkiv b/tex/context/base/page-run.mkiv index 1f2551ebc..7affedcbe 100644 --- a/tex/context/base/page-run.mkiv +++ b/tex/context/base/page-run.mkiv @@ -74,9 +74,11 @@ \startluacode local format, concat = string.format, table.concat +local todimen = number.todimen +local texdimen = tex.dimen -local function todimen(name,unit,fmt) - return number.todimen(tex.dimen[name],unit,fmt) +local function asdimen(name,unit) + return todimen(texdimen[name],unit,"%0.4f") -- 4 is more than enough, even 3 would be okay end local function checkedoptions(options) @@ -122,7 +124,7 @@ function commands.showlayoutvariables(options) for i=1,#dimensions do local d = dimensions[i] if options[d] then - context("%s%s",todimen(name,d,"%0.4f"),d) + context("%s%s",asdimen(name,d),d) context.NC() end end @@ -143,7 +145,7 @@ function commands.showlayoutvariables(options) for i=1,#dimensions do local d = dimensions[i] if options[d] then - result[#result+1] = format("%12s%s",todimen(name,d,"%0.4f"),d) + result[#result+1] = format("%12s%s",asdimen(name,d),d) end end commands.writestatus("layout",format("%-24s %s",interfaces.interfacedcommand(name),concat(result," "))) diff --git a/tex/context/base/publ-aut.lua b/tex/context/base/publ-aut.lua index 764550998..f91ba0039 100644 --- a/tex/context/base/publ-aut.lua +++ b/tex/context/base/publ-aut.lua @@ -56,7 +56,7 @@ local period = P(".") local dash = P("-") local firstcharacter = lpegpatterns.utf8byte local utf8character = lpegpatterns.utf8character -local p_and = space^1 * "and" * space^1 +local p_and = space^1 * (P("and") + P("&&") + P("++")) * space^1 local p_comma = space^0 * comma * space^0 local p_space = space^1 local p_shortone = C((utf8character -dash-period)^1) @@ -93,10 +93,14 @@ local function is_upper(str) return okay and okay.category == "lu" end +-- local cleaner = Cs( ( P("{}")/"" + P(1) )^1 ) + local cache = { } -- 33% reuse on tugboat.bib local nofhits = 0 local nofused = 0 +publications.authorcache = cache + local function makeinitials(firstnames) if firstnames and #firstnames > 0 then local initials = { } @@ -108,7 +112,9 @@ local function makeinitials(firstnames) end local function splitauthorstring(str) - if not str then + if str then + -- str = lpegmatch(cleaner,str) + else return end nofused = nofused + 1 diff --git a/tex/context/base/publ-dat.lua b/tex/context/base/publ-dat.lua index bfb38645b..be5f1eca8 100644 --- a/tex/context/base/publ-dat.lua +++ b/tex/context/base/publ-dat.lua @@ -33,7 +33,7 @@ local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns local textoutf = characters and characters.tex.toutf local settings_to_hash, settings_to_array = utilities.parsers.settings_to_hash, utilities.parsers.settings_to_array local formatters = string.formatters -local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash +local sortedkeys, sortedhash, keys = table.sortedkeys, table.sortedhash, table.keys local xmlcollected, xmltext, xmlconvert = xml.collected, xml.text, xml.convert local setmetatableindex = table.setmetatableindex @@ -42,6 +42,7 @@ local setmetatableindex = table.setmetatableindex local P, R, S, V, C, Cc, Cs, Ct, Carg, Cmt, Cp = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Carg, lpeg.Cmt, lpeg.Cp local p_whitespace = lpegpatterns.whitespace +local p_utf8character = lpegpatterns.utf8character local trace = false trackers.register("publications", function(v) trace = v end) local trace_duplicates = true trackers.register("publications.duplicates", function(v) trace = v end) @@ -145,17 +146,22 @@ local defaulttypes = allocate { url = "url", } +local defaultsets = allocate { + page = { "page", "pages" }, +} + tables.implicits = implicits tables.origins = origins tables.virtuals = virtuals tables.types = defaulttypes +tables.sets = defaultsets tables.privates = privates tables.specials = specials local variables = interfaces and interfaces.variables or setmetatableindex("self") local v_all = variables.all -local v_standard = variables.standard +local v_default = variables.default if not publications.usedentries then function publications.usedentries() @@ -196,8 +202,9 @@ local unknowncategory = function(t,k) required = false, optional = false, virtual = false, - fields = setmetatableindex(unknownfield), - types = defaulttypes, + fields = setmetatableindex(unknownfield), -- this will remember them + types = unknowntypes, + sets = setmetatableindex(defaultsets), -- new, but rather small } t[k] = v return v @@ -219,7 +226,7 @@ local default = { types = setmetatableindex(defaulttypes,unknowntype), } --- maybe at some point we can han da handlers table with per field +-- maybe at some point we can have a handlers table with per field -- a found, fetch, ... method local function checkfield(specification,category,data) @@ -279,10 +286,10 @@ local specifications = setmetatableindex(function(t,name) end setmetatableindex(types,unknowntype) -- - local fields = setmetatableindex(unknownfield) + local fields = setmetatableindex(unknownfield) specification.fields = fields -- - local virtual = specification.virtual + local virtual = specification.virtual if virtual == nil then -- so false is valid virtual = virtuals specification.virtual = virtual @@ -405,7 +412,10 @@ do ----- command = P("\\") * Cc("btxcmd{") * (R("az","AZ")^1) * Cc("}") ----- command = P("\\") * (Carg(1) * C(R("az","AZ")^1) / function(list,c) list[c] = (list[c] or 0) + 1 return "btxcmd{" .. c .. "}" end) + ----- command = P("\\") * (Carg(1) * C(R("az","AZ")^1) * space^0 / function(list,c) list[c] = (list[c] or 0) + 1 return "btxcmd{" .. c .. "}" end) local command = P("\\") * (Carg(1) * C(R("az","AZ")^1) * space^0 / function(list,c) list[c] = (list[c] or 0) + 1 return "btxcmd{" .. c .. "}" end) + local whatever = P("\\") * P(" ")^1 / " " + + P("\\") * ( P("hbox") + P("raise") ) -- bah local somemath = P("$") * ((1-P("$"))^1) * P("$") -- let's not assume nested math ----- character = lpegpatterns.utf8character local any = P(1) @@ -414,15 +424,24 @@ do local one_r = P("}") / "" local two_l = P("{{") / "" local two_r = P("}}") / "" - local special = P("#") / "\\letterhash" + local zero_l_r = P("{}") / "" * #P(1) + local special = P("#") / "\\letterhash " - local filter_0 = S('\\{}') + local filter_0 = S('\\{}#') local filter_1 = (1-filter_0)^0 * filter_0 local filter_2 = Cs( -- {{...}} ... {{...}} -- two_l * (command + special + any - two_r - done)^0 * two_r * done + -- one_l * (command + special + any - one_r - done)^0 * one_r * done + - (somemath + command + special + collapsed + any)^0 + ( + somemath + + whatever + + command + + special + + collapsed + + zero_l_r + + any + )^0 ) -- Currently we expand shortcuts and for large ones (like the acknowledgements @@ -443,57 +462,57 @@ do publicationsstats.nofdefinitions = publicationsstats.nofdefinitions + 1 local fields = dataset.fields local luadata = dataset.luadata + local hashtag = tag if luadata[tag] then local t = tags[tag] local d = dataset.name local n = (t[n] or 0) + 1 t[d] = n + hashtag = tag .. "-" .. n if trace_duplicates then local p = { } for k, v in sortedhash(t) do p[#p+1] = formatters["%s:%s"](k,v) end - report_duplicates("tag %a is present multiple times: % t",tag,p) + report_duplicates("tag %a is present multiple times: % t, assigning hashtag %a",tag,p,hashtag) end - else - local found = luadata[tag] - local index = getindex(dataset,luadata,tag) - local entries = { - category = lower(category), - tag = tag, - index = index, - } - for i=1,#tab,2 do - local original = tab[i] - local normalized = fields[original] - if not normalized then - normalized = lower(original) -- we assume ascii fields - fields[original] = normalized + end + local index = getindex(dataset,luadata,hashtag) + local entries = { + category = lower(category), + tag = tag, + index = index, + } + for i=1,#tab,2 do + local original = tab[i] + local normalized = fields[original] + if not normalized then + normalized = lower(original) -- we assume ascii fields + fields[original] = normalized + end + -- if entries[normalized] then + if rawget(entries,normalized) then + if trace_duplicates then + report_duplicates("redundant field %a is ignored for tag %a in dataset %a",normalized,tag,dataset.name) end - -- if entries[normalized] then - if rawget(entries,normalized) then - if trace_duplicates then - report_duplicates("redundant field %a is ignored for tag %a in dataset %a",normalized,tag,dataset.name) - end - else - local value = tab[i+1] - value = textoutf(value) - if lpegmatch(filter_1,value) then - value = lpegmatch(filter_2,value,1,dataset.commands) -- we need to start at 1 for { } - end - if normalized == "crossref" then - local parent = luadata[value] - if parent then - setmetatableindex(entries,parent) - else - -- warning - end + else + local value = tab[i+1] + value = textoutf(value) + if lpegmatch(filter_1,value) then + value = lpegmatch(filter_2,value,1,dataset.commands) -- we need to start at 1 for { } + end + if normalized == "crossref" then + local parent = luadata[value] + if parent then + setmetatableindex(entries,parent) + else + -- warning end - entries[normalized] = value end + entries[normalized] = value end - luadata[tag] = entries end + luadata[hashtag] = entries end local function resolve(s,dataset) @@ -534,17 +553,17 @@ do local collapsed = p_whitespace^1/" " local nospaces = p_whitespace^1/"" - local p_left = (p_whitespace^0 * left * p_whitespace^0) / "" - local p_right = (p_whitespace^0 * right * p_whitespace^0) / "" + local p_left = (p_whitespace^0 * left) / "" + local p_right = (right * p_whitespace^0) / "" local balanced = P { - [1] = ((escape * (left+right)) + collapsed + (1 - (left+right))^1 + V(2))^0, + [1] = ((escape * (left+right)) + (collapsed + 1 - (left+right))^1 + V(2))^0, [2] = left * V(1) * right, } local unbalanced = P { [1] = left * V(2) * right, - [2] = ((escape * (left+right)) + collapsed + (1 - (left+right))^1 + V(1))^0, + [2] = ((escape * (left+right)) + (collapsed + 1 - (left+right))^1 + V(1))^0, } local keyword = C((R("az","AZ","09") + S("@_:-"))^1) @@ -555,20 +574,7 @@ do local s_quoted = ((escape*single) + collapsed + (1-single))^0 local d_quoted = ((escape*double) + collapsed + (1-double))^0 - -- local p_strip = C((1-(p_whitespace * P(-1)))^1) - -- - -- local function stripendspace(s) - -- return lpegmatch(p_strip,s) or s - -- end - - local p_strip = (Cp() * p_whitespace^1 * P(-1) + 1)^1 - - local function stripendspace(s) - local p = lpegmatch(p_strip,s) - return p and sub(s,1,p-1) or s - end - - local b_value = p_left * (Cs(balanced)/stripendspace) * p_right + local b_value = p_left * balanced * p_right local u_value = p_left * unbalanced * p_right -- get rid of outer { } local s_value = (single/"") * (u_value + s_quoted) * (single/"") local d_value = (double/"") * (u_value + d_quoted) * (double/"") @@ -577,6 +583,8 @@ do local somevalue = d_value + b_value + s_value + r_value local value = Cs((somevalue * ((spacing * hash * spacing)/"" * somevalue)^0)) + value = value / function(s) return lpegmatch(lpegpatterns.stripper,s) end + local forget = percent^1 * (1-lineending)^0 local spacing = spacing * forget^0 * spacing local assignment = spacing * key * spacing * equal * spacing * value * spacing @@ -618,14 +626,7 @@ do current.loaded[source] = kind or true end current.newtags = #current.luadata > 0 and { } or current.newtags - local before = #current.luadata lpegmatch(bibtotable,content or "",1,current) - local after = #current.luadata - if before == after then - report("no entries added") - else - report("%s entries added",after-before) - end statistics.stoptiming(publications) end @@ -751,6 +752,36 @@ do publications.resolvedname = resolvedname + local cleaner = false + local cleaned = false + + function loaders.registercleaner(what,fullname) + if not fullname or fullname == "" then + report("no %s file %a",what,fullname) + return + end + local list = table.load(fullname) + if not list then + report("invalid %s file %a",what,fullname) + return + end + list = list.replacements + if not list then + report("no replacement table in %a",fullname) + return + end + if cleaned then + report("adding replacements from %a",fullname) + for k, v in next, list do + cleaned[k] = v + end + else + report("using replacements from %a",fullname) + cleaned = list + end + cleaner = true + end + function loaders.bib(dataset,filename,kind) local dataset, fullname = resolvedname(dataset,filename) if not fullname then @@ -761,6 +792,12 @@ do report("empty file %a, nothing loaded",fullname) return end + if cleaner == true then + cleaner = Cs((lpeg.utfchartabletopattern(keys(cleaned)) / cleaned + p_utf8character)^1) + end + if cleaner ~= false then + data = lpegmatch(cleaner,data) + end if trace then report("loading file %a",fullname) end @@ -840,7 +877,7 @@ do end) function publications.load(specification) - local current = datasets[specification.dataset or v_standard] + local current = datasets[specification.dataset or v_default] local files = settings_to_array(specification.filename) local kind = specification.kind local dataspec = specification.specification @@ -931,6 +968,14 @@ do end +function publications.tags(dataset) + return sortedkeys(datasets[dataset].luadata) +end + +function publications.sortedentries(dataset) + return sortedhash(datasets[dataset].luadata) +end + -- a helper: function publications.concatstate(i,n) @@ -954,17 +999,17 @@ do local savers = { } local s_preamble = [[ - % this is an export from context mkiv - - @preamble{ - \ifdefined\btxcmd - % we're probably in context - \else - \def\btxcmd#1{\csname#1\endcsname} - \fi - } +% this is an export from context mkiv + +@preamble{ + \ifdefined\btxcmd + % we're probably in context + \else + \def\btxcmd#1{\csname#1\endcsname} + \fi +} - ]] +]] function savers.bib(dataset,filename,usedonly) local current = datasets[dataset] @@ -1074,12 +1119,12 @@ do local pagessplitter = lpeg.splitat(P("-")^1) - casters.pagenumber = function(str) + casters.range = function(str) local first, last = lpegmatch(pagessplitter,str) return first and last and { first, last } or str end - writers.pagenumber = function(p) + writers.range = function(p) if type(p) == "table" then return concat(p,"-") else @@ -1087,4 +1132,7 @@ do end end + casters.pagenumber = casters.range + writers.pagenumber = writers.range + end diff --git a/tex/context/base/publ-fnd.lua b/tex/context/base/publ-fnd.lua index 780ce039e..2457709ff 100644 --- a/tex/context/base/publ-fnd.lua +++ b/tex/context/base/publ-fnd.lua @@ -19,12 +19,15 @@ local publications = publications local tonumber, next, type = tonumber, next, type local find = string.find -local P, R, C, Cs, Cp, Cc, Carg = lpeg.P, lpeg.R, lpeg.C, lpeg.Cs, lpeg.Cp, lpeg.Cc, lpeg.Carg +local P, R, S, C, Cs, Cp, Cc, Carg, V = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Cp, lpeg.Cc, lpeg.Carg, lpeg.V local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns local concat = table.concat local formatters = string.formatters local lowercase = characters.lower +local topattern = string.topattern + +publications = publications or { } -- for testing local report = logs.reporter("publications","match") @@ -42,68 +45,182 @@ local word = Cs(lpegpatterns.unquoted + lpegpatterns.argument + valid^1) local simple = C(valid^1) local number = C(valid^1) ------ f_string_key = formatters[" local s_%s = entry[%q]"] -local f_string_key = formatters[" local s_%s = entry[%q] if s_%s then s_%s = lower(s_%s) end "] -local f_number_key = formatters[" local n_%s = tonumber(entry[%q]) or 0"] -local f_field_key = formatters[" local f_%s = entry[%q] or ''"] +----- f_string_key = formatters[" local s_%s = entry[%q] if s_%s then s_%s = lower(s_%s) end "] +----- f_number_key = formatters[" local n_%s = tonumber(entry[%q]) or 0"] +----- f_field_key = formatters[" local f_%s = entry[%q] or ''"] ------ f_string_match = formatters["(s_%s and find(lower(s_%s),%q))"] -local f_string_match = formatters["(s_%s and find(s_%s,%q))"] -local f_number_match = formatters["(n_%s and n_%s >= %s and n_%s <= %s)"] -local f_field_match = formatters["f_%s"] +-- getfuzzy(entry,%q,categories) -local f_all_match = formatters["anywhere(entry,%q)"] +-- local f_string_key = formatters[" local s_%s = get(entry,%q)\n if s_%s then s_%s = lower(s_%s) end"] +-- local f_field_key = formatters[" local f_%s = get(entry,%q) or ''"] +-- local f_field_key_c = formatters[" local c_%s = get(entry,%q,categories) or ''"] +-- local f_number_key = formatters[" local n_%s = tonumber(get(entry,%q)) or 0"] +-- +-- local f_string_match = formatters["(s_%s and find(s_%s,%q))"] +-- local f_number_match = formatters["(n_%s and n_%s >= %s and n_%s <= %s)"] +-- local f_field_match = formatters["f_%s"] +-- local f_field_match_c = formatters["c_%s"] +-- +-- local f_all_match = formatters["anywhere(entry,%q)"] + +-- topattern(lowercase(word)) : utflowercase + only *? + +-- local match = ( (key + wildcard) * (colon/"") ) * word * Carg(1) / function(key,_,word,keys) +-- if key == "*" or key == "any" then +-- keys.anywhere = true +-- if word == "" or word == "*" then +-- return "true" +-- else +-- return f_all_match(topattern(lowercase(word))) +-- end +-- else +-- keys[key] = f_string_key(key,key,key,key,key) +-- return f_string_match(key,key,topattern(lowercase(word))) +-- end +-- end +-- +-- local default = simple * Carg(1) / function(word,keys) +-- keys.anywhere = true +-- if word == "" or word == "*" then +-- return "true" +-- else +-- return f_all_match(topattern(lowercase(word))) +-- end +-- end +-- +-- local range = key * (colon/"") * number * (dash/"") * number * Carg(1) / function(key,_,first,_,last,keys) +-- keys[key] = f_number_key(key,key) +-- return f_number_match(key,key,tonumber(first) or 0,key,tonumber(last) or 0) +-- end +-- +-- local field = (P("field:")/"") * key * Carg(1) / function(_,key,keys) +-- keys[key] = f_field_key(key,key) +-- return f_field_match(key) +-- end +-- +-- local cast = (P("cast:")/"") * key * Carg(1) / function(_,key,keys) +-- keys[key] = f_field_key_c(key,key) +-- return f_field_match_c(key) +-- end +-- +-- local compare = C("==") + P("=")/"==" + P("!=")/"~=" + P("<>")/"~=" +-- +-- local b_match = lparent +-- local e_match = rparent * space^0 * (#P(-1) + P(",")/" or ") -- maybe also + -> and +-- local f_match = ((field + cast + range + match + space + compare + P(1))-e_match)^1 +-- local p_match = b_match * default * e_match +-- + b_match * f_match * e_match +-- +-- local pattern = Cs(Cc("(") * (P("match")/"" * space^0 * p_match)^1 * Cc(")")) -local match = ( (key + wildcard) * (colon/"") ) * word * Carg(1) / function(key,_,word,keys) - if key == "*" or key == "any" then - keys.anywhere = true - return f_all_match(lowercase(word)) +-- field contains fieldname:nonspaces|"whatever"|'whatever'|{whatever} +-- field exact fieldname=nonspaces|"whatever"|'whatever'|{whatever} +-- set contains [fieldname]:nonspaces|"whatever"|'whatever'|{whatever} +-- set exact [fieldname]=nonspaces|"whatever"|'whatever'|{whatever} +-- +-- with * : any sequence +-- ? : one character +-- +-- and match(),match() ... equivalent to () and () +-- +-- <123 444> : range +-- +-- unquoted = field +-- [..] = set +-- +-- () and or not +-- +-- spaces are mandate (at least for now) + +local key = C(R("az","AZ")^1) +local contains = S(":~") +local exact = P("=") +local valid = (1 - space - lparent -rparent)^1 +local wildcard = P("*") / ".*" +local single = P("?") / "." +local dash = P("-") / "%." +local percent = P("-") / "%%" +local word = Cs(lpegpatterns.unquoted + lpegpatterns.argument + valid) +local range = P("<") * space^0 * C((1-space)^1) * space^1 * C((1-space- P(">"))^1) * space^0 * P(">") + +local f_key_fld = formatters[" local kf_%s = get(entry,%q) \n if kf_%s then kf_%s = lower(kf_%s) end"] +local f_key_set = formatters[" local ks_%s = get(entry,%q,categories)\n if ks_%s then ks_%s = lower(ks_%s) end"] +local f_number_fld = formatters[" local nf_%s = tonumber(get(entry,%q))"] +local f_number_set = formatters[" local ns_%s = tonumber(get(entry,%q,categories))"] + +local f_fld_exact = formatters["(kf_%s == %q)"] +local f_set_exact = formatters["(ks_%s == %q)"] +local f_fld_contains = formatters["(kf_%s and find(kf_%s,%q))"] +local f_set_contains = formatters["(ks_%s and find(ks_%s,%q))"] +local f_fld_between = formatters["(nf_%s and nf_%s >= %s and nf_%s <= %s)"] +local f_set_between = formatters["(ns_%s and ns_%s >= %s and ns_%s <= %s)"] + +local f_all_match = formatters["anywhere(entry,%q)"] + +local function test_key_value(keys,where,key,first,last) + if not key or key == "" then + return "(false)" + elseif key == "*" then + last = "^.*" .. topattern(lowercase(last)) .. ".*$" + return f_all_match(last) + elseif first == false then + -- exact + last = lowercase(last) + if where == "set" then + keys[key] = f_key_set(key,key,key,key,key) + return f_set_exact(key,last) + else + keys[key] = f_key_fld(key,key,key,key,key) + return f_fld_exact(key,last) + end + elseif first == true then + -- contains + last = "^.*" .. topattern(lowercase(last)) .. ".*$" + if where == "set" then + keys[key] = f_key_set(key,key,key,key,key) + return f_set_contains(key,key,last) + else + keys[key] = f_key_fld(key,key,key,key,key) + return f_fld_contains(key,key,last) + end else - keys[key] = f_string_key(key,key,key,key,key) - return f_string_match(key,key,lowercase(word)) + -- range + if where == "set" then + keys[key] = f_number_set(key,key) + return f_set_between(key,key,tonumber(first),key,tonumber(last)) + else + keys[key] = f_number_fld(key,key) + return f_fld_between(key,key,tonumber(first),key,tonumber(last)) + end end end -local default = simple * Carg(1) / function(word,keys) - keys.anywhere = true - return f_all_match(lowercase(word)) -end - -local range = key * (colon/"") * number * (dash/"") * number * Carg(1) / function(key,_,first,_,last,keys) - keys[key] = f_number_key(key,key) - return f_number_match(key,key,tonumber(first) or 0,key,tonumber(last) or 0) -end - -local field = (P("field:")/"") * key * Carg(1) / function(_,key,keys) - keys[key] = f_field_key(key,key) - return f_field_match(key) -end - ------ b_match = lparent ------ e_match = rparent * space^0 * P(-1) ------ pattern = Cs(b_match * ((field + range + match + space + P(1))-e_match)^1 * e_match) +local p_compare = P { "all", + all = (V("one") + V("operator") + V("nested") + C(" "))^1, + nested = C("(") * V("all") * C(")"), + operator = C("and") + + C("or") + + C("not"), + one = Carg(1) + * V("where") + * V("key") + * (V("how") * V("word") + V("range")) + / test_key_value, + key = key + + C("*"), + where = C("set") * P(":") + + Cc(""), + how = contains * Cc(true) + + exact * Cc(false), + word = word, + range = range, +} -local b_match = lparent -local e_match = rparent * space^0 * (#P(-1) + P(",")/" or ") -- maybe also + -> and -local f_match = ((field + range + match + space + P(1))-e_match)^1 -local p_match = b_match * default * e_match + -b_match * f_match * e_match +local p_combine = space^0 + * (P(",")/" or ") + * space^0 -local pattern = Cs(Cc("(") * (P("match")/"" * space^0 * p_match)^1 * Cc(")")) - --- -- -- -- -- -- -- -- -- -- -- -- -- --- -- -- -- -- -- -- -- -- -- -- -- -- - --- no longer faster --- --- local tolower = lpegpatterns.tolower --- local lower = string.lower --- --- local allascii = R("\000\127")^1 * P(-1) --- --- function characters.checkedlower(str) --- return lpegmatch(allascii,str) and lower(str) or lpegmatch(tolower,str) or str --- end +local pattern = Cs((P("match")/"" * space^0 * p_compare + p_combine)^1) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -120,6 +237,9 @@ local f_template = string.formatters[ [[ local find = string.find local lower = characters.lower local anywhere = publications.anywhere +local get = publications.getfuzzy +local specification = publications.currentspecification +local categories = specification and specification.categories return function(entry) %s return %s and true or false @@ -127,7 +247,46 @@ end ]] ] ----- function compile(expr,start) -local function compile(expr) +-- local function compile(dataset,expr) +-- local keys = { } +-- -- local expression = lpegmatch(pattern,expr,start,keys) +-- local expression = lpegmatch(pattern,expr,1,keys) +-- if trace_match then +-- report("compiling expression: %s",expr) +-- end +-- local definitions = { } +-- local anywhere = false +-- for k, v in next, keys do +-- if k == "anywhere" then +-- anywhere = true +-- else +-- definitions[#definitions+1] = v +-- end +-- end +-- if not anywhere or #definitions == 0 then +-- report("invalid expression: %s",expr) +-- elseif trace_match then +-- for i=1,#definitions do +-- report("% 3i : %s",i,definitions[i]) +-- end +-- end +-- definitions = concat(definitions,"\n") +-- local code = f_template(definitions,expression) +-- if trace_match then +-- report("generated code: %s",code) +-- end +-- code = loadstring(code) +-- if type(code) == "function" then +-- code = code() +-- if type(code) == "function" then +-- return code +-- end +-- end +-- report("invalid expression: %s",expr) +-- return false +-- end + +local function compile(dataset,expr) local keys = { } -- local expression = lpegmatch(pattern,expr,start,keys) local expression = lpegmatch(pattern,expr,1,keys) @@ -135,15 +294,10 @@ local function compile(expr) report("compiling expression: %s",expr) end local definitions = { } - local anywhere = false for k, v in next, keys do - if k == "anywhere" then - anywhere = true - else - definitions[#definitions+1] = v - end + definitions[#definitions+1] = v end - if not anywhere and #definitions == 0 then + if #definitions == 0 then report("invalid expression: %s",expr) elseif trace_match then for i=1,#definitions do @@ -166,30 +320,40 @@ local function compile(expr) return false end --- print(lpegmatch(pattern,"match ( author:cleveland and year:1993 ) "),1,{}) - --- compile([[match(key:"foo bar")]]) --- compile([[match(key:'foo bar')]]) --- compile([[match(key:{foo bar})]]) +-- local function test(str) +-- local keys = { } +-- local definitions = { } +-- local expression = lpegmatch(pattern,str,1,keys) +-- for k, v in next, keys do +-- definitions[#definitions+1] = v +-- end +-- definitions = concat(definitions,"\n") +-- print(f_template(definitions,expression)) +-- end -local cache = { } -- todo: make weak, or just remember the last one (trial typesetting) +-- test("match(foo:bar and (foo:bar or foo:bar))") +-- test("match(foo=bar and (foo=bar or foo=bar))") +-- test("match(set:foo:bar),match(set:foo:bar)") +-- test("match(set:foo=bar)") +-- test("match(foo:{bar bar})") +-- test("match(foo={bar bar})") +-- test("match(set:foo:'bar bar')") +-- test("match(set:foo='bar bar')") +-- test("match(set:foo<1000 2000>)") +-- test("match(set:foo<1000 2000>)") +-- test("match(*:foo)") +-- test("match(*:*)") local check = P("match") -- * space^0 * Cp() -local function finder(expression) - local found = cache[expression] - if found == nil then - -- local e = lpegmatch(check,expression) - -- found = e and compile(expression,e) or false - found = lpegmatch(check,expression) and compile(expression) or false - if found then - local okay, message = pcall(found,{}) - if not okay then - found = false - report("error in match: %s",message) - end +local function finder(dataset,expression) + local found = lpegmatch(check,expression) and compile(dataset,expression) or false + if found then + local okay, message = pcall(found,{}) + if not okay then + found = false + report("error in match: %s",message) end - cache[expression] = found end return found end @@ -202,7 +366,7 @@ end publications.finder = finder function publications.search(dataset,expression) - local find = finder(expression) + local find = finder(dataset,expression) if find then local ordered = dataset.ordered local target = { } @@ -218,37 +382,15 @@ function publications.search(dataset,expression) end end --- local dataset = publications.new() --- publications.load(dataset,"t:/manuals/hybrid/tugboat.bib") --- --- local n = 500 +-- local d = publications.datasets.default -- --- local function test(dataset,str) --- local found --- local start = os.clock() --- for i=1,n do --- found = search(dataset,str) --- end --- local elapsed = os.clock() - start --- print(elapsed,elapsed/500,#table.keys(dataset.luadata),str) --- print(table.concat(table.sortedkeys(found)," ")) --- return found --- end +-- local d = publications.load { +-- dataset = "default", +-- filename = "t:/manuals/mkiv/hybrid/tugboat.bib" +-- } -- --- local found = test(dataset,[[match(author:hagen)]]) --- local found = test(dataset,[[match(author:hagen and author:hoekwater and year:1990-2010)]]) --- local found = test(dataset,[[match(author:"Bogusław Jackowski")]]) --- local found = test(dataset,[[match(author:"Bogusław Jackowski" and (tonumber(field:year) or 0) > 2000)]]) --- local found = test(dataset,[[Hagen:TB19-3-304]]) - --- 1.328 0.002656 2710 author:hagen --- Berdnikov:TB21-2-129 Guenther:TB5-1-24 Hagen:TB17-1-54 Hagen:TB19-3-304 Hagen:TB19-3-311 Hagen:TB19-3-317 Hagen:TB22-1-58 Hagen:TB22-3-118 Hagen:TB22-3-136 Hagen:TB22-3-160 Hagen:TB23-1-49 Hagen:TB25-1-108 Hagen:TB25-1-48 Hagen:TB26-2-152 - --- 1.812 0.003624 2710 author:hagen and author:hoekwater and year:1990-2010 --- Berdnikov:TB21-2-129 - --- 1.344 0.002688 2710 author:"Bogusław Jackowski" --- Berdnikov:TB21-2-129 Jackowski:TB16-4-388 Jackowski:TB19-3-267 Jackowski:TB19-3-272 Jackowski:TB20-2-104 Jackowski:TB24-1-64 Jackowski:TB24-3-575 Nowacki:TB19-3-242 Rycko:TB14-3-171 - --- 1.391 0.002782 2710 author:"Bogusław Jackowski" and (tonumber(field:year) or 0) > 2000 --- Jackowski:TB24-1-64 Jackowski:TB24-3-575 +-- inspect(publications.search(d,[[match(author:hagen)]])) +-- inspect(publications.search(d,[[match(author:hagen and author:hoekwater and year:1990-2010)]])) +-- inspect(publications.search(d,[[match(author:"Bogusław Jackowski")]])) +-- inspect(publications.search(d,[[match(author:"Bogusław Jackowski" and (tonumber(field:year) or 0) > 2000)]])) +-- inspect(publications.search(d,[[Hagen:TB19-3-304]])) diff --git a/tex/context/base/publ-imp-apa.lua b/tex/context/base/publ-imp-apa.lua index d26e32ac4..5182e016d 100644 --- a/tex/context/base/publ-imp-apa.lua +++ b/tex/context/base/publ-imp-apa.lua @@ -30,43 +30,27 @@ local specification = { -- vons Last, Jrs, First -- Vons, Last, Jrs, First -- - author = "author", + author = "author", -- interpreted as name(s) editor = "author", artist = "author", interpreter = "author", composer = "author", producer = "author", - doi = "url", + doi = "url", -- an external link url = "url", - page = "pagenumber", + page = "pagenumber", -- number or range: f--t pages = "pagenumber", - keywords = "keyword", + volume = "range", + number = "range", + keywords = "keyword", -- comma|-|separated list + year = "number", }, -- -- categories with their specific fields -- categories = { -- - -- the following fields are for documentation and testing purposes - -- - ["demo-a"] = { - sets = { - author = { "author", "institution", "organization" }, - doi = { "doi", "url" }, - }, - required = { "author", "title", "year", "note", "doi" }, - optional = { "subtitle", "file" }, - }, - ["demo-b"] = { - sets = { - authors = { "author", "institution", "organization" }, - doi = { "doi", "url" }, - }, - required = { "authors", "title", "year", "note", "doi" }, - optional = { "subtitle", "file" }, - }, - -- - -- more categories are added below + -- categories are added below -- }, } @@ -78,7 +62,8 @@ local generic = { -- allows the substitution of an alternate field. -- -- note that anything can get assigned a doi or be available online. - doi = { "doi", "url" }, + doi = { "doi", "url" }, + editionset = { "edition", "volume", "number", "pages" }, } -- Definition of recognized categories and the fields that they contain. @@ -98,7 +83,6 @@ local categories = specification.categories categories.article = { sets = { author = { "author", "editor", "title" }, - volume = { "volume", "number", "pages" }, doi = generic.doi, isbn = { "issn" }, }, @@ -108,7 +92,7 @@ categories.article = { optional = { "year", "subtitle", "type", "file", - "journal", "volume", + "journal", "volume", "number", "pages", "doi", "note", "isbn" }, } @@ -124,7 +108,7 @@ categories.magazine = { }, optional = { "subtitle", "type", "file", - "volume", + "number", "month", "day", "doi", "note", "isbn" }, @@ -174,15 +158,15 @@ categories.standard = { categories.book = { sets = { - author = { "author", "editor", "publisher", "title" }, - edition = { "edition", "volume", "number", "pages" }, - doi = generic.doi, + author = { "author", "editor", "publisher", "title" }, + editionset = generic.editionset, + doi = generic.doi, }, required = { "author" }, optional = { "year", "month", "day", "subtitle", "type", "file", - "edition", "series", + "editionset", "series", "address", "doi", "note", "isbn" }, @@ -192,9 +176,9 @@ categories.book = { categories.inbook = { sets = { - author = { "author", "editor", "publisher", "title", "chapter" }, - edition = { "edition", "volume", "number", "pages" }, - doi = generic.doi, + author = { "author", "editor", "publisher", "title", }, + editionset = generic.editionset, + doi = generic.doi, }, required = { "author", @@ -202,72 +186,78 @@ categories.inbook = { }, optional = { "subtitle", "type", "file", - "edition", "series", + "booktitle", + -- APA ignores this: "chapter", + "editionset", "series", "month", "address", "doi", "note", "isbn" }, } --- a work that is printed and bound, but without a named publisher or sponsoring institution. +-- a book having its own title as part of a collection. +-- (like inbook, but we here make booktitle required) -categories.booklet = { +categories.incollection = { sets = { - author = { "author", "title" }, - doi = generic.doi, + author = { "author", "editor", "publisher", "title", }, + editionset = generic.editionset, + doi = generic.doi, }, required = { - "author" + "author", + "booktitle", + "year", }, optional = { - "year", "month", "subtitle", "type", "file", + "editionset", "series", + -- APA ignores this: "chapter", + "month", "address", - "howpublished", "doi", "note", "isbn" - }, + }, } --- a part of a book having its own title. +-- a work that is printed and bound, but without a named publisher or sponsoring institution. -categories.incollection = { +categories.booklet = { sets = { - author = { "author", "editor", "publisher", "title" }, - edition = { "edition", "volume", "number", "pages" }, - doi = generic.doi, + author = { "author", "title", }, + publisher = { "howpublished" }, -- no "publisher"! + doi = generic.doi, }, required = { - "author", - "booktitle", - "year", + "author" }, optional = { + "publisher", + "year", "month", "subtitle", "type", "file", - "month", - "edition", "series", - "chapter", "address", "doi", "note", "isbn" - }, + }, } -- the proceedings of a conference. categories.proceedings = { sets = { - author = { "editor", "publisher", "title" }, - edition = { "edition", "volume", "number", "pages" }, - doi = generic.doi, + author = { "editor", "organization", "publisher", "title" }, -- no "author"! + publisher = { "publisher", "organization" }, + editionset = generic.editionset, + doi = generic.doi, }, required = { "author", "year" }, optional = { + "publisher", "subtitle", "file", - "edition", "series", + "editionset", "series", "month", - "address", "organization", + "address", "doi", "note", "isbn" }, } @@ -331,9 +321,10 @@ categories.phdthesis = categories.mastersthesis categories.techreport = { sets = { - -- no "edition"! - edition = { "type", "volume", "number", "pages" }, - doi = generic.doi, + author = { "author", "institution", "publisher", "title" }, + publisher = { "publisher", "institution", }, + editionset = { "type", "volume", "number", "pages" }, -- no "edition"! + doi = generic.doi, }, required = { "author", @@ -342,10 +333,11 @@ categories.techreport = { "year" }, optional = { + "publisher", + "address", "subtitle", "file", - "edition", -- set, not field! + "editionset", "month", - "address", "doi", "note", "isbn" }, } @@ -354,16 +346,19 @@ categories.techreport = { categories.manual = { sets = { - edition = { "edition", "volume", "number", "pages" }, - doi = generic.doi, + author = { "author", "organization", "publisher", "title" }, + publisher = { "publisher", "organization", }, + editionset = generic.editionset, + doi = generic.doi, }, required = { "title" }, optional = { + "author", "publisher", + "address", "subtitle", "file", - "author", "address", "organization", - "edition", "month", "year", + "editionset", "month", "year", "doi", "note", "isbn" }, } @@ -372,20 +367,25 @@ categories.manual = { categories.patent = { sets = { + author = { "author", "assignee", }, + publisher = { "publisher", "assignee", }, + year = { "year", "yearfiled", }, + month = { "month", "monthfiled", }, + day = { "day", "dayfiled", }, doi = generic.doi, }, required = { "nationality", "number", - "year", "yearfiled" + "year", }, optional = { "type", --check this: "language", - "author", "assignee", + "author", "publisher", "title", "subtitle", "file", "address", - "day", "dayfiled", "month", "monthfiled", + "day", "month", "doi", "note" }, } diff --git a/tex/context/base/publ-imp-apa.mkvi b/tex/context/base/publ-imp-apa.mkvi index d7dc4db9a..256636325 100644 --- a/tex/context/base/publ-imp-apa.mkvi +++ b/tex/context/base/publ-imp-apa.mkvi @@ -10,10 +10,10 @@ %C This module is part of the \CONTEXT\ macro||package and is therefore copyrighted %D by \PRAGMA. See mreadme.pdf for details. -% \loadbtxdefinitionfile[def] - \startbtxrenderingdefinitions[apa] +\ifdefined\c!translate \else \def\c!translate{translate} \fi + %D Reference: %D \startTEX %D @Book{APA2010, @@ -27,68 +27,261 @@ %D } %D \stopTEX -% set all APA compliant values (may be redundant but we do not count on defaults.) +% The APA style sorts the unnumbered rendered list by authoryear + +% Hans: should we be using or not using \c!, \s! and \v! ?? + +% Sure: not using \c! and v! would mean that only the english interface is +% supported and \s! saves some bytes (only within the setups). I'll deal with +% that in the end. + +\definebtxrendering + [apa] + [\c!specification=apa, + \c!sorttype=authoryear, + \c!numbering=\v!no] \setupbtxlist - [alternative=hanging, - margin=3em] + [apa] + [\c!alternative=\v!paragraph, + \c!width=\v!fit, + \c!distance=.5\emwidth, + \c!margin=3\emwidth] + +% The sameauthor feature may not be APA compliant +% (there is nothing in the manual cited above). +% It can be removed using the command: +% \resetsetups [apa:list:sameauthor] + +% Or texdefinition? + +\startsetups [apa:list:sameauthor] + \fastsetup{apa:list:sameauthor:rule} +\stopsetups + +\startsetups [apa:list:sameauthor:rule] + \blackrule + [\c!width=\dimexpr\listparameter\c!margin-\interwordspace\relax, + \c!height=1.5\linewidth]% are you sure you want to inconsistent with the rest? happens nowhere! +\stopsetups -\setupbtxlistvariant - [\c!namesep={,\space}, - \c!lastnamesep={,\nobreakspace\textampersand\space}, - \c!finalnamesep={,\nobreakspace\textampersand\space}, +\startsetups [apa:list:sameauthor:\v!empty]% it's not a space + \kern\dimexpr\listparameter\c!margin-\interwordspace\relax +\stopsetups + +\startsetups [apa:list:sameauthor:ditto] % horrible ! + \inframed + [\c!width=\dimexpr\listparameter\c!margin-\interwordspace\relax, + \c!frame=\v!off, + \c!align=\v!middle] + {\doubleprime} +\stopsetups + +% set ALL specific APA compliant values +% Note that fallback is apa, default, then root + +\definebtx + [apa] + [\c!default=, % no fallback on default rendering + \c!namesep={,\space}, + \c!lastnamesep={,\nobreakspace\textampersand\space}, % comma separated list + \c!finalnamesep={\nobreakspace\textampersand\space}, % last of two, no comma! \c!firstnamesep=\space, - \c!otherstext={,\space\btxlabeltext{\currentbtxspecification:others}}, - \c!juniorsep=\space, - \c!vonsep=\space, - \c!initialsep=\space, % between initials and lastname - %\c!initialssep=\space, % between multiple initials % todo - %\c!initialsterminator={.}, % todo + \c!otherstext={\space\btxlabeltext{apa:others}}, + \c!juniorsep={\space}, + \c!vonsep={\space}, + \c!initialsep={\space}, \c!surnamesep={,\space}, \c!surnameinitialsep={,\space}, \c!surnamefirstnamesep={,\space}, - \c!etallimit=5, - \c!etaldisplay=\btxlistvariantparameter\c!etallimit, - %\c!journalconversion=\v!normal, + \c!pubsep={,\space}, + \c!lastpubsep={,\space\btxlabeltext{apa:and}\space},% not btxcomma? + \c!finalpubsep={\space\btxlabeltext{apa:and}\space}] + +\definebtx + [apa:list] + [apa] + [\c!otherstext={,\nobreakspace\textellipsis\space}, + \c!etallimit=7, + \c!etaldisplay=6, + %c!journalconversion=\v!normal, \c!monthconversion=\v!month, \c!authorconversion=invertedshort] -\definebtxlistvariant - [author] +% The following are similar to default, but inherit from apa:list + +\definebtx + [apa:list:author] + [apa:list] + +\definebtx + [apa:list:editor] + [apa:list:author] + +\definebtx + [apa:list:suffix] + [apa:list] + +\definebtx + [apa:list:url] + [apa:list] + +\definebtx + [apa:list:doi] + [apa:list] + +\definebtx + [apa:list:invertedshort] + [apa:list] + +\definebtx + [apa:list:short] + [apa:list] + +%D In order to be able to get journals expanded (or normalized or abbreviated) you need +%D to load a list: +%D +%D \starttyping +%D \btxloadjournallist[journals.txt] % the jabref list +%D \stoptyping + +% TODO + +\definebtx + [apa:list:journal] + [\c!style=\v!italic] + %command=\btxexpandedjournal] % btxabbreviatedjournal + +\definebtx + [apa:list:title] + [\c!style=\v!italic, + \c!command=\Word, + \c!translate=\v!yes] + +\definebtx + [apa:list:title:article] + [apa:list:title] + [\c!style=] % journal is set in italics + +\definebtx + [apa:list:title:magazine] + [apa:list:title] + +\definebtx + [apa:list:title:newspaper] + [apa:list:title] + +\definebtx + [apa:list:title:periodical] + [apa:list:title] + +\definebtx + [apa:list:title:standard] + [apa:list:title] + +\definebtx + [apa:list:title:book] + [apa:list:title] + +\definebtx + [apa:list:title:inbook] + [apa:list:title] + +\definebtx + [apa:list:title:incollection] + [apa:list:title] + [\c!style=] % booktitle is set in italics + +\definebtx + [apa:list:title:proceedings] + [apa:list:title] -\definebtxlistvariant - [editor] - [author] +\definebtx + [apa:list:title:inproceedings] + [apa:list:title] + [\c!style=] % booktitle is set in italics -% like \setupbtxlistvariant above but not exactly... +\definebtx + [apa:list:title:conference] + [apa:list:title] + [\c!style=] % booktitle is set in italics + +\definebtx + [apa:list:title:thesis] + [apa:list:title] + +\definebtx + [apa:list:title:phdthesis] + [apa:list:title] + +\definebtx + [apa:list:title:mastersthesis] + [apa:list:title] + +\definebtx + [apa:list:title:booklet] + [apa:list:title] + +\definebtx + [apa:list:title:manual] + [apa:list:title] + +\definebtx + [apa:list:title:techreport] + [apa:list:title] + +\definebtx + [apa:list:title:unpublished] + [apa:list:title] + +\definebtx + [apa:list:title:patent] + [apa:list:title] + +\definebtx + [apa:list:title:electronic] + [apa:list:title] + +\definebtx + [apa:list:title:other] + [apa:list:title] + +\definebtx + [apa:list:title:misc] + [apa:list:title] + +\definebtx + [apa:list:title:literal] + [apa:list:title] + +\definebtx + [apa:list:type] + [\c!command=\Word] + +% We define [page] settings in the apa namespace, inheriting the root +% settings, in order to eventually allow for modifications without touching +% root. + +\definebtx + [apa:page] + [\s!page] + +\definebtx + [apa:page:list] + [apa:page] + [\c!command={\wordright}] % The APA style defines authoryear citations. -\setupbtxcitevariant +\definebtx + [apa:cite] + [apa:list] [\c!alternative=authoryear, - \c!namesep=\btxlistvariantparameter\c!namesep, - \c!lastnamesep=\btxlistvariantparameter\c!lastnamesep, - \c!finalnamesep={\nobreakspace\textampersand\space}, % no comma! - \c!firstnamesep=\btxlistvariantparameter\c!firstnamesep, - \c!otherstext=\btxlistvariantparameter\c!otherstext, - \c!juniorsep=\btxlistvariantparameter\c!juniorsep, - \c!vonsep=\btxlistvariantparameter\c!vonsep, - \c!initialsep=\btxlistvariantparameter\c!initialsep, - %\c!initialssep=\btxlistvariantparameter\c!initialssep, - %\c!initialsterminator=\btxlistvariantparameter\c!initialsterminator, - \c!surnamesep=\btxlistvariantparameter\c!surnamesep, - \c!surnameinitialsep=\btxlistvariantparameter\c!surnameinitialsep, - \c!surnamefirstnamesep=\btxlistvariantparameter\c!surnamefirstnamesep, - \c!etallimit=5, % when 2-4, show all first time, etaldisplay subsequently... - \c!etaldisplay=1, - % \c!monthconversion=\btxlistvariantparameter\c!monthconversion, + \c!otherstext={,\space\btxlabeltext{apa:others}}, + \c!etallimit=5, + \c!etaldisplay=1, % TODO: when 2-4, show all first time, etaldisplay subsequently... \c!authorconversion=\v!name, - \c!interaction=\v!start, - % \c!setups=btx:cite:initialize, - \c!pubsep={,\space}, - \c!lastpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!sorttype=, + \c!sorttype=authoryear, \c!compress=\v!no, \c!inbetween=\space, \c!range=\endash, @@ -96,51 +289,170 @@ \c!middle=, \c!right=] -\definebtxcitevariant - [author] - [\c!lastnamesep={,\nobreakspace\textampersand\space}, - \c!finalnamesep={\nobreakspace\textampersand\space}, % no comma! - \c!authorconversion=\v!name] - -\definebtxcitevariant - [authoryear] - [\c!compress=\v!yes, - \c!inbetween={,\space}, - \c!left={(}, - \c!right={)}, - \c!pubsep={;\space}, - \c!lastpubsep={;\space}, - \c!finalpubsep={;\space}, - \c!lastnamesep={,\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalnamesep={\space\btxlabeltext{\currentbtxspecification:and}\space}, % no comma! - \c!authorconversion=\v!name] - -\definebtxcitevariant - [authoryears] - [authoryear] - [\c!left=, - \c!inbetween={\space(}, - \c!pubsep={);\space}, - \c!lastpubsep={);\space}, - \c!finalpubsep={);\space}, - \c!lastnamesep={,\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalnamesep={\space\btxlabeltext{\currentbtxspecification:and}\space}, % no comma! - \c!authorconversion=\v!name] - -% The APA style also sorts the rendered list by authoryear - -\setupbtxrendering - [sorttype=authoryear, - numbering=no] - -% Should the following be loaded by default? +\definebtx + [apa:cite:author] + [apa:cite] + [\c!lastnamesep={,\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!finalnamesep={\space\btxlabeltext{apa:and}\space}] % not \textampersand + +% The following are similar to default, but inherit from apa:cite + +\definebtx + [apa:cite:authoryear] + [apa:cite:author] + [\c!compress=\v!yes, + \c!left={(}, + \c!right={)}, + \c!inbetween={,\space}, + \c!pubsep={;\space}, + \c!lastpubsep={;\space}, + \c!finalpubsep={;\space}] + +\definebtx + [apa:cite:authoryears] + [apa:cite:authoryear] + [\c!left=, + \c!right=, + \c!inbetween={\space}, + \c!pubsep={;\space}, + \c!lastpubsep={;\space}, + \c!finalpubsep={;\space}] + +\definebtx + [apa:cite:authornum] + [apa:cite:author] + [\c!left={(}, + \c!right={)}, + \c!sorttype=authornum] + +\definebtx + [apa:cite:authorref] + [apa:cite:authornum] + +\definebtx + [apa:cite:author:num] % todo + [apa:cite:authornum] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:author:year] % todo + [apa:cite:authoryear] + [\c!left=, + \c!right=] -%D In order to be able to get journals expanded (or normalized or abbreviated) you need -%D to load a list: -%D -%D \starttyping -%D \btxloadjournallist[journals.txt] % the jabref list -%D \stoptyping +\definebtx + [apa:cite:author:years] % todo + [apa:cite:authoryears] + [\c!inbetween=, + \c!left=(, + \c!right=)] + +\definebtx + [apa:cite:year] + [apa:cite] + [\c!pubsep={,\space}, + \c!lastpubsep={,\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!finalpubsep={\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!compress=\v!yes, + \c!sorttype=\v!default] + +\definebtx + [apa:cite:title] + [apa:cite] + [\c!pubsep={,\space}, + \c!lastpubsep={,\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!finalpubsep={\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!command={\language[\currentbtxlanguage]}, % BAH + \c!style=\v!italic] + +\definebtx + [apa:cite:booktitle] + [apa:cite:title] + +\definebtx + [apa:cite:tag] + [apa:cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:key] + [apa:cite:tag] + +\definebtx + [apa:cite:serial] + [apa:cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:page] + [apa:cite] + [\c!left=, + \c!right=, + \c!pubsep={,\space}, + \c!lastpubsep={,\space\btxlabeltext{apa:and}\space}, % not \textampersand + \c!finalpubsep={\space\btxlabeltext{apa:and}\space}] % not \textampersand + +\definebtx + [apa:cite:pages] + [apa:cite:page] + +\definebtx + [apa:cite:keywords] + [apa:cite] + [\c!left={(}, + \c!right={)}] + +\definebtx + [apa:cite:invertedshort] + [apa:cite] + +\definebtx + [apa:cite:short] + [apa:cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:category] + [apa:cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:type] + [apa:cite:category] + +\definebtx + [apa:cite:url] + [apa:cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [apa:cite:doi] + [apa:cite:url] + +\definebtx + [apa:cite:num] + [apa:cite] + [\c!compress=\v!yes, + \c!left={[}, + \c!right={]}, + \c!pubsep={,}, + \c!lastpubsep={,}, + \c!finalpubsep={,}] + +\definebtx + [apa:cite:textnum] + [apa:cite:num] + [\c!left={Ref.\nbsp}, + \c!right=, + \c!pubsep={,}, + \c!lastpubsep={\space\btxlabeltext{apa:and}\space}, + \c!finalpubsep={\space\btxlabeltext{apa:and}\space}] %D Sometimes we have verbose injections in an entry and these can be language %D dependent, so we use labels. @@ -148,357 +460,477 @@ %D Because we want to mix rendering (in the manual) we need a namespace in label %D texts: -% TODO: The APA guide calls for abbreviations, but this should be a tunable option. -% We need then to define both and create a mechanism to select. - \setupbtxlabeltext [en] - [apa:mastersthesis={Master's thesis}, - apa:phdthesis={PhD thesis}, + [apa:and=and, + apa:number={no.}, + apa:edition={ed.}, + apa:Editor={Ed.}, + apa:Editors={Eds.}, + apa:Volume={Vol.}, + apa:Volumes={Vols.}, + apa:others={et al.}, + apa:page={p.}, + apa:pages={pp.}, + apa:nd={n.d.}, % no date + apa:mastersthesis={Master's thesis}, + apa:phdthesis={Doctoral dissertation}, apa:technicalreport={Tech. Rep.}, % Technical report apa:supplement={Suppl.}, % Supplement apa:patent=Patent, - apa:Translator={Trans.}, % Translator(s) - apa:Editor={Ed.}, % Editor - apa:Editors={Eds.}, % Editors - apa:edition={ed.}, % edition - apa:volume=volume, % used? - apa:Volume={Vol.}, % Volume - apa:Volumes={Vols.}, % Volumes - apa:number=number, - apa:Number={No.}, % Number - apa:nd={n.d.}, % no date - apa:in=in, - apa:of=of, - apa:In=In, - apa:Part={Pt.}, % Part - apa:p={p.}, - apa:pp={pp.}, - apa:pages=pages, - apa:and=and, - apa:period={. }, apa:Author=Author, - apa:Reference={Ref.}, - apa:References={Refs.}, + apa:Translator={Trans.}, % Translator(s) apa:Advanced={Advanced online publication}, apa:Retrieved={Available from}, % {Retrieved from}, - apa:others={et al.}] + apa:In=In] + +% Check this (google translate!!): + +\setupbtxlabeltext + [nl] + [apa:and=en, + apa:number={nr.}, + apa:edition={ed.}, % editie + apa:Editor=Editor, % Ed./Eds. + apa:Editors=Editors, + apa:Volume={Vol.}, + apa:Volumes={Vols.}, + apa:others={et al.}, + apa:page={p.}, + apa:pages={pp.}, + apa:nd={g.d.} % geen datum + apa:mastersthesis=Masterproef, + apa:phdthesis=Proefschrift, + apa:technicalreport={Technisch rapport}, % Technical report + apa:supplement=Supplement, + apa:patent=Octrooi, + apa:Author=Auteur, + apa:Translator=Vertaler, + apa:Advanced={Geavanceerde online publicatie}, + apa:Retrieved={Beschikbaar vanaf}, % {Ontvangen van}, + apa:In=In] \setupbtxlabeltext [fr] - [apa:mastersthesis={Thèse de master (DEA, DESS, master)}, - apa:phdthesis={Thèse de doctorat}, - apa:technicalreport={Rapport technique}, - apa:supplement=Supplément, - apa:patent=Brevet, - apa:Translator=Traducteur, + [apa:and=et, + apa:others={et al.}, + apa:number={n\high{o}}, + apa:edition={édition}, apa:Editor=Éditeur, apa:Editors=Éditeurs, - apa:edition=édition, - apa:volume=volume, apa:Volume=Volume, apa:Volumes=Volumes, - apa:number=numéro, - apa:Number=Numéro, - apa:nd={s.d.} % sans date - apa:in=dans, - apa:of=de, - apa:In=Dans, - apa:Part=Partie, - apa:p={p.}, - apa:pp={pp.}, - apa:pages=pages, - apa:and=et, - apa:period={. }, + apa:others={et al.}, + apa:page={p.}, + apa:pages={pp.}, + apa:nd={s.d.} % sans date + apa:mastersthesis={Thèse de master (DEA, DESS, master)}, + apa:phdthesis={Thèse de doctorat}, + apa:technicalreport={Rapport technique}, + apa:supplement=Supplément, + apa:patent=Brevet, apa:Author=Auteur, - apa:Reference={Réf.}, - apa:References={Réfs.}, + apa:Translator=Traducteur, apa:Advanced={Publication en ligne anticipée}, apa:Retrieved={Disponible à}, % {Téléchargé de}, - apa:others={et al.}] + apa:In=Dans] \setupbtxlabeltext [de] - [apa:mastersthesis={Masterarbeit}, + [apa:and=und, + apa:number={nr.}, + apa:edition=Auf\/lage, + apa:Editor=Herausgeber, % Hrsg./Hg. + apa:Editors=Herausgeber, + apa:Volume=Band, % Bd. + apa:Volumes={Bände}, + apa:others={et al.}, + apa:page={S.}, + apa:pages={S.}, + apa:nd={o.D.}, % ohne Datum (mostly: o.J. / ohne Jahr) + apa:mastersthesis={Masterarbeit}, apa:phdthesis={Dissertation}, apa:technicalreport={Technischer Bericht}, apa:supplement={Beilage}, % Supplement apa:patent=Patent, - apa:Translator={Übersetzer}, % Übers. - apa:Editor=Herausgeber, % Hrsg./Hg. - apa:Editors=Herausgeber, - apa:edition=Auf\/lage, - apa:volume=Band, % Bd. - apa:Volume=Band, - apa:Volumes={Bände}, - apa:number=Nummer, - apa:Number={Nr.}, - apa:nd={o.D.}, % ohne Datum (mostly: o.J. / ohne Jahr) - apa:in=in, - apa:of=von, - apa:In=In, - apa:Part=Teil, - apa:p={S.}, - apa:pp={S.}, - apa:pages=Seiten, - apa:and=und, - apa:period={. }, apa:Author=Autor, - apa:Reference={Ref.}, - apa:References={Ref.}, + apa:Translator={Übersetzer}, % Übers. apa:Advanced={Erweiterte Online-Publikation}, apa:Retrieved={heruntergeladen von}, - apa:others={et al.}] + apa:In=In] % thanks: Andrea Valle \setupbtxlabeltext [it] - [apa:mastersthesis={Tesi di laurea}, + [apa:and=e, + apa:number={nº}, + apa:edition={ed.}, % edizione + apa:Editor={A cura di}, + apa:Editors={A cura di}, + apa:Volume={Vol.}, % Volume + apa:Volumes={Vol.}, % Volumi + apa:others={et al.}, + apa:page={p.}, + apa:pages={pp.}, + apa:nd={s.d.}, % senza data + apa:mastersthesis={Tesi di laurea}, apa:phdthesis={Tesi di dottorato}, apa:technicalreport={Relazione tecnica}, apa:supplement={Supplemento}, apa:patent=Brevetto, - apa:Translator={Trad.}, % Translator(s) - apa:Editor={A cura di}, - apa:Editors={A cura di}, - apa:edition={ed.}, - apa:volume=volume, - apa:Volume={Vol.}, - apa:Volumes={Vol.}, - apa:number=numero, - apa:Number=Numero, - apa:nd={s.d.}, - apa:in=in, - apa:of=di, - apa:In=In, - apa:Part=Parte, - apa:p={p.}, - apa:pp={pp.}, - apa:pages=pagine, - apa:and=e, - apa:period={. }, apa:Author=Autore, - apa:Reference={Rif.}, - apa:References={Rif.}, + apa:Translator={Trad.}, % Translator(s) apa:Advanced={Pre-pubblicazione on line}, apa:Retrieved={Accessible online}, - apa:others={et al.}] + apa:In=In] -%D Instead of texdefinitions without arguments, we could have used setups but in my -%D editor (hh, scite) the commands stand out better. It also saves an additional -%D component in the name (e.g. common:) because commands and setups have a different -%D namespace, so similar calls don't clash. Performance of definitions is somewhat -%D better. +\setupbtxlabeltext + [es] + [apa:and=y, + apa:number={nº}, + apa:edition={ed.}, % edición + apa:Editor=Editor, % Ed./Eds. + apa:Editors=Editores, + apa:Volume={Vol.}, % Volumen + apa:Volumes={Vols.}, % Volúmenes + apa:others={et al.}, + apa:page={p.}, + apa:pages={pp.}, + apa:nd={s.f.}, % sin fecha + apa:mastersthesis={Tesis de maestría}, + apa:phdthesis={Tesis doctoral}, + apa:technicalreport={Informe técnico}, + apa:supplement=Suplemento, + apa:patent=Patente, + apa:Author=Autor, + apa:Translator=Traductor, + apa:Advanced={Publicación en línea avanzada}, + apa:Retrieved={Disponible desde}, % {Obtenido de}, + apa:In=En] + +% cite setups + +% as we don't fallback on default (no sane person will render the titles +% differently so it's a bit over the top): -%D \btxdoif... and \btxflush rely on the definitions in publ-imp-apa.lua: -%D fields that are not listed as required nor optional are IGNORED. +\startsetups btx:apa:cite:empty + \fastsetup{\s!btx:\s!cite:\s!empty} +\stopsetups +\startsetups btx:apa:cite:unknown + \fastsetup{\s!btx:\s!cite:\s!unknown} +\stopsetups +\startsetups btx:apa:cite:author + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups btx:apa:cite:authoryear + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups btx:apa:cite:authoryears + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups btx:apa:cite:authornum + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups btx:apa:cite:title + \fastsetup{\s!btx:\s!cite:\s!normal} +\stopsetups +\startsetups btx:apa:cite:booktitle + \fastsetup{btx:apa:cite:title} +\stopsetups +\startsetups btx:apa:cite:entry + \fastsetup{\s!btx:\s!cite:\s!normal} +\stopsetups +\startsetups btx:apa:cite:num + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups btx:apa:cite:textnum + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups btx:apa:cite:year + \fastsetup{\s!btx:\s!cite:range} +\stopsetups + +\startsetups btx:apa:cite:author:year + \texdefinition{\s!btx:\s!cite:concat} + \ifx\currentbtxfirst\empty + \btxlabeltext{apa:nd} + \else + \texdefinition {\s!btx:\s!cite:inject} { + \btxcitereference + \currentbtxfirst + } + \ifx\currentbtxsecond\empty \else + \btxparameter\v!inbetween + \texdefinition {\s!btx:\s!cite:inject} { + \currentbtxsecond + } + \fi + \ifx\currentbtxthird\empty \else + \texdefinition {\s!btx:\s!cite:inject} { + \currentbtxthird + } + \fi + \fi +\stopsetups -% First some helpers: +\startsetups btx:apa:cite:author:years + \fastsetup{btx:apa:cite:author:year} +\stopsetups -\starttexdefinition btx:apa:inject #link #content +\startsetups [btx:apa:page:list] + \fastsetup{\s!btx:\s!page:concat} + \ifx\currentbtxlastpage\empty + \btxlabeltext{apa:page} + \else + \btxlabeltext{apa:pages} + \fi + \btxnbsp \ifconditional\btxinteractive - \ifx\currentbtxinternal\empty - #content - \else + \goto { + \currentbtxfirstpage + } [ + internal(\currentbtxfirstinternal) + ] + \ifx\currentbtxlastpage\empty \else + \btxparameter\c!pageconnector \goto { - #content + \currentbtxlastpage } [ - #link + internal(\currentbtxlastinternal) ] \fi \else - #content + \currentbtxfirstpage + \ifx\currentbtxlastpage\empty \else + \btxparameter\c!pageconnector + \currentbtxlastpage + \fi \fi +\stopsetups + +%D Instead of texdefinitions without arguments, we could have used setups but in my +%D editor (hh, scite) the commands stand out better. It also saves an additional +%D component in the name (e.g. common:) because commands and setups have a different +%D namespace, so similar calls don't clash. Performance of definitions is somewhat +%D better. + +%D We use "texdefinitions" (with eventual arguments) for helpers that are used +%D in the rendering "setups" defined for each category below. + +%D Note that \btxdoif... and \btxflush rely on the definitions in +%D publ-imp-apa.lua: fields that are not listed as required nor optional are +%D IGNORED. We also make heavy use of the notion of sets - comma-separated lists +%D of alternative fields to be used in hierarchal order. For example: +%D author = { "author", "editor", "publisher", "title" }, will return the +%D author field if it exists; if not, the editor field will be returned, if it +%D exists; if not, the publisher field will be returned, if it exists; if not, +%D the title field will be returned, it it exists; if not, nothing will be +%D returned. In lua syntax, it can be understood as +%D author or editor or publisher or title or "" + + +\starttexdefinition btx:apa:translated-title #title + \ifx\currentbtxlanguage\empty + % no need for an extra + \else\ifx\mainbtxlanguage\currentbtxlanguage + % no need for an extra + \else + \btxdoif {#title:\mainbtxlanguage} { + \begingroup + \language[\mainbtxlanguage] + \btxleftbracket + \btxusecommand[apa:list:title:\currentbtxcategory] { + \btxflush{#title:\mainbtxlanguage} + } + \btxrightbracket + \endgroup + } + \fi\fi +\stoptexdefinition + +\starttexdefinition btx:apa:composed-title #title + \begingroup + \language[\currentbtxlanguage] + \btxusecommand[apa:list:title:\currentbtxcategory] { + \btxflush{#title} + \btxdoif {sub#title} { + \btxcolon + \btxflush{sub#title} + } + } + \endgroup + \doif{\btxparameter{translate}}\v!yes { + \texdefinition{btx:apa:translated-title}{#title} + } \stoptexdefinition \starttexdefinition btx:apa:title \setmode{btx:apa:title-placed} - \btxdoif {file} { - % we make the title active, opening file - \texdefinition{btx:apa:inject} {url(file:\btxflush{file})} - } - { - \btxflush{Word -> title} - \btxdoif {subtitle} { - \btxcolon - \btxflush{Word -> subtitle} - } - \doifnot {\currentbtxcategory} {techreport} { - \doifnotmode {btx:apa:thesis} { - \btxdoif{type} { - \btxleftbracket - \btxflush{Word -> type} - \btxrightbracket - } + % we make the title active, opening file + \btxdoifelse {file} { + \texdefinition{btx:format:inject} + {url(file:\btxflush{file})} + { + \btxstartstyleandcolor [apa:list:title:\currentbtxcategory] + \texdefinition{btx:apa:composed-title}{title} + \btxstopstyleandcolor } - } + } { + \btxstartstyleandcolor [apa:list:title:\currentbtxcategory] + \texdefinition{btx:apa:composed-title}{title} + \btxstopstyleandcolor + } + \btxdoif {title} { \btxperiod } \stoptexdefinition -\starttexdefinition btx:apa:title-if-not-placed #it - \doifnotmode {btx:apa:title-placed} { +\starttexdefinition btx:apa:title-if-not-placed + \doifmodeelse {btx:apa:title-placed} { + \resetmode{btx:apa:title-placed} + } { \btxdoif {title} { \btxspace - \doifelse {#it} {it} { - \begingroup - \it - \texdefinition{btx:apa:title} - \italiccorrection - \endgroup - } { - \texdefinition{btx:apa:title} - } + \texdefinition {btx:apa:title} } } \stoptexdefinition -\starttexdefinition btx:apa:editor - \btxflush{editor} - \btxleftparenthesis - \btxsingularorplural {editor} { - \btxlabeltext{apa:Editor} +\starttexdefinition btx:apa:suffixedyear + \btxdoifelse {year} { + \btxflush{year} + \btxflush{suffix} } { - \btxlabeltext{apa:Editors} + \btxlabeltext{apa:nd} } - \btxrightparenthesisperiod \stoptexdefinition -\starttexdefinition btx:apa:author - \btxflush{author} +\starttexdefinition btx:apa:author-or-editor #author + \btxdoif {#author} { + \btxflush{#author} + \doif {\btxfoundname{#author}} {editor} { + \btxleftparenthesis + \btxsingularorplural {editor} { + \btxlabeltext{apa:Editor} + } { + \btxlabeltext{apa:Editors} + } + \btxrightparenthesisperiod + } + } \stoptexdefinition \starttexdefinition btx:apa:authoryear % we make the authoryear active, pointing to the citation - \texdefinition{btx:apa:inject} {internal(\currentbtxinternal)} - { - % author is a set, e.g. - % author = { "author", "editor", "publisher", "title" }, - \executeifdefined - {btx:apa:\btxfoundname{author}} - {\texdefinition{btx:apa:author}} - \btxleftparenthesis - \btxdoifelse {year} { - \btxflush{year} - %\btxflush{suffix} - \btxflush{suffixedyear} - \btxdoif {month} { - \btxcomma - \btxflush{month} - \btxdoif {day} { - \btxspace - \btxflush{day} + \texdefinition{btx:format:inject} + {internal(\currentbtxinternal)} + { + \doifsetupselse{apa:list:sameauthor} { + \btxdoifsameaspreviouselse {author} { + \fastsetup{apa:list:sameauthor} + } { + \texdefinition{btx:apa:author-or-editor} {author} } + } { + \texdefinition{btx:apa:author-or-editor} {author} } - } { - \btxlabeltext{apa:nd} - \btxdoif {suffix} {% check this! - \btxspace - \btxflush{suffix} - } + \btxleftparenthesis + \texdefinition{btx:apa:suffixedyear} + \btxrightparenthesis } - \btxrightparenthesis - } \btxperiod % outside of interaction + \doif {\btxfoundname{author}} {title} { + \setmode{btx:apa:title-placed} + } \stoptexdefinition -\starttexdefinition btx:apa:italic #field - \begingroup - \it - \btxflush{#field} - \italiccorrection - \endgroup -\stoptexdefinition - -\starttexdefinition btx:apa:editor-in- #title - \btxdoifelse {editor} { +\starttexdefinition btx:apa:editor-in + \btxdoif {booktitle} { \btxlabeltext{apa:In} - \btxspace - \texdefinition{btx:apa:editor} - \btxdoif {#title} { - \texdefinition{btx:apa:italic}{Word -> #title} - } - } { - \btxdoif {#title} { - \btxlabeltext{apa:In} + \doifnot {\btxfoundname{author}} {editor} { \btxspace - \texdefinition{btx:apa:italic}{Word -> #title} + \texdefinition{btx:apa:author-or-editor} {editor} } + \btxspace + \btxstartstyleandcolor[apa:list:title] % NOT :\currentbtxcategory ! + \texdefinition{btx:apa:composed-title} {booktitle} + \btxstopstyleandcolor + \btxperiod } \stoptexdefinition \starttexdefinition btx:apa:editionset - \btxdoifelse {edition} { - \btxleftparenthesis - \doif {\currentbtxcategory} {techreport} { - \btxdoifelse {type} { - \btxflush{Word -> type} - } { - \btxlabeltext{apa:technicalreport} - } - \setmode{btx:apa:comma} - } - \doif {\btxfoundname{edition}} {edition} { - \doifmode {btx:apa:comma} - {\btxcomma} - \btxflush{edition} - \btxspace - \btxlabeltext{apa:edition} - \setmode{btx:apa:comma} - } - \btxdoif {volume} { - \doifmode {btx:apa:comma} - {\btxcomma} - \btxoneorrange {volume} { - \btxlabeltext{apa:Volume} - } { - \btxlabeltext{apa:Volumes} + \btxleftparenthesis + \setmode{btx:apa:editionset-empty} + \doif {\currentbtxcategory} {techreport} { + \resetmode{btx:apa:editionset-empty} + \btxdoifelse {type} { + \btxusecommand[apa:list:type] { + \btxflush{type} } - \btxspace - \btxflush{volume} - \setmode{btx:apa:comma} + } { + \btxlabeltext{apa:technicalreport} } - \btxdoif {number} { - \doifmode {btx:apa:comma} - {\btxcomma} - \btxlabeltext{apa:Number} - \btxspace - \btxflush{number} - \setmode{btx:apa:comma} + \btxcomma + } + \btxdoif {volume} { + \resetmode{btx:apa:editionset-empty} + \btxoneorrange {volume} { + \btxlabeltext{apa:Volume} + } { + \btxlabeltext{apa:Volumes} } - \btxdoif {pages} { - \doifmode {btx:apa:comma} - {\btxcomma} - \btxoneorrange {pages} { - \btxlabeltext{apa:p} - } { - \btxlabeltext{apa:pp} - } - \btxspace - \btxflush{pages} + \btxspace + \btxflush{volume} + \btxcomma + } + \btxdoif {number} { + \resetmode{btx:apa:editionset-empty} + \btxlabeltext{apa:number} + \btxspace + \btxflush{number} + \btxcomma + } + \btxdoif {edition} { + \resetmode{btx:apa:editionset-empty} + \btxflush{edition} + \btxspace + \btxlabeltext{apa:edition} + \btxcomma + } + \btxdoif {pages} { + \resetmode{btx:apa:editionset-empty} + \btxoneorrange {pages} { + \btxlabeltext{apa:page} + } { + \btxlabeltext{apa:pages} } + \btxnbsp + \btxflush{pages} + \btxcomma + } + \removeunwantedspaces + \removepunctuation + \doifnotmode {btx:apa:editionset-empty} { \btxrightparenthesisperiod - } { - \doif {\currentbtxcategory} {techreport} { - \btxleftparenthesis - \btxlabeltext{apa:technicalreport} - \btxrightparenthesisperiod - } } \stoptexdefinition -\starttexdefinition btx:apa:journal-volumeset +\starttexdefinition btx:apa:journal-volume-number-pages + % this could be simplified! \btxdoif {journal} { \btxspace - % expandedjournal abbreviatedjournal - \texdefinition{btx:apa:italic}{expandedjournal -> journal} - % A newspaper may not have a volume but may have a number! + \btxstartstyleandcolor[apa:list:journal] + \btxusecommand[apa:list:journal] { + \btxflush{journal} + } + \btxstopstyleandcolor \btxdoif {volume} { \btxcomma - \doif {\btxfoundname{volume}} {volume} { - \texdefinition{btx:apa:italic}{volume} - } + \btxstartstyleandcolor[apa:list:journal] + \btxflush{volume} + \btxstopstyleandcolor \btxdoifnot {number} { \btxdoifelse {pages} {\btxcomma} @@ -525,11 +957,11 @@ } \doif {\currentbtxcategory} {newspaper} { \btxoneorrange {pages} { - \btxlabeltext{apa:p} + \btxlabeltext{apa:page} } { - \btxlabeltext{apa:pp} + \btxlabeltext{apa:pages} } - \btxspace + \btxnbsp } \btxflush{pages} \btxperiod @@ -556,6 +988,32 @@ } \stoptexdefinition +\starttexdefinition btx:apa:wherefrom-publisher + \btxdoifelse {address} { + \btxflush{address} + \btxdoif {country} { + \btxcomma + \btxflush{country} + } + \btxcolon + } { + \btxdoif {country} { + \btxflush{country} + \btxcolon + } + } + \doifelse {\btxfoundname{author}} {\btxfoundname{publisher}} { + \btxlabeltext{apa:Author} + } { + \btxdoifelse {publisher} { + \btxflush{publisher} + } { + \btxlabeltext{apa:Author} + } + } + \btxperiod +\stoptexdefinition + \definebreakpoints[doi] \definebreakpoint [doi][:][nleft=3,type=1] \definebreakpoint [doi][/][nleft=3,type=1] @@ -569,15 +1027,15 @@ \btxspace \begingroup \setbreakpoints[doi] - \btxdoifelseinteractive {url} { + \ifconditional\btxinteractive \goto { \btxflush{url} } [ url(\btxflush{url}) ] - } { + \else \btxflush{url} - } + \fi \endgroup \stoptexdefinition @@ -586,15 +1044,15 @@ \btxspace \begingroup \setbreakpoints[doi] - \btxdoifelseinteractive {doi} { + \ifconditional\btxinteractive \goto { doi:\btxflush{doi} } [ url(http://dx.doi.org/\btxflush{doi}) ] - } { + \else doi:\btxflush{doi} - } + \fi \endgroup \stoptexdefinition @@ -603,148 +1061,78 @@ \btxdoif {isbn} { \btxleftparenthesis \WORD{\btxfoundname{isbn}}:\btxspace + \setbreakpoints[doi] \btxflush{isbn} \btxrightparenthesis } \stoptexdefinition \starttexdefinition btx:apa:note - % grouping could indeed be useful for note. \btxdoif {note} { \btxleftparenthesis - {\btxflush{note}} + \btxflush{note} \btxrightparenthesis } \stoptexdefinition -\starttexdefinition btx:apa:url-note-doi +\starttexdefinition btx:apa:url-doi-note \doif {\btxfoundname{doi}} {url} { \texdefinition{btx:apa:url} } \texdefinition{btx:apa:isbn} - \texdefinition{btx:apa:note} \doif {\btxfoundname{doi}} {doi} { \texdefinition{btx:apa:doi} } + \texdefinition{btx:apa:note} \removeunwantedspaces \stoptexdefinition -\starttexdefinition btx:apa:doifelse-publisher-or-author-or-editor #author #if #else - \btxdoifelse {publisher} { - \btxdoifelse {#author} { - #if - } { - \btxdoifelse {editor} { - #if - } { - #else - } - } - } { - \btxdoifelse {#author} { - #if - } { - \doifelse {editor} { - #if - } { - #else - } - } - } -\stoptexdefinition - -% #author is author, editor, organization, howpublished or assignee -\starttexdefinition btx:apa:wherefrom-publisher-author-is- #author - \btxdoifelse {country} { - \btxspace - \btxdoif {address} { - \btxflush{address} - \btxcomma - } - \btxflush{country} - \doifelse {#author} {howpublished} - {\btxdoifelse {howpublished}} - {\texdefinition{btx:apa:doifelse-publisher-or-author-or-editor}{#author}} - {\btxcolon} {\btxperiod} - } { - \btxdoifelse {address} { - \btxspace - \btxflush{address} - \doifelse {#author} {howpublished} - {\btxdoifelse {howpublished}} - {\texdefinition{btx:apa:doifelse-publisher-or-author-or-editor}{#author}} - {\btxcolon} {\btxperiod} - } { - \doifelse {#author} {howpublished} - {\btxdoifelse {howpublished}} - {\texdefinition{btx:apa:doifelse-publisher-or-author-or-editor}{#author}} - {\btxspace} {} - } - } - \doifelse {#author} {howpublished} { - \btxdoif {howpublished} { - \btxflush{howpublished} - \btxperiod - } - } { - \btxdoifelse {publisher} { - \btxdoifelse {#author} { - \btxflush{publisher} - \btxperiod - } { - \btxdoif {editor} { - \btxflush{publisher} - \btxperiod - } - } - } { - \btxdoifelse {#author} { - \btxlabeltext{apa:Author} - \btxperiod - } { - \btxdoif {editor} { - \btxlabeltext{apa:Author} - \btxperiod - } - } - } - } -\stoptexdefinition - -% Then by category +% Then setups, by category % An article from a journal % Required fields: author or editor or title, journal, (year). % Optional fields: volume, number, pages, type, doi, url, note. % Note that bibtex (and tools) do not include editor (e.g. special issue or section) -\startsetups btx:apa:article +\startsetups btx:apa:list:article \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:journal-volumeset} - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:title-if-not-placed} + \texdefinition{btx:apa:journal-volume-number-pages} + \texdefinition{btx:apa:url-doi-note} \stopsetups % An article from a magazine. % Required fields: author or title, journal, (year). -% Optional fields: volume, number, pages, type, month, day, doi, url, note. +% Optional fields: number, pages, type, month, day, doi, url, note. -\startsetups btx:apa:magazine - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:journal-volumeset} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:magazine + \fastsetup{btx:apa:list:article} \stopsetups % An article from a newspaper. % Required fields: author or title, journal, (year). % Optional fields: volume, number, pages, type, month, day, doi, url, note. -\startsetups btx:apa:newspaper +\startsetups btx:apa:list:newspaper + \fastsetup{btx:apa:list:article} +\stopsetups + +% A complete issue of a periodical, such as a special issue of a journal. +% Required fields: title, year +% Optional fields: editor, publisher, subtitle, series, volume, number, month, organization, doi, url, issn, note + +\startsetups btx:apa:list:periodical + \fastsetup{btx:apa:list:article} % needs to be tuned... +\stopsetups + +% National and international standards issued by a standards body +% Required fields: author, institution, or organization, year, title +% Optional fields: subtitle, doi, url, note + +\startsetups btx:apa:list:standard \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:journal-volumeset} - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:title-if-not-placed} + \texdefinition{btx:apa:url-doi-note} \stopsetups % A book with an explicit publisher. @@ -754,47 +1142,39 @@ % todo: series? -\startsetups btx:apa:book +\startsetups btx:apa:list:book \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} + \texdefinition{btx:apa:title-if-not-placed} \texdefinition{btx:apa:editionset} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{author} - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:wherefrom-publisher} + \texdefinition{btx:apa:url-doi-note} \stopsetups +% There is some debate about how inbook should differ from incollection + % A part of a book, which may be a chapter (or section or whatever) and/or a range of pages. +% (note that inbook is handled differently by bibtex and biblatex) % Required fields: author or editor, title, chapter and/or pages, publisher, year. % Optional fields: volume or number, series, type, address, edition, month, note. -% APA ignores: month - -% todo: series? +% We add optional: booktitle. +% APA ignores: chapter, month -\startsetups btx:apa:inbook +\startsetups btx:apa:list:inbook \texdefinition{btx:apa:authoryear} - \btxdoif {chapter} { - \btxflush{Word -> chapter} - \btxspace - } - \texdefinition{btx:apa:editor-in-}{title} + \texdefinition{btx:apa:title-if-not-placed} + \texdefinition{btx:apa:editor-in} \texdefinition{btx:apa:editionset} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{author} - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:wherefrom-publisher} + \texdefinition{btx:apa:url-doi-note} \stopsetups % A part of a book having its own title. % Required fields: author, title, booktitle, publisher, year. % Optional fields: editor, volume or number, series, type, chapter, pages, address, edition, month, note. -% APA ignores: month +% APA ignores: chapter, month -% todo: series? - -\startsetups btx:apa:incollection - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:editor-in-}{booktitle} - \texdefinition{btx:apa:editionset} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{author} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:incollection + \fastsetup{btx:apa:list:inbook} \stopsetups % The proceedings of a conference. @@ -802,59 +1182,46 @@ % Optional fields: editor, volume or number, series, address, month, organization, publisher, note. % todo: series? -\startsetups btx:apa:proceedings - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:editionset} - \btxdoifelse {editor} { - \btxdoif {organization} { - \btxspace - \btxflush{organization} - \btxcomma - } - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{editor} - } { - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{organization} - } - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:proceedings + \fastsetup{btx:apa:list:book} \stopsetups % An article in a conference proceedings. % Required fields: author, title, booktitle, year. % Optional fields: editor, volume or number, series, pages, address, month, organization, publisher, note. -% todo: series? -\startsetups btx:apa:inproceedings +\startsetups btx:apa:list:inproceedings \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{} - \texdefinition{btx:apa:editor-in-}{booktitle} + \texdefinition{btx:apa:title-if-not-placed} + \texdefinition{btx:apa:editor-in} \texdefinition{btx:apa:editionset} \btxdoif {organization} { \btxspace \btxflush{organization} \btxcomma } - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{author} - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:wherefrom-publisher} + \texdefinition{btx:apa:url-doi-note} \stopsetups -\startsetups btx:apa:conference - \fastsetup{btx:apa:inproceedings} +\startsetups btx:apa:list:conference + \fastsetup{btx:apa:list:inproceedings} \stopsetups % A thesis. % Required fields: author, title, school, year. % Optional fields: type, address, month, note. -\startsetups btx:apa:thesis - \setmode{btx:apa:thesis} +\startsetups btx:apa:list:thesis \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} + \texdefinition{btx:apa:title-if-not-placed} \btxleftparenthesis \btxdoifelse {type} { - \btxflush{Word -> type} + \btxusecommand[apa:list:type] { + \btxflush{type} + } } { - \Word{\btxlabeltext{apa:\currentbtxcategory}} + \btxlabeltext{apa:\currentbtxcategory} } \btxrightparenthesis \btxdoif {school} { @@ -874,60 +1241,47 @@ } } \btxperiod - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:url-doi-note} \stopsetups -\startsetups btx:apa:phdthesis - \fastsetup{btx:apa:thesis} +\startsetups btx:apa:list:phdthesis + \fastsetup{btx:apa:list:thesis} \stopsetups -\startsetups btx:apa:mastersthesis - \fastsetup{btx:apa:thesis} +\startsetups btx:apa:list:mastersthesis + \fastsetup{btx:apa:list:thesis} \stopsetups % A work that is printed and bound, but without a named publisher or sponsoring institution. % Required field: title. % Optional fields: author, howpublished, address, month, year, note. -\startsetups btx:apa:booklet - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{howpublished} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:booklet + \fastsetup{btx:apa:list:book} \stopsetups % Technical documentation. % Required field: title. % Optional fields: author, organization, address, edition, month, year, note. -\startsetups btx:apa:manual - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} - \texdefinition{btx:apa:editionset} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{organization} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:manual + \fastsetup{btx:apa:list:book} \stopsetups % A report published by a school or other institution, usually numbered within a series. % Required fields: author, title, institution, year. % Optional fields: type, number, address, month, note. -\startsetups btx:apa:techreport - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} - \texdefinition{btx:apa:editionset} - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{institution} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:techreport + \fastsetup{btx:apa:list:book} \stopsetups % A document having an author and title, but not formally published. % Required fields: author, title, note. % Optional fields: month, year. -\startsetups btx:apa:unpublished - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:unpublished + \fastsetup{btx:apa:list:book} \stopsetups % A patent. Note that this category was not defined with BIBTEX. Below from JabRef: @@ -937,9 +1291,9 @@ % todo: yearfiled, monthfiled, dayfiled -\startsetups btx:apa:patent +\startsetups btx:apa:list:patent \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} + \texdefinition{btx:apa:title-if-not-placed} \begingroup \it \btxdoif {nationality} { @@ -950,41 +1304,14 @@ \btxlabeltext{apa:patent} \btxdoif {number} { \btxspace - \btxlabeltext{apa:Number} + \btxlabeltext{apa:number} \btxspace \btxflush{number} } \btxperiod \italiccorrection \endgroup - \btxdoifelse {author} { - \btxdoifelse {country} { - \btxspace - \btxdoif {address} { - \btxflush{address} - \btxcomma - } - \btxflush{country} - \btxdoifelse {assignee} - {\btxcolon} {\btxperiod} - } { - \btxdoifelse {address} { - \btxspace - \btxflush{address} - \btxdoifelse {assignee} - {\btxcolon} {\btxperiod} - } { - \btxdoifelse {assignee} - {\btxspace} {} - } - } - \btxdoif {assignee} { - \btxflush{assignee} - \btxperiod - } - } { - \texdefinition{btx:apa:wherefrom-publisher-author-is-}{assignee} - } + \texdefinition{btx:apa:wherefrom-publisher} \texdefinition{btx:apa:url} \texdefinition{btx:apa:note} \stopsetups @@ -996,9 +1323,9 @@ % Like Misc below but includes organization. -\startsetups btx:apa:electronic +\startsetups btx:apa:list:electronic \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} + \texdefinition{btx:apa:title-if-not-placed} \btxdoif {organization} { \btxspace \btxflush{organization} @@ -1009,37 +1336,35 @@ \btxflush{howpublished} \btxperiod } - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:url-doi-note} \stopsetups % Other. Note that this category was not defined with BIBTEX. Below from JabRef: % Required fields: author or title, year % Optional fields: note, doi, url -\startsetups btx:apa:other - \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} - \texdefinition{btx:apa:url-note-doi} +\startsetups btx:apa:list:other + \fastsetup{btx:apa:list:book} \stopsetups % Use this type when nothing else fits. % Required fields: none. % Optional fields: author, title, howpublished, month, year, note. -\startsetups btx:apa:misc +\startsetups btx:apa:list:misc \texdefinition{btx:apa:authoryear} - \texdefinition{btx:apa:title-if-not-placed}{it} + \texdefinition{btx:apa:title-if-not-placed} \btxdoif {howpublished} { \btxspace \btxflush{howpublished} \btxperiod } - \texdefinition{btx:apa:url-note-doi} + \texdefinition{btx:apa:url-doi-note} \stopsetups % If all else fails to match: -\startsetups btx:apa:literal +\startsetups btx:apa:list:literal %\btxleftparenthesis \removeunwantedspaces( \btxflush{key} @@ -1049,14 +1374,35 @@ } \stopsetups -%D Experiment: - -\startsetups btx:apa:lefttext - \currentbtxlefttext -\stopsetups - -\startsetups btx:apa:righttext - \currentbtxrighttext -\stopsetups +% HH: an example of setting up translations using a sub rendering. Keep it here +% till we find another spot as otherwise I forget about it and I don't want to +% waste hours reinventing a wheel when something like this is needed. +% +% \definebtx +% [apa:cite:title:translated] +% [apa:cite:title] +% [left=\btxleftbracket, +% right=\btxrightbracket, +% style=\v!bolditalic] +% +% \startsetups btx:apa:cite:title +% % need to add concat, etc. +% \btxcitereference +% \currentbtxfirst +% \doifmode {btx:apa:translatedtitles} { +% \ifx\currentbtxlanguage\empty +% % no need for an extra +% \else\ifx\mainbtxlanguage\currentbtxlanguage +% % no need for an extra +% \else +% \btxdoif {title:\mainbtxlanguage} { +% \btxstartciterendering[title:translated] +% \language[\mainbtxlanguage] +% \btxflush{title:\mainbtxlanguage} +% \btxstopciterendering +% } +% \fi\fi +% } +% \stopsetups \stopbtxrenderingdefinitions diff --git a/tex/context/base/publ-imp-aps.mkvi b/tex/context/base/publ-imp-aps.mkvi index bd07a9a55..dde6a289a 100644 --- a/tex/context/base/publ-imp-aps.mkvi +++ b/tex/context/base/publ-imp-aps.mkvi @@ -1,3 +1,7 @@ +\endinput + +% todo + %D \module %D [ file=publ-imp-aps, %D version=2013.12.12, @@ -10,8 +14,6 @@ %C This module is part of the \CONTEXT\ macro||package and is therefore copyrighted %D by \PRAGMA. See mreadme.pdf for details. -% \loadbtxdefinitionfile[def] - \startbtxrenderingdefinitions[aps] %D Reference: @@ -31,7 +33,12 @@ % set all APS compliant values (may be redundant but we do not count on defaults.) -\setupbtxlistvariant +\setupbtxrendering + [sorttype=, % num ? + numbering=yes] + +\definebtxlistvariant + [aps] [\c!namesep={,\space}, \c!lastnamesep={,\space and\space}, \c!finalnamesep={,\space and\space}, @@ -123,11 +130,6 @@ \c!finalnamesep={\space\btxlabeltext{\currentbtxspecification:and}\space}, % no comma! \c!authorconversion=\v!name] -\setupbtxrendering - [sorttype=, % num ? - numbering=yes] - -% Should the following be loaded by default? %D In order to be able to get journals expanded (or normalized or abbreviated) you need %D to load a list: @@ -513,15 +515,15 @@ \btxspace \begingroup \setbreakpoints[doi] - \btxdoifelseinteractive {url} { + \ifconditional\btxinteractive \goto { \btxflush{url} } [ url(\btxflush{url}) ] - } { + \else \btxflush{url} - } + \fi \endgroup \stoptexdefinition @@ -530,15 +532,15 @@ \btxspace \begingroup \setbreakpoints[doi] - \btxdoifelseinteractive {doi} { + \ifconditional\btxinteractive \goto { doi:\btxflush{doi} } [ url(http://dx.doi.org/\btxflush{doi}) ] - } { + \else doi:\btxflush{doi} - } + \fi \endgroup \stoptexdefinition diff --git a/tex/context/base/publ-imp-author.mkvi b/tex/context/base/publ-imp-author.mkvi index d852e325e..6547573cf 100644 --- a/tex/context/base/publ-imp-author.mkvi +++ b/tex/context/base/publ-imp-author.mkvi @@ -1,3 +1,5 @@ +% TODO: MAKE default + %D \module %D [ file=publ-imp-author, %D version=2014.06.23, @@ -13,17 +15,6 @@ \unprotect -% We can do a better check for pre-sep-post at the lua end but by keeping it at the -% tex end users can easier mess with it. So, we just assume sane names. -% -% maybe cite will just inherit from list (only \current.. alias) -% -% \startsetups \s!btx:\s!cite:\s!author:normal -% \fastsetup{\s!btx:\s!list:\s!author:normal} -% \stopsetups - -% You can adapt these setups to your liking, for instance as: - % these can be used instead of the macros and they accept manipulator prefixes % % \currentbtxinitials : \btxauthorfield{initials} @@ -32,24 +23,29 @@ % \currentbtxsurnames : \btxauthorfield{surnames} % \currentbtxjuniors : \btxauthorfield{juniors} +\starttexdefinition \s!btx:\s!cite:\s!author:\s!de + \ifx\currentbtxlanguage\s!de + \setmode{\s!btx:\s!de} + \fi +\stoptexdefinition + \startsetups \s!btx:\s!cite:\s!author:concat \ifcase\currentbtxoverflow \ifcase\currentbtxconcat \or \or - \btxcitevariantparameter\c!namesep + \btxparameter\c!namesep \or - \btxcitevariantparameter\c!lastnamesep + \btxparameter\c!lastnamesep \or - \btxcitevariantparameter\c!finalnamesep + \btxparameter\c!finalnamesep \fi \else - % \btxcitevariantparameter\c!namesep + % \btxparameter\c!namesep \fi \stopsetups \startsetups \s!btx:\s!cite:\s!author:others \ifcase\currentbtxoverflow \else - \btxspace - \btxcitevariantparameter\c!otherstext + \btxparameter\c!otherstext \fi \stopsetups @@ -57,18 +53,18 @@ \fastsetup{\s!btx:\s!cite:\s!author:concat} \ifx\currentbtxfirstnames\empty \else \currentbtxfirstnames - \btxcitevariantparameter\c!firstnamesep + \btxparameter\c!firstnamesep \fi \ifx\currentbtxvons\empty \else \currentbtxvons \ifx\currentbtxsurnames\empty \else - \btxcitevariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxcitevariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi @@ -79,18 +75,18 @@ \fastsetup{\s!btx:\s!cite:\s!author:concat} \ifx\currentbtxinitials\empty \else \currentbtxinitials - \btxcitevariantparameter\c!initialsep + \btxparameter\c!initialsep \fi \ifx\currentbtxvons\empty \else \currentbtxvons \ifx\currentbtxsurnames\empty \else - \btxcitevariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxcitevariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi @@ -100,58 +96,77 @@ \startsetups \s!btx:\s!cite:\s!author:inverted \fastsetup{\s!btx:\s!cite:\s!author:concat} \ifx\currentbtxvons\empty \else - \currentbtxvons - \btxcitevariantparameter\c!vonsep + \texdefinition{\s!btx:\s!cite:\s!author:\s!de} + \doifmode {\s!btx:\s!de} { + \currentbtxvons + \btxparameter\c!vonsep + } \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxcitevariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi \ifx\currentbtxfirstnames\empty % firstnames are optional \else - \btxcitevariantparameter\c!surnamefirstnamesep + \btxparameter\c!surnamefirstnamesep \currentbtxfirstnames \fi + \ifx\currentbtxvons\empty \else + \doifnotmode {\s!btx:\s!de} { + \btxparameter\c!vonsep + \currentbtxvons + } + \fi \fastsetup{\s!btx:\s!cite:\s!author:others} \stopsetups \startsetups \s!btx:\s!cite:\s!author:invertedshort \fastsetup{\s!btx:\s!cite:\s!author:concat} \ifx\currentbtxvons\empty \else - \currentbtxvons - \btxcitevariantparameter\c!vonsep + \texdefinition{\s!btx:\s!cite:\s!author:\s!de} + \doifnotmode {\s!btx:\s!de} { + \currentbtxvons + \btxparameter\c!vonsep + } \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxcitevariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi \ifx\currentbtxinitials\empty % initials are optional \else - \btxcitevariantparameter\c!surnameinitialsep + \btxparameter\c!surnameinitialsep \currentbtxinitials \fi + \ifx\currentbtxvons\empty \else + \doifmode {\s!btx:\s!de} { + \btxparameter\c!vonsep + \currentbtxvons + } + \fi \fastsetup{\s!btx:\s!cite:\s!author:others} \stopsetups \startsetups \s!btx:\s!cite:\s!author:name \fastsetup{\s!btx:\s!cite:\s!author:concat} + % is this treated differently in german? \ifx\currentbtxvons\empty \else \currentbtxvons - \btxcitevariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \currentbtxsurnames \ifcase\currentbtxauthorstate \else % potential clash of names so we force initials \ifx\currentbtxinitials\empty \else - \btxcitevariantparameter\c!surnameinitialsep + \btxparameter\c!surnameinitialsep \currentbtxinitials \fi \fi @@ -163,20 +178,20 @@ \startsetups \s!btx:\s!list:\s!author:concat \ifcase\currentbtxoverflow \ifcase\currentbtxconcat \or \or - \btxlistvariantparameter\c!namesep + \btxparameter\c!namesep \or - \btxlistvariantparameter\c!lastnamesep + \btxparameter\c!lastnamesep \or - \btxlistvariantparameter\c!finalnamesep + \btxparameter\c!finalnamesep \fi \else - \btxlistvariantparameter\c!namesep + \btxparameter\c!namesep \fi \stopsetups \startsetups \s!btx:\s!list:\s!author:others \ifcase\currentbtxoverflow \else - \btxlistvariantparameter\c!otherstext + \btxparameter\c!otherstext \fi \stopsetups @@ -184,18 +199,18 @@ \fastsetup{\s!btx:\s!list:\s!author:concat} \ifx\currentbtxfirstnames\empty \else \currentbtxfirstnames - \btxlistvariantparameter\c!firstnamesep + \btxparameter\c!firstnamesep \fi \ifx\currentbtxvons\empty \else \currentbtxvons \ifx\currentbtxsurnames\empty \else - \btxlistvariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxlistvariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi @@ -206,18 +221,18 @@ \fastsetup{\s!btx:\s!list:\s!author:concat} \ifx\currentbtxinitials\empty \else \currentbtxinitials - \btxlistvariantparameter\c!initialsep + \btxparameter\c!initialsep \fi \ifx\currentbtxvons\empty \else \currentbtxvons \ifx\currentbtxsurnames\empty \else - \btxlistvariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxlistvariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi @@ -227,52 +242,71 @@ \startsetups \s!btx:\s!list:\s!author:inverted \fastsetup{\s!btx:\s!list:\s!author:concat} \ifx\currentbtxvons\empty \else - \currentbtxvons - \btxlistvariantparameter\c!vonsep + \texdefinition{\s!btx:\s!cite:\s!author:\s!de} + \doifnotmode {\s!btx:\s!de} { + \currentbtxvons + \btxparameter\c!vonsep + } \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxlistvariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi \ifx\currentbtxfirstnames\empty % firstnames are optional \else - \btxlistvariantparameter\c!surnamefirstnamesep + \btxparameter\c!surnamefirstnamesep \currentbtxfirstnames \fi + \ifx\currentbtxvons\empty \else + \doifmode {\s!btx:\s!de} { + \btxparameter\c!vonsep + \currentbtxvons + } + \fi \fastsetup{\s!btx:\s!list:\s!author:others} \stopsetups \startsetups \s!btx:\s!list:\s!author:invertedshort \fastsetup{\s!btx:\s!list:\s!author:concat} \ifx\currentbtxvons\empty \else - \currentbtxvons - \btxlistvariantparameter\c!vonsep + \texdefinition{\s!btx:\s!cite:\s!author:\s!de} + \doifnotmode {\s!btx:\s!de} { + \currentbtxvons + \btxparameter\c!vonsep + } \fi \ifx\currentbtxsurnames\empty \else \currentbtxsurnames \ifx\currentbtxjuniors\empty \else - \btxlistvariantparameter\c!juniorsep + \btxparameter\c!juniorsep \currentbtxjuniors \fi \fi \ifx\currentbtxinitials\empty % initials are optional \else - \btxlistvariantparameter\c!surnameinitialsep + \btxparameter\c!surnameinitialsep \currentbtxinitials \fi + \ifx\currentbtxvons\empty \else + \doifmode {\s!btx:\s!de} { + \btxparameter\c!vonsep + \currentbtxvons + } + \fi \fastsetup{\s!btx:\s!list:\s!author:others} \stopsetups \startsetups \s!btx:\s!list:\s!author:name \fastsetup{\s!btx:\s!list:\s!author:concat} + % is this treated differently in german? \ifx\currentbtxvons\empty \else \currentbtxvons - \btxlistvariantparameter\c!vonsep + \btxparameter\c!vonsep \fi \currentbtxsurnames \fastsetup{\s!btx:\s!list:\s!author:others} diff --git a/tex/context/base/publ-imp-cite.mkvi b/tex/context/base/publ-imp-cite.mkvi index b49e8339d..869384969 100644 --- a/tex/context/base/publ-imp-cite.mkvi +++ b/tex/context/base/publ-imp-cite.mkvi @@ -13,11 +13,6 @@ \unprotect -\startsetups \s!btx:\s!cite:nocite - \dontleavehmode - \btxcitereference -\stopsetups - \starttexdefinition btx:cite:inject #content \ifconditional\btxinteractive \ifx\currentbtxinternal\empty @@ -43,103 +38,117 @@ % The null case: -\startsetups \s!btx:\s!cite:none +\startsetups btx:cite:none + \btxcitereference % dummy \stopsetups -% This saves keying: - -\startsetups [\s!btx:\s!cite:\s!unknown] - \begingroup - \showmessage\m!publications{13}{\currentbtxcitevariant,\currentbtxtag,\currentbtxdataset} - \tttf - <\currentbtxcitevariant:\currentbtxtag> - \endgroup -\stopsetups - -\startsetups \s!btx:\s!cite:common:normal - \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} - \else\ifx\currentbtxsecond\empty - \btxcitereference - \currentbtxfirst - \ifx\currentbtxthird\empty \else - \currentbtxthird - \fi - \else - \btxcitereference - \currentbtxfirst - \btxcitevariantparameter\v!inbetween - \currentbtxsecond - \ifx\currentbtxthird\empty \else - \currentbtxthird - \fi - \fi\fi +\startsetups btx:cite:nocite + \dontleavehmode + \btxcitereference \stopsetups -\startsetups \s!btx:\s!cite:common:range - \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} - \else\ifx\currentbtxsecond\empty - \btxcitereference - \currentbtxfirst - \ifx\currentbtxthird\empty \else - \currentbtxthird - \fi - \else +\startsetups btx:cite:unknown + \begingroup \btxcitereference \currentbtxfirst - \btxcitevariantparameter\c!range - \currentbtxsecond - \ifx\currentbtxthird\empty \else - \currentbtxthird - \fi - \fi\fi + \endgroup \stopsetups -\startsetups \s!btx:\s!cite:concat +\startsetups btx:cite:empty + \btxcitereference + <empty> +\stopsetups + +% \startsetups btx:cite:normal +% \ifx\currentbtxfirst\empty +% \fastsetup{\s!btx:\s!cite:\s!empty} +% \else\ifx\currentbtxsecond\empty +% \btxcitereference +% \currentbtxfirst +% \ifx\currentbtxthird\empty \else +% \currentbtxthird +% \fi +% \else +% \btxcitereference +% \currentbtxfirst +% \btxparameter\v!inbetween +% \currentbtxsecond +% \ifx\currentbtxthird\empty \else +% \currentbtxthird +% \fi +% \fi\fi +% \stopsetups + +%\startsetups btx:cite:range +% \ifx\currentbtxfirst\empty +% \fastsetup{\s!btx:\s!cite:\s!empty} +% \else\ifx\currentbtxsecond\empty +% \btxcitereference +% \currentbtxfirst +% \ifx\currentbtxthird\empty \else +% \currentbtxthird +% \fi +% \else +% \btxcitereference +% \currentbtxfirst +% \btxparameter\c!range +% \currentbtxsecond +% \ifx\currentbtxthird\empty \else +% \currentbtxthird +% \fi +% \fi\fi +%\stopsetups + +\starttexdefinition btx:cite:concat \ifcase\currentbtxconcat \or \or - \btxcitevariantparameter\c!pubsep + \btxparameter\c!pubsep \or - \btxcitevariantparameter\c!finalpubsep + \btxparameter\c!lastpubsep \or - \btxcitevariantparameter\c!lastpubsep + \btxparameter\c!finalpubsep \fi -\stopsetups +\stoptexdefinition -\startsetups \s!btx:\s!cite:render:normal - \fastsetup{\s!btx:\s!cite:concat} +\startsetups btx:cite:normal + \texdefinition{\s!btx:\s!cite:concat} \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} + \fastsetup{\s!btx:\s!cite:\s!empty} \else - \texdefinition {btx:cite:inject} { + \texdefinition {\s!btx:\s!cite:inject} { \btxcitereference - \currentbtxfirst + \btxusecommand[\currentbtxspecification:cite:\currentbtxcitevariant] { + \currentbtxfirst + } } \ifx\currentbtxsecond\empty \else - \btxcitevariantparameter\v!inbetween - \texdefinition {btx:cite:inject} { - \currentbtxsecond + \btxparameter\v!inbetween + \texdefinition {\s!btx:\s!cite:inject} { + \btxusecommand[\currentbtxspecification:cite:\currentbtxcitevariant] { + \currentbtxsecond + } } \fi \ifx\currentbtxthird\empty \else - \texdefinition {btx:cite:inject} { - \currentbtxthird + \texdefinition {\s!btx:\s!cite:inject} { + \btxusecommand[\currentbtxspecification:cite:\currentbtxvariant] { + \currentbtxthird + } } \fi \fi \stopsetups -\startsetups \s!btx:\s!cite:render:range - \fastsetup{\s!btx:\s!cite:concat} +\startsetups btx:cite:range + \texdefinition{\s!btx:\s!cite:concat} \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:missing} + \fastsetup{\s!btx:\s!cite:\s!empty} \else - \texdefinition {btx:cite:inject} { + \texdefinition {\s!btx:\s!cite:inject} { \btxcitereference \currentbtxfirst \ifx\currentbtxsecond\empty \else - \btxcitevariantparameter\c!range + \btxparameter\c!range \currentbtxsecond \fi \ifx\currentbtxthird\empty \else @@ -149,120 +158,76 @@ \fi \stopsetups -\startsetups \s!btx:\s!cite:render:variant - \fastsetup{\s!btx:\s!cite:concat} - \fastsetup{\s!btx:\s!cite:render:\currentbtxcitevariant} +\startsetups btx:cite:listelement + \texdefinition{\s!btx:\s!cite:concat} + \ifx\currentbtxfirst\empty + \fastsetup{\s!btx:\s!cite:\s!empty} + \else + \texdefinition {\s!btx:\s!cite:inject} { + \btxcitereference + \currentbtxfirst + } + \fi \stopsetups -\startsetups \s!btx:\s!cite:common:author +\startsetups btx:cite:author + \texdefinition{\s!btx:\s!cite:concat} \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} + \fastsetup{\s!btx:\s!cite:\s!empty} \else - \texdefinition {btx:cite:inject} { + \texdefinition {\s!btx:\s!cite:inject} { \btxcitereference \currentbtxfirst } \fi \ifx\currentbtxsecond\empty \else \relax % keeps a following space - \btxcitevariantparameter\v!inbetween - \texdefinition {btx:cite:inject} { + \btxparameter\v!inbetween + \texdefinition {\s!btx:\s!cite:inject} { \currentbtxsecond } \fi \ifx\currentbtxthird\empty \else - \texdefinition {btx:cite:inject} { + \texdefinition {\s!btx:\s!cite:inject} { \currentbtxthird } \fi \stopsetups -% one level will be removed -% yes, isn't there one too many? - -\startsetups \s!btx:\s!cite:render:author - \fastsetup{\s!btx:\s!cite:common:author} -\stopsetups -\startsetups \s!btx:\s!cite:render:authoryear - \fastsetup{\s!btx:\s!cite:common:author} -\stopsetups -\startsetups \s!btx:\s!cite:render:authoryears - \fastsetup{\s!btx:\s!cite:common:author} -\stopsetups -\startsetups \s!btx:\s!cite:render:authornum - \fastsetup{\s!btx:\s!cite:common:author} -\stopsetups - -\startsetups \s!btx:\s!cite:author:num - \fastsetup{\s!btx:\s!cite:render:range} -\stopsetups -\startsetups \s!btx:\s!cite:author:year - \fastsetup{\s!btx:\s!cite:render:range} -\stopsetups -\startsetups \s!btx:\s!cite:author:years - \fastsetup{\s!btx:\s!cite:render:range} -\stopsetups +% these three are goodies to get something bit are not set up as it makes no +% sense to have something root for combinations like this (esp not because one +% gets default anyway -\startsetups \s!btx:\s!cite:author - \fastsetup{\s!btx:\s!cite:render:variant} -\stopsetups -\startsetups \s!btx:\s!cite:authoryear - \fastsetup{\s!btx:\s!cite:render:variant} -\stopsetups -\startsetups \s!btx:\s!cite:authoryears - \fastsetup{\s!btx:\s!cite:render:variant} -\stopsetups -\startsetups \s!btx:\s!cite:authornum - \fastsetup{\s!btx:\s!cite:render:variant} -\stopsetups - -\startsetups \s!btx:\s!cite:year - \fastsetup{\s!btx:\s!cite:render:range} -\stopsetups -\startsetups \s!btx:\s!cite:short - \fastsetup{\s!btx:\s!cite:render:normal} +\startsetups btx:cite:authoryear + \fastsetup{btx:cite:author} \stopsetups -\startsetups \s!btx:\s!cite:serial - \fastsetup{\s!btx:\s!cite:render:range} +\startsetups btx:cite:authoryears + \fastsetup{btx:cite:author} \stopsetups -\startsetups \s!btx:\s!cite:tag - \fastsetup{\s!btx:\s!cite:render:normal} +\startsetups btx:cite:authornum + \fastsetup{btx:cite:author} \stopsetups -\startsetups \s!btx:\s!cite:key - \fastsetup{\s!btx:\s!cite:render:normal} -\stopsetups -%startsetups \s!btx:\s!cite:doi -% \fastsetup{\s!btx:\s!cite:render:normal} -%stopsetups -%startsetups \s!btx:\s!cite:url -% \fastsetup{\s!btx:\s!cite:render:normal} -%stopsetups -\startsetups \s!btx:\s!cite:category - \fastsetup{\s!btx:\s!cite:render:normal} -\stopsetups -\startsetups \s!btx:\s!cite:type - \fastsetup{\s!btx:\s!cite:render:normal} -\stopsetups -\startsetups \s!btx:\s!cite:num - \fastsetup{\s!btx:\s!cite:render:range} -\stopsetups -\startsetups \s!btx:\s!cite:textnum - \fastsetup{\s!btx:\s!cite:render:range} +\startsetups btx:cite:authorref + \ifx{\btxparameter\c!alternative}{authoryear} + \fastsetup{btx:cite:authoryears} + \else\ifx{\btxparameter\c!alternative}{num} + \fastsetup{btx:cite:authornum} + \else + \fastsetup{btx:cite:author} + \fi\fi \stopsetups -\startsetups \s!btx:\s!cite:title - \fastsetup{\s!btx:\s!cite:render:normal} +\startsetups btx:cite:num + \fastsetup{btx:cite:range} \stopsetups -\startsetups \s!btx:\s!cite:pages - \fastsetup{\s!btx:\s!cite:render:range} +\startsetups btx:cite:year + \fastsetup{btx:cite:range} \stopsetups -\startsetups \s!btx:\s!cite:page - \fastsetup{\s!btx:\s!cite:render:normal} -\stopsetups +% the following is kind of specific, but can be used in many renderings -\startsetups \s!btx:\s!cite:doi +\startsetups btx:cite:url \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} + \fastsetup{\s!btx:\s!cite:\s!empty} \else\ifconditional\btxinteractive \goto { \btxcitereference @@ -272,12 +237,8 @@ ] \else \btxcitereference - \hyphenatedurl{doi:\currentbtxfirst} + \hyphenatedurl{\doif{\currentbtxcitevariant}{doi}{doi:}\currentbtxfirst} \fi\fi \stopsetups -\startsetups \s!btx:\s!cite:url - \fastsetup{\s!btx:\s!cite:\s!doi} -\stopsetups - \protect diff --git a/tex/context/base/publ-imp-commands.mkiv b/tex/context/base/publ-imp-commands.mkiv deleted file mode 100644 index 14e2dbae1..000000000 --- a/tex/context/base/publ-imp-commands.mkiv +++ /dev/null @@ -1,15 +0,0 @@ -\unprotect - -% for tugboat - -\definebtxcommand\hbox {\hbox} -\definebtxcommand\vbox {\vbox} -\definebtxcommand\llap {\llap} -\definebtxcommand\rlap {\rlap} -\definebtxcommand\url #1{\hyphenatedurl{#1}} -\definebtxcommand\acro #1{\dontleavehmode{\smallcaps#1}} - -\let\<< -\let\<> - -\protect \endinput diff --git a/tex/context/base/publ-imp-commands.mkvi b/tex/context/base/publ-imp-commands.mkvi new file mode 100644 index 000000000..14e2dbae1 --- /dev/null +++ b/tex/context/base/publ-imp-commands.mkvi @@ -0,0 +1,15 @@ +\unprotect + +% for tugboat + +\definebtxcommand\hbox {\hbox} +\definebtxcommand\vbox {\vbox} +\definebtxcommand\llap {\llap} +\definebtxcommand\rlap {\rlap} +\definebtxcommand\url #1{\hyphenatedurl{#1}} +\definebtxcommand\acro #1{\dontleavehmode{\smallcaps#1}} + +\let\<< +\let\<> + +\protect \endinput diff --git a/tex/context/base/publ-imp-default.lua b/tex/context/base/publ-imp-default.lua new file mode 100644 index 000000000..61b08f30c --- /dev/null +++ b/tex/context/base/publ-imp-default.lua @@ -0,0 +1,124 @@ +-- For the moment I put this here as example. When writing the publication modules we +-- explored several approached: pure tex, pure lua, a mix with xml, etc. In the end +-- each has advantages and drawbacks so we ended up with readable tex plus helpers in +-- lua. Anyway here is a lua variant of a setup ... it doesn't look nicer. An alternative +-- can be to build a table with characters but then we need to pass left, right and +-- other separators so again no real gain. + +-- function publications.maybe.default.journal(currentdataset,currenttag) +-- if publications.okay(currentdataset,currenttag,"journal") then +-- context.btxspace() +-- context.startbtxstyle("italic") +-- commands.btxflush(currentdataset,currenttag,"expandedjournal -> journal") +-- context.stopbtxstyle() +-- if publications.okay(currentdataset,currenttag,"volume") then +-- context.btxspace() +-- commands.btxflush(currentdataset,currenttag,"volume") +-- if publications.okay(currentdataset,currenttag,"number") then +-- context.ignorespaces() +-- context.btxleftparenthesis() +-- commands.btxflush(currentdataset,currenttag,"number") +-- context.btxrightparenthesis() +-- end +-- elseif publications.okay(currentdataset,currenttag,"number") then +-- context.btxlabeltext("default:number") +-- context.btxspace() +-- commands.btxflush(currentdataset,currenttag,"number") +-- end +-- if publications.okay(currentdataset,currenttag,"pages") then +-- context.btxcomma() +-- commands.btxflush(currentdataset,currenttag,"pages") +-- end +-- context.btxcomma() +-- end +-- end + +return { + -- + -- metadata + -- + name = "default", + version = "1.00", + comment = "DEFAULT specification", + author = "Alan Braslau and Hans Hagen", + copyright = "ConTeXt development team", + -- + -- derived (combinations of) fields (all share the same default set) + -- + virtual = { + "authoryear", + "authoryears", + "authornum", + "num", + "suffix", + }, + -- + -- special datatypes + -- + types = { + author = "author", -- interpreted as name(s) + editor = "author", -- interpreted as name(s) + page = "pagenumber", -- number or range: f--t -- maybe just range + pages = "pagenumber", -- number or range: f--t -- maybe just range + volume = "range", -- number or range: f--t + number = "range", -- number or range: f--t + keywords = "keyword", -- comma|-|separated list + }, + -- + -- categories with their specific fields + -- + categories = { + -- + -- the following fields are for documentation and testing purposes + -- + ["demo-a"] = { + sets = { + author = { "author", "institution", "organization" }, + }, + required = { "author", "title", "year" }, + optional = { "subtitle" }, + }, + ["demo-b"] = { + sets = { + authors = { "author", "institution", "organization" }, + }, + required = { "authors", "title", "year" }, + optional = { "subtitle" }, + }, + -- + -- we only provide article and book (maybe a few more later) and we keep it + -- real simple. See the apa and aps definitions for more extensive examples + -- + article = { + sets = { + author = { "author", "editor" }, + }, + required = { + "author", -- a set + "year", + }, + optional = { + "title", + "keywords", + "journal", "volume", "number", "pages", + }, + }, + book = { + sets = { + author = { "author", "editor", }, + editionset = { "edition", "volume", "number" }, + }, + required = { + "author", -- a set + "title", + "year", + }, + optional = { + "subtitle", + "keywords", + "publisher", "address", + "editionset", + }, + }, + }, +} diff --git a/tex/context/base/publ-imp-default.mkvi b/tex/context/base/publ-imp-default.mkvi new file mode 100644 index 000000000..e3e032d12 --- /dev/null +++ b/tex/context/base/publ-imp-default.mkvi @@ -0,0 +1,597 @@ +%D \module +%D [ file=publ-imp-default, +%D version=2014.02.06, +%D title=Default bibliography style, +%D subtitle=Publications, +%D author=Alan Braslau and 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 therefore copyrighted +%D by \PRAGMA. See mreadme.pdf for details. + +%D This default style defines only a few categories: book and article. +%D If you want more, you need to load a more complete style such as \type {apa}, +%D \type {aps}, etc. The default style is used in the manuals that ship with +%D \CONTEXT. This file is always loaded. + +\startbtxrenderingdefinitions[\s!default] + +% \definebtx [\s!default:\s!page ] [\s!page] +% \definebtx [\s!default:\s!cite ] [\s!cite] +% \definebtx [\s!default:\s!list ] [\s!list] +% \definebtx [\s!default:\s!author] [\s!author] + +\definebtxrendering % no need to set \c!default ! ... also confusing + [\s!default] + [\c!specification=\s!default] + +\definebtx + [\s!default] + [\c!namesep={,\space}, + \c!lastnamesep={\space\btxlabeltext{default:and}\space}, + \c!finalnamesep={\space\btxlabeltext{default:and}\space}, + \c!firstnamesep=\space, + \c!otherstext={\space\btxlabeltext{default:others}}, + \c!juniorsep=\space, + \c!vonsep=\space, + \c!initialsep=\space, + \c!surnamesep={,\space}, + \c!surnameinitialsep={,\space}, + \c!surnamefirstnamesep={,\space}, + \c!pubsep={,\space}, + \c!lastpubsep={,\space\btxlabeltext{default:and}\space}, + \c!finalpubsep={\space\btxlabeltext{default:and}\space}] + +\definebtx + [\s!default:\s!list] + [\s!default] + [%c!journalconversion=\v!normal, + \c!monthconversion=\v!number, + \c!authorconversion=normalshort] + +\definebtx + [\s!default:\s!cite] + [\s!default:\s!list] + [\c!alternative=num, + \c!authorconversion=\v!name, + \c!sorttype=, + \c!compress=\v!no, + \c!inbetween=\space, + \c!range=\endash, + \c!left=, + \c!middle=, + \c!right=] + +% We define [page] settings in the default namespace, inheriting the root +% settings, in order to eventually allow for modifications without touching +% root. + +\definebtx + [\s!default:\s!page] + [\s!page] + +% List variants, some having specific settings: + +\definebtx + [\s!default:\s!list:author] + [\s!default:\s!list] + +\definebtx + [\s!default:\s!list:editor] + [\s!default:\s!list:author] + +\definebtx + [\s!default:\s!list:url] + [\s!default:\s!list] + +\definebtx + [\s!default:\s!list:doi] + [\s!default:\s!list] + +\definebtx + [\s!default:\s!list:invertedshort] + [\s!default:\s!list] + +% normalshort? + +\definebtx + [\s!default:\s!list:short] + [\s!default:\s!list] + +\definebtx + [\s!default:\s!list:journal] + [\s!default:\s!list] + [\c!style=\v!italic] + +\definebtx + [\s!default:\s!list:title] + [\s!default:\s!list] + [\c!style=\v!italic, + \c!command=\Word] + +\definebtx + [\s!default:\s!list:title:article] + [\s!default:\s!list:title] + [\c!style=, % journal is set in italics + \c!command={\quotation\Word}] + +\definebtx + [\s!default:\s!list:title:book] + [\s!default:\s!list:title] + +% Citation variants, some having specific settings : + +\definebtx + [\s!default:\s!cite:author] + [\s!default:\s!cite] + +\definebtx + [\s!default:\s!cite:authornum] + [\s!default:\s!cite:author] + [\c!left={(}, + \c!right={)}, + \c!pubsep={;\space}, + \c!lastpubsep={;\space}, + \c!finalpubsep={;\space}] + +\definebtx + [\s!default:\s!cite:authoryear] + [\s!default:\s!cite:author] + [\c!compress=\v!yes, + \c!left={(}, + \c!right={)}, + \c!inbetween={,\space}, + \c!pubsep={;\space}, + \c!lastpubsep={;\space}, + \c!finalpubsep={;\space}] + +\definebtx + [\s!default:\s!cite:authorref] + [\s!default:\s!cite:authornum] + +\definebtx + [\s!default:\s!cite:authoryears] + [\s!default:\s!cite:author] + +\definebtx + [\s!default:\s!cite:author:num] % todo + [\s!default:\s!cite:authornum] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:author:year] % todo + [\s!default:\s!cite:authoryear] + [\c!left=, + \c!right=] + +\definebtx + [\s!default:\s!cite:author:years] % todo + [\s!default:\s!cite:authoryears] + [\c!inbetween=, + \c!left=(, + \c!right=)] + +\definebtx + [\s!default:\s!cite:year] + [\s!default:\s!cite] + [\c!compress=\v!yes, + \c!sorttype=year] + +\definebtx + [\s!default:\s!cite:title] + [\s!default:\s!cite] + [command={\language[\currentbtxlanguage]}, % BAH + \c!style=\v!italic] + +\definebtx + [\s!default:\s!cite:tag] + [\s!default:\s!cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:key] + [\s!default:\s!cite:tag] + +\definebtx + [\s!default:\s!cite:serial] + [\s!default:\s!cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:page] + [\s!default:\s!cite] + [\c!left=, + \c!right=] + +\definebtx + [\s!default:\s!cite:pages] + [\s!default:\s!cite:page] + +\definebtx + [\s!default:\s!cite:keywords] + [\s!default:\s!cite] + [\c!left={(}, + \c!right={)}] + +\definebtx + [\s!default:\s!cite:invertedshort] + [\s!default:\s!cite] + +\definebtx + [\s!default:\s!cite:short] + [\s!default:\s!cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:category] + [\s!default:\s!cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:type] + [\s!default:\s!cite:category] + +\definebtx + [\s!default:\s!cite:url] + [\s!default:\s!cite] + [\c!left={[}, + \c!right={]}] + +\definebtx + [\s!default:\s!cite:doi] + [\s!default:\s!cite:url] + +\definebtx + [\s!default:\s!cite:num] + [\s!default:\s!cite] + [\c!compress=\v!yes, + \c!left={[}, + \c!right={]}, + \c!pubsep={,}, + \c!lastpubsep={,}, + \c!finalpubsep={,}] + +\definebtx + [\s!default:\s!cite:textnum] + [\s!default:\s!cite:num] + [\c!left=, % in apa: {Ref.\nbsp} or so + \c!right=, + \c!pubsep={,}, + \c!lastpubsep={,\space\btxlabeltext{default:and}\space}, + \c!finalpubsep={\space\btxlabeltext{default:and}\space}] + +% Multilingual text strings + +\setupbtxlabeltext + [en] + [\s!default:and=and, + \s!default:number={no.}, + \s!default:edition={ed.}, + \s!default:Editor=Editor, % Ed./Eds. + \s!default:Editors=Editors, + \s!default:Volume={Vol.}, + \s!default:Volumes={Vols.}, + \s!default:others={et al.}] + +\setupbtxlabeltext + [nl] + [\s!default:and=en, + \s!default:number={nr.}, + \s!default:edition={ed.}, % editie + \s!default:Editor=Editor, % Ed./Eds. + \s!default:Editors=Editors, + \s!default:Volume={Vol.}, + \s!default:Volumes={Vols.}, + \s!default:others={et al.}] + +\setupbtxlabeltext + [fr] + [\s!default:and=et, + \s!default:others={et al.}, + \s!default:number={n\high{o}}, + \s!default:edition={édition}, + \s!default:Editor=Éditeur, + \s!default:Editors=Éditeurs, + \s!default:Volume=Volume, + \s!default:Volumes=Volumes, + \s!default:others={et al.}] + +\setupbtxlabeltext + [de] + [\s!default:and=und, + \s!default:number={nr.}, + \s!default:edition=Auf\/lage, + \s!default:Editor=Herausgeber, % Hrsg./Hg. + \s!default:Editors=Herausgeber, + \s!default:Volume=Band, % Bd. + \s!default:Volumes={Bände}, + \s!default:others={et al.}] + +\setupbtxlabeltext + [it] + [\s!default:and=e, + \s!default:number={nº}, + \s!default:edition={ed.}, % edizione + \s!default:Editor={A cura di}, + \s!default:Editors={A cura di}, + \s!default:Volume={Vol.}, % Volume + \s!default:Volumes={Vol.}, % Volumi + \s!default:others={et al.}] + +\setupbtxlabeltext + [es] + [\s!default:and=y, + \s!default:number={nº}, + \s!default:edition={ed.}, % edición + \s!default:Editor=Editor, % Ed./Eds. + \s!default:Editors=Editores, + \s!default:Volume={Vol.}, % Volumen + \s!default:Volumes={Vols.}, % Volúmenes + \s!default:others={et al.}] + +% First some helpers: + +\starttexdefinition btx:default:composed-title + \begingroup + \language[\currentbtxlanguage] + \btxflush{title} + \btxdoif {subtitle} { + \btxcolon + \btxflush{subtitle} + } + \endgroup +\stoptexdefinition + +\starttexdefinition btx:default:title + \btxdoif {title} { + \btxspace + \btxstartstyleandcolor [default:list:title:\currentbtxcategory] + \btxusecommand[default:list:title:\currentbtxcategory] { + \texdefinition{btx:default:composed-title} + } + \btxstopstyleandcolor + \btxcomma + } +\stoptexdefinition + +\starttexdefinition btx:default:author + \btxdoif {author} { + \btxflush{author} + \doif {\btxfoundname{author}} {editor} { + \btxcomma + \btxsingularorplural {editor} { + \btxlabeltext{default:Editor} + } { + \btxlabeltext{default:Editors} + } + } + \btxcomma + } +\stoptexdefinition + +\starttexdefinition btx:default:year + \btxflush{year} + \btxflush{suffix} +\stoptexdefinition + +\starttexdefinition btx:default:journal + \btxdoif {journal} { + \btxspace + \btxstartstyleandcolor [default:list:journal] + \btxusecommand[default:list:journal] { + \btxflush{journal} + } + \btxstopstyleandcolor + \btxdoifelse {volume} { + \btxspace + \btxflush{volume} + \btxdoif {number} { + \ignorespaces % brrr + \btxleftparenthesis + \btxflush{number} + \btxrightparenthesis + } + + } { + \btxdoif {number} { + \btxlabeltext{default:number} + \btxspace + \btxflush{number} + } + } + \btxdoif {pages} { + \btxcomma + \btxflush{pages} + } + \btxcomma + } +\stoptexdefinition + +\starttexdefinition btx:default:editionset + \btxdoif {editionset} { + \removeunwantedspaces + \removepunctuation + \btxleftparenthesis + \doif {\btxfoundname{editionset}} {edition} { + \btxflush{edition} + \btxspace + \btxlabeltext{default:edition} + \btxcomma + } + \btxdoif {volume} { + \btxoneorrange {volume} { + \btxlabeltext{default:Volume} + } { + \btxlabeltext{default:Volumes} + } + \btxspace + \btxflush{volume} + \btxcomma + } + \btxdoifelse {number} { + \btxlabeltext{default:number} + \btxspace + \btxflush{number} + } { + \removeunwantedspaces + \removepunctuation + } + \btxrightparenthesiscomma + } +\stoptexdefinition + +\starttexdefinition btx:default:publisher + \btxdoif {publisher} { + \btxflush{publisher} + \btxcomma + } + \btxdoif {address} { + \btxflush{address} + \btxcomma + } +\stoptexdefinition + +% Then a minimal number of setups: + +\startsetups btx:default:list:article + \texdefinition{btx:default:author} + \texdefinition{btx:default:title} + \texdefinition{btx:default:journal} + \texdefinition{btx:default:year} + \removeunwantedspaces + \removepunctuation + \btxperiod +\stopsetups + +\startsetups btx:default:list:book + \texdefinition{btx:default:author} + \texdefinition{btx:default:title} + \texdefinition{btx:default:editionset} + \texdefinition{btx:default:publisher} + \texdefinition{btx:default:year} + \removeunwantedspaces + \removepunctuation + \btxperiod +\stopsetups + +\startsetups btx:default:list:unknown + \currentbtxcategory\btxcolon + \btxshowentryinline +\stopsetups + +%D Experiment: + +\startsetups btx:default:lefttext + \currentbtxlefttext +\stopsetups + +\startsetups btx:default:righttext + \currentbtxrighttext +\stopsetups + +%D Citations: + +\startsetups \s!btx:\s!default:\s!cite:author + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:authoryear + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:authoryears + \fastsetup{\s!btx:\s!cite:author} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:authornum + \fastsetup{\s!btx:\s!cite:author} +\stopsetups + +\startsetups \s!btx:\s!default:\s!cite:author:num + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:author:year + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:author:years + \fastsetup{\s!btx:\s!cite:concat} + \fastsetup{\s!btx:\s!cite:range} +\stopsetups + +\startsetups \s!btx:\s!default:\s!cite:keywords + \fastsetup{\s!btx:\s!cite:list} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:year + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:short + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:serial + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:tag + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:key + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:category + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:type + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:num + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:textnum + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:title + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:pages + \fastsetup{\s!btx:\s!cite:range} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:page + \fastsetup{\s!btx:\s!cite:normal} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:doi + \fastsetup{\s!btx:\s!cite:url} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:url + \fastsetup{\s!btx:\s!cite:url} +\stopsetups + +\startsetups \s!btx:\s!default:\s!cite:unknown + \fastsetup{\s!btx:\s!cite:unknown} +\stopsetups +\startsetups \s!btx:\s!default:\s!cite:none + \fastsetup{\s!btx:\s!cite:none} +\stopsetups + +\startsetups \s!btx:\s!default:\s!cite:nocite + \fastsetup{\s!btx:\s!cite:nocite} +\stopsetups + +\startsetups \s!btx:\s!default:\s!list:page + \fastsetup{\s!btx:\s!list:page} +\stopsetups +\startsetups \s!btx:\s!default:\s!list:yes + \fastsetup{\s!btx:\s!list:yes} +\stopsetups +\startsetups \s!btx:\s!default:\s!list:num + \fastsetup{\s!btx:\s!list:num} +\stopsetups +\startsetups \s!btx:\s!default:\s!list:bib + \fastsetup{\s!btx:\s!list:bib} +\stopsetups +\startsetups \s!btx:\s!default:\s!list:short + \fastsetup{\s!btx:\s!list:short} +\stopsetups + +\stopbtxrenderingdefinitions diff --git a/tex/context/base/publ-imp-definitions.mkiv b/tex/context/base/publ-imp-definitions.mkiv deleted file mode 100644 index a3196cc37..000000000 --- a/tex/context/base/publ-imp-definitions.mkiv +++ /dev/null @@ -1,77 +0,0 @@ -%D \module -%D [ file=publ-imp-def, -%D version=2013.12.24, -%D title=\CONTEXT\ Publication Support, -%D subtitle=Definitions, -%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. - -%D Here we collect some helper setups. We assume that checking of a field -%D happens in the calling setup, if only because that is the place where -%D fences are also dealt with. - -% These will become texdefinitions - -\unprotect - -\startxmlsetups btx:format:crossref - \cite[\btxfield{crossref}] -\stopxmlsetups - -\startxmlsetups btx:format:key - \btxfield{short} -\stopxmlsetups - -\startxmlsetups btx:format:doi - \edef\currentbtxfielddoi{\btxfield{doi}} - \ifx\currentbtxfielddoi\empty - {\tttf no-doi} - \else\ifconditional\btxinteractive - \goto{\hyphenatedurl{\currentbtxfielddoi}}[url(http://dx.doi.org/\currentbtxfielddoi)] - \else - \hyphenatedurl{\currentbtxfielddoi} - \fi\fi -\stopxmlsetups - -\startxmlsetups btx:format:url - \edef\currentbtxfieldurl{\btxfield{url}} - \ifx\currentbtxfieldurl\empty - {\tttf no-url} - \else\ifconditional\btxinteractive - \goto{\hyphenatedurl{\currentbtxfieldurl}}[url(\currentbtxfieldurl)] - \else - \hyphenatedurl{\currentbtxfieldurl} - \fi\fi -\stopxmlsetups - -\startxmlsetups btx:format:year - \edef\currentbtxfieldyear{\btxfield{year}} - \ifx\currentbtxfieldyear\empty - \btxlabeltext{\currentbtxspecification:nd} - \fi -\stopxmlsetups - -\startxmlsetups btx:format:month - \edef\currentbtxfieldmonth{\btxfield{month}} - \ifx\currentbtxfieldmonth\empty - {\tttf no-month} - \else - \edef\p_monthconversion{\btxlistvariantparameter\c!monthconversion} - \ifx\p_monthconversion\empty % month month:mnem - \currentbtxfieldmonth - \else - \doifnumberelse \currentbtxfieldmonth { - \convertnumber\p_monthconversion\currentbtxfieldmonth - } { - \currentbtxfieldmonth - } - \fi - \fi -\stopxmlsetups - -\protect diff --git a/tex/context/base/publ-imp-definitions.mkvi b/tex/context/base/publ-imp-definitions.mkvi new file mode 100644 index 000000000..9485335ce --- /dev/null +++ b/tex/context/base/publ-imp-definitions.mkvi @@ -0,0 +1,123 @@ +%D \module +%D [ file=publ-imp-def, +%D version=2013.12.24, +%D title=\CONTEXT\ Publication Support, +%D subtitle=Definitions, +%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. + +%D Here we collect some helper setups. We assume that checking of a field +%D happens in the calling setup, if only because that is the place where +%D fences are also dealt with. + +% These will become texdefinitions + +\unprotect + +\startxmlsetups btx:format:crossref + \cite[\btxfield{crossref}] +\stopxmlsetups + +\startxmlsetups btx:format:key + \btxfield{short} +\stopxmlsetups + +\starttexdefinition btx:format:inject #link #content + \ifx\currentbtxinternal\empty + #content + \else\ifconditional\btxinteractive + \goto {#content} [#link] + \else + #content + \fi\fi +\stoptexdefinition + +\startxmlsetups btx:format:doi + \edef\currentbtxfielddoi{\btxfield{doi}} + \ifx\currentbtxfielddoi\empty + {\tttf no-doi} + \else\ifconditional\btxinteractive + \goto{\hyphenatedurl{\currentbtxfielddoi}}[url(http://dx.doi.org/\currentbtxfielddoi)] + \else + \hyphenatedurl{\currentbtxfielddoi} + \fi\fi +\stopxmlsetups + +\startxmlsetups btx:format:url + \edef\currentbtxfieldurl{\btxfield{url}} + \ifx\currentbtxfieldurl\empty + {\tttf no-url} + \else\ifconditional\btxinteractive + \goto{\hyphenatedurl{\currentbtxfieldurl}}[url(\currentbtxfieldurl)] + \else + \hyphenatedurl{\currentbtxfieldurl} + \fi\fi +\stopxmlsetups + +\startxmlsetups btx:format:year + \edef\currentbtxfieldyear{\btxfield{year}} + \ifx\currentbtxfieldyear\empty + \btxlabeltext{\currentbtxspecification:nd} + \fi +\stopxmlsetups + +\startxmlsetups btx:format:month + \edef\currentbtxfieldmonth{\btxfield{month}} + \ifx\currentbtxfieldmonth\empty + {\tttf no-month} + \else + \edef\p_monthconversion{\btxparameter\c!monthconversion} + \ifx\p_monthconversion\empty % month month:mnem + \currentbtxfieldmonth + \else + \doifnumberelse \currentbtxfieldmonth { + \convertnumber\p_monthconversion\currentbtxfieldmonth + } { + \currentbtxfieldmonth + } + \fi + \fi +\stopxmlsetups + +% macros: + +\starttexdefinition btx:style:italic #content + \dontleavehmode + \begingroup + \it + #content + \italiccorrection + \endgroup +\stoptexdefinition + +\starttexdefinition btx:style:bold #content + \dontleavehmode + \begingroup + \bf + #content + \endgroup +\stoptexdefinition + +\starttexdefinition btx:style:quote #content + \dontleavehmode + \startquote + #content + \stopquote +\stoptexdefinition + +\starttexdefinition btx:style #style #content + \doifdefinedelse {btx:style:#style} { + \texdefinition{btx:style:#style} { + #content + } + } { + #content + } +\stoptexdefinition + +\protect diff --git a/tex/context/base/publ-imp-list.mkvi b/tex/context/base/publ-imp-list.mkvi index 52e5694e2..815bb2038 100644 --- a/tex/context/base/publ-imp-list.mkvi +++ b/tex/context/base/publ-imp-list.mkvi @@ -29,20 +29,20 @@ \fi \stoptexdefinition -\startsetups \s!btx:\s!list:concat -% \ifcase\currentbtxconcat \or \or -% \btxcitevariantparameter\c!pubsep -% \or -% \btxcitevariantparameter\c!finalpubsep -% \or -% \btxcitevariantparameter\c!lastpubsep -% \fi +\starttexdefinition btx:list:helpers:concat + % \ifcase\currentbtxconcat \or \or + % \btxparameter\c!pubsep + % \or + % \btxparameter\c!finalpubsep + % \or + % \btxparameter\c!lastpubsep + % \fi \space -\stopsetups +\stoptexdefinition \startsetups \s!btx:\s!list:page - \directsetup{\s!btx:\s!list:concat} - \texdefinition {\s!btx:\s!list:inject} { + \texdefinition{\s!btx:\s!list:concat} + \texdefinition{\s!btx:\s!list:inject} { % real pagenumber: todo, userpage \currentbtxfirst % order diff --git a/tex/context/base/publ-imp-page.mkvi b/tex/context/base/publ-imp-page.mkvi index 3f8fb96be..19673c829 100644 --- a/tex/context/base/publ-imp-page.mkvi +++ b/tex/context/base/publ-imp-page.mkvi @@ -13,57 +13,66 @@ \unprotect -\setupbtxlist - [\c!pageleft={\space (p.\nobreakspace}, - \c!pageright={)}, +\definebtx + [\s!page] % or just outer level + [\c!pagestate=\v!stop, + \c!pageleft=\btxleftparenthesis, % see below!! + \c!pageright=\btxrightparenthesis, \c!pagesep={,\space}, - \c!lastpagesep={\space and\space}, - \c!finalpagesep={,\space and\space}, + \c!lastpagesep={,\space\btxlabeltext{\currentbtxspecification:and}\space}, + \c!finalpagesep={\space\btxlabeltext{\currentbtxspecification:and}\space}, \c!pageconnector=\endash] -\setupbtxrendering - [\c!pagestate=\v!stop] +\definebtx + [\s!page:\s!list] + [\s!page] + [\c!command={\wordright}] -\definebtxlistvariant - [\v!page] - -\startsetups \s!btx:\s!list:\s!page:concat +\startsetups \s!btx:\s!page:concat \ifcase\currentbtxoverflow \ifcase\currentbtxconcat \or % first \or % second - \btxlistparameter\c!pagesep + \btxparameter\c!pagesep \or % second of two - \btxlistparameter\c!lastpagesep + \btxparameter\c!lastpagesep \or % last - \btxlistparameter\c!finalpagesep + \btxparameter\c!finalpagesep \fi \fi \stopsetups -\startsetups \s!btx:\s!list:\s!page:normal - \fastsetup{\s!btx:\s!list:\s!page:concat} - \btxdoifelseinteractive {page} { +% for the moment we have only one variant + +\startsetups [\s!btx:\s!page:\s!list] + \fastsetup{\s!btx:\s!page:concat} + % \ifx\currentbtxlastpage\empty + % p. + % \else + % pp. + % \fi + % \btxnbsp + \ifconditional\btxinteractive \goto { \currentbtxfirstpage } [ internal(\currentbtxfirstinternal) ] \ifx\currentbtxlastpage\empty \else - \btxlistvariantparameter\c!pageconnector + \btxparameter\c!pageconnector \goto { \currentbtxlastpage } [ internal(\currentbtxlastinternal) ] \fi - } { + \else \currentbtxfirstpage \ifx\currentbtxlastpage\empty \else - \btxlistvariantparameter\c!pageconnector + \btxparameter\c!pageconnector \currentbtxlastpage \fi - } + \fi \stopsetups \protect diff --git a/tex/context/base/publ-imp-replacements.lua b/tex/context/base/publ-imp-replacements.lua new file mode 100644 index 000000000..b15b17e30 --- /dev/null +++ b/tex/context/base/publ-imp-replacements.lua @@ -0,0 +1,13 @@ +return { + name = "replacements", + version = "1.00", + comment = "Good riddance", + author = "Alan Braslau and Hans Hagen", + copyright = "ConTeXt development team", + replacements = { + [ [[Th\^e\llap{\raise0.5ex\hbox{\'{\relax}}}]] ] = "Thánh", + [ [[Th\^e\llap{\raise 0.5ex\hbox{\'{\relax}}}]] ] = "Thánh", + [ [[Th{\^e}\llap{\raise0.5ex\hbox{\'{\relax}}}]] ] = "Thánh", + [ [[Th{\^e}\llap{\raise 0.5ex\hbox{\'{\relax}}}]] ] = "Thánh", + }, +} diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 2d85637a2..6cde49d7b 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -11,15 +11,16 @@ if not modules then modules = { } end modules ['publ-ini'] = { -- plug the list sorted in the list mechanism (specification.sortorder) --- todo: delay details till alternative is known so that potential author --- fields are known - -- If we define two datasets with the same bib file we can consider -- sharing the data but that means that we need to have a parent which -- in turn makes things messy if we start manipulating entries in -- different ways (future) .. not worth the trouble as we will seldom -- load big bib files many times and even then ... fonts are larger. +-- A potential optimization is to work with current_dataset, current_tag when +-- fetching fields but the code become real messy that way (many currents). The +-- gain is not that large anyway because not much publication stuff is flushed. + local next, rawget, type, tostring, tonumber = next, rawget, type, tostring, tonumber local match, find = string.match, string.find local concat, sort, tohash = table.concat, table.sort, table.tohash @@ -32,9 +33,11 @@ local sortedkeys, sortedhash = table.sortedkeys, table.sortedhash local setmetatableindex = table.setmetatableindex local lpegmatch = lpeg.match local P, S, C, Ct, R, Carg = lpeg.P, lpeg.S, lpeg.C, lpeg.Ct, lpeg.R, lpeg.Carg +local upper = utf.upper local report = logs.reporter("publications") local report_cite = logs.reporter("publications","cite") +local report_list = logs.reporter("publications","list") local report_reference = logs.reporter("publications","reference") local trace = false trackers.register("publications", function(v) trace = v end) @@ -60,16 +63,9 @@ local v_local = variables["local"] local v_global = variables["global"] local v_force = variables.force -local v_standard = variables.standard -local v_start = variables.start local v_none = variables.none -local v_left = variables.left -local v_right = variables.right -local v_middle = variables.middle -local v_inbetween = variables.inbetween local v_yes = variables.yes local v_all = variables.all -local v_cite = variables.cite local v_default = variables.default local v_dataset = variables.dataset @@ -78,7 +74,8 @@ local numbertochar = converters.characters local logsnewline = logs.newline local logspushtarget = logs.pushtarget local logspoptarget = logs.poptarget -local csname_id = token.csname_id + +local isdefined = tex.isdefined ----- basicsorter = sorters.basicsorter -- (a,b) ----- sortstripper = sorters.strip @@ -96,78 +93,85 @@ manipulatormethods.WORD = converters.WORD manipulatormethods.Words = converters.Words manipulatormethods.WORDS = converters.WORDS -local context = context -local commands = commands - -local ctx_doifelse = commands.doifelse -local ctx_doif = commands.doif -local ctx_doifnot = commands.doifnot - -local ctx_setvalue = context.setvalue -local ctx_firstoftwoarguments = context.firstoftwoarguments -local ctx_secondoftwoarguments = context.secondoftwoarguments -local ctx_firstofoneargument = context.firstofoneargument -local ctx_gobbleoneargument = context.gobbleoneargument - -local ctx_btxlistparameter = context.btxlistparameter -local ctx_btxcitevariantparameter = context.btxcitevariantparameter -local ctx_btxlistvariantparameter = context.btxlistvariantparameter -local ctx_btxdirectlink = context.btxdirectlink -local ctx_btxhandlelistentry = context.btxhandlelistentry -local ctx_btxhandlelisttextentry = context.btxhandlelisttextentry -local ctx_btxchecklistentry = context.btxchecklistentry -local ctx_btxchecklistcombi = context.btxchecklistcombi -local ctx_btxsetcitereference = context.btxsetcitereference -local ctx_btxsetlistreference = context.btxsetlistreference ------ ctx_btxmissing = context.btxmissing - -local ctx_btxsetdataset = context.btxsetdataset -local ctx_btxsettag = context.btxsettag -local ctx_btxsetnumber = context.btxsetnumber -local ctx_btxsetlanguage = context.btxsetlanguage -local ctx_btxsetcombis = context.btxsetcombis -local ctx_btxsetcategory = context.btxsetcategory -local ctx_btxcitesetup = context.btxcitesetup -local ctx_btxpagesetup = context.btxpagesetup -local ctx_btxsetfirst = context.btxsetfirst -local ctx_btxsetsecond = context.btxsetsecond -local ctx_btxsetthird = context.btxsetthird -local ctx_btxsetinternal = context.btxsetinternal -local ctx_btxsetlefttext = context.btxsetlefttext -local ctx_btxsetrighttext = context.btxsetrighttext -local ctx_btxsetbefore = context.btxsetbefore -local ctx_btxsetafter = context.btxsetafter -local ctx_btxsetbacklink = context.btxsetbacklink -local ctx_btxsetbacktrace = context.btxsetbacktrace -local ctx_btxsetcount = context.btxsetcount -local ctx_btxsetconcat = context.btxsetconcat -local ctx_btxsetoveflow = context.btxsetoverflow -local ctx_btxsetfirstpage = context.btxsetfirstpage -local ctx_btxsetlastpage = context.btxsetlastpage -local ctx_btxsetfirstinternal = context.btxsetfirstinternal -local ctx_btxsetlastinternal = context.btxsetlastinternal -local ctx_btxstartcite = context.btxstartcite -local ctx_btxstopcite = context.btxstopcite -local ctx_btxstartciteauthor = context.btxstartciteauthor -local ctx_btxstopciteauthor = context.btxstopciteauthor -local ctx_btxstartsubcite = context.btxstartsubcite -local ctx_btxstopsubcite = context.btxstopsubcite -local ctx_btxlistsetup = context.btxlistsetup -local ctx_btxflushauthor = context.btxflushauthor - -local registeredcitevariants = publications.registeredcitevariants or allocate() -local registeredlistvariants = publications.registeredlistvariants or allocate() - -storage.register("publications/registeredcitevariants", registeredcitevariants,"publications.registeredcitevariants") -storage.register("publications/registeredlistvariants", registeredlistvariants,"publications.registeredlistvariants") - -function commands.registerbtxcitevariant(name,parent) - registeredcitevariants[name] = parent or "" -end - -function commands.registerbtxlistvariant(name,parent) - registeredlistvariants[name] = parent or "" -end +local context = context +local commands = commands + +local ctx_doifelse = commands.doifelse +local ctx_doif = commands.doif +local ctx_doifnot = commands.doifnot + +local ctx_firstoftwoarguments = context.firstoftwoarguments +local ctx_secondoftwoarguments = context.secondoftwoarguments +local ctx_firstofoneargument = context.firstofoneargument + +local ctx_gobbleoneargument = context.gobbleoneargument +local ctx_gobbletwoarguments = context.gobbletwoarguments + +local ctx_btxdirectlink = context.btxdirectlink +local ctx_btxhandlelistentry = context.btxhandlelistentry +local ctx_btxhandlelisttextentry = context.btxhandlelisttextentry +local ctx_btxchecklistentry = context.btxchecklistentry +local ctx_btxchecklistcombi = context.btxchecklistcombi +----- ctx_btxsetcitereference = context.btxsetcitereference +----- ctx_btxsetlistreference = context.btxsetlistreference + +local ctx_btxsetdataset = context.btxsetdataset +local ctx_btxsettag = context.btxsettag +local ctx_btxsetnumber = context.btxsetnumber +local ctx_btxsetlanguage = context.btxsetlanguage +local ctx_btxsetcombis = context.btxsetcombis +local ctx_btxsetcategory = context.btxsetcategory +local ctx_btxcitesetup = context.btxcitesetup +local ctx_btxpagesetup = context.btxpagesetup +local ctx_btxsetfirst = context.btxsetfirst +local ctx_btxsetsecond = context.btxsetsecond +local ctx_btxsetthird = context.btxsetthird +local ctx_btxsetinternal = context.btxsetinternal +local ctx_btxsetlefttext = context.btxsetlefttext +local ctx_btxsetrighttext = context.btxsetrighttext +local ctx_btxsetbefore = context.btxsetbefore +local ctx_btxsetafter = context.btxsetafter +local ctx_btxsetbacklink = context.btxsetbacklink +local ctx_btxsetbacktrace = context.btxsetbacktrace +local ctx_btxsetcount = context.btxsetcount +local ctx_btxsetconcat = context.btxsetconcat +local ctx_btxsetoveflow = context.btxsetoverflow +local ctx_btxsetfirstpage = context.btxsetfirstpage +local ctx_btxsetlastpage = context.btxsetlastpage +local ctx_btxsetfirstinternal = context.btxsetfirstinternal +local ctx_btxsetlastinternal = context.btxsetlastinternal +local ctx_btxstartcite = context.btxstartcite +local ctx_btxstopcite = context.btxstopcite +local ctx_btxstartciteauthor = context.btxstartciteauthor +local ctx_btxstopciteauthor = context.btxstopciteauthor +local ctx_btxstartsubcite = context.btxstartsubcite +local ctx_btxstopsubcite = context.btxstopsubcite +local ctx_btxstartlistentry = context.btxstartlistentry +local ctx_btxstoplistentry = context.btxstoplistentry +local ctx_btxlistsetup = context.btxlistsetup +local ctx_btxflushauthor = context.btxflushauthor +local ctx_btxsetnoflistentries = context.btxsetnoflistentries +local ctx_btxsetcurrentlistentry = context.btxsetcurrentlistentry +local ctx_btxsetcurrentlistindex = context.btxsetcurrentlistindex + +local ctx_setmacro = tokens.setters and tokens.setters.macro + +languages.data = languages.data or { } +local data = languages.data + +-- local registeredcitevariants = publications.registeredcitevariants or { } +-- local registeredlistvariants = publications.registeredlistvariants or { } +-- +-- storage.register("publications/registeredcitevariants", registeredcitevariants,"publications.registeredcitevariants") +-- storage.register("publications/registeredlistvariants", registeredlistvariants,"publications.registeredlistvariants") +-- +-- function commands.registerbtxcitevariant(name,parent) +-- registeredcitevariants[name] = parent or "" +-- end +-- +-- function commands.registerbtxlistvariant(name,parent) +-- registeredlistvariants[name] = parent or "" +-- end local specifications = publications.specifications local currentspecification = specifications[false] @@ -205,7 +209,6 @@ end) luatex.registerstopactions(function() local done = false - local undefined = csname_id("undefined*crap") for name, dataset in sortedhash(datasets) do for command, n in sortedhash(dataset.commands) do if not done then @@ -215,16 +218,12 @@ luatex.registerstopactions(function() logsnewline() done = true end - local c = csname_id(command) - if c and c ~= undefined then + if isdefined[command] then report("%-20s %-20s % 5i %s",name,command,n,"known") + elseif isdefined[upper(command)] then + report("%-20s %-20s % 5i %s",name,command,n,"KNOWN") else - local u = csname_id(utf.upper(command)) - if u and u ~= undefined then - report("%-20s %-20s % 5i %s",name,command,n,"KNOWN") - else - report("%-20s %-20s % 5i %s",name,command,n,"unknown") - end + report("%-20s %-20s % 5i %s",name,command,n,"unknown") end end end @@ -363,9 +362,9 @@ do -- reference (in list) local userdata = entry.userdata if userdata then - local set = userdata.btxset - if set then - local tag = userdata.btxref + local tag = userdata.btxref + if tag then + local set = userdata.btxset or v_default local s = usedentries[set] if s then local u = s[tag] @@ -476,17 +475,23 @@ local findallused do local finder = publications.finder findallused = function(dataset,reference,internal) + local current = datasets[dataset] local finder = publications.finder -- for the moment, not yet in all betas - local find = finder and finder(reference) + local find = finder and finder(current,reference) local tags = not find and settings_to_array(reference) local todo = { } local okay = { } -- only if mark local set = usedentries[dataset] - local current = datasets[dataset] local valid = current.luadata local ordered = current.ordered if set then + local registered = { } local function register(tag) + if registered[tag] then + return + else + registered[tag] = true + end local entry = set[tag] if entry then -- only once in a list but at some point we can have more (if we @@ -527,7 +532,14 @@ local findallused do end todo[tag] = true end - if find then + if reference == "*" then + tags = { } + for i=1,#ordered do + local tag = ordered[i].tag + register(tag) + tags[#tags+1] = tag + end + elseif find then tags = { } for i=1,#ordered do local entry = ordered[i] @@ -554,7 +566,9 @@ local findallused do for i=1,#ordered do local entry = ordered[i] if find(entry) then - tags[#tags+1] = entry.tag + local tag = entry.tag + tags[#tags+1] = tag + todo[tag] = true end end else @@ -635,7 +649,7 @@ function commands.flushmarked() -- keep order local tag = marked_list[i] local tbm = tobemarked[tag] - if not tbm or tbm == true then + if tbm == nil or tbm == true then nofcitations = nofcitations + 1 marknocite(marked_dataset,tag,nofcitations) if trace_cite then @@ -764,11 +778,44 @@ local function getdirect(dataset,data,field,catspec) -- no field check, no datas end end +local function getfuzzy(data,field,categories) -- no field check, no dataset check + local catspec + if categories then + local category = data.category + if category then + catspec = categories[data.category] + end + end + if not field then + return + elseif not catspec then + return data[field] + end + local fields = catspec.fields + if fields then + local sets = catspec.sets + if sets then + local set = sets[field] + if set then + for i=1,#set do + local field = set[i] + local value = fields[field] and data[field] -- redundant check + if value then + return value + end + end + end + end + return fields[field] and data[field] or nil -- redundant check + end +end + publications.getfield = getfield publications.getdetail = getdetail publications.getcasted = getcasted publications.getfaster = getfaster publications.getdirect = getdirect +publications.getfuzzy = getfuzzy -- this needs to be checked: a specific type should have a checker @@ -832,24 +879,28 @@ function commands.btxsingularorplural(dataset,tag,name) ctx_doifelse(true) end -function firstandlast.pagenumber(d) +function firstandlast.range(d) if type(d) == "table" then return d[1], d[2] end end -function commands.oneorrange(dataset,tag,name) +firstandlast.pagenumber = firstandlast.range + +function commands.btxoneorrange(dataset,tag,name) local data, field, kind = getcasted(dataset,tag,name) if data then local test = firstandlast[kind] if test then local first, last = test(data) ctx_doifelse(not (first and last)) + return end end + ctx_gobbletwoarguments() end -function commands.firstofrange(dataset,tag,name) +function commands.btxfirstofrange(dataset,tag,name) local data, field, kind = getcasted(dataset,tag,name) if data then local test = firstandlast[kind] @@ -909,6 +960,8 @@ do -- seconds are irrelevant (there is for sure more to gain by proper coding -- of the source and or style). + local f_short = formatters["%t%02i"] + function publications.enhancers.suffixes(dataset) if not dataset then return -- bad news @@ -922,11 +975,12 @@ do local luadata = dataset.luadata local details = dataset.details local ordered = dataset.ordered - local field = "author" -- currently only author - local shorts = { } if not luadata or not details or not ordered then + report("nothing to be analyzed in %a",dataset.name) return -- also bad news end + local field = "author" -- currently only author + local shorts = { } for i=1,#ordered do local entry = ordered[i] if entry then @@ -940,6 +994,7 @@ do local userdata = listentry.userdata local btxspc = userdata and userdata.btxspc if btxspc then + -- this will become a specification entry local author = getcasted(dataset,tag,field,specifications[btxspc]) if type(author) == "table" then -- number depends on sort order @@ -956,7 +1011,7 @@ do end end local year = tonumber(entry.year) or 0 - local short = formatters["%t%02i"](t,mod(year,100)) + local short = f_short(t,mod(year,100)) local s = shorts[short] -- we could also sort on reference i.e. entries.text if u then @@ -1030,8 +1085,8 @@ function commands.setbtxdataset(name,default) elseif default and default ~= "" then context(default) else - context(v_standard) - report("unknown dataset %a, forcing %a",name,standard) + context(v_default) + report("unknown dataset %a, forcing %a",name,v_default) end end @@ -1091,6 +1146,8 @@ do -- then there can be cases where we have no specification for instance -- when we have a special kind of database + local splitter = lpeg.splitat(":") + local function permitted(category,field) local catspec = currentspecification.categories[category] if not catspec then @@ -1105,6 +1162,10 @@ do if ignoredfields and ignoredfields[field] then return false end + local virtual = catspec.virtual + if virtual and virtual[field] then + return true + end local sets = catspec.sets if sets then local set = sets[field] @@ -1115,6 +1176,10 @@ do if fields[field] then return true end + local f, l = lpegmatch(splitter,field) + if f and l and fields[f] then + return true -- language specific one + end end local function found(dataset,tag,field,valid,fields) @@ -1234,8 +1299,8 @@ do local fields = dataset.luadata[tag] if fields then local category = fields.category + local manipulator, field = splitmanipulation(field) if permitted(category,field) then - local manipulator, field = splitmanipulation(field) local value = fields[field] if value then typesetters[currentspecification.types[field]](field,value,manipulator) @@ -1261,8 +1326,8 @@ do local details = dataset.details[tag] if details then local category = fields.category + local manipulator, field = splitmanipulation(field) if permitted(category,field) then - local manipulator, field = splitmanipulation(field) local value = details[field] if value then typesetters[currentspecification.types[field]](field,value,manipulator) @@ -1298,6 +1363,7 @@ do end end + publications.okay = okay function commands.btxdoifelse(name,tag,field) ctx_doifelse(okay(name,tag,field)) end function commands.btxdoif (name,tag,field) ctx_doif (okay(name,tag,field)) end @@ -1319,7 +1385,11 @@ end do - local patterns = { "publ-imp-%s.mkvi", "publ-imp-%s.mkiv", "publ-imp-%s.tex" } + local patterns = { + "publ-imp-%s.mkvi", + "publ-imp-%s.mkiv", + "publ-imp-%s.tex", + } local function failure(name) report("unknown library %a",name) @@ -1339,6 +1409,20 @@ do } end + local patterns = { + "publ-imp-%s.lua", + } + + function commands.loadbtxreplacementfile(name) -- a more specific name + commands.uselibrary { + name = string.gsub(name,"^publ%-",""), + patterns = patterns, + action = publications.loaders.registercleaner, + failure = failure, + onlyonce = true, + } + end + end -- lists @@ -1464,7 +1548,7 @@ do local list = rendering.list for tag, data in sortedhash(luadata) do if not keyword or validkeyword(dataset,tag,keyword) then - list[#list+1] = { tag, false, 0, false, false } + list[#list+1] = { tag, false, 0, false, false, data.index or 0} end end end @@ -1472,17 +1556,21 @@ do methods[v_force] = function (dataset,rendering,keyword) -- only for checking, can have duplicates, todo: collapse page numbers, although -- we then also needs deferred writes - local result = structures.lists.filter(rendering.specification) or { } + local result = structures.lists.filter(rendering.specifications) or { } local list = rendering.list local current = datasets[dataset] local luadata = current.luadata for listindex=1,#result do local r = result[listindex] local u = r.userdata - if u and u.btxset == dataset then - local tag = u.btxref - if tag and (not keyword or validkeyword(dataset,tag,keyword)) then - list[#list+1] = { tag, listindex, 0, u, u.btxint } + if u then + local set = u.btxset or v_default + if set == dataset then + local tag = u.btxref + if tag and (not keyword or validkeyword(dataset,tag,keyword)) then + local data = luadata[tag] + list[#list+1] = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } + end end end end @@ -1493,7 +1581,7 @@ do -- global : if tag and not alldone[tag] and done[tag] ~= section then ... methods[v_local] = function(dataset,rendering,keyword) - local result = structures.lists.filter(rendering.specification) or { } + local result = structures.lists.filter(rendering.specifications) or { } local section = sections.currentid() local list = rendering.list local repeated = rendering.repeated == v_yes @@ -1506,34 +1594,40 @@ do local pages = { } local current = datasets[dataset] local luadata = current.luadata +rendering.result = result for listindex=1,#result do local r = result[listindex] local u = r.userdata - if u and u.btxset == dataset then - local tag = u.btxref - if not tag then - -- problem - elseif done[tag] == section then -- a bit messy for global and all and so - -- skip - elseif doglobal and alldone[tag] then - -- skip - elseif not keyword or validkeyword(dataset,tag,keyword) then - if traced then - local l = traced[tag] - if l then - l[#l+1] = u.btxint + if u then + local set = u.btxset or v_default + if set == dataset then + local tag = u.btxref + if not tag then + -- problem + elseif done[tag] == section then -- a bit messy for global and all and so + -- skip + elseif doglobal and alldone[tag] then + -- skip + elseif not keyword or validkeyword(dataset,tag,keyword) then + if traced then + local l = traced[tag] + if l then + l[#l+1] = u.btxint + else + local data = luadata[tag] + local l = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } + list[#list+1] = l + traced[tag] = l + end else - local l = { tag, listindex, 0, u, u.btxint } - list[#list+1] = l - traced[tag] = l + done[tag] = section + alldone[tag] = true + local data = luadata[tag] + list[#list+1] = { tag, listindex, 0, u, u.btxint, data and data.index or 0 } end - else - done[tag] = section - alldone[tag] = true - list[#list+1] = { tag, listindex, 0, u, u.btxint } end + registerpage(pages,tag,result,listindex) end - registerpage(pages,tag,result,listindex) end end if traced then @@ -1558,18 +1652,20 @@ do if not rendering then return end - local method = specification.method or v_none - local ignored = specification.ignored or "" - rendering.method = method - rendering.ignored = ignored ~= "" and settings_to_set(ignored) or nil - rendering.list = { } - rendering.done = { } - rendering.sorttype = specification.sorttype or v_default - rendering.criterium = specification.criterium or v_none - rendering.repeated = specification.repeated or v_no - rendering.specification = specification - local filtermethod = methods[method] + local method = specification.method or v_none + local ignored = specification.ignored or "" + rendering.method = method + rendering.ignored = ignored ~= "" and settings_to_set(ignored) or nil + rendering.list = { } + rendering.done = { } + rendering.sorttype = specification.sorttype or v_default + rendering.criterium = specification.criterium or v_none + rendering.repeated = specification.repeated or v_no + rendering.group = specification.group or "" + rendering.specifications = specification + local filtermethod = methods[method] if not filtermethod then + report_list("invalid method %a",method or "") return end lists.result = { } -- kind of reset @@ -1580,11 +1676,12 @@ do keyword = nil end filtermethod(dataset,rendering,keyword) + ctx_btxsetnoflistentries(#rendering.list) end -- for determining width - local lastreferencenumber = 0 -- document wide + local groups = setmetatableindex("number") function lists.prepareentries(dataset) local rendering = renderings[dataset] @@ -1593,11 +1690,13 @@ do local forceall = rendering.criterium == v_all local repeated = rendering.repeated == v_yes local sorttype = rendering.sorttype or v_default + local group = rendering.group or "" local sorter = lists.sorters[sorttype] local current = datasets[dataset] local luadata = current.luadata local details = current.details local newlist = { } + local lastreferencenumber = groups[group] -- current.lastreferencenumber or 0 for i=1,#list do local li = list[i] local tag = li[1] @@ -1628,6 +1727,7 @@ do end end end + groups[group] = lastreferencenumber if type(sorter) == "function" then rendering.list = sorter(dataset,rendering,newlist,sorttype) or newlist else @@ -1655,7 +1755,12 @@ do function commands.btxflushpages(dataset,tag) -- todo: interaction local rendering = renderings[dataset] - local pages = rendering.pages[tag] + local pages = rendering.pages + if not pages then + return + else + pages = pages[tag] + end if not pages then return end @@ -1713,67 +1818,153 @@ do end end - function lists.flushentries(dataset,textmode) + function lists.sameasprevious(dataset,i,name) local rendering = renderings[dataset] local list = rendering.list + local n = tonumber(i) + if n and n > 1 and n <= #list then + local luadata = datasets[dataset].luadata + local current = getdirect(dataset,luadata[list[n ][1]],name) + local previous = getdirect(dataset,luadata[list[n-1][1]],name) + if trace_detail then + report("previous %a, current %a",tostring(previous),tostring(current)) + end + return current and current == previous + else + return false + end + end + + function lists.flushentry(dataset,i,textmode) + local rendering = renderings[dataset] + local list = rendering.list +-- local result = rendering.result local luadata = datasets[dataset].luadata - -- maybe a startflushing here - ignoredfields = rendering.ignored or { } - -- - if list then - for i=1,#list do - local li = list[i] - local tag = li[1] - local n = li[3] - local entry = luadata[tag] - local combined = entry.combined - local language = entry.language - if combined then - ctx_btxsetcombis(concat(combined,",")) + local li = list[i] + if li then + local tag = li[1] + local listindex = li[2] + local n = li[3] + local entry = luadata[tag] + -- + ctx_btxstartlistentry() + ctx_btxsetcurrentlistentry(i) -- redundant + ctx_btxsetcurrentlistindex(listindex) + local combined = entry.combined + local language = entry.language + if combined then + ctx_btxsetcombis(concat(combined,",")) + end + ctx_btxsetcategory(entry.category or "unknown") + ctx_btxsettag(tag) + ctx_btxsetnumber(n) + if language then + ctx_btxsetlanguage(language) + end + local bl = li[5] + if bl and bl ~= "" then + ctx_btxsetbacklink(bl) + ctx_btxsetbacktrace(concat(li," ",5)) + local uc = citetolist[tonumber(bl)] + if uc then + ctx_btxsetinternal(uc.references.internal or "") end - ctx_btxsetcategory(entry.category or "unknown") - ctx_btxsettag(tag) - ctx_btxsetnumber(n) - if language then - ctx_btxsetlanguage(language) + else + -- nothing + end + local userdata = li[4] + if userdata then + local b = userdata.btxbtx + local a = userdata.btxatx + if b then + ctx_btxsetbefore(b) end - local bl = li[5] - if bl and bl ~= "" then - ctx_btxsetbacklink(bl) - ctx_btxsetbacktrace(concat(li," ",5)) - local uc = citetolist[tonumber(bl)] - if uc then - ctx_btxsetinternal(uc.references.internal or "") - end - else - -- nothing + if a then + ctx_btxsetafter(a) end - local userdata = li[4] - if userdata then - local b = userdata.btxbtx - local a = userdata.btxatx - if b then - ctx_btxsetbefore(b) - end - if a then - ctx_btxsetafter(a) - end + end + rendering.userdata = userdata + if textmode then + ctx_btxhandlelisttextentry() + else + ctx_btxhandlelistentry() + end + ctx_btxstoplistentry() + -- + -- context(function() + -- -- wrapup + -- rendering.ignoredfields = nil + -- end) + end + end + + +if ctx_setmacro then -- no real gain, but nice as test + + function lists.flushentry(dataset,i,textmode) + local rendering = renderings[dataset] + local list = rendering.list + local luadata = datasets[dataset].luadata + local li = list[i] + if li then + local tag = li[1] + local listindex = li[2] + local n = li[3] + local entry = luadata[tag] + -- + ctx_btxstartlistentry() + ctx_setmacro("currentbtxlistentry",i) -- redundant + ctx_setmacro("currentbtxlistindex",listindex) + local combined = entry.combined + local language = entry.language + if combined then + ctx_setmacro("currentbtxcombis",concat(combined,",")) + end + ctx_setmacro("currentbtxcategory",entry.category or "unknown") + ctx_setmacro("currentbtxtag",tag) + ctx_setmacro("currentbtxnumber",n) + if language then + ctx_setmacro("currentbtxlanguage",language) + end + local bl = li[5] + if bl and bl ~= "" then + ctx_setmacro("currentbtxbacklink",bl) + ctx_setmacro("currentbtxbacktrace",concat(li," ",5)) + local uc = citetolist[tonumber(bl)] + if uc then + ctx_setmacro("currentbtxinternal",uc.references.internal or "") end - rendering.userdata = userdata - if textmode then - ctx_btxhandlelisttextentry() - else - ctx_btxhandlelistentry() + else + -- nothing + end + local userdata = li[4] + if userdata then + local b = userdata.btxbtx + local a = userdata.btxatx + if b then + ctx_setmacro("currentbtxbefore",b) + end + if a then + ctx_setmacro("currentbtxafter",a) end end + rendering.userdata = userdata + if textmode then + ctx_btxhandlelisttextentry() + else + ctx_btxhandlelistentry() + end + ctx_btxstoplistentry() + -- + -- context(function() + -- -- wrapup + -- rendering.ignoredfields = nil + -- end) end - context(function() - -- wrapup - ignoredfields = nil - setspecification(false) - end) end +end + local function getuserdata(dataset,key) local rendering = renderings[dataset] if rendering then @@ -1813,13 +2004,14 @@ do end end - commands.btxresolvelistreference = lists.resolve - commands.btxaddtolist = lists.addentry - commands.btxcollectlistentries = lists.collectentries - commands.btxpreparelistentries = lists.prepareentries - commands.btxfetchlistentries = lists.fetchentries - commands.btxflushlistentries = lists.flushentries - commands.btxflushlistentry = lists.flushentry + commands.btxresolvelistreference = lists.resolve + commands.btxaddtolist = lists.addentry + commands.btxcollectlistentries = lists.collectentries + commands.btxpreparelistentries = lists.prepareentries + commands.btxfetchlistentries = lists.fetchentries + commands.btxflushlistentry = lists.flushentry + + commands.btxdoifelsesameasprevious = function(...) ctx_doifelse(lists.sameasprevious(...)) end end @@ -1829,9 +2021,12 @@ do publications.citevariants = citevariants function commands.btxhandlecite(specification) - local dataset = specification.dataset or "" -- standard + local dataset = specification.dataset or v_default local reference = specification.reference - local variant = specification.variant or defaultvariant + local variant = specification.variant + if not variant or variant == "" then + variant = "default" + end if not reference or reference == "" then return end @@ -1842,11 +2037,11 @@ do -- local prefix, rest = lpegmatch(prefixsplitter,reference) if prefix and rest then + dataset = prefix specification.dataset = prefix specification.reference = rest end -- - -- if trace_cite then report_cite("inject, dataset: %s, tag: %s, variant: %s, compressed", specification.dataset or "-", @@ -1855,14 +2050,14 @@ do ) end -- - ctx_setvalue("currentbtxdataset",dataset) + ctx_btxsetdataset(dataset) -- citevariants[variant](specification) -- we always fall back on default end function commands.btxhandlenocite(specification) - local dataset = specification.dataset or "" -- standard + local dataset = specification.dataset or v_default local reference = specification.reference if not reference or reference == "" then return @@ -1901,7 +2096,21 @@ do -- sorter - local keysorter = function(a,b) return a.sortkey < b.sortkey end + local keysorter = function(a,b) + local ak = a.sortkey + local bk = b.sortkey + if ak == bk then + local as = a.suffix -- alphabetic + local bs = b.suffix -- alphabetic + if as and bs then + return (as or "") < (bs or "") + else + return false + end + else + return ak < bk + end + end -- local suffix = 0 -- local function setsuffix(entry,suffix,sortfld) @@ -1940,7 +2149,12 @@ do local function compresslist(source) for i=1,#source do - if type(source[i].sortkey) ~= "number" then + local t = type(source[i].sortkey) + if t == "number" then + -- okay + -- elseif t == "string" then + -- -- okay + else return source end end @@ -1968,6 +2182,7 @@ do for i=1,#source do local entry = source[i] local current = entry.sortkey + local suffix = entry.suffix -- todo but what if not first then first, last, firstr, lastr = current, current, entry, entry elseif current == last + 1 then @@ -2016,49 +2231,52 @@ do local setter = specification.setter local compressor = specification.compressor -- - local reference = publications.parenttag(dataset,reference) -- local found, todo, list = findallused(dataset,reference,internal) tobemarked = specification.markentry and todo -- - if not found then + if not found or #found == 0 then report("nothing found for %a",reference) elseif not setup then report("invalid reference for %a",reference) else + if trace_cite then + report("processing reference %a",reference) + end local source = { } local badkey = false local luadata = datasets[dataset].luadata for i=1,#found do - local entry = found[i] - local tag = entry.userdata.btxref - -- we can probably move the test into the flush - -- local category = luadata[tag].category - -- if currentspecificationfields[category][setup] then - local internal = entry.references.internal - local data = setter(dataset,tag,entry,internal) - if compress and not compressor then - local sortkey = data.sortkey - if sortkey then - local key = lpegmatch(numberonly,sortkey) - if key then - data.sortkey = key - else - badkey = true - end + local entry = found[i] + local tag = entry.userdata.btxref + local ldata = luadata[tag] + local data = { + internal = entry.references.internal, + language = ldata.language, + dataset = dataset, + tag = tag, + -- luadata = ldata, + } + setter(data,dataset,tag,entry) + if compress and not compressor then + local sortkey = data.sortkey + if sortkey then + local key = lpegmatch(numberonly,sortkey) + if key then + data.sortkey = key else badkey = true end - end - if type(data) == "table" then - source[#source+1] = data else - report("error in cite rendering %a",setup or "?") + badkey = true end - -- else - -- report("cite rendering %a is not available for %a",setup,category) - -- end + end + if type(data) == "table" then + source[#source+1] = data + else + report("error in cite rendering %a",setup or "?") + end end local lefttext = specification.lefttext @@ -2071,6 +2289,9 @@ do if before and before ~= "" then before = settings_to_array(before) end if after and after ~= "" then after = settings_to_array(after) end + local oneleft = lefttext and #lefttext == 1 and lefttext [1] + local oneright = righttext and #righttext == 1 and righttext[1] + local function flush(i,n,entry,last) local tag = entry.tag local currentcitation = markcite(dataset,tag) @@ -2078,10 +2299,26 @@ do ctx_btxstartcite() ctx_btxsettag(tag) -- - if lefttext then ctx_btxsetlefttext (lefttext [i] or #lefttext == 1 and lefttext [1] or "") end - if righttext then ctx_btxsetrighttext(righttext[i] or #righttext == 1 and righttext[1] or "") end - if before then ctx_btxsetbefore (before [i] or #before == 1 and before [1] or "") end - if after then ctx_btxsetafter (after [i] or #after == 1 and after [1] or "") end + if oneleft then + if i == 1 then + ctx_btxsetlefttext(oneleft) + end + elseif lefttext then + ctx_btxsetlefttext(lefttext[i] or "") + end + if oneright then + if i == n then + ctx_btxsetrighttext(oneright) + end + elseif righttext then + ctx_btxsetrighttext(righttext[i] or "") + end + if before then + ctx_btxsetbefore(before[i] or #before == 1 and before[1] or "") + end + if after then + ctx_btxsetafter(after[i] or #after == 1 and after[1] or "") + end -- ctx_btxsetbacklink(currentcitation) local bl = listtocite[currentcitation] @@ -2097,7 +2334,7 @@ do ctx_btxsetlanguage(language) end if not getter(entry,last) then - ctx_btxsetfirst(f_missing(tag)) + ctx_btxsetfirst("") -- (f_missing(tag)) end ctx_btxsetconcat(concatstate(i,n)) if trace_detail then @@ -2155,15 +2392,12 @@ do end local setters = setmetatableindex({},function(t,k) - local v = function(dataset,tag,entry,internal) - local value = getfield(dataset,tag,k) - return { - tag = tag, - internal = internal, - [k] = value, - sortkey = value, - sortfld = k, - } + local v = function(data,dataset,tag,entry) + local value = getcasted(dataset,tag,k) + data.value = value -- not really needed + data[k] = value + data.sortkey = value + data.sortfld = k end t[k] = v return v @@ -2178,66 +2412,28 @@ do end) setmetatableindex(citevariants,function(t,k) - local p = registeredcitevariants[k] - local v = nil - if p and p ~= "" then - v = rawget(t,p) - end - if not v then - p = defaultvariant or "default" - v = rawget(t,p) - end - report_cite("variant %a falls back on %a",k,p) + local p = defaultvariant or "default" + local v = rawget(t,p) + report_cite("variant %a falls back on %a setter and getter with setup %a",k,p,k) t[k] = v return v end) - function citevariants.default(presets) -- no longer used + function citevariants.default(presets) local variant = presets.variant processcite(presets,{ - setter = setters[variant], - getter = getters[variant], + setup = variant, + setter = setters[variant], + getter = getters[variant], }) end - -- - - -- -- what to do with sort .. todo: sorters by type - - -- function citevariants.handler(key) - -- local function setter(dataset,tag,entry,internal) - -- return { - -- dataset = dataset, - -- tag = tag, - -- internal = internal, - -- category = getfield(dataset,tag,key), - -- } - -- end - -- local function getter(first,last) - -- return simplegetter(first,last,key) - -- end - -- return function(presets) - -- processcite(presets,{ - -- setter = setter, - -- getter = getter, - -- }) - -- end - -- end - -- - -- citevariants.category = citevariants.handler("category") - -- citevariants.type = citevariants.handler("type") - -- category | type do - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - category = getfield(dataset,tag,"category"), - } + local function setter(data,dataset,tag,entry) + data.category = getfield(dataset,tag,"category") end local function getter(first,last) @@ -2267,11 +2463,8 @@ do do - local function setter(dataset,tag,entry,internal) - return { - tag = tag, - internal = internal, - } + local function setter(data,dataset,tag,entry) + -- nothing end local function getter(first,last) -- last not used @@ -2293,13 +2486,9 @@ do do - local function setter(dataset,tag,entry,internal) - return { - tag = tag, - internal = internal, - short = getdetail(dataset,tag,"short"), - suffix = getdetail(dataset,tag,"suffix"), - } + local function setter(data,dataset,tag,entry) + data.short = getdetail(dataset,tag,"short") + data.suffix = getdetail(dataset,tag,"suffix") end local function getter(first,last) -- last not used @@ -2330,13 +2519,8 @@ do do - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - pages = getcasted(dataset,tag,"pages"), - } + local function setter(data,dataset,tag,entry) + data.pages = getcasted(dataset,tag,"pages") end local function getter(first,last) @@ -2366,15 +2550,11 @@ do do - local function setter(dataset,tag,entry,internal) + local function setter(data,dataset,tag,entry) local entries = entry.entries - local text = entries and entries.text or "?" - return { - tag = tag, - internal = internal, - num = text, - sortkey = text, - } + local text = entries and entries.text or "?" + data.num = text + data.sortkey = text end local function getter(first,last) @@ -2395,15 +2575,12 @@ do do - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - year = getfield(dataset,tag,"year"), - suffix = getdetail(dataset,tag,"suffix"), - sortkey = getdetail(dataset,tag,"suffixedyear"), - } + local function setter(data,dataset,tag,entry) + local year = getfield (dataset,tag,"year") + local suffix = getdetail(dataset,tag,"suffix") + data.year = year + data.suffix = suffix + data.sortkey = tonumber(year) or 0 end local function getter(first,last) @@ -2424,15 +2601,10 @@ do do - local function setter(dataset,tag,entry,internal) + local function setter(data,dataset,tag,entry) local index = getfield(dataset,tag,"index") - return { - dataset = dataset, - tag = tag, - internal = internal, - index = index, - sortkey = index, - } + data.index = index + data.sortkey = index end local function getter(first,last) @@ -2461,12 +2633,8 @@ do do - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - } + local function setter(data,dataset,tag,entry) + -- nothing end local function getter(first,last) @@ -2492,6 +2660,44 @@ do end + -- keyword + + do + + local function listof(list) + local size = type(list) == "table" and #list or 0 + if size > 0 then + return function() + for i=1,size do + ctx_btxsetfirst(list[i]) + ctx_btxsetconcat(concatstate(i,size)) + ctx_btxcitesetup("listelement") + end + return true + end + else + return "?" -- unknown + end + end + + local function setter(data,dataset,tag,entry) + data.keywords = getcasted(dataset,tag,"keywords") + end + + local function getter(first,last) + context(listof(first.keywords)) + end + + function citevariants.keywords(presets) + return processcite(presets,{ + variant = "keywords", + setter = setter, + getter = getter, + }) + end + + end + -- authors do @@ -2516,6 +2722,8 @@ do end end end + -- beware: we usetables as hash so we get a cycle when inspecting (unless we start + -- hashing with strings) for i=1,#found do local entry = found[i] local author = entry.author @@ -2553,7 +2761,7 @@ do local bl = listtocite[currentcitation] ctx_btxsetinternal(bl and bl.references.internal or "") if first then - ctx_btxsetfirst(first[key] or f_missing(first.tag)) + ctx_btxsetfirst(first[key] or "") -- f_missing(first.tag)) local suffix = entry.suffix local value = entry.last[key] if value then @@ -2564,7 +2772,7 @@ do end else local suffix = entry.suffix - local value = entry[key] or f_missing(tag) + local value = entry[key] or "" -- f_missing(tag) ctx_btxsetfirst(value) if suffix then ctx_btxsetthird(suffix) @@ -2572,7 +2780,7 @@ do end ctx_btxsetconcat(concatstate(i,nofcollected)) if trace_detail then - report("expanding %a cite setup %a","single author",setup) + report("expanding %a cite setup %a","multiple author",setup) end ctx_btxcitesetup(setup) ctx_btxstopciteauthor() @@ -2590,10 +2798,12 @@ do -- ctx_btxsetbacklink(currentcitation) -- local bl = listtocite[currentcitation] -- ctx_btxsetinternal(bl and bl.references.internal or "") - ctx_btxsetfirst(entry[key] or f_missing(tag)) - ctx_btxsetthird(entry.suffix) + ctx_btxsetfirst(entry[key] or "") -- f_missing(tag) + if suffix then + ctx_btxsetthird(entry.suffix) + end if trace_detail then - report("expanding %a cite setup %a","multiple author",setup) + report("expanding %a cite setup %a","single author",setup) end ctx_btxcitesetup(setup) ctx_btxstopciteauthor() @@ -2604,7 +2814,12 @@ do local function authorgetter(first,last,key,setup) -- only first -- ctx_btxsetfirst(first.author) -- unformatted - ctx_btxsetfirst(currentbtxciteauthor) -- formatter (much slower) + -- ctx_btxsetfirst(currentbtxciteauthor) -- formatter (much slower) + if first.type == "author" then + ctx_btxsetfirst(currentbtxciteauthor) -- formatter (much slower) + else + ctx_btxsetfirst(first.author) -- unformatted + end local entries = first.entries -- alternatively we can use a concat with one ... so that we can only make the -- year interactive, as with the concat @@ -2612,11 +2827,13 @@ do entries = { first } end if entries then + -- happens with year local c = compresslist(entries) local f = function() authorconcat(c,key,setup) return true end -- indeed return true? ctx_btxsetcount(#c) ctx_btxsetsecond(f) - else + elseif first then + -- happens with num local f = function() authorsingle(first,key,setup) return true end -- indeed return true? ctx_btxsetcount(0) ctx_btxsetsecond(f) @@ -2626,18 +2843,16 @@ do -- author - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - author = getcasted(dataset,tag,"author"), - } + local function setter(data,dataset,tag,entry) + data.author, data.field, data.type = getcasted(dataset,tag,"author") end local function getter(first,last,_,setup) - -- ctx_btxsetfirst(first.author) -- unformatted - ctx_btxsetfirst(currentbtxciteauthor) -- formatter (much slower) + if first.type == "author" then + ctx_btxsetfirst(currentbtxciteauthor) -- formatter (much slower) + else + ctx_btxsetfirst(first.author) -- unformatted + end return true end @@ -2652,16 +2867,12 @@ do -- authornum - local function setter(dataset,tag,entry,internal) - local text = entry.entries.text - return { - dataset = dataset, - tag = tag, - internal = internal, - author = getcasted(dataset,tag,"author"), - num = text, - sortkey = text and lpegmatch(numberonly,text), - } + local function setter(data,dataset,tag,entry) + local entries = entry.entries + local text = entries and entries.text or "?" + data.author, data.field, data.type = getcasted(dataset,tag,"author") + data.num = text + data.sortkey = text and lpegmatch(numberonly,text) end local function getter(first,last) @@ -2680,16 +2891,13 @@ do -- authoryear | authoryears - local function setter(dataset,tag,entry,internal) - return { - dataset = dataset, - tag = tag, - internal = internal, - author = getcasted(dataset,tag,"author"), - year = getfield(dataset,tag,"year"), - suffix = getdetail(dataset,tag,"suffix"), - sortkey = getdetail(dataset,tag,"suffixedyear"), - } + local function setter(data,dataset,tag,entry) + data.author, data.field, data.type = getcasted(dataset,tag,"author") + local year = getfield (dataset,tag,"year") + local suffix = getdetail(dataset,tag,"suffix") + data.year = year + data.suffix = suffix + data.sortkey = tonumber(year) or 0 end local function getter(first,last) diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index c9670f535..e0e0489ab 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -93,58 +93,67 @@ % The main rendering style (standard driven). -\installcorenamespace {btx} - -\installsimplecommandhandler \??btx {btx} \??btx - -% \newconstant\btxmode -% \newconstant\btxnonemode -% \newconstant\btxcitemode -% \newconstant\btxlistmode - -%D Loading variants: +%D We assume that a specification is global or used grouped. It doesn't make much sense +%D to split between cite and list here as it only complicates matters (timing) and is +%D not clear either. -\let\currentbtxrenderingdefinition\empty -\let\currentbtxspecification \empty +\let\currentbtxspecification\empty \unexpanded\def\startbtxrenderingdefinitions[#1]% - {\pushmacro\currentbtxrenderingdefinition - \edef\currentbtxrenderingdefinition{#1}% - \letvalue{\??btxrenderingdefinition\currentbtxrenderingdefinition}\currentbtxrenderingdefinition - \unprotect} + {\unprotect + \pushmacro\currentbtxspecification + \edef\currentbtxspecification{#1}} \unexpanded\def\stopbtxrenderingdefinitions - {\protect - \popmacro\currentbtxrenderingdefinition} + {\popmacro\currentbtxspecification + \protect} \unexpanded\def\loadbtxdefinitionfile[#1]% {\ctxcommand{loadbtxdefinitionfile("#1")}} -\appendtoks - \edef\currentbtxspecification{\btxparameter\c!specification}% - \ifcsname\??btxrenderingdefinition\currentbtxspecification\endcsname - % maybe fall back on 4 ? - \else - \loadbtxdefinitionfile[\currentbtxspecification]% - \showmessage\m!publications{14}{\currentbtxspecification}% - \fi -\to \everysetupbtx +\unexpanded\def\loadbtxreplacementfile[#1]% + {\ctxcommand{loadbtxreplacementfile("#1")}} -\unexpanded\def\publ_specification_push#1% local, don't override +\unexpanded\def\publ_specification_push#1% {\pushmacro\currentbtxspecification + \pushmacro\currentbtxspecificationfallback \edef\currentbtxspecification{#1}% + \edef\currentbtxspecificationfallback{\namedbtxparameter\currentbtxspecification\c!default}% + \ifx\currentbtxspecificationfallback\currentbtxspecification + \let\currentbtxspecificationfallback\empty + \fi \ctxcommand{setbtxspecification("\currentbtxspecification")}} \unexpanded\def\publ_specification_pop - {\popmacro\currentbtxspecification + {\popmacro\currentbtxspecificationfallback + \popmacro\currentbtxspecification \ctxcommand{setbtxspecification("\currentbtxspecification")}} \unexpanded\def\publ_specification_set#1% beware: is global {\edef\currentbtxspecification{#1}% - \ctxcommand{setbtxspecification("\currentbtxspecification")}} + \edef\currentbtxspecificationfallback{\namedbtxparameter\currentbtxspecification\c!default}% + \ifx\currentbtxspecificationfallback\currentbtxspecification + \let\currentbtxspecificationfallback\empty + \fi + % has to be done explicitly: \loadbtxdefinitionfile[\currentbtxspecification]% + \ctxcommand{setbtxspecification("\currentbtxspecification")}}% todo: ,true == also load + +\installcorenamespace {btx} + +\installswitchcommandhandler \??btx {btx} \??btx \appendtoks - \publ_specification_set{\btxparameter\c!specification}% + \ifnum\btxsetupmode=\doingrootsetuproot + \publ_specification_set{\btxparameter\c!specification}% + \else\ifnum\btxsetupmode=\doingrootsetupnamed + \publ_specification_set{\btxparameter\c!specification}% + \fi\fi +\to \everysetupbtx + +\appendtoks + \ifnum\btxsetupmode=\doingrootsetuproot + \edef\currentbtxdataset{\ctxcommand{setbtxdataset("\btxparameter\c!dataset","\currentbtxdataset")}}% + \fi \to \everysetupbtx \appendtoks @@ -156,226 +165,68 @@ \let\stopusingbtxspecification\publ_specification_pop -% a dedicated construction mechanism - -\installcorenamespace {btxlist} - -\installcommandhandler \??btxlist {btxlist} \??btxlist - -\unexpanded\setvalue{\??constructioninitializer\v!btxlist}% - {\let\currentbtxlist \currentconstruction - \let\constructionparameter \btxlistparameter - \let\constructionnamespace \??btxlist - \let\detokenizedconstructionparameter\detokenizedbtxlistparameter - \let\letconstructionparameter \letbtxlistparameter - \let\useconstructionstyleandcolor \usebtxliststyleandcolor - \let\setupcurrentconstruction \setupcurrentbtxlist} - -\expandafter\let\csname\??constructionmainhandler \v!btxlist\expandafter\endcsname\csname\??constructionmainhandler \v!construction\endcsname -\expandafter\let\csname\??constructioncommandhandler\v!btxlist\expandafter\endcsname\csname\??constructioncommandhandler\v!construction\endcsname -\expandafter\let\csname\??constructiontexthandler \v!btxlist\expandafter\endcsname\csname\??constructiontexthandler \v!construction\endcsname - -\unexpanded\setvalue{\??constructioncommandhandler\v!btxlist}% - {\csname\??constructionstarthandler\v!construction\endcsname - \csname\??constructionstophandler \v!construction\endcsname - \endgroup} - -\unexpanded\def\startbtxlistentry#1% - {\begingroup - \strc_constructions_initialize{#1}% - \csname\??constructionstarthandler\currentconstructionhandler\endcsname} - -\unexpanded\def\stopbtxlistentry - {\csname\??constructionstophandler\currentconstructionhandler\endcsname} - -% interactivity is handled in setups - -\unexpanded\setvalue{\??constructiontexthandler\v!btxlist}% - {\begingroup - \fastsetup{\v!btxrendering:\v!number:\constructionparameter\c!number}% - \endgroup} - -% the whole entry can be interactive - -\unexpanded\setvalue{\??constructionstarthandler\v!btxlist}% - {\csname\??constructionstarthandler\v!construction\endcsname - \ifconditional\btx_interactive - \ifx\currentbtxnumbering\v!no\else - \ifx\currentbtxinternal\empty \else - \startgoto[\s!internal(\currentbtxinternal)]% - \fi - \fi - \fi} - -\unexpanded\setvalue{\??constructionstophandler\v!btxlist}% - {\ifconditional\btx_interactive - \ifx\currentbtxnumbering\v!no\else - \ifx\currentbtxinternal\empty \else - \stopgoto - \fi - \fi - \fi - \csname\??constructionstophandler\v!construction\endcsname - \endgroup} - -\startsetups[\v!btxrendering:\v!number:\v!no] - % \btx_reference_checked % needs testing -\stopsetups - -\startsetups[\v!btxrendering:\v!number:\v!yes] - \useconstructionstyleandcolor\c!headstyle\c!headcolor % move to \currentconstructiontext - \the\everyconstruction - \relax - \strut - \constructionparameter\c!text - \btx_list_reference_inject - \relax -\stopsetups - -% construction (todo:low level builder commands without using the constructor) - -\unexpanded\def\strc_constructions_initialize#1% class instance - {\edef\currentconstruction{#1}% - \let\currentconstructionlistentry\!!zerocount - \expandafter\let\expandafter\currentconstructionmain \csname\??constructionmain \currentconstruction\endcsname - \expandafter\let\expandafter\currentconstructionlevel \csname\??constructionlevel\currentconstruction\endcsname - \expandafter\let\expandafter\currentconstructionhandler\csname\??constructionclass\currentconstruction\endcsname - \csname\??constructioninitializer\currentconstructionhandler\endcsname} - -\appendtoks - % \ifx\currentbtxlistparent\empty - % \defineconstruction[\currentbtxlist][\currentbtxlistparent][\s!handler=\v!btxlist,\c!level=1]% - % \else - % \defineconstruction[\currentbtxlist][\s!handler=\v!btxlist,\c!level=1]% - % \fi - \ifx\currentbtxlistparent\empty - \letvalue{\??constructionmain\currentbtxlist}\currentbtxlist - \else - \letvalue{\??constructionmain\currentbtxlist}\currentbtxlistparent - \fi - \setevalue{\??constructionlevel\currentbtxlist}{\number\btxlistparameter\c!level}% - \setevalue{\??constructionclass\currentbtxlist}{\btxlistparameter\s!handler}% -\to \everydefinebtxlist - -\setupbtxlist - [\s!handler=\v!btxlist, - \c!level=1] - -\setupbtxlist - [\c!alternative=\v!left, - \c!headstyle=, - \c!titlestyle=, - %\c!style=, - %\c!color=, - %\c!headcolor=, - %\c!titlecolor=, - \c!width=4\emwidth, - \c!distance=\emwidth, - %\c!titledistance=.5\emwidth, - %\c!hang=, - %\c!sample=, - %\c!align=, - %\c!headalign=, - \c!margin=\v!no, - \c!before=\blank, - \c!inbetween=\blank, - \c!after=\blank, - %\c!indentnext=\v!yes, - %\c!indenting=\v!never, - %\c!titleleft=(, - %\c!titleright=), - %\c!closesymbol=, - %\c!closecommand=\wordright, - \c!display=\v!yes, - \c!command=, - %\c!titlecommand=, - %\c!expansion=\v!no, - %\c!xmlsetup=, - %\s!catcodes=, - %\c!title=\v!yes, - %\c!text=, - \c!number=\v!yes, - ] +% \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth] +% \setupbtxlist[alternative=paragraph,width=auto,distance=\emwidth,margin=2em] % useless +% \setupbtxlist[alternative=paragraph,width=fit,distance=\emwidth] +% \setupbtxlist[alternative=paragraph,width=fit,distance=\emwidth,margin=2em] % here starts the bib stuff \installcorenamespace {btxdataset} -\installcorenamespace {btxlistvariant} -\installcorenamespace {btxcitevariant} \installcorenamespace {btxrendering} \installcorenamespace {btxregister} \installcorenamespace {btxcommand} \installcorenamespace {btxrenderingdefinition} -\installcommandhandler \??btxdataset {btxdataset} \??btxdataset -\installcommandhandler \??btxlistvariant {btxlistvariant} \??btxlistvariant -\installcommandhandler \??btxcitevariant {btxcitevariant} \??btxcitevariant -\installcommandhandler \??btxregister {btxregister} \??btxregister -\installcommandhandler \??btxrendering {btxrendering} \??btxrendering - -%D The following two helpers permits us to use prefixes (if we want): -%D -%D \startbuffer -%D \let\btxciteparameter\btxspecificationciteparameter -%D \let\btxlistparameter\btxspecificationlistparameter -%D -%D \edef\currentbtxspecification {apa} -%D \edef\currentbtxcitealternative{author} -%D -%D \setupbtxcitevariant [crap=crap] -%D \definebtxcitevariant [author] [check=author,extra=author] -%D \definebtxcitevariant [authoryear] [author] [check=authoryear] -%D \definebtxcitevariant [authoryears] [authoryear] [check=authoryears] -%D \setupbtxcitevariant [author] [apa:check=apa-author] -%D \setupbtxcitevariant [authoryear] [apa:check=apa-authoryear] -%D -%D \starttabulate[|lT|lT|] -%D \NC \bf check \EQ \btxciteparameter{check} \NC\NR -%D \NC \bf extra \EQ \btxciteparameter{extra} \NC\NR -%D \NC \bf crap \EQ \btxciteparameter{crap} \NC\NR -%D \stoptabulate -%D \stopbuffer -%D -%D \typebuffer \start \getbuffer \stop - -\def\btxspecificationciteparameter#1% - {\csname - \??btxcitevariant - \ifcsname\??btxcitevariant\currentbtxcitealternative:\currentbtxspecification:#1\endcsname - \currentbtxcitealternative:\currentbtxspecification:#1% - \else\ifcsname\??btxcitevariant\currentbtxcitealternative:#1\endcsname - \currentbtxcitealternative:#1% - \else - :#1% we assume defined variants - \fi\fi - \endcsname} - -\def\btxspecificationlistparameter#1% - {\csname - \??btxlistvariant - \ifcsname\??btxlistvariant\currentbtxlistalternative:\currentbtxspecification:#1\endcsname - \currentbtxlistalternative:\currentbtxspecification:#1% - \else\ifcsname\??btxlistvariant\currentbtxlistalternative:#1\endcsname - \currentbtxlistalternative:#1% - \else - :#1% we assume defined variants - \fi\fi - \endcsname} - -% \let\btxciteparameter\btxspecificationciteparameter -% \let\btxlistparameter\btxspecificationlistparameter - -\appendtoks - \ifx\currentbtxlistvariant\empty \else - \ctxcommand{registerbtxlistvariant("\currentbtxlistvariant","\currentbtxlistvariantparent")}% - \fi -\to \everydefinebtxlistvariant - -\appendtoks - \ifx\currentbtxcitevariant\empty \else - \ctxcommand{registerbtxcitevariant("\currentbtxcitevariant","\currentbtxcitevariantparent")}% - \fi -\to \everydefinebtxcitevariant +\installcommandhandler \??btxdataset {btxdataset} \??btxdataset +\installcommandhandler \??btxregister {btxregister} \??btxregister +\installcommandhandler \??btxrendering {btxrendering} \??btxrendering + +% named: check all listvariant and citevariant + +\let\currentbtxcitevariant\empty +\let\currentbtxlistvariant\empty + +\let\currentbtxspecificationfallback\empty + +\unexpanded\def\setbtxparameterset#1#2% + {\edef\currentbtx + {\ifcsname\??btx\currentbtxspecification:#1:#2:\s!parent\endcsname + \currentbtxspecification:% + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:#1:#2:\s!parent\endcsname + \currentbtxspecificationfallback:% + \fi\fi\fi#1:#2}} + +\unexpanded\def\setbtxparametersetroot#1% + {\edef\currentbtx + {\ifcsname\??btx\currentbtxspecification:#1:\s!parent\endcsname + \currentbtxspecification:#1% + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:#1:\s!parent\endcsname + \currentbtxspecificationfallback:#1% + \fi\fi\fi}} + +\unexpanded\def\setbtxrendering + {\edef\currentbtxrendering + {\ifcsname\??btx\currentbtxspecification:\s!parent\endcsname + \currentbtxspecification + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:\s!parent\endcsname + \currentbtxspecificationfallback + \fi\fi\fi}} + +\unexpanded\def\setbtxlist % maybe simplify this one, always list=rendering? + {\edef\currentbtxlist + {\ifcsname\??btx\currentbtxrendering:\s!parent\endcsname + \currentbtxrendering + \else\ifcsname\??btx\currentbtxspecification:\s!parent\endcsname + \currentbtxspecification + \else\ifx\currentbtxspecificationfallback\empty + \else\ifcsname\??btx\currentbtxspecificationfallback:\s!parent\endcsname + \currentbtxspecificationfallback + \fi\fi\fi\fi}% + \edef\currentlist{\s!btx:\currentbtxlist}} \unexpanded\def\usebtxdataset {\begingroup @@ -392,18 +243,18 @@ \else\iffirstargument \ctxcommand{usebtxdataset{ specification = "\dummyparameter\c!specification", - dataset = "\v!standard", + dataset = "\v!default", filename = "#1", }}% \fi\fi \endgroup} \definebtxdataset - [\v!standard] + [\v!default] % [\c!language=] % nothing set so use current % \usebtxdataset -% [standard] +% [default] % [mybibs.bib] \unexpanded\def\startpublication @@ -423,11 +274,11 @@ \fi\fi{#1}{#2}} \def\publ_set_publication_default#1#2% - {\publ_set_publication_indeed\v!standard{#1}} + {\publ_set_publication_indeed\v!default{#1}} \def\publ_set_publication_checked#1#2% {\doifassignmentelse{#1} - {\publ_set_publication_indeed\v!standard{#1}} + {\publ_set_publication_indeed\v!default{#1}} {\publ_set_publication_indeed{#1}{}}} \def\publ_set_publication_indeed#1#2#3\stoppublication @@ -479,10 +330,7 @@ % access \let\currentbtxtag \empty -\let\currentbtxdataset\v!standard - -\unexpanded\def\setbtxdataset[#1]% - {\edef\currentbtxdataset{\ctxcommand{setbtxdataset("#1","\currentbtxdataset")}}} +\let\currentbtxdataset\v!default \unexpanded\def\setbtxentry[#1]% {\edef\currentbtxtag{\ctxcommand{setbtxentry("\currentbtxdataset","#1")}}} @@ -495,17 +343,17 @@ % \btxfield : current % \btxspecificfield : dataset,tag,key -\def\btxfield #1{\ctxcommand{btxfield("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdetail #1{\ctxcommand{btxdetail("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxflush #1{\ctxcommand{btxflush("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxfieldname #1{\ctxcommand{btxfieldname("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxfieldtype #1{\ctxcommand{btxfieldtype("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxfoundname #1{\ctxcommand{btxfoundname("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxfoundtype #1{\ctxcommand{btxfoundtype("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxauthorfield #1{\ctxcommand{btxauthorfield(\number\currentbtxauthorindex,"#1")}} -\def\btxdoifelse #1{\ctxcommand{btxdoifelse("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdoif #1{\ctxcommand{btxdoif("\currentbtxdataset","\currentbtxtag","#1")}} -\def\btxdoifnot #1{\ctxcommand{btxdoifnot("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxfield #1{\ctxcommand{btxfield("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxdetail #1{\ctxcommand{btxdetail("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxflush #1{\ctxcommand{btxflush("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxfieldname #1{\ctxcommand{btxfieldname("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxfieldtype #1{\ctxcommand{btxfieldtype("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxfoundname #1{\ctxcommand{btxfoundname("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxfoundtype #1{\ctxcommand{btxfoundtype("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxauthorfield#1{\ctxcommand{btxauthorfield(\number\currentbtxauthorindex,"#1")}} +\def\btxdoifelse #1{\ctxcommand{btxdoifelse("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxdoif #1{\ctxcommand{btxdoif("\currentbtxdataset","\currentbtxtag","#1")}} +\def\btxdoifnot #1{\ctxcommand{btxdoifnot("\currentbtxdataset","\currentbtxtag","#1")}} \let\btxsetup\fastsetup @@ -607,6 +455,26 @@ \setconstant\currentbtxconcat \zerocount \setconstant\currentbtxcount \zerocount} +%D Language: + +\def\mainbtxlanguage{\currentmainlanguage} + +\unexpanded\def\btx_check_language + {\let\mainbtxlanguage\currentlanguage + \ifx\currentbtxlanguage\empty + \let\currentbtxlanguage\currentlanguage + \else + \btx_check_language_indeed + \fi} + +\unexpanded\def\btx_check_language_indeed + {\edef\currentbtxlanguage{\reallanguagetag\currentbtxlanguage}% + \ifx\currentbtxlanguage\empty + \let\currentbtxlanguage\currentlanguage + \else\ifx\currentbtxlanguage\currentlanguage\else + \setcurrentlanguage\currentmainlanguage\currentbtxlanguage + \fi\fi} + %D Tracing \newconditional\c_btx_trace @@ -618,18 +486,6 @@ %D Rendering lists and citations. -\unexpanded\def\startbtxrendering - {\begingroup - \dosingleempty\btx_start_rendering} - -\def\btx_start_rendering[#1]% - {\edef\currentbtxrendering{#1}% - \btxrenderingparameter\c!before} - -\unexpanded\def\stopbtxrendering - {\btxrenderingparameter\c!after - \endgroup} - \unexpanded\def\btxtodo#1% {[#1]} @@ -652,17 +508,38 @@ \setuplist [\s!btx] - [\c!state=\v!start] + [\c!prefixstopper=:, + \c!state=\v!start, + \c!alternative=\v!paragraph, + \c!before=\blank, + \c!after=\blank, + \c!width=\v!auto, + \c!distance=\emwidth] + +\unexpanded\def\setupbtxlist + {\dodoubleempty\publ_setup_list} + +\unexpanded\def\publ_setup_list[#1][#2]% + {\ifsecondargument + \setuplist[\s!btx:#1][#2]% + \else\iffirstargument + \setuplist[\s!btx][#1]% + \fi\fi} \appendtoks \ifx\currentbtxrenderingparent\empty - \definebtxlist - [\currentbtxrendering]% + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx]% + \else\ifx\currentbtxrenderingparent\s!btx + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx]% \else - \definebtxlist - [\currentbtxrendering]% - [\currentbtxrenderingparent]% - \fi + \definelist + [\s!btx:\currentbtxrendering]% + [\s!btx:\currentbtxrenderingparent]% + \fi\fi \to \everydefinebtxrendering \newconditional\c_btx_list_texts @@ -699,18 +576,21 @@ \settrue\setfalse\c_btx_list_pages \to \everysetupbtxlistplacement -\unexpanded\def\btx_entry_inject_pages +\unexpanded\def\btx_entry_inject_pages % for the moment only normal {\dontleavehmode \begingroup - \let\currentlist\s!btx + \setbtxlist % probably already set \btxpagereset - \btxlistparameter\c!pageleft - \ctxcommand{btxflushpages("\currentbtxdataset","\currentbtxtag")}% - \btxlistparameter\c!pageright + \setbtxparameterset\s!page\s!list + \btxparameter\c!command + {\usebtxstyleandcolor\c!style\c!color + \btxparameter\c!pageleft + \ctxcommand{btxflushpages("\currentbtxdataset","\currentbtxtag")}% + \btxparameter\c!pageright}% \endgroup} \unexpanded\def\btxpagesetup - {\fastsetup{\s!btx:\s!list:\s!page:normal}% + {\fastbtxsetup\s!page\s!list \btxpagereset} % end of page stuff @@ -719,17 +599,13 @@ {\begingroup \edef\currentbtxcategory{\btxfield{category}}% \ignorespaces - \edef\currentbtxsetup{\s!btx:\currentbtxspecification:\currentbtxcategory}% - \doifsetupselse\currentbtxsetup - \btx_entry_inject_yes - \btx_entry_inject_nop - \endgroup} - -\unexpanded\def\btx_entry_inject_yes - {\ifconditional\c_btx_list_texts + \ifconditional\c_btx_list_texts \currentbtxbefore \fi - \fastsetup\currentbtxsetup + \begingroup + \usebtxstyleandcolor\c!style\c!color + \fastbtxsetup\s!list\currentbtxcategory + \endgroup \removeunwantedspaces \ifconditional\c_btx_list_pages \btx_entry_inject_pages @@ -740,16 +616,26 @@ \fi \ifconditional\c_btx_list_texts \currentbtxafter - \fi} + \fi + \endgroup} + +\unexpanded\def\btxshowentryinline + {\dodoubleempty\btx_entry_show_inline} -\def\btx_entry_inject_nop - {\tttf \getmessage\m!publications{12}{\currentbtxsetup}} +\unexpanded\def\btx_entry_show_inline[#1][#2]% + {\ifsecondargument + \ctxcommand{showbtxentry("#1","#2")} + \else\iffirstargument + \ctxcommand{showbtxentry("\currentbtxdataset","#1")} + \else + \ctxcommand{showbtxentry("\currentbtxdataset","\currentbtxtag")} + \fi\fi} \def\btx_entry_inject_combi#1% {\begingroup \def\currentbtxtag{#1}% \ignorespaces - \fastsetup{\s!btx:\currentbtxspecification:\currentbtxcategory}% + \fastbtxsetup\s!list\currentbtxcategory \removeunwantedspaces \endgroup} @@ -762,8 +648,7 @@ \newtoks\everybtxlistrendering \appendtoks - \let\currentlist\s!btx - \let\currentbtxlist\currentbtxrendering + \setbtxlist % \edef\currentbtxcriterium{\btxrenderingparameter\c!criterium}% \v!cite will become \s!cite \ifx\currentbtxcriterium\empty @@ -777,94 +662,116 @@ \fi \to \everybtxlistrendering -\def\publ_place_list_complete[#1][#2]% title might become obsolete, just headtext - {\begingroup - \ifsecondargument - \edef\currentbtxrendering{#1}% - \setupcurrentbtxrendering[#2]% - \else\iffirstargument - \let\currentbtxrendering\currentbtxdataset - \setupcurrentbtxrendering[#1]% - \fi\fi - \the\everybtxlistrendering - \edef\currentbtxrenderingtitle{\btxrenderingparameter\c!title}% - \ifx\currentbtxrenderingtitle\empty - \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\headtext{\currentbtxrendering}}]}% - \else - \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\currentbtxrenderingtitle}]}% - \fi - \publ_place_list_indeed - \stopnamedsection - \endgroup} +\def\nofbtxlistentries {0} +\def\currentbtxlistentry{0} +\def\currentbtxlistindex{0} % only for internal use (points back to big list) + +\newconditional\c_publ_prefixed + +\unexpanded\def\btxsetnoflistentries #1{\edef\nofbtxlistentries {#1}} +\unexpanded\def\btxsetcurrentlistentry#1{\edef\currentbtxlistentry{#1}} +\unexpanded\def\btxsetcurrentlistindex#1{\edef\currentbtxlistindex{#1}} + +\unexpanded\def\btxdoifsameaspreviouselse#1% + {\ctxcommand{btxdoifelsesameasprevious("\currentbtxdataset",\number\currentbtxlistentry,"#1")}} -\def\publ_place_list_standard[#1][#2]% +\def\publ_place_list_indeed#1[#2][#3]% {\begingroup \ifsecondargument - \edef\currentbtxrendering{#1}% - \setupcurrentbtxrendering[#2]% + % [rendering] [settings] + \edef\currentbtxrendering{#2}% + \setupcurrentbtxrendering[#3]% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \fi \else\iffirstargument - \let\currentbtxrendering\currentbtxdataset - \setupcurrentbtxrendering[#1]% + \doifassignmentelse{#2} + {% [settings] + \let\currentbtxrendering\currentbtxspecification + \setupcurrentbtxrendering[#2]% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \let\currentbtxrendering\currentbtxspecification % tricky + \fi} + {\edef\currentbtxrendering{#2}% + \edef\p_specification{\btxrenderingparameter\c!specification}% + \ifx\p_specification\empty\else + \let\currentbtxspecification\p_specification + \fi}% \else - \let\currentbtxrendering\currentbtxdataset + \let\currentbtxrendering\currentbtxspecification \fi\fi + \setbtxparameterset\s!list\currentbtxspecification \the\everybtxlistrendering - \publ_place_list_indeed - \endgroup} - -\def\publ_place_list_indeed - {\startbtxrendering[\currentbtxrendering]% - % \fastsetup{\btxrenderingparameter\c!setups}% specific initializations - % \determinelistcharacteristics[\currentbtxrendering]% - \publ_specification_push{\btxrenderingparameter\c!specification}% - \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% - \uselanguageparameter\btxdatasetparameter % new - \let\currentlist\s!btx - \let\currentbtxlist\currentbtxrendering - \the\everysetupbtxlistplacement - \forgetall - % why not pass this with collect .. todo + \ifconditional#1\relax + \edef\currentbtxrenderingtitle{\btxrenderingparameter\c!title}% + \ifx\currentbtxrenderingtitle\empty + \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\headtext{\currentbtxrendering}}]}% + \else + \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbtxrendering,\c!title={\currentbtxrenderingtitle}]}% + \fi + \fi + \ifx\currentbtxrendering\empty + \setbtxrendering % hm + \fi + \btxrenderingparameter\c!before + \edef\currentbtxdataset{\btxrenderingparameter\c!dataset}% + \uselanguageparameter\btxdatasetparameter % new + \setbtxlist + \the\everystructurelist + \the\everysetupbtxlistplacement + \forgetall + % why not pass this with collect .. todo + % here we just collect items + \ctxcommand{btxcollectlistentries { + names = "btx", + criterium = "\currentbtxcriterium", + reference = "\btxrenderingparameter\c!reference", + method = "\btxrenderingparameter\c!method", + btxdataset = "\currentbtxdataset", + keyword = "\btxrenderingparameter\c!keyword", + sorttype = "\btxrenderingparameter\c!sorttype", + repeated = "\btxrenderingparameter\c!repeat", + ignored = "\btxrenderingparameter\c!ignore", + group = "\btxrenderingparameter\c!group", + }}% + \ifnum\nofbtxlistentries>\zerocount \startpacked[\v!blank]% - % here we just collect items - \ctxcommand{btxcollectlistentries { - names = "btx", - criterium = "\currentbtxcriterium", - reference = "\btxrenderingparameter\c!reference", - method = "\btxrenderingparameter\c!method", - btxdataset = "\currentbtxdataset", - keyword = "\btxrenderingparameter\c!keyword", - sorttype = "\btxrenderingparameter\c!sorttype", - repeated = "\btxrenderingparameter\c!repeat", - ignored = "\btxrenderingparameter\c!ignore", - }}% - % sorting and so - \ctxcommand{btxpreparelistentries("\currentbtxdataset")}% - % next we analyze the width - \ifx\currentbtxnumbering\empty \else - \edef\p_width{\btxrenderingparameter\c!width}% - \ifx\p_width\v!auto - \setbox\scratchbox\vbox \bgroup - \settrialtypesetting - \ctxcommand{btxfetchlistentries("\currentbtxdataset")}% - \egroup - \d_publ_number_width\wd\scratchbox - \letbtxlistparameter\c!width\d_publ_number_width - \fi + % sorting and so + \ctxcommand{btxpreparelistentries("\currentbtxdataset")}% could be put in collect + % next we analyze the width + \ifx\currentbtxnumbering\empty \else + \edef\p_width{\listparameter\c!width}% + \ifx\p_width\v!auto + \setbox\scratchbox\vbox \bgroup + \settrialtypesetting + \ctxcommand{btxfetchlistentries("\currentbtxdataset")}% + \egroup + \d_publ_number_width\wd\scratchbox + \letlistparameter\c!width\d_publ_number_width \fi - % this actually typesets them - \ctxcommand{btxflushlistentries("\currentbtxdataset")}% + \fi + \doifelse{\listparameter\c!prefix}\v!yes\settrue\setfalse\c_publ_prefixed + % this actually typesets them, we loop here as otherwise the whole + % bunch gets flushed at once + \dorecurse\nofbtxlistentries + {\let\currentbtxlistentry\recurselevel + \ctxcommand{btxflushlistentry("\currentbtxdataset",\currentbtxlistentry)}}% \stoppacked - \publ_specification_pop - \stopbtxrendering - \global\advance\btxblock\plusone} + \fi + \btxrenderingparameter\c!after + \global\advance\btxblock\plusone + \ifconditional#1\relax + \stopnamedsection + \fi + \endgroup} -\def\currentbtxblock{\number\btxblock} +\def\publ_place_list_complete{\publ_place_list_indeed\conditionaltrue} +\def\publ_place_list_standard{\publ_place_list_indeed\conditionalfalse} -\unexpanded\def\btxsetlanguage#1% - {\def\currentbtxlanguage{#1}% - \ifx\currentbtxlanguage\currentlanguage \else - \setcurrentlanguage\currentmainlanguage\currentbtxlanguage - \fi} +\def\currentbtxblock{\number\btxblock} % called at the lua end, for determining the width @@ -877,25 +784,69 @@ % called at the lua end, the real rendering +% we could have a yes and no where o nils the btx_reference_indeed ... saves a check there + +\installstructurelistprocessor{\s!btx} + {\let\currentlistentrynumber \btx_reference_indeed + \let\currentlistentrytitle \btx_entry_indeed + \let\currentlistentrypagenumber\btx_page_indeed + \strc_lists_apply_renderingsetup} + +\def\btx_entry_indeed + {\btx_list_reference_inject + \btx_entry_inject} + +\def\btx_page_indeed + {} + \unexpanded\def\btxhandlelistentry - {\begingroup - \let\currentlist\s!btx % probably obsolete here - \startbtxlistentry\currentbtxrendering - \btx_entry_inject - \stopbtxlistentry - \endgroup} + {\strc_lists_entry_process} -\unexpanded\def\btxlistsetup#1% - {\fastsetup{\s!btx:\s!list:#1}} +\unexpanded\def\btxstartlistentry % maybe pass i + {\begingroup} + +\unexpanded\def\btxstoplistentry + {\endgroup} + +\newtoks\everybtxlistentry + +\unexpanded\def\btxlistsetup#1% used for the reference in the list + {\the\everybtxlistentry + \everybtxlistentry\emptytoks % so only once per entry to be sure + \fastbtxsetup\s!list{#1}} + +\appendtoks + \btx_check_language +\to \everybtxlistentry \unexpanded\def\btx_reference_indeed {\begingroup \let\currentbtxlistvariant\currentbtxnumbering - \btxlistvariantparameter\c!left - \ctxcommand{btxlistvariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","\currentbtxnumbering","\currentbtxnumber")}% some can go - \btxlistvariantparameter\c!right + \setbtxparameterset\c!list\currentbtxnumbering + \ifx\currentbtxnumbering\empty + % nothing + \else\ifx\currentbtxnumbering\v!no + % nothing + \else + \btxparameter\c!left + \ifconditional\c_publ_prefixed\btxlistprefixednumber\fi + \ctxcommand{btxlistvariant("\currentbtxdataset","\currentbtxblock","\currentbtxtag","\currentbtxnumbering","\currentbtxnumber")}% some can go + \btxparameter\c!right + \fi\fi \endgroup} +\unexpanded\def\btxlistprefixednumber % hack but alan needs it + {\ctxcommand{listprefixednumber("\currentlist",\currentbtxlistindex, { + prefix = "\listparameter\c!prefix", + separatorset = "\listparameter\c!prefixseparatorset", + conversionset = "\listparameter\c!prefixconversionset", + starter = \!!bs\listparameter\c!prefixstarter\!!es, + stopper = \!!bs\listparameter\c!prefixstopper\!!es, + set = "\listparameter\c!prefixset", + segments = "\listparameter\c!prefixsegments", + connector = \!!bs\listparameter\c!prefixconnector\!!es, + })}} + \unexpanded\def\btx_reference_checked {\dontleavehmode\hbox\bgroup \btx_reference_indeed @@ -908,14 +859,14 @@ \iftrialtypesetting\else \btx_list_reference_inject_now \fi - \btx_reference_indeed + % \btx_reference_indeed % else double entry in list \endgroup} \def\btx_list_reference_inject_now {\btx_trace_list_cross\empty\currentbtxbacktrace \global\advance\c_btx_list_reference\plusone \strc_references_direct_full_user - {\s!btxset="\currentbtxdataset",% + {\ifx\currentbtxdataset\v!default\else\s!btxset="\currentbtxdataset",\fi% \s!btxref="\currentbtxtag",% \s!btxspc="\currentbtxspecification",% \ifx\currentbtxbefore\empty\else\s!btxbtx={\currentbtxbefore},\fi% @@ -941,7 +892,7 @@ \the\t_btx_reference_inject \normalexpanded{\writedatatolist [\s!btx]% - [\s!btxset=\currentbtxdataset,% + [\ifx\currentbtxdataset\v!default\else\s!btxset=\currentbtxdataset,\fi% \s!btxref=\currentbtxtag,% \ifx\currentbtxbefore\empty\else\s!btxbtx={\currentbtxbefore},\fi% \ifx\currentbtxafter \empty\else\s!btxatx={\currentbtxafter },\fi% @@ -956,16 +907,19 @@ \let\currentbtxnumbering\empty \appendtoks - \edef\currentbtxnumbering{\btxrenderingparameter\c!numbering}% - \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed - \ifx\currentbtxnumbering\v!no - \letlistparameter\c!textcommand\outdented % needed? we can use titlealign - \letlistparameter\c!symbol \v!none - \letlistparameter\c!aligntitle \v!yes - \let\currentbtxnumbering\empty - \else - \letlistparameter\c!headnumber\v!always - \fi + \edef\currentbtxnumbering{\btxrenderingparameter\c!numbering}% + \edef\p_numbering{\btxrenderingparameter\c!numbering}% link to headnumber + \ifx\p_numbering\v!no + \letlistparameter\c!headnumber\v!no + \let\currentbtxnumbering\empty + % \letlistparameter\c!textcommand\outdented % needed? we can use titlealign + \letlistparameter\c!symbol \v!none + \letlistparameter\c!aligntitle \v!yes + \letlistparameter\c!numbercommand\firstofoneargument % for the moment, no doubling needed + \else + \letlistparameter\c!headnumber\v!always + \fi + \let\currentlistmethod\s!btx \to \everysetupbtxlistplacement % \appendtoks @@ -976,22 +930,23 @@ {\doifnextoptionalcselse\btx_flush_author_yes\btx_flush_author_nop} \def\btx_flush_author_yes[#1]{\btx_flush_author{#1}} -\def\btx_flush_author_nop {\btx_flush_author{\btxlistvariantparameter\c!authorconversion}} +\def\btx_flush_author_nop {\btx_flush_author{\btxparameter\c!authorconversion}} \unexpanded\def\btx_flush_author#1#2% {\begingroup \edef\currentbtxfield{#2}% + \setbtxparameterset\s!list\currentbtxfield \let\currentbtxlistvariant\currentbtxfield \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","\currentbtxfield",{ combiner = "#1", kind = "list", - %symbol = \btxlistvariantparameter\c!initialsterminator, - %connector = \btxlistvariantparameter\c!initialssep, - etallimit = \number\btxlistvariantparameter\c!etallimit, - etaldisplay = \number\btxlistvariantparameter\c!etaldisplay, + etallimit = "\btxparameter\c!etallimit", + etaldisplay = "\btxparameter\c!etaldisplay", })}% \endgroup} +% yes or no: maybe just \flushauthor{...}{...} + \unexpanded\def\btxflushauthorname {\btx_flush_author{name}} % #1 \unexpanded\def\btxflushauthornormal {\btx_flush_author{normal}} % #1 \unexpanded\def\btxflushauthornormalshort {\btx_flush_author{normalshort}} % #1 @@ -1000,13 +955,12 @@ \unexpanded\def\currentbtxciteauthor % always author {\begingroup - \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","author",{ - combiner = "\btxcitevariantparameter\c!authorconversion", + \setbtxparameterset\s!cite\s!author + \ctxcommand{btxauthor("\currentbtxdataset","\currentbtxtag","\s!author",{ + combiner = "\btxparameter\c!authorconversion", kind = "cite", - %symbol = \btxcitevariantparameter\c!initialsterminator, - %connector = \btxcitevariantparameter\c!initialssep, - etallimit = \number\btxcitevariantparameter\c!etallimit, - etaldisplay = \number\btxcitevariantparameter\c!etaldisplay, + etallimit = "\btxparameter\c!etallimit", + etaldisplay = "\btxparameter\c!etaldisplay", })}% \endgroup} @@ -1040,40 +994,19 @@ % \btxflushauthor[inverted]{author} % \btxflushauthor[invertedshort]{author} -% Interaction: only list +% Interaction \newconditional\btxinteractive \newconditional\btx_interactive -\unexpanded\def\btxdoifelseinteractive{\thirdofthreearguments} -\unexpanded\def\btxdoifelseinteraction{\secondoftwoarguments} - -\unexpanded\def\publ_doifelse_interactive_list_yes#1% - {\edef\p_interaction{\namedbtxlistvariantparameter{#1}\c!interaction}% - \ifx\p_interaction\v!start - \expandafter\firstoftwoarguments - \else - \expandafter\secondoftwoarguments - \fi} - -\unexpanded\def\publ_doifelse_interactive_cite_yes#1% - {\edef\p_interaction{\namedbtxcitevariantparameter{#1}\c!interaction}% - \ifx\p_interaction\v!start - \expandafter\firstoftwoarguments - \else - \expandafter\secondoftwoarguments - \fi} +% of maybe modes? \appendtoks \iflocation - \edef\p_interaction{\btxrenderingparameter\c!interaction}% + \edef\p_interaction{\btxparameter\c!interaction}% \ifx\p_interaction\v!stop - \let\btxdoifelseinteraction\secondoftwounexpanded - \let\btxdoifelseinteractive\thirdofthreeunexpanded \setfalse\btxinteractive \else - \let\btxdoifelseinteraction\firstoftwounexpanded - \let\btxdoifelseinteractive\publ_doifelse_interactive_list_yes \settrue\btxinteractive \ifx\p_interaction\v!all \settrue\btx_interactive @@ -1082,8 +1015,6 @@ \fi \fi \else - \let\btxdoifelseinteraction\secondoftwounexpanded - \let\btxdoifelseinteractive\thirdofthreeunexpanded \setfalse\btxinteractive \setfalse\btx_interactive \fi @@ -1091,44 +1022,26 @@ \appendtoks \iflocation - \edef\p_interaction{\btxcitevariantparameter\c!interaction}% + \edef\p_interaction{\btxparameter\c!interaction}% \ifx\p_interaction\v!stop - \let\btxdoifelseinteraction\secondoftwounexpanded - \let\btxdoifelseinteractive\thirdofthreeunexpanded \setfalse\btxinteractive \else - \let\btxdoifelseinteraction\firstoftwounexpanded - \let\btxdoifelseinteractive\publ_doifelse_interactive_cite_yes \settrue\btxinteractive \fi \else - \let\btxdoifelseinteraction\secondoftwounexpanded - \let\btxdoifelseinteractive\thirdofthreeunexpanded \setfalse\btxinteractive \fi \to \everysetupbtxciteplacement -\appendtoks - % for old times sake, for a while at least - \let\maybeyear\gobbleoneargument - \let\noopsort \gobbleoneargument -\to \everysetupbtxlistplacement - -\appendtoks - % for old times sake, for a while at least - \let\maybeyear\gobbleoneargument - \let\noopsort \gobbleoneargument -\to \everysetupbtxciteplacement - % till here \unexpanded\def\btxnumberedreference[#1]% \bibtexnumref (replaced by \cite[num]) {\dontleavehmode \begingroup - \btxcitevariantparameter\v!left + \btxparameter\v!left \penalty\plustenthousand % todo \ctxcommand{btxresolvelistreference("\currentbtxdataset","#1")}% todo: split dataset from #1, so another call - \btxcitevariantparameter\v!right + \btxparameter\v!right \endgroup} %D When a publication is cited, we need to signal that somehow. This is done with the @@ -1172,7 +1085,9 @@ \unexpanded\def\publ_cite_tags_indeed#1% {\letinteractionparameter\c!style\empty - \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% + \setbtxparametersetroot\s!cite % we need to get the default + \edef\currentbtxcitevariant{\btxparameter\c!alternative}% + \setbtxparameterset\s!cite\currentbtxcitevariant \edef\currentbtxcitetag{#1}% \the\everysetupbtxciteplacement \publ_cite_variant @@ -1185,7 +1100,6 @@ {\letinteractionparameter\c!style\empty %\letinteractionparameter\c!color\empty \letdummyparameter\c!reference \empty - \letdummyparameter\c!extras \empty \letdummyparameter\c!alternative\empty \letdummyparameter\c!before \empty \letdummyparameter\c!after \empty @@ -1201,26 +1115,19 @@ \fi \edef\p_alternative{\dummyparameter\c!alternative}% \ifx\p_alternative\empty - \edef\currentbtxcitevariant{\btxcitevariantparameter\c!alternative}% + \setbtxparametersetroot\s!cite + \edef\currentbtxcitevariant{\btxparameter\c!alternative}% \else \let\currentbtxcitevariant\p_alternative \fi - \setupcurrentbtxcitevariant[#1]% + \setbtxparameterset\s!cite\currentbtxcitevariant + \setupcurrentbtx[#1]% % \edef\p_publ_cite_before {\dummyparameter\c!before}% \edef\p_publ_cite_after {\dummyparameter\c!after}% \edef\p_publ_cite_lefttext {\dummyparameter\c!lefttext}% \edef\p_publ_cite_righttext{\dummyparameter\c!righttext}% % - \edef\p_extras {\dummyparameter\c!extras}% - \ifx\p_extras\empty \else - \ifx\p_publ_cite_righttext\empty - \let\p_publ_cite_righttex\p_extras - \else - % ignored: righttext wins over extras - \fi - \fi - % \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} @@ -1229,12 +1136,15 @@ {\letinteractionparameter\c!style\empty \edef\currentbtxcitevariant{#1}% \edef\currentbtxcitetag{#2}% + \setbtxparameterset\s!cite\currentbtxcitevariant \the\everysetupbtxciteplacement \publ_cite_variant \endgroup} \newconditional\btxcitecompress +\let\currentbtxreference\empty + \def\publ_cite_variant {\begingroup \publ_cite_handle_variant_indeed[\currentbtxcitetag]} @@ -1242,31 +1152,31 @@ \unexpanded\def\publ_cite_handle_variant#1% {\begingroup \edef\currentbtxcitevariant{#1}% + \setbtxparameterset\s!cite\currentbtxcitevariant \the\everysetupbtxciteplacement \dosingleargument\publ_cite_handle_variant_indeed} \def\publ_cite_handle_variant_indeed[#1]% - {\usebtxcitevariantstyleandcolor\c!style\c!color + {\letbtxparameter\c!alternative\currentbtxcitevariant + \usebtxstyleandcolor\c!style\c!color \uselanguageparameter\btxdatasetparameter % new - \publ_specification_push{\btxcitevariantparameter\c!specification}% - \letbtxcitevariantparameter\c!alternative\currentbtxcitevariant - \btxcitevariantparameter\v!left + \btxparameter\v!left + \edef\currentbtxreference{#1}% \ctxcommand{btxhandlecite{% dataset = "\currentbtxdataset",% - reference = "#1",% + reference = \!!bs\currentbtxreference\!!es,% markentry = \iftrialtypesetting false\else true\fi,% variant = "\currentbtxcitevariant",% - sorttype = "\btxcitevariantparameter\c!sorttype",% - compress = "\btxcitevariantparameter\c!compress",% - author = "\btxcitevariantparameter\c!author",% + sorttype = "\btxparameter\c!sorttype",% + compress = "\btxparameter\c!compress",% + author = "\btxparameter\c!author",% lefttext = \!!bs\p_publ_cite_lefttext\!!es,% righttext = \!!bs\p_publ_cite_righttext\!!es,% before = \!!bs\p_publ_cite_before\!!es,% after = \!!bs\p_publ_cite_after\!!es,% }}% - \btxcitevariantparameter\v!right + \btxparameter\v!right \ctxcommand{flushmarked()}% - \publ_specification_pop \endgroup} \unexpanded\def\btxcitation @@ -1286,12 +1196,15 @@ \unexpanded\def\publ_cite_no[#1]% {\iftrialtypesetting \else + \begingroup + \edef\currentbtxreference{#1}% \ctxcommand{btxhandlenocite{% dataset = "\currentbtxdataset",% - reference = "#1",% + reference = \!!bs\currentbtxreference#1\!!es,% markentry = true,% }}% % \ctxcommand{flushmarked()}% + \endgroup \fi} \unexpanded\def\btxmissing#1% @@ -1305,23 +1218,151 @@ \let\nocitation \btxnocitation %let\usepublication\btxnocitation +%D Setup helpers, beware, we need to wrap this .. now we need to know +%D how setups are implemented. + +\setvalue{\??setup:\s!btx:\s!unknown}#1{\inframed{\tttf#1}} + +\def\fastbtxsetup_yes#1#2% + {\csname\??setup:\s!btx:% + \ifcsname\??setup:\s!btx:\currentbtxspecification:#1:#2\endcsname + \currentbtxspecification:#1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:#2\endcsname + \currentbtxspecificationfallback:#1:#2% + \else\ifcsname\??setup:\s!btx:#1:#2\endcsname + #1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecification:#1:\s!unknown\endcsname + \currentbtxspecification:#1:\s!unknown + \else\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:\s!unknown\endcsname + \currentbtxspecificationfallback:#1:\s!unknown + \else + #1:\s!unknown + \fi\fi\fi\fi\fi + \endcsname{#2}} + +\def\fastbtxsetup_nop#1#2% + {\csname\??setup:\s!btx:% + \ifcsname\??setup:\s!btx:\currentbtxspecification:#1:#2\endcsname + \currentbtxspecification:#1:#2% + \else\ifcsname\??setup:\s!btx:#1:#2\endcsname + #1:#2% + \else\ifcsname\??setup:\s!btx:\currentbtxspecification:#1:\s!unknown\endcsname + \currentbtxspecification:#1:\s!unknown + \else + #1:\s!unknown + \fi\fi\fi + \endcsname{#2}} + +\def\fastbtxsetup + {\ifx\currentbtxspecificationfallback\empty + \expandafter\fastbtxsetup_nop + \else + \expandafter\fastbtxsetup_yes + \fi} + +\let\publ_fastbtxsetup_normal\fastbtxsetup + +% \unexpanded\def\publ_fastbtxsetup_chain_yes#1#2% +% {\inframed[\c!foregroundstyle=\infofont]{% +% \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else->% +% \currentbtxspecificationfallback:#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback :#1:#2\endcsname\else->% +% #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else->% +% \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else->% +% \currentbtxspecificationfallback:#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:\s!unknown\endcsname\else->% +% ?\fi\fi\fi\fi\fi}} + +% \unexpanded\def\publ_fastbtxsetup_chain_nop#1#2% +% {\inframed[\c!foregroundstyle=\infofont]{% +% \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else->% +% #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else->% +% \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else->% +% ?\fi\fi\fi}} + +\unexpanded\def\publ_fastbtxsetup_chain_inbetween + {\allowbreak->\allowbreak} + +\unexpanded\def\publ_fastbtxsetup_chain_yes#1#2% + {\dontleavehmode\begingroup\infofont\darkblue[% + \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecificationfallback:#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecificationfallback:#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecificationfallback:#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + unset\fi\fi\fi\fi\fi + ]\endgroup} + +\unexpanded\def\publ_fastbtxsetup_chain_nop#1#2% + {\dontleavehmode\begingroup\infofont\darkred[% + \currentbtxspecification :#1:#2\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + #1:#2\ifcsname\??setup:\s!btx :#1:#2\endcsname\else + \publ_fastbtxsetup_chain_inbetween + \currentbtxspecification :#1:\s!unknown\ifcsname\??setup:\s!btx:\currentbtxspecification :#1:\s!unknown\endcsname\else + \publ_fastbtxsetup_chain_inbetween + unset\fi\fi\fi + ]\endgroup} + +\unexpanded\def\publ_fastbtxsetup_chain + {\ifx\currentbtxspecificationfallback\empty + \expandafter\publ_fastbtxsetup_chain_nop + \else + \expandafter\publ_fastbtxsetup_chain_yes + \fi} + +\unexpanded\def\publ_fastbtxsetup_visual#1#2% + {\publ_fastbtxsetup_chain{#1}{#2}% + \publ_fastbtxsetup_normal{#1}{#2}} + +\installtextracker + {publications.setups} + {\let\fastbtxsetup\publ_fastbtxsetup_visual} + {\let\fastbtxsetup\publ_fastbtxsetup_normal} + %D Cite helpers: +\newtoks\everybtxciteentry + \unexpanded\def\btxcitesetup#1% - {\currentbtxlefttext - \fastsetup{\s!btx:\s!cite:#1}% + {\the\everybtxciteentry + \everybtxciteentry\emptytoks % tricky maybe not when subcites + \currentbtxlefttext + \fastbtxsetup\s!cite{#1}% \currentbtxrighttext} % no \btxcitereset as we loose dataset and such -\unexpanded\def\btxstartsubcite#1% #1 can go +\appendtoks + \btx_check_language +\to \everybtxciteentry + +\unexpanded\def\btxstartsubcite#1% {\begingroup \btxcitereset % todo: limited set \def\currentbtxcitevariant{#1}% - \btxcitevariantparameter\c!left + \setbtxparameterset\s!cite\currentbtxcitevariant + \usebtxstyleandcolor\c!style\c!color + \btxparameter\c!left \relax} \unexpanded\def\btxstopsubcite {\relax - \btxcitevariantparameter\c!right + \btxparameter\c!right + \endgroup} + +\unexpanded\def\btxstartciterendering[#1]% + {\begingroup + \edef\currentbtxcitevariant{#1}% + \setbtxparameterset\s!cite\currentbtxcitevariant + \usebtxstyleandcolor\c!style\c!color + \btxparameter\c!left + \relax} + +\unexpanded\def\btxstopciterendering + {\relax + \btxparameter\c!right \endgroup} \let\btxstartcite \begingroup @@ -1332,8 +1373,8 @@ %D Whatever helpers: \unexpanded\def\btxsingularplural#1{\ctxcommand{btxsingularorplural("\currentbtxdataset","\currentbtxtag","#1")}} -\unexpanded\def\btxoneorrange #1{\ctxcommand{oneorrange("\currentbtxdataset","\currentbtxtag","#1")}} -\unexpanded\def\btxfirstofrange #1{\ctxcommand{firstofrange("\currentbtxdataset","\currentbtxtag","#1")}} +\unexpanded\def\btxoneorrange #1{\ctxcommand{btxoneorrange("\currentbtxdataset","\currentbtxtag","#1")}} +\unexpanded\def\btxfirstofrange #1{\ctxcommand{btxfirstofrange("\currentbtxdataset","\currentbtxtag","#1")}} \let\btxsingularorplural\btxsingularplural @@ -1372,29 +1413,29 @@ \ctxcommand{btxsavedataset("#1","#2","\dummyparameter\c!alternative","\dummyparameter\c!criterium")}% \endgroup} -% \savebtxdataset[standard][e:/tmp/foo.bib] -% \savebtxdataset[standard][e:/tmp/foo.lua] -% \savebtxdataset[standard][e:/tmp/foo.xml] +% \savebtxdataset[default][e:/tmp/foo.bib] +% \savebtxdataset[default][e:/tmp/foo.lua] +% \savebtxdataset[default][e:/tmp/foo.xml] %D In-text entries: -\definebtxcitevariant - [entry] +% \definebtxcitevariant +% [entry] \unexpanded\def\placecitation{\citation[entry]} % [#1] \unexpanded\def\btxhandleciteentry {\dontleavehmode \begingroup - \publ_specification_push{\btxcitevariantparameter\c!specification}% + \def\currentbtxcitevariant{entry}% + \setbtxparameterset\s!cite\currentbtxcitevariant % needs checking \btxcitereference \btx_entry_inject - \publ_specification_pop \endgroup} \startsetups \s!btx:\s!cite:entry \ifx\currentbtxfirst\empty - \fastsetup{\s!btx:\s!cite:\s!unknown} + \fastbtxsetup\s!cite\s!unknown \else \btxhandleciteentry \fi @@ -1454,239 +1495,82 @@ \def\currentbtxinitials {#4}% \def\currentbtxfirstnames {#5}% \def\currentbtxjuniors {#6}% + \setbtxparameterset\s!cite\currentbtxcitevariant \fastsetup{\s!btx:\s!cite:\s!author:\currentbtxcitevariant}% \endgroup} -%D Defaults: +%D We hook some setters in the definition sets: + +% \installdefinitionsetmember \??btx {btxspecification} \??btxcitevariant {btxcitevariant} +% \installdefinitionsetmember \??btx {btxspecification} \??btxlistvariant {btxlistvariant} +% \installdefinitionsetmember \??btx {btxspecification} \??btxlist {btxlist} +% \installdefinitionsetmember \??btx {btxspecification} \??btxrendering {btxrendering} +% \installdefinitionsetmember \??btx {btxspecification} \??btx {btx} + +%D And more helpers ... a never ending story these publications: + +% \definebtx +% [btx:apa:list:article:title] +% [style=bolditalic, +% command=\WORD] +% +% \btxstartstyle[btx:apa:list:article:title] +% \btxusecommand[btx:apa:list:article:title]{foo} +% \btxstopstyle -\setbtxdataset - [\v!standard] +\unexpanded\def\btxstartstyle[#1]% + {\begingroup + \def\currentbtx{#1}% + \usebtxstyle\c!style} + +\unexpanded\def\btxstartcolor[#1]% + {\begingroup + \def\currentbtx{#1}% + \usebtxcolor\c!color} + +\unexpanded\def\btxstartstyleandcolor[#1]% + {\begingroup + \def\currentbtx{#1}% + \usebtxstyleandcolor\c!style\c!color} + +\let\btxstopstyle \endgroup +\let\btxstopcolor \endgroup +\let\btxstopstyleandcolor\endgroup + +\unexpanded\def\btxusecommand[#1]% + {\namedbtxparameter{#1}\c!command} + +%D Defaults: \setupbtxrendering [\c!interaction=\v!start, % \v!all \c!specification=\btxparameter\c!specification, - \c!dataset=\v!standard, + \c!dataset=\v!default, \c!repeat=\v!no, \c!continue=\v!no, \c!method=\v!global, % \c!setups=btx:\btxrenderingparameter\c!alternative:initialize, % not the same usage as cite ! -% \c!sorttype=authoryear, + % \c!sorttype=authoryear, \c!criterium=\v!text, \c!refcommand=authoryears, % todo \c!numbering=\v!yes, - % \c!autohang=\v!no, % not used %\c!saveinlist=\v!no, % maybe for before/after \c!textstate=\v!start, \c!width=\v!auto, + %\c!pageright=, + %\c!pageleft=, \c!separator={;\space}, \c!distance=1.5\emwidth] -\definebtxrendering - [\v!standard] - -% reasonable defaults; may be redefined by style. - -\setupbtxlistvariant - [\c!namesep={,\space}, - \c!lastnamesep={,\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalnamesep={,\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!firstnamesep=\space, - \c!otherstext={\space\btxlabeltext{\currentbtxspecification:others}}, - \c!juniorsep=\space, - \c!vonsep=\space, - \c!initialsep=\space, % between initials and lastname - %\c!initialssep=\space, % between multiple initials % todo - %\c!initialsterminator={.}, % todo - \c!surnamesep={,\space}, - \c!surnameinitialsep={,\space}, - \c!surnamefirstnamesep={,\space}, +% Quite some interpunction and labels are the same of at least consistent witin +% a standard when citations and list entries are involved. We assume that each +% standard defines its own set but it can fall back on the defaults. + +\setupbtx + [\c!alternative=\v!num, % default cite + \c!interaction=\v!start, \c!etallimit=3, - \c!etaldisplay=\btxlistvariantparameter\c!etallimit, - %\c!journalconversion=\v!normal, - \c!monthconversion=\v!number, - \c!authorconversion=\v!inverted, - \c!interaction=\c!start] - -\definebtxlistvariant - [author] - -\definebtxlistvariant - [editor] - [author] - -\definebtxlistvariant - [url] - -\definebtxlistvariant - [doi] - -\definebtxlistvariant % because we inherit - [invertedshort] - -\definebtxlistvariant % because we inherit - [short] - -\setupbtxcitevariant - [\c!specification=\btxparameter\c!specification, - \c!alternative=num, - \c!namesep=\btxlistvariantparameter\c!namesep, - \c!lastnamesep=\btxlistvariantparameter\c!lastnamesep, - \c!finalnamesep=\btxlistvariantparameter\c!finalnamesep, - \c!firstnamesep=\btxlistvariantparameter\c!firstnamesep, - \c!otherstext=\btxlistvariantparameter\c!otherstext, - \c!juniorsep=\btxlistvariantparameter\c!juniorsep, - \c!vonsep=\btxlistvariantparameter\c!vonsep, - \c!initialsep=\btxlistvariantparameter\c!initialsep, - %\c!initialssep=\btxlistvariantparameter\c!initialssep, - %\c!initialsterminator=\btxlistvariantparameter\c!initialsterminator, - \c!surnamesep=\btxlistvariantparameter\c!surnamesep, - \c!surnameinitialsep=\btxlistvariantparameter\c!surnameinitialsep, - \c!surnamefirstnamesep=\btxlistvariantparameter\c!surnamefirstnamesep, - \c!etallimit=\btxlistvariantparameter\c!etallimit, - \c!etaldisplay=\btxlistvariantparameter\c!etaldisplay, - \c!monthconversion=\btxlistvariantparameter\c!monthconversion, - \c!authorconversion=\v!name, - % \c!setups=btx:cite:initialize, - \c!pubsep={,\space}, - \c!lastpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!sorttype=, - \c!compress=\v!no, - \c!inbetween=\space, - \c!range=\endash, - \c!left=, - \c!middle=, - \c!right=, - \c!interaction=\v!start] - -\definebtxcitevariant - [author] - -\definebtxcitevariant - [authornum] - [author] - [\c!left={(}, - \c!right={)}] - -\definebtxcitevariant - [authoryear] - [\c!compress=\v!yes, - \c!inbetween={,\space}, - \c!left={(}, - \c!right={)}, - \c!pubsep={;\space}, - \c!lastpubsep={;\space}, - \c!finalpubsep={;\space}] - -\definebtxcitevariant - [authoryears] - [authoryear] - [\c!left=, - \c!inbetween={\space(}, - \c!pubsep={);\space}, - \c!lastpubsep={);\space}, - \c!finalpubsep={);\space}] - -\definebtxcitevariant - [author:num] - [authornum] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [author:year] - [authoryear] - [\c!left=, - \c!right=] - -\definebtxcitevariant - [author:years] - [author:year] - -\definebtxcitevariant - [year] - [\c!left={(}, - \c!pubsep={,\space}, - \c!lastpubsep={,\space}, - \c!finalpubsep={,\space}, - \c!right={)}] - -\definebtxcitevariant - [title] - -\definebtxcitevariant - [tag] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [key] - [tag] - -\definebtxcitevariant - [serial] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [page] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [pages] - [page] - -\definebtxcitevariant - [invertedshort] - -\definebtxcitevariant - [short] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [category] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [type] - [category] - -\definebtxcitevariant - [doi] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [url] - [\c!left={[}, - \c!right={]}] - -\definebtxcitevariant - [page] - [\c!left=, - \c!right=] - -\definebtxcitevariant - [num] - [\c!compress=\v!yes, - \c!left={[}, - \c!right={]}, - \c!pubsep={,}, - \c!lastpubsep={,}, - \c!finalpubsep={,}] - -\definebtxcitevariant - [textnum] - [num] - [\c!left={Ref.\nbsp}, % {Refs.\nbsp}, if multiple? - %yuck! ={\btxlabeltext{\currentbtxspecification:Reference\btxsingularplural{num}{}{s}}\nbsp} - \c!right=, - \c!pubsep={,}, - \c!lastpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}, - \c!finalpubsep={\space\btxlabeltext{\currentbtxspecification:and}\space}] + \c!etaldisplay=\btxparameter\c!etallimit] % Do we want these in the format? Loading them delayed is somewhat messy. @@ -1698,9 +1582,19 @@ \loadbtxdefinitionfile[page] \loadbtxdefinitionfile[author] +% we assume that the users sets up the right specification and if not ... well, +% hope for the best that something shows up and consult the manual otherwise + +\unexpanded\def\usebtxdefinitions[#1]% + {\loadbtxdefinitionfile[#1]% % for hh + \setupbtx[\c!specification=#1]} % for ab + \setupbtx - [\c!specification=apa] + [\c!specification=\s!default, + \c!dataset=\v!default, + \c!default=] -% \letvalue{\??btxrenderingdefinition apa}\undefined % we will reload at runtime +\loadbtxdefinitionfile + [\s!default] \protect diff --git a/tex/context/base/publ-reg.lua b/tex/context/base/publ-reg.lua index 3df853736..531c4dcf0 100644 --- a/tex/context/base/publ-reg.lua +++ b/tex/context/base/publ-reg.lua @@ -17,7 +17,6 @@ local commands = commands local variables = interfaces.variables local v_once = variables.once -local v_standard = variables.standard local v_stop = variables.stop local v_all = variables.all diff --git a/tex/context/base/publ-sor.lua b/tex/context/base/publ-sor.lua index c17273cc3..c3fcdb0ee 100644 --- a/tex/context/base/publ-sor.lua +++ b/tex/context/base/publ-sor.lua @@ -23,7 +23,7 @@ local writers = publications.writers local variables = interfaces.variables local v_short = variables.short -local v_default = variables.reference +local v_default = variables.default local v_reference = variables.reference local v_dataset = variables.dataset @@ -238,9 +238,10 @@ local sorters = { end, [v_dataset] = function(dataset,rendering,list) local function compare(a,b) - local aa, bb = a and a[1], b and b[1] +-- inspect(a,b) + local aa, bb = a and a[6], b and b[6] if aa and bb then - aa, bb = list[aa].index or 0, list[bb].index or 0 + -- aa, bb = list[aa].index or 0, list[bb].index or 0 return aa and bb and aa < bb end return false diff --git a/tex/context/base/publ-tra.lua b/tex/context/base/publ-tra.lua index 5f1610beb..65e9b7ff4 100644 --- a/tex/context/base/publ-tra.lua +++ b/tex/context/base/publ-tra.lua @@ -19,22 +19,32 @@ local concat = table.concat local context = context local commands = commands +local v_default = interfaces.variables.default + local publications = publications local tracers = publications.tracers local tables = publications.tables local datasets = publications.datasets local specifications = publications.specifications +local citevariants = publications.citevariants local getfield = publications.getfield local getcasted = publications.getcasted local ctx_NC, ctx_NR, ctx_HL, ctx_FL, ctx_ML, ctx_LL, ctx_EQ = context.NC, context.NR, context.HL, context.FL, context.ML, context.LL, context.EQ -local ctx_bold, ctx_monobold, ctx_rotate, ctx_llap, ctx_rlap = context.bold, context.formatted.monobold, context.rotate, context.llap, context.rlap local ctx_starttabulate = context.starttabulate local ctx_stoptabulate = context.stoptabulate -local ctx_verbatim = context.verbatim +local ctx_formatted = context.formatted +local ctx_bold = ctx_formatted.monobold +local ctx_monobold = ctx_formatted.monobold +local ctx_verbatim = ctx_formatted.verbatim + +local ctx_rotate = context.rotate +local ctx_llap = context.llap +local ctx_rlap = context.rlap +local ctx_page = context.page local privates = tables.privates local specials = tables.specials @@ -313,7 +323,11 @@ function tracers.showtables(settings) ctx_NC() context(k) ctx_NC() - context(tostring(v)) + if type(v) == "table" then + context("% t",v) + else + context(tostring(v)) + end ctx_NC() ctx_NR() end @@ -329,8 +343,8 @@ function tracers.showdatasetauthors(settings) local sortkey = publications.writers.author - if not dataset or dataset == "" then dataset = "standard" end - if not field or field == "" then field = "author" end + if not dataset or dataset == "" then dataset = v_default end + if not field or field == "" then field = "author" end local function row(i,k,v) ctx_NC() @@ -374,36 +388,43 @@ function tracers.showdatasetauthors(settings) local d = datasets[dataset].luadata + local trialtypesetting = context.trialtypesetting() + for tag, entry in sortedhash(d) do - local a = getcasted(dataset,tag,field) + local a, f, k = getcasted(dataset,tag,field) - if a then + if type(a) == "table" and #a > 0 and k == "author" then context.start() context.tt() - context.starttabulate { "|B|Bl|p|" } + ctx_starttabulate { "|B|Bl|p|" } ctx_FL() + local original = getfield(dataset,tag,field) commonrow("tag",tag) commonrow("field",field) - commonrow("content",getfield(dataset,tag,field)) + commonrow("original",original) commonrow("sortkey",sortkey(a)) for i=1,#a do ctx_ML() local ai = a[i] - authorrow(ai,"original",i) - authorrow(ai,"snippets") - authorrow(ai,"initials") - authorrow(ai,"firstnames") - authorrow(ai,"vons") - authorrow(ai,"surnames") - authorrow(ai,"juniors") - local options = ai.options - if options then - row(false,"options",sortedkeys(options)) + if ai then + authorrow(ai,"original",i) + authorrow(ai,"snippets") + authorrow(ai,"initials") + authorrow(ai,"firstnames") + authorrow(ai,"vons") + authorrow(ai,"surnames") + authorrow(ai,"juniors") + local options = ai.options + if options then + row(false,"options",sortedkeys(options)) + end + elseif not trialtypesetting then + report("bad author name: %s",original or "?") end end ctx_LL() - context.stoptabulate() + ctx_stoptabulate() context.stop() end @@ -411,8 +432,49 @@ function tracers.showdatasetauthors(settings) end +function tracers.showentry(dataset,tag) + local dataset = datasets[dataset] + if dataset then + local entry = dataset.luadata[tag] + local done = false + for k, v in sortedhash(entry) do + if not privates[k] then + ctx_verbatim("%w[%s: %s]",done and 1 or 0,k,v) + done = true + end + end + end +end + +local skipped = { index = true, default = true } + +function tracers.showvariants(dataset,pages) + local variants = sortedkeys(citevariants) + for tag in publications.sortedentries(dataset or v_default) do + if pages then + ctx_page() + end + ctx_starttabulate { "|T||" } + for i=1,#variants do + local variant = variants[i] + if not skipped[variant] then + ctx_NC() context(variant) + -- ctx_EQ() citevariants[variant] { dataset = v_default, reference = tag, variant = variant } + ctx_EQ() context.cite({variant},{dataset .. "::" .. tag}) + ctx_NC() ctx_NR() + end + end + ctx_stoptabulate() + if pages then + ctx_page() + end + end +end + commands.showbtxdatasetfields = tracers.showdatasetfields commands.showbtxdatasetcompleteness = tracers.showdatasetcompleteness commands.showbtxfields = tracers.showfields commands.showbtxtables = tracers.showtables commands.showbtxdatasetauthors = tracers.showdatasetauthors +commands.showbtxentry = tracers.showentry +commands.showbtxvariants = tracers.showvariants diff --git a/tex/context/base/publ-tra.mkiv b/tex/context/base/publ-tra.mkiv index f4e7e867e..fb64b4171 100644 --- a/tex/context/base/publ-tra.mkiv +++ b/tex/context/base/publ-tra.mkiv @@ -28,7 +28,7 @@ \def\publ_show_dataset_whatever#1[#2]% {\begingroup - \setdummyparameter\c!specification{\btxparameter\c!specification}% + \letdummyparameter\c!specification\currentbtxspecification \setdummyparameter\c!dataset {\currentbtxdataset}% \letdummyparameter\c!field \empty \iffirstargument @@ -54,10 +54,12 @@ \def\publ_show_fields[#1]% {\begingroup \setdummyparameter\c!rotation{90}% - \doifassignmentelse{#1} - {\setdummyparameter\c!specification{\btxparameter\c!specification}% + \doifassignmentelse{#1}% + {\letdummyparameter\c!specification\currentbtxspecification \getdummyparameters[#1]}% - {\setdummyparameter\c!specification{#1}}% + {\doifelsenothing{#1}% + {\letdummyparameter\c!specification\currentbtxspecification}% + {\setdummyparameter\c!specification{#1}}}% % \publ_specification_push{"\dummyparameter\c!specification}% \ctxcommand{showbtxfields{ rotation = "\dummyparameter\c!rotation", @@ -80,4 +82,6 @@ \showbtxfields[rotation=85] \page \showbtxfields[rotation=90] \page + \showbtxtables \page + \stoptext diff --git a/tex/context/base/publ-xml.mkiv b/tex/context/base/publ-xml.mkiv index 007f9bb27..c08d84a9b 100644 --- a/tex/context/base/publ-xml.mkiv +++ b/tex/context/base/publ-xml.mkiv @@ -19,7 +19,7 @@ {\dosingleempty\publ_convert_to_xml} \def\publ_convert_to_xml[#1]% - {\ctxcommand{convertbtxdatasettoxml("\iffirstargument#1\else\v!standard\fi",true)}} % or current when not empty + {\ctxcommand{convertbtxdatasettoxml("\iffirstargument#1\else\v!default\fi",true)}} % or current when not empty % \startxmlsetups btx:initialize % \xmlregistereddocumentsetups{#1}{} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index bebc7d2e5..a210afdc5 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 789ee16eb..ab1a38859 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/strc-bkm.lua b/tex/context/base/strc-bkm.lua index 527188f23..f41f79db8 100644 --- a/tex/context/base/strc-bkm.lua +++ b/tex/context/base/strc-bkm.lua @@ -80,8 +80,13 @@ function bookmarks.overload(name,text) end end if ls then - ls.titledata.bookmark = text + local titledata = ls.titledata + if titledata then + titledata.bookmark = text + end end + -- last resort + -- context.writetolist({name},text,"") end local function stripped(str) -- kind of generic @@ -124,6 +129,24 @@ function bookmarks.place() local name = metadata.name if not metadata.nolist or forced[name] then -- and levelmap[name] then local titledata = li.titledata + -- + if not titledata then + local userdata = li.userdata + if userdata then + local first = userdata.first + local second = userdata.second + if first then + if second then + titledata = { title = first .. " " .. second } + else + titledata = { title = first } + end + else + titledata = { title = second } + end + end + end + -- if titledata then if not blockdone then if showblocktitle then @@ -151,12 +174,11 @@ function bookmarks.place() local title = titledata.bookmark if not title or title == "" then -- We could typeset the title and then convert it. - if not structural then - -- placeholder, todo: bookmarklabel - title = name .. ": " .. (titledata.title or "?") - else + -- if not structural then + -- title = titledata.title or "?") + -- else title = titledata.title or "?" - end + -- end end if numbered[name] then local sectiondata = sections.collected[li.references.section] @@ -174,12 +196,14 @@ function bookmarks.place() noflevels = noflevels + 1 local references = li.references levels[noflevels] = { - level = lastlevel, - title = stripped(title), -- can be replaced by converter - reference = references, -- has internal and realpage - opened = allopen or opened[name], - realpage = references and references.realpage or 0, -- handy for later - usedpage = true, + level = lastlevel, + title = stripped(title), -- can be replaced by converter + reference = references, -- has internal and realpage + opened = allopen or opened[name], + realpage = references and references.realpage or 0, -- handy for later + usedpage = true, + structural = structural, + name = name, } end end @@ -204,7 +228,11 @@ function bookmarks.flatten(levels) local function showthem() for i=1,noflevels do local level = levels[i] - report_bookmarks("%i > %s > %s",level.level,level.reference.block,level.title) + -- if level.structural then + -- report_bookmarks("%i > %s > %s",level.level,level.reference.block,level.title) + -- else + report_bookmarks("%i > %s > %s > %s",level.level,level.reference.block,level.name,level.title) + -- end end end if trace_bookmarks then diff --git a/tex/context/base/strc-bkm.mkiv b/tex/context/base/strc-bkm.mkiv index 5f1acb686..48273787a 100644 --- a/tex/context/base/strc-bkm.mkiv +++ b/tex/context/base/strc-bkm.mkiv @@ -74,7 +74,11 @@ \def\strc_bookmarks_bookmark_yes[#1]#2% {\begingroup \simplifycommands - \ctxcommand{overloadbookmark("#1",\!!bs\detokenize\expandafter{\normalexpanded{#2}}\!!es)}% + \ifnum\thenamedheadlevel{#1}>\zerocount + \ctxcommand{overloadbookmark("#1",\!!bs\detokenize\expandafter{\normalexpanded{#2}}\!!es)}% + \else + \strc_lists_write_to[#1][]{#2}{}% todo: a dedicated bookmark writer + \fi \endgroup} \def\strc_bookmarks_bookmark_nop[#1]#2% diff --git a/tex/context/base/strc-def.mkiv b/tex/context/base/strc-def.mkiv index 2f5116459..b4d2a5fea 100644 --- a/tex/context/base/strc-def.mkiv +++ b/tex/context/base/strc-def.mkiv @@ -32,6 +32,7 @@ \defineresetset [\s!default] [] [1] % each level \defineprefixset [\s!default] [section-1,section-2,section-3] [] +\defineconversionset [\v!number] [] [numbers] \defineconversionset [\v!pagenumber] [] [numbers] \defineprefixset [\v!all] [section-1,section-2,section-3,section-4,section-5,section-6,section-7,section-8] [] @@ -47,6 +48,9 @@ \setupuserpagenumber [\c!numberconversionset=\v!pagenumber] +\setupcounters + [\c!numberconversionset=\v!number] + % \startsetups defaults:frontpart:pagenumbers:roman % \defineconversionset[\c!frontpart:\c!pagenumber][][romannumerals] % \setupuserpagenumber[\c!way=\v!by\v!block] diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua index f91136f5d..f63832035 100644 --- a/tex/context/base/strc-doc.lua +++ b/tex/context/base/strc-doc.lua @@ -21,6 +21,7 @@ local concat, fastcopy = table.concat, table.fastcopy local max, min = math.max, math.min local allocate, mark, accesstable = utilities.storage.allocate, utilities.storage.mark, utilities.tables.accesstable local setmetatableindex = table.setmetatableindex +local lpegmatch, P, C = lpeg.match, lpeg.P, lpeg.C local catcodenumbers = catcodes.numbers local ctxcatcodes = catcodenumbers.ctxcatcodes @@ -59,6 +60,8 @@ local startapplyprocessor = processors.startapply local stopapplyprocessor = processors.stopapply local strippedprocessor = processors.stripped +local convertnumber = converters.convert + local a_internal = attributes.private('internal') local ctx_convertnumber = context.convertnumber @@ -600,10 +603,10 @@ local function process(index,numbers,ownnumbers,criterium,separatorset,conversio if ownnumber ~= "" then result[#result+1] = ownnumber elseif conversion and conversion ~= "" then -- traditional (e.g. used in itemgroups) .. inherited! - result[#result+1] = converters.convert(conversion,number,language) + result[#result+1] = convertnumber(conversion,number,language) else local theconversion = sets.get("structure:conversions",block,conversionset,index,"numbers") - result[#result+1] = converters.convert(theconversion,number,language) + result[#result+1] = convertnumber(theconversion,number,language) end else if ownnumber ~= "" then @@ -921,7 +924,14 @@ end function sections.getnumber(depth,what) -- redefined here local sectiondata = sections.findnumber(depth,what) - context((sectiondata and sectiondata.numbers[depth]) or 0) + local askednumber = 0 + if sectiondata then + local numbers = sectiondata.numbers + if numbers then + askednumber = numbers[depth] or 0 + end + end + context(askednumber) end -- experimental @@ -1003,8 +1013,16 @@ commands.setsectionentry = sections.setentry commands.reportstructure = sections.reportstructure -- -local byway = "^" .. v_by -- ugly but downward compatible +-- local byway = "^" .. v_by -- ugly but downward compatible + +-- function commands.way(way) +-- context((gsub(way,byway,""))) +-- end + +local pattern = P(v_by)^-1 * C(P(1)^1) function commands.way(way) - context((gsub(way,byway,""))) + if way ~= "" then + context(lpegmatch(pattern,way)) + end end diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua index a48679e6f..e7dc97dcd 100644 --- a/tex/context/base/strc-ini.lua +++ b/tex/context/base/strc-ini.lua @@ -160,7 +160,7 @@ local function simplify(d,nodefault) t[k] = simplify(v) end elseif tv == "string" then - if v ~= "" and v ~= "default" then + if v ~= "" then t[k] = v end elseif tv == "boolean" then @@ -336,7 +336,8 @@ function sets.getall(namespace,block,name) end end --- messy (will be another keyword, fixedconversion) +-- messy (will be another keyword, fixedconversion) .. needs to be documented too +-- maybe we should cache local splitter = lpeg.splitat("::") diff --git a/tex/context/base/strc-itm.lua b/tex/context/base/strc-itm.lua index 675917d59..b736ff4e3 100644 --- a/tex/context/base/strc-itm.lua +++ b/tex/context/base/strc-itm.lua @@ -15,7 +15,6 @@ local getvariable = jobpasses.getfield local texsetcount = tex.setcount local texsetdimen = tex.setdimen -local texgetcount = tex.getcount local f_stamp = string.formatters["itemgroup:%s:%s"] local counts = table.setmetatableindex("number") @@ -24,6 +23,8 @@ local counts = table.setmetatableindex("number") -- an itemgroup which in turn makes for less passes when one itemgroup -- entry is added or removed. +local trialtypesetting = context.trialtypesetting + function commands.analyzeitemgroup(name,level) local n = counts[name] if level == 1 then @@ -39,7 +40,7 @@ end function commands.registeritemgroup(name,level,nofitems,maxwidth) local n = counts[name] - if texgetcount("@@trialtypesetting") == 0 then + if not trialtypesetting() then -- no trialtypsetting setvariable(f_stamp(name,n), { nofitems, maxwidth }, level) elseif level == 1 then diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index f3fd9867d..9e0309139 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -891,11 +891,11 @@ function lists.number(name,n,spec) end end -function lists.prefixednumber(name,n,prefixspec,numberspec) +function lists.prefixednumber(name,n,prefixspec,numberspec,forceddata) local data = lists.result[n] if data then helpers.prefix(data,prefixspec) - local numberdata = data.numberdata + local numberdata = data.numberdata or forceddata if numberdata then typesetnumber(numberdata,"number",numberspec or false,numberdata or false) end diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi index 6e7e28e99..e5bdbdc99 100644 --- a/tex/context/base/strc-lst.mkvi +++ b/tex/context/base/strc-lst.mkvi @@ -453,13 +453,8 @@ \let\dotaglistlocation\relax -\unexpanded\def\strclistsentryprocess#tag#method#index#extra% This one is called at the lua end! - {\ctxcommand{pushlist(#index)}% - \edef\currentlist {#tag}% - \edef\currentlistmethod{#method}% - \edef\currentlistindex {#index}% - \edef\currentlistextra {#extra}% - \listextraparameter\c!before +\def\strc_lists_entry_process % assume things to be set up + {\listextraparameter\c!before \dostarttagged\t!listitem\currentlist \dotaglistlocation \csname\??structurelistprocessor @@ -469,7 +464,15 @@ \s!default \fi\fi\fi \endcsname \dostoptagged - \listextraparameter\c!after + \listextraparameter\c!after} + +\unexpanded\def\strclistsentryprocess#tag#method#index#extra% This one is called at the lua end! + {\ctxcommand{pushlist(#index)}% + \edef\currentlist {#tag}% + \edef\currentlistmethod{#method}% + \edef\currentlistindex {#index}% + \edef\currentlistextra {#extra}% + \strc_lists_entry_process \ctxcommand{poplist()}} % lists that have a number/title are kind of generic and can share code @@ -964,6 +967,8 @@ \hsize\scratchhsize \usealignparameter\listparameter \ifdim\scratchwidth<\hsize + % we have leftskip so we'd better just skip back instead of messing + % with hang* \edef\p_hang{\listparameter\c!hang} \hangindent\dimexpr\wd\b_strc_lists_number+\scratchdistance\relax \hangafter\ifx\p_hang\v!no\zerocount\else\plusone\fi @@ -976,7 +981,7 @@ \scratchdistance\zeropoint \fi \parindent\zeropoint - \dontleavehmode + \dontleavehmode % this nils hang: i need to figure out why % % topaligned % % \scratchdimen\wd\b_strc_lists_number @@ -1193,6 +1198,90 @@ \listparameter\c!after \stopsetups +%D One special for publications (as Alan loves to hangindent). No fonts and +%D such (for now). No interaction either as that is dealt with elsewhere. +%D +%D \currentlistsymbol +%D \currentlistentry +%D \currentlistentrypagenumber % not really used + +\definelistalternative + [\v!paragraph] + [\c!filler=\hskip.25\emwidth, + \c!renderingsetup=\??listrenderings:\v!paragraph] + +\startsetups[\??listrenderings:\v!paragraph] + \endgraf % are we grouped? + \typo_injectors_check_list % ? + \listparameter\c!before + \endgraf + \begingroup + \forgetall + \noindent + \parindent\zeropoint + \edef\p_width{\listparameter\c!width}% + \edef\p_distance{\listparameter\c!distance}% we are nice for bib users + \edef\p_margin{\listparameter\c!margin}% we are nice for bib users + \ifx\p_distance\v!none + \scratchdistance\zeropoint + \else + \scratchdistance\p_distance + \fi + \ifx\p_margin\v!none + \scratchoffset\zeropoint + \else + \scratchoffset\p_margin + \fi + \ifx\p_width\v!fit + \scratchwidth\zeropoint + \leftskip\scratchoffset + \else + \scratchwidth\p_width + \ifdim\scratchoffset=\zeropoint + \leftskip\dimexpr\scratchwidth+\scratchdistance\relax + \else + \leftskip\scratchoffset + \fi + \fi + \usealignparameter\listparameter + \hskip-\leftskip + \ifconditional\c_lists_has_number + \ifconditional\c_lists_show_number + \setbox\scratchbox\hbox\ifdim\scratchwidth>\zeropoint to \scratchwidth\fi + \bgroup + \useliststyleandcolor\c!numberstyle\c!numbercolor + \currentlistsymbol + \hss + \egroup + \ifdim\wd\scratchbox>\zeropoint + \box\scratchbox + \hskip\scratchdistance\relax + \fi + \fi + \fi + \begingroup + \useliststyleandcolor\c!textstyle\c!textcolor + \setstrut + \begstrut + \currentlistentrytitle + \endstrut + \endgroup + \ifconditional\c_lists_has_page + \ifconditional\c_lists_show_page + \nobreak + \listalternativeparameter\c!filler\relax + \begingroup + \useliststyleandcolor\c!pagestyle\c!pagecolor + \currentlistentrypagenumber + \endgroup + \fi + \fi + \endgraf + \endgroup + \allowbreak + \listparameter\c!after +\stopsetups + %D List elements are packaged in such a way that we can click on them %D in an interactive document. Here are a few helpers. diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi index 142696b28..3de4766ca 100644 --- a/tex/context/base/strc-not.mkvi +++ b/tex/context/base/strc-not.mkvi @@ -1830,4 +1830,24 @@ % [ownnote] % [\ownnotesymbol] +% tricky: +% +% \enabletrackers[nodes.areas] +% \enabletrackers[nodes.references] +% \enabletrackers[nodes.destinations] +% +% \setupnotes[interaction=all,rule=no] +% \setupinteraction[state=start,focus=standard] +% +% \starttext +% \goto{\input tufte\relax}[page(2)] \par +% \ruledhbox{\gotobox{\vtop{\input tufte\relax}}[page(2)]} \par +% \ruledhbox{\gotobox{\vbox{\input tufte\relax}}[page(2)]} \par +% % \completecontent +% % \chapter{Chapter} +% % \dorecurse{5}{\input knuth} +% a\footnote{\input tufte\par\input ward\relax} +% \stoptext + \protect \endinput + diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv index 7c3ac17db..5adec5afd 100644 --- a/tex/context/base/strc-num.mkiv +++ b/tex/context/base/strc-num.mkiv @@ -27,7 +27,9 @@ \installcommandhandler \??counter {counter} \??counter -\let\setupstructurecounting\setupcounter +\let\setupcounters\setupcounter + +\let\setupstructurecounting\setupcounter % will disappear \setupcounter [\c!way=\v!by\v!chapter, diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua index 1a4ccecd8..58ef9625f 100644 --- a/tex/context/base/strc-ref.lua +++ b/tex/context/base/strc-ref.lua @@ -1955,12 +1955,12 @@ function genericfilters.text(data) end end -function genericfilters.number(data,what,prefixspec) -- todo: spec and then no stopper +function genericfilters.number(data,what,prefixspec,numberspec) if data then numberdata = lists.reordered(data) -- data.numberdata if numberdata then helpers.prefix(data,prefixspec) - sections.typesetnumber(numberdata,"number",numberdata) + sections.typesetnumber(numberdata,"number",numberspec,numberdata) else local useddata = data.useddata if useddata and useddata.number then diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index d2f36eb74..4d4b07e9c 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -2046,15 +2046,36 @@ \installcorenamespace{referencingprefix} +% \def\getreferencestructureprefix#kind#name#category% name will change +% {{ +% prefix = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefix", +% separatorset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixseparatorset", +% conversion = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversion", +% conversionset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversionset", +% set = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixset", +% segments = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixsegments", +% connector = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconnector\!!es, +% }} + \def\getreferencestructureprefix#kind#name#category% name will change {{ prefix = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefix", separatorset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixseparatorset", conversion = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversion", conversionset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversionset", + starter = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixstarter\!!es, + stopper = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixstopper\!!es, set = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixset", segments = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixsegments", connector = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconnector\!!es, + }, + { + separatorset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberseparatorset", + conversion = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberconversion", + conversionset = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberconversionset", + starter = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberstarter\!!es, + stopper = \!!bs\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberstopper\!!es, + segments = "\referencestructureprefixparameter{#kind}{#name}{#category}\c!numbersegments", }} \unexpanded\def\setupreferencestructureprefix diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index 0d59cc321..a8d388a71 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -983,22 +983,18 @@ function registers.flush(data,options,prefixspec,pagespec) local data = sublist.data local d, n = 0, 0 ctx_startregistersection(sublist.tag) - --- -- no: we lost the see word --- --- for d=1,#data do --- local entry = data[d] --- if entry.metadata.kind == "see" then --- local list = entry.list --- if #list > 1 then --- list[#list] = nil --- else --- -- we have an \seeindex{Foo}{Bar} without Foo being defined anywhere --- report_registers("invalid see entry in register %a, reference %a",entry.metadata.name,list[1][1]) --- end --- end --- end - + for d=1,#data do + local entry = data[d] + if entry.metadata.kind == "see" then + local list = entry.list + if #list > 1 then + list[#list] = nil + else + -- we have an \seeindex{Foo}{Bar} without Foo being defined anywhere + report_registers("invalid see entry in register %a, reference %a",entry.metadata.name,list[1][1]) + end + end + end -- ok, this is tricky: we use e[i] delayed so we need it to be local -- but we don't want to allocate too many entries so there we go while d < #data do diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index 26ddfaac0..5c539794f 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -413,7 +413,7 @@ \definemarking[\currenthead] [\currentheadsection]% \definemarking[\currenthead\v!number][\currentheadsection]% \setupmarking [\currenthead] [\c!filtercommand=\noexpand\sectionheadmarkingtitle {\currenthead}]% - \setupmarking [\currenthead\c!number][\c!filtercommand=\noexpand\sectionheadmarkingnumber{\currenthead}]% + \setupmarking [\currenthead\v!number][\c!filtercommand=\noexpand\sectionheadmarkingnumber{\currenthead}]% }% \doifelselist\currenthead\donothing {\definelist[\currenthead][\c!prefix=\v!no]}% diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua index c65f97fd0..69c9f8168 100644 --- a/tex/context/base/syst-aux.lua +++ b/tex/context/base/syst-aux.lua @@ -131,4 +131,4 @@ function commands.upper(s) context(upper(s)) end function commands.lower(s) context(lower(s)) end function commands.strip(s) context(strip(s)) end -function commands.converteddimen(dimen,unit) context(todimen(dimen,unit or "pt","%0.5f")) end -- no unit appended +function commands.converteddimen(dimen,unit) context(todimen(dimen,unit or "pt","%0.5f")) end -- no unit appended (%F) diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 81b6406f9..38afd034f 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -11,13 +11,17 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D There are some references to \LUA\ variants here but these concern -%D (often old) experiments, moved from local test modules to here, -%D cleaned up, but not really used. After all it's not that urgent -%D and replacing helpers is a delicate process. Don't depend on it. +%D There are some references to \LUA\ variants here but these concern (often old) +%D experiments, moved from local test modules to here, cleaned up, but not really +%D used. After all it's not that urgent and replacing helpers is a delicate process. +%D Don't depend on it. \registerctxluafile{syst-aux}{1.001} +% A dedicated primitive \ifvoidmacro\cs == \ifx\cs\empty is some 10% faster but +% probably not that noticeable in practice. An \ifvoidtoks might make sense but we +% don't test that often for it (and it's more work to implement in the engine). + %D This is a stripped down combination of: %D %D \startitemize @@ -26,20 +30,18 @@ %D \item \type {syst-new.tex} %D \stopitemize %D -%D We keep them around (for \MKII) so you can find comments, -%D experiences, intermediate versions and cleaner variants -%D there (and also non-\ETEX\ variants). +%D We keep them around (for \MKII) so you can find comments, experiences, +%D intermediate versions and cleaner variants there (and also non-\ETEX\ variants). %D -%D Contrary to the older files, we now assume that this one -%D is used in \CONTEXT\ and therefore we might also assume that -%D some basic functionality is available. +%D Contrary to the older files, we now assume that this one is used in \CONTEXT\ and +%D therefore we might also assume that some basic functionality is available. %D -%D The original files contain previous implementations and notes about -%D performance. This file will be stripped down in due time. - -%D Some of the macros here were only used in the bibliography module. They -%D have been be moved to a separate syst module since the bib module is no -%D longer using them. Some more will go away. +%D The original files contain previous implementations and notes about performance. +%D This file will be stripped down in due time. +%D +%D Some of the macros here were only used in the bibliography module. They have been +%D be moved to a separate syst module since the bib module is no longer using them. +%D Some more will go away. \unprotect @@ -3403,6 +3405,7 @@ {\expandafter\syst_helpers_checked_stripped_csname\string#1} \def\syst_helpers_checked_stripped_csname#1% + %{\ifx#1\letterbackslash\else#1\fi} {\if\noexpand#1\letterbackslash\else#1\fi} %D \macros diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index 7628788d2..879f3ed53 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -638,6 +638,8 @@ %D %D In \LUATEX\ we have ways around this. +% no longer \errorstopmode cf. plain tex 3.141592653 + \normalprotected\def\tracingall {\tracingonline \plusone \tracingcommands \plusthree @@ -654,8 +656,7 @@ \tracingifs \plusone \tracingscantokens\plusone \tracingnesting \plusone - \tracingassigns \plustwo - \errorstopmode} + \tracingassigns \plustwo} \normalprotected\def\loggingall {\tracingall diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua index 95f8628ee..c50c5f1ca 100644 --- a/tex/context/base/syst-lua.lua +++ b/tex/context/base/syst-lua.lua @@ -123,13 +123,18 @@ function commands.ntimes(str,n) context(rep(str,n or 1)) end -function commands.write(n,str) - if n == 18 then - os.execute(str) - elseif n == 16 then - logs.report(str) - else - -- at the tex end we can still drop the write - context.writeviatex(n,str) - end +function commands.execute(str) + os.execute(str) -- wrapped in sandbox end + +-- function commands.write(n,str) +-- if n == 18 then +-- os.execute(str) +-- elseif n == 16 then +-- -- immediate +-- logs.report(str) +-- else +-- -- at the tex end we can still drop the write / also delayed vs immediate +-- context.writeviatex(n,str) +-- end +-- end diff --git a/tex/context/base/syst-lua.mkiv b/tex/context/base/syst-lua.mkiv index c146b81b7..2a6bcdf6d 100644 --- a/tex/context/base/syst-lua.mkiv +++ b/tex/context/base/syst-lua.mkiv @@ -72,15 +72,28 @@ % which in fact we can do by defining write18 as macro instead of % primitive ... todo. -\unexpanded\def\write#1#% - {\syst_write{#1}} +% \unexpanded\def\write#1#% +% {\syst_write{#1}} +% +% \def\syst_write#1#2% +% {\ctxcommand{write(\number#1,\!!bs\normalunexpanded{#2}\!!es)}} +% +% \unexpanded\def\writeviatex#1#2% +% {\ifx\normalwrite\relax\else +% \normalwrite#1{#2}% +% \fi} + +% we have no way yet to pickup \immediate unless we redefine it +% we assume immediate execution -\def\syst_write#1#2% - {\ctxcommand{write(\number#1,\!!bs#2\!!es)}} +\def\syst_write_execute#1% + {\ctxcommand{execute(\!!bs#1\!!es)}} -\unexpanded\def\writeviatex#1#2% - {\ifx\normalwrite\relax\else - \normalwrite#1{#2}% +\unexpanded\def\write#1#% + {\ifnum#1=18 + \expandafter\syst_write_execute + \else + \normalwrite#1% \fi} \protect \endinput diff --git a/tex/context/base/syst-rtp.mkiv b/tex/context/base/syst-rtp.mkiv index f65e599ec..58278972b 100644 --- a/tex/context/base/syst-rtp.mkiv +++ b/tex/context/base/syst-rtp.mkiv @@ -13,6 +13,6 @@ \unprotect -\def\executesystemcommand#1{\ctxlua{os.execute([[#1]])}} +\def\executesystemcommand#1{\ctxlua{os.execute(\!!bs#1\!!es)}} \protect \endinput diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 56e52794f..d0997c045 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -29,6 +29,8 @@ % - maybe only tag the box % - scale to fit % +% - buffers permit verbatim but are not always handy + %D This module started as an afternoon experiment and surprisingly could be %D mostly finished the same evening. Of course it builds upon existing %D functionality. The main reason for writing it is that we occasionally diff --git a/tex/context/base/toks-ini.lua b/tex/context/base/toks-ini.lua index 0f0c016f8..82c801b88 100644 --- a/tex/context/base/toks-ini.lua +++ b/tex/context/base/toks-ini.lua @@ -5,338 +5,219 @@ if not modules then modules = { } end modules ['toks-ini'] = { license = "see context related readme files" } -local context, commands = context, commands -local utfbyte, utfchar, utfvalues = utf.byte, utf.char, utf.values -local format, gsub = string.format, string.gsub - ---[[ldx-- -<p>This code is experimental and needs a cleanup. The visualizers will move to -a module.</p> ---ldx]]-- - --- 1 = command, 2 = modifier (char), 3 = controlsequence id --- --- callback.register('token_filter', token.get_next) --- --- token.get_next() --- token.expand() --- token.create() --- token.csname_id() --- token.csname_name(v) --- token.command_id() --- token.command_name(v) --- token.is_expandable() --- token.is_activechar() --- token.lookup(v) - --- actually, we can use token registers to store tokens - -local token, tex = token, tex - -local createtoken = token.create -local csname_id = token.csname_id -local command_id = token.command_id -local command_name = token.command_name -local get_next = token.get_next -local expand = token.expand -local is_activechar = token.is_activechar -local csname_name = token.csname_name - -tokens = tokens or { } -local tokens = tokens - -tokens.vbox = createtoken("vbox") -tokens.hbox = createtoken("hbox") -tokens.vtop = createtoken("vtop") -tokens.bgroup = createtoken(utfbyte("{"), 1) -tokens.egroup = createtoken(utfbyte("}"), 2) - -tokens.letter = function(chr) return createtoken(utfbyte(chr), 11) end -tokens.other = function(chr) return createtoken(utfbyte(chr), 12) end - -tokens.letters = function(str) - local t, n = { }, 0 - for chr in utfvalues(str) do - n = n + 1 - t[n] = createtoken(chr, 11) - end - return t -end - -tokens.collectors = tokens.collectors or { } -local collectors = tokens.collectors - -collectors.data = collectors.data or { } -local collectordata = collectors.data - -collectors.registered = collectors.registered or { } -local registered = collectors.registered - -local function printlist(data) - callbacks.push('token_filter', function () - callbacks.pop('token_filter') -- tricky but the nil assignment helps - return data - end) -end - -tex.printlist = printlist -- will change to another namespace - -function collectors.flush(tag) - printlist(collectordata[tag]) -end - -function collectors.test(tag) - printlist(collectordata[tag]) -end - -function collectors.register(name) - registered[csname_id(name)] = name -end - -local call = command_id("call") -local letter = command_id("letter") -local other = command_id("other_char") - -function collectors.install(tag,end_cs) - local data, d = { }, 0 - collectordata[tag] = data - local endcs = csname_id(end_cs) - while true do - local t = get_next() - local a, b = t[1], t[3] - if b == endcs then - context["end_cs"]() - return - elseif a == call and registered[b] then - expand() - else - d = d + 1 - data[d] = t +tokens = tokens or { } + +local tokens = tokens +local tostring = tostring +local utfchar = utf.char +local char = string.char +local printtable = table.print +local concat = table.concat + +if newtoken then + + if setinspector then + + local istoken = newtoken.is_token + local simple = { letter = "letter", other_char = "other" } + + local function astable(t) + if t and istoken(t) then + local cmdname = t.cmdname + local simple = simple[cmdname] + if simple then + return { + category = simple, + character = utfchar(t.mode) or nil, + } + else + return { + command = t.command, + id = t.id, + tok = t.tok, + csname = t.csname, + active = t.active, + expandable = t.expandable, + protected = t.protected, + mode = t.mode, + cmdname = cmdname, + } + end + end end - end -end - -function collectors.handle(tag,handle,flush) - collectordata[tag] = handle(collectordata[tag]) - if flush then - collectors.flush(tag) - end -end -local show_methods = { } -collectors.show_methods = show_methods + tokens.istoken = istoken + tokens.astable = astable -function collectors.show(tag, method) - if type(tag) == "table" then - show_methods[method or 'a'](tag) - else - show_methods[method or 'a'](collectordata[tag]) - end -end + setinspector(function(v) if istoken(v) then printtable(astable(v),tostring(v)) return true end end) -function collectors.defaultwords(t,str) - local n = #t - n = n + 1 - t[n] = tokens.bgroup - n = n + 1 - t[n] = createtoken("red") - for i=1,#str do - n = n + 1 - t[n] = tokens.other('*') end - n = n + 1 - t[n] = tokens.egroup -end -function collectors.dowithwords(tag,handle) - local t, w, tn, wn = { }, { }, 0, 0 - handle = handle or collectors.defaultwords - local tagdata = collectordata[tag] - for k=1,#tagdata do - local v = tagdata[k] - if v[1] == letter then - wn = wn + 1 - w[wn] = v[2] - else - if wn > 0 then - handle(t,w) - wn = 0 + local scan_toks = newtoken.scan_toks + local scan_string = newtoken.scan_string + local scan_int = newtoken.scan_int + local scan_code = newtoken.scan_code + local scan_dimen = newtoken.scan_dimen + local scan_glue = newtoken.scan_glue + local scan_keyword = newtoken.scan_keyword + local scan_token = newtoken.scan_token + + local get_next = newtoken.get_next + + local set_macro = newtoken.set_macro + + local bits = { + escape = 2^ 0, + begingroup = 2^ 1, + endgroup = 2^ 2, + mathshift = 2^ 3, + alignment = 2^ 4, + endofline = 2^ 5, + parameter = 2^ 6, + superscript = 2^ 7, + subscript = 2^ 8, + ignore = 2^ 9, + space = 2^10, -- 1024 + letter = 2^11, + other = 2^12, + active = 2^13, + comment = 2^14, + invalid = 2^15, + -- + character = 2^11 + 2^12, + whitespace = 2^13 + 2^10, -- / needs more checking + -- + open = 2^10 + 2^1, -- space + begingroup + close = 2^10 + 2^2, -- space + endgroup + } + + -- for k, v in next, bits do bits[v] = k end + + tokens.bits = bits + + local space_bits = bits.space + + -- words are space or \relax terminated and the trailing space is gobbled; a word + -- can contain any non-space letter/other + + local t = { } -- small optimization, a shared variable that is not reset + + local function scan_word() + local n = 0 + while true do + local c = scan_code() + if c then + n = n + 1 + t[n] = utfchar(c) + elseif scan_code(space_bits) then + if n > 0 then + break + end + elseif n > 0 then + break + else + return end - tn = tn + 1 - t[tn] = v end + return concat(t,"",1,n) end - if wn > 0 then - handle(t,w) - end - collectordata[tag] = t -end -local function showtoken(t) - if t then - local cmd, chr, id, cs, name = t[1], t[2], t[3], nil, command_name(t) or "" - if cmd == letter or cmd == other then - return format("%s-> %s -> %s", name, chr, utfchar(chr)) - elseif id > 0 then - cs = csname_name(t) or nil - if cs then - return format("%s-> %s", name, cs) - elseif tonumber(chr) < 0 then - return format("%s-> %s", name, id) + -- so we gobble the space (like scan_int) (number has to be space or non-char terminated + -- as we accept 0xabcd and such so there is no clear separator for a keyword + + local function scan_number(base) + local n = 0 + while true do + local c = scan_code() + if c then + n = n + 1 + t[n] = char(c) + elseif scan_code(space_bits) then + if n > 0 then + break + end + elseif n > 0 then + break else - return format("%s-> (%s,%s)", name, chr, id) + return end - else - return format("%s", name) - end - else - return "no node" - end -end - -collectors.showtoken = showtoken - -function collectors.trace() - local t = get_next() - logs.report("tokenlist",showtoken(t)) - return t -end - --- these might move to a runtime module - -show_methods.a = function(data) -- no need to store the table, just pass directly - local function row(one,two,three,four,five) - context.NC() context(one) - context.NC() context(two) - context.NC() context(three) - context.NC() context(four) - context.NC() context(five) - context.NC() context.NR() - end - context.starttabulate { "|T|Tr|cT|Tr|T|" } - row("cmd","chr","","id","name") - context.HL() - for _,v in next, data do - local cmd, chr, id, cs, sym = v[1], v[2], v[3], "", "" - local name = gsub(command_name(v) or "","_","\\_") - if id > 0 then - cs = csname_name(v) or "" - if cs ~= "" then cs = "\\string " .. cs end - else - id = "" - end - if cmd == letter or cmd == other then - sym = "\\char " .. chr end - if tonumber(chr) < 0 then - row(name,"",sym,id,cs) + local s = concat(t,"",1,n) + if base then + return tonumber(s,base) else - row(name,chr,sym,id,cs) + return tonumber(s) end end - context.stoptabulate() -end -local function show_b_c(data,swap) -- no need to store the table, just pass directly - local function row(one,two,three) - context.NC() context(one) - context.NC() context(two) - context.NC() context(three) - context.NC() context.NR() - end - if swap then - context.starttabulate { "|Tl|Tl|Tr|" } - else - context.starttabulate { "|Tl|Tr|Tl|" } - end - row("cmd","chr","name") - context.HL() - for _,v in next, data do - local cmd, chr, id, cs, sym = v[1], v[2], v[3], "", "" - local name = gsub(command_name(v) or "","_","\\_") - if id > 0 then - cs = csname_name(v) or "" - end - if cmd == letter or cmd == other then - sym = "\\char " .. chr - elseif cs == "" then - -- okay - elseif is_activechar(v) then - sym = "\\string " .. cs - else - sym = "\\string\\" .. cs - end - if swap then - row(name,sym,chr) - elseif tonumber(chr) < 0 then - row(name,"",sym) + -- -- the next one cannot handle \iftrue true\else false\fi + -- + -- local function scan_boolean() + -- if scan_keyword("true") then + -- return true + -- elseif scan_keyword("false") then + -- return false + -- else + -- return nil + -- end + -- end + + local function scan_boolean() + local kw = scan_word() + if kw == "true" then + return true + elseif kw == "false" then + return false else - row(name,chr,sym) + return nil end end - context.stoptabulate() -end - --- Even more experimental ... -show_methods.b = function(data) show_b_c(data,false) end -show_methods.c = function(data) show_b_c(data,true ) end - -local remapper = { } -- namespace -collectors.remapper = remapper - -local remapperdata = { } -- user mappings -remapper.data = remapperdata - -function remapper.store(tag,class,key) - local s = remapperdata[class] - if not s then - s = { } - remapperdata[class] = s - end - s[key] = collectordata[tag] - collectordata[tag] = nil -end - -function remapper.convert(tag,toks) - local data = remapperdata[tag] - local leftbracket, rightbracket = utfbyte('['), utfbyte(']') - local skipping = 0 - -- todo: math - if data then - local t, n = { }, 0 - for s=1,#toks do - local tok = toks[s] - local one, two = tok[1], tok[2] - if one == 11 or one == 12 then - if two == leftbracket then - skipping = skipping + 1 - n = n + 1 ; t[n] = tok - elseif two == rightbracket then - skipping = skipping - 1 - n = n + 1 ; t[n] = tok - elseif skipping == 0 then - local new = data[two] - if new then - if #new > 1 then - for n=1,#new do - n = n + 1 ; t[n] = new[n] - end - else - n = n + 1 ; t[n] = new[1] - end - else - n = n + 1 ; t[n] = tok - end - else - n = n + 1 ; t[n] = tok - end - else - n = n + 1 ; t[n] = tok - end - end - return t - else - return toks - end -end + tokens.scanners = { -- these expand + token = scan_token or get_next, + toks = scan_toks, + tokens = scan_toks, + dimen = scan_dimen, + dimension = scan_dimen, + glue = scan_glue, + skip = scan_glue, + integer = scan_int, + count = scan_int, + string = scan_string, + code = scan_code, + word = scan_word, + number = scan_number, + boolean = scan_boolean, + keyword = scan_keyword, + } + + tokens.getters = { -- these don't expand + token = get_next, + } + + tokens.setters = { + macro = set_macro, + } + +end + +-- static int run_scan_token(lua_State * L) +-- { +-- saved_tex_scanner texstate; +-- save_tex_scanner(texstate); +-- get_x_token(); +-- make_new_token(L, cur_cmd, cur_chr, cur_cs); +-- unsave_tex_scanner(texstate); +-- return 1; +-- } +-- +-- static int run_get_future(lua_State * L) +-- { +-- /* saved_tex_scanner texstate; */ +-- /* save_tex_scanner(texstate); */ +-- get_token(); +-- make_new_token(L, cur_cmd, cur_chr, cur_cs); +-- back_input(); +-- /* unsave_tex_scanner(texstate); */ +-- return 1; +-- } diff --git a/tex/context/base/toks-ini.mkiv b/tex/context/base/toks-ini.mkiv index 4eb756b75..c23b84e06 100644 --- a/tex/context/base/toks-ini.mkiv +++ b/tex/context/base/toks-ini.mkiv @@ -17,54 +17,6 @@ \unprotect -%D Handy for manuals \unknown - -\unexpanded\def\starttokens [#1]{\ctxlua{tokens.collectors.install("#1","stoptokens")}} - \let\stoptokens \relax - \def\flushtokens [#1]{\ctxlua{tokens.collectors.flush("#1")}} - \def\showtokens [#1]{\ctxlua{tokens.collectors.show("#1")}} - \def\testtokens [#1]{\ctxlua{tokens.collectors.with_words("#1")}} - \def\registertoken #1{\ctxlua{tokens.collectors.register("#1")}} - -%D Inspired by a prototype by Taco for Thomas cum suis. - -% \defineremapper[babelgreek] -% -% \remapcharacter[babelgreek][`a]{\alpha} -% \remapcharacter[babelgreek][`b]{\beta} -% \remapcharacter[babelgreek][`c]{\gamma} -% \remapcharacter[babelgreek][`d]{OEPS} -% -% \starttext -% -% [\startbabelgreek -% a b c some stuff here \blank[big] oeps b d -% \stopbabelgreek] -% -% [\babelgreek{some stuff here}] -% -% \stoptext - -\unexpanded\def\defineremapper[#1]% - {\setuevalue{\e!start#1}{\toks_start_remapper{#1}}% - \setuevalue{\e!stop #1}{\toks_stop_remapper {#1}}% - \letvalue{#1}\relax - \normalexpanded{\expandafter\def\csname#1\endcsname##1{\csname\e!start#1\endcsname##1\csname\e!stop#1\endcsname}}} - -\unexpanded\def\toks_start_remapper#1% - {\ctxlua{tokens.collectors.install("#1", "\e!stop#1")}} - -\unexpanded\def\toks_stop_remapper#1% - {\ctxlua{tokens.collectors.handle("#1",function(str) return tokens.collectors.remapper.convert("#1",str) end, true)}} - -\unexpanded\def\remaptokens#1% - {\ctxlua{tokens.collectors.handle("#1",function(str) return tokens.collectors.remapper.convert("#1",str) end)}} - -\unexpanded\def\remapcharacter - {\dodoubleempty\toks_remap_character} - -\def\toks_remap_character[#1][#2]#3% - {\ctxlua{tokens.collectors.install("store", "ctxlua")}#3% - \ctxlua{tokens.collectors.remapper.store("store","#1",\number#2)}} +% nothing yet \protect \endinput diff --git a/tex/context/base/toks-map.lua b/tex/context/base/toks-map.lua new file mode 100644 index 000000000..9120c2084 --- /dev/null +++ b/tex/context/base/toks-map.lua @@ -0,0 +1,70 @@ +if not modules then modules = { } end modules ['toks-map'] = { + version = 1.001, + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- Even more experimental ... this used to be part of toks-ini but as +-- this kind of remapping has not much use it is not loaded in the +-- core. We just keep it here for old times sake. + +-- local remapper = { } -- namespace +-- collectors.remapper = remapper +-- +-- local remapperdata = { } -- user mappings +-- remapper.data = remapperdata +-- +-- function remapper.store(tag,class,key) +-- local s = remapperdata[class] +-- if not s then +-- s = { } +-- remapperdata[class] = s +-- end +-- s[key] = collectordata[tag] +-- collectordata[tag] = nil +-- end +-- +-- function remapper.convert(tag,toks) +-- local data = remapperdata[tag] +-- local leftbracket = utfbyte('[') +-- local rightbracket = utfbyte(']') +-- local skipping = 0 +-- -- todo: math +-- if data then +-- local t, n = { }, 0 +-- for s=1,#toks do +-- local tok = toks[s] +-- local one, two = tok[1], tok[2] +-- if one == 11 or one == 12 then +-- if two == leftbracket then +-- skipping = skipping + 1 +-- n = n + 1 ; t[n] = tok +-- elseif two == rightbracket then +-- skipping = skipping - 1 +-- n = n + 1 ; t[n] = tok +-- elseif skipping == 0 then +-- local new = data[two] +-- if new then +-- if #new > 1 then +-- for n=1,#new do +-- n = n + 1 ; t[n] = new[n] +-- end +-- else +-- n = n + 1 ; t[n] = new[1] +-- end +-- else +-- n = n + 1 ; t[n] = tok +-- end +-- else +-- n = n + 1 ; t[n] = tok +-- end +-- else +-- n = n + 1 ; t[n] = tok +-- end +-- end +-- return t +-- else +-- return toks +-- end +-- end diff --git a/tex/context/base/toks-map.mkiv b/tex/context/base/toks-map.mkiv new file mode 100644 index 000000000..f1b63a68b --- /dev/null +++ b/tex/context/base/toks-map.mkiv @@ -0,0 +1,63 @@ +%D \module +%D [ file=toks-map, % experimental moved from toks-ini +%D version=2007.03.03, +%D title=\CONTEXT\ Token Support, +%D subtitle=Initialization, +%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 Token Support / Remapping} +% +% \registerctxluafile{toks-map}{1.001} +% +% \unprotect +% +% %D Inspired by a prototype by Taco for Thomas cum suis. +% %D +% %D \starttyping +% %D \defineremapper[babelgreek] +% %D +% %D \remapcharacter[babelgreek][`a]{\alpha} +% %D \remapcharacter[babelgreek][`b]{\beta} +% %D \remapcharacter[babelgreek][`c]{\gamma} +% %D \remapcharacter[babelgreek][`d]{OEPS} +% %D +% %D \starttext +% %D +% %D [\startbabelgreek +% %D a b c some stuff here \blank[big] oeps b d +% %D \stopbabelgreek] +% %D +% %D [\babelgreek{some stuff here}] +% %D +% %D \stoptext +% %D \stoptyping +% +% \unexpanded\def\defineremapper[#1]% +% {\setuevalue{\e!start#1}{\toks_start_remapper{#1}}% +% \setuevalue{\e!stop #1}{\toks_stop_remapper {#1}}% +% \letvalue{#1}\relax +% \normalexpanded{\expandafter\def\csname#1\endcsname##1{\csname\e!start#1\endcsname##1\csname\e!stop#1\endcsname}}} +% +% \unexpanded\def\toks_start_remapper#1% +% {\ctxlua{tokens.collectors.install("#1", "\e!stop#1")}} +% +% \unexpanded\def\toks_stop_remapper#1% +% {\ctxlua{tokens.collectors.handle("#1",function(str) return tokens.collectors.remapper.convert("#1",str) end, true)}} +% +% \unexpanded\def\remaptokens#1% +% {\ctxlua{tokens.collectors.handle("#1",function(str) return tokens.collectors.remapper.convert("#1",str) end)}} +% +% \unexpanded\def\remapcharacter +% {\dodoubleempty\toks_remap_character} +% +% \def\toks_remap_character[#1][#2]#3% +% {\ctxlua{tokens.collectors.install("store", "ctxlua")}#3% +% \ctxlua{tokens.collectors.remapper.store("store","#1",\number#2)}} +% +% \protect \endinput diff --git a/tex/context/base/toks-tra.lua b/tex/context/base/toks-tra.lua new file mode 100644 index 000000000..bf2b91d38 --- /dev/null +++ b/tex/context/base/toks-tra.lua @@ -0,0 +1,298 @@ +if not modules then modules = { } end modules ['toks-ini'] = { + version = 1.001, + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + + +local utfbyte, utfchar, utfvalues = utf.byte, utf.char, utf.values +local format, gsub = string.format, string.gsub +local tostring = tostring + +local tokens = tokens +local newtoken = newtoken +local tex = tex +local context = context +local commands = commands + +tokens.collectors = tokens.collectors or { } +local collectors = tokens.collectors + +collectors.data = collectors.data or { } +local collectordata = collectors.data + +collectors.registered = collectors.registered or { } +local registered = collectors.registered + +local report = logs.reporter("tokens","collectors") + +if newtoken then + + -- todo: + -- + -- register : macros that will be expanded (only for demo-ing) + -- flush : print back to tex + -- test : fancy stuff + + local get_next = newtoken.get_next + local create = newtoken.create + + function collectors.install(tag,end_cs) + local data, d = { }, 0 + collectordata[tag] = data + end_cs = gsub(end_cs,"^\\","") + while true do + local t = get_next() + if t.csname == end_cs then + context[end_cs]() + return + else + d = d + 1 + data[d] = t + end + end + end + + local simple = { letter = "letter", other_char = "other" } + + function collectors.show(data) + -- We no longer have methods as we only used (in demos) method a + -- so there is no need to burden the core with this. We have a + -- different table anyway. + if type(data) == "string" then + data = collectordata[data] + end + if not data then + return + end + local ctx_NC = context.NC + local ctx_NR = context.NR + local ctx_bold = context.bold + local ctx_verbatim = context.verbatim + context.starttabulate { "|Tl|Tc|Tl|" } + ctx_NC() ctx_bold("cmd") + ctx_NC() ctx_bold("meaning") + ctx_NC() ctx_bold("properties") + ctx_NC() ctx_NR() + context.HL() + for i=1,#data do + local token = data[i] + local cmdname = token.cmdname + local simple = simple[cmdname] + ctx_NC() + ctx_verbatim(simple or cmdname) + ctx_NC() + ctx_verbatim(simple and utfchar(token.mode) or token.csname) + ctx_NC() + if token.active then context("active ") end + if token.expandable then context("expandable ") end + if token.protected then context("protected ") end + ctx_NC() + ctx_NR() + end + context.stoptabulate() + end + + local function printlist(data) + if data and #data > 0 then + report("not supported (yet): printing back to tex") + end + end + + tokens.printlist = printlist -- will change to another namespace + + function collectors.flush(tag) + printlist(collectordata[tag]) + end + + function collectors.test(tag,handle) + report("not supported (yet): testing") + end + + function collectors.register(name) + report("not supported (yet): registering") + end + +else + + -- 1 = command, 2 = modifier (char), 3 = controlsequence id + + local create = token.create + local csname_id = token.csname_id + local command_id = token.command_id + local command_name = token.command_name + local get_next = token.get_next + local expand = token.expand + local csname_name = token.csname_name + + local function printlist(data) + if data and #data > 0 then + callbacks.push('token_filter', function () + callbacks.pop('token_filter') -- tricky but the nil assignment helps + return data + end) + end + end + + tokens.printlist = printlist -- will change to another namespace + + function collectors.flush(tag) + printlist(collectordata[tag]) + end + + function collectors.register(name) + registered[csname_id(name)] = name + end + + local call = command_id("call") + local letter = command_id("letter") + local other = command_id("other_char") + + function collectors.install(tag,end_cs) + local data, d = { }, 0 + collectordata[tag] = data + end_cs = gsub(end_cs,"^\\","") + local endcs = csname_id(end_cs) + while true do + local t = get_next() + local a, b = t[1], t[3] + if b == endcs then + context[end_cs]() + return + elseif a == call and registered[b] then + expand() + else + d = d + 1 + data[d] = t + end + end + end + + function collectors.show(data) + -- We no longer have methods as we only used (in demos) method a + -- so there is no need to burden the core with this. + if type(data) == "string" then + data = collectordata[data] + end + if not data then + return + end + local ctx_NC = context.NC + local ctx_NR = context.NR + local ctx_bold = context.bold + local ctx_verbatim = context.verbatim + context.starttabulate { "|T|Tr|cT|Tr|T|" } + ctx_NC() ctx_bold("cmd") + ctx_NC() ctx_bold("chr") + ctx_NC() + ctx_NC() ctx_bold("id") + ctx_NC() ctx_bold("name") + ctx_NC() ctx_NR() + context.HL() + for i=1,#data do + local token = data[i] + local cmd = token[1] + local chr = token[2] + local id = token[3] + local name = command_name(token) + ctx_NC() + ctx_verbatim(name) + ctx_NC() + if tonumber(chr) >= 0 then + ctx_verbatim(chr) + end + ctx_NC() + if cmd == letter or cmd == other then + ctx_verbatim(utfchar(chr)) + end + ctx_NC() + if id > 0 then + ctx_verbatim(id) + end + ctx_NC() + if id > 0 then + ctx_verbatim(csname_name(token) or "") + end + ctx_NC() ctx_NR() + end + context.stoptabulate() + end + + function collectors.test(tag,handle) + local t, w, tn, wn = { }, { }, 0, 0 + handle = handle or collectors.defaultwords + local tagdata = collectordata[tag] + for k=1,#tagdata do + local v = tagdata[k] + if v[1] == letter then + wn = wn + 1 + w[wn] = v[2] + else + if wn > 0 then + handle(t,w) + wn = 0 + end + tn = tn + 1 + t[tn] = v + end + end + if wn > 0 then + handle(t,w) + end + collectordata[tag] = t + end + +end + +-- Interfacing: + +commands.collecttokens = collectors.install +commands.showtokens = collectors.show +commands.flushtokens = collectors.flush +commands.testtokens = collectors.test +commands.registertoken = collectors.register + +-- Redundant: + +-- function collectors.test(tag) +-- printlist(collectordata[tag]) +-- end + +-- For old times sake: + +collectors.dowithwords = collectors.test + +-- This is only used in old articles ... will move to a module: + +local create = newtoken and newtoken.create or token.create + +tokens.vbox = create("vbox") +tokens.hbox = create("hbox") +tokens.vtop = create("vtop") +tokens.bgroup = create(utfbyte("{"),1) +tokens.egroup = create(utfbyte("}"),2) + +tokens.letter = function(chr) return create(utfbyte(chr),11) end +tokens.other = function(chr) return create(utfbyte(chr),12) end + +tokens.letters = function(str) + local t, n = { }, 0 + for chr in utfvalues(str) do + n = n + 1 + t[n] = create(chr, 11) + end + return t +end + +function collectors.defaultwords(t,str) + if t then + local n = #t + n = n + 1 ; t[n] = tokens.bgroup + n = n + 1 ; t[n] = create("red") + for i=1,#str do + n = n + 1 ; t[n] = tokens.other('*') + end + n = n + 1 ; t[n] = tokens.egroup + end +end diff --git a/tex/context/base/toks-tra.mkiv b/tex/context/base/toks-tra.mkiv new file mode 100644 index 000000000..a3e27eaf8 --- /dev/null +++ b/tex/context/base/toks-tra.mkiv @@ -0,0 +1,31 @@ +%D \module +%D [ file=toks-tra, % was toks-ini +%D version=2007.03.03, +%D title=\CONTEXT\ Token Support, +%D subtitle=Initialization, +%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 Token Support / Tracing} + +\registerctxluafile{toks-tra}{1.001} + +\unprotect + +%D Handy for manuals \unknown\ but not really used in practice, so it might +%D become a runtime loaded module instead. + +\unexpanded\def\starttokens [#1]{\ctxcommand{collecttokens("#1","stoptokens")}} + \let\stoptokens \relax + \def\flushtokens [#1]{\ctxcommand{flushtokens("#1")}} + \def\showtokens [#1]{\ctxcommand{showtokens("#1")}} + \def\testtokens [#1]{\ctxcommand{testtokens("#1")}} + \def\registertoken #1{\ctxcommand{registertoken("#1")}} + + +\protect \endinput diff --git a/tex/context/base/trac-tex.lua b/tex/context/base/trac-tex.lua index 7e3406073..5fe4754cb 100644 --- a/tex/context/base/trac-tex.lua +++ b/tex/context/base/trac-tex.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['trac-tex'] = { -- moved from trac-deb.lua -local format = string.format +local next = next local texhashtokens = tex.hashtokens @@ -20,23 +20,70 @@ function trackers.savehash() saved = texhashtokens() end -function trackers.dumphashtofile(filename,delta) - local list, hash, command_name = { }, texhashtokens(), token.command_name - for name, token in next, hash do - if not delta or not saved[name] then - -- token: cmd, chr, csid -- combination cmd,chr determines name - local category = command_name(token) - local dk = list[category] - if not dk then - -- a bit funny names but this sorts better (easier to study) - dk = { names = { }, found = 0, code = token[1] } - list[category] = dk +if newtoken then + + function trackers.dumphashtofile(filename,delta) + local list = { } + local hash = tex.hashtokens() + local create = newtoken.create + for name, token in next, hash do + if not delta or not saved[name] then + if token[2] ~= 0 then -- still old interface + local token = create(name) + -- inspect(token) + local category = token.cmdname + local dk = list[category] + if not dk then + dk = { + names = { }, + found = 0, + -- code = token[1], + } + list[category] = dk + end + if token.protected then + if token.expandable then + dk.names[name] = "ep" + else + dk.names[name] = "-p" + end + else + if token.expandable then + dk.names[name] = "ep" + else + dk.names[name] = "--" + end + end + dk.found = dk.found + 1 + end end - dk.names[name] = { token[2], token[3] } - dk.found = dk.found + 1 end + table.save(filename or tex.jobname .. "-hash.log",list) end - io.savedata(filename or tex.jobname .. "-hash.log",table.serialize(list,true)) + +else + + function trackers.dumphashtofile(filename,delta) + local list = { } + local hash = texhashtokens() + local getname = token.command_name + for name, token in next, hash do + if not delta or not saved[name] then + -- token: cmd, chr, csid -- combination cmd,chr determines name + local category = getname(token) + local dk = list[category] + if not dk then + -- a bit funny names but this sorts better (easier to study) + dk = { names = { }, found = 0, code = token[1] } + list[category] = dk + end + dk.names[name] = { token[2], token[3] } + dk.found = dk.found + 1 + end + end + table.save(filename or tex.jobname .. "-hash.log",list) + end + end local delta = nil diff --git a/tex/context/base/typo-chr.lua b/tex/context/base/typo-chr.lua new file mode 100644 index 000000000..87cffa7d4 --- /dev/null +++ b/tex/context/base/typo-chr.lua @@ -0,0 +1,104 @@ +if not modules then modules = { } end modules ['typo-chr'] = { + version = 1.001, + comment = "companion to typo-bld.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- local nodecodes = nodes.nodecodes +-- local whatsitcodes = nodes.whatsitcodes +-- local glyph_code = nodecodes.glyph +-- local whatsit_code = nodecodes.whatsit +-- local user_code = whatsitcodes.userdefined +-- +-- local stringusernode = nodes.pool.userstring +-- +-- local nuts = nodes.nuts +-- local pool = nuts.pool +-- +-- local tonut = nuts.tonut +-- local tonode = nuts.tonode +-- local getid = nuts.getid +-- local getprev = nuts.getprev +-- local getsubtype = nuts.getsubtype +-- local getchar = nuts.getchar +-- local getfield = nuts.getfield +-- +-- local remove_node = nuts.remove +-- local traverse_by_id = nuts.traverse_id +-- +-- local signal = pool.userids.signal +-- +-- local is_punctuation = characters.is_punctuation +-- +-- local actions = { +-- removepunctuation = function(head,n) +-- local prev = getprev(n) +-- if prev then +-- if getid(prev) == glyph_code then +-- if is_punctuation[getchar(prev)] then +-- head = remove_node(head,prev,true) +-- end +-- end +-- end +-- return head +-- end +-- } +-- +-- -- we can also use properties .. todo (saves pass) +-- +-- typesetters.signals = { } +-- +-- function typesetters.signals.handler(head) +-- local h = tonut(head) +-- local done = false +-- for n in traverse_by_id(whatsit_code,h) do +-- if getsubtype(n) == user_code and getfield(n,"user_id") == signal and getfield(n,"type") == 115 then +-- local action = actions[getfield(n,"value")] +-- if action then +-- h = action(h,n) +-- end +-- h = remove_node(h,n,true) +-- done = true +-- end +-- end +-- if done then +-- return tonode(h), true +-- else +-- return head +-- end +-- end +-- +-- local enabled = false +-- +-- function commands.signal(what) +-- if not enabled then +-- nodes.tasks.prependaction("processors","normalizers", "typesetters.signals.handler") +-- enabled = true +-- end +-- context(stringusernode(signal,what)) +-- end + +local nodecodes = nodes.nodecodes +local glyph_code = nodecodes.glyph + +local texnest = tex.nest +local free_node = node.free + +local punctuation = characters.is_punctuation + +function commands.removepunctuation() + local list = texnest[texnest.ptr] + if list then + local tail = list.tail + if tail and tail.id == glyph_code and punctuation[tail.char] then + local prev = tail.prev + list.tail = prev + if prev then + prev.next = nil + end + free_node(tail) + end + end +end diff --git a/tex/context/base/typo-chr.mkiv b/tex/context/base/typo-chr.mkiv new file mode 100644 index 000000000..138bf348a --- /dev/null +++ b/tex/context/base/typo-chr.mkiv @@ -0,0 +1,27 @@ + +%D \module +%D [ file=typo-cap, +%D version=2009.03.27, % code moved from core-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Capping, +%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 Typesetting Macros / Characters} + +\unprotect + +%D Maybe we need a more clever system: either command or style mode etc. so +%D that we can avoid the grouped mess in a simple style switch. + +\registerctxluafile{typo-chr}{1.001} + +%unexpanded\def\removepunctuation{\ctxcommand{signal("removepunctuation")}} +\unexpanded\def\removepunctuation{\ctxcommand{removepunctuation()}} + +\protect diff --git a/tex/context/base/typo-del.mkiv b/tex/context/base/typo-del.mkiv index 6ce768ab2..2b4e6e6aa 100644 --- a/tex/context/base/typo-del.mkiv +++ b/tex/context/base/typo-del.mkiv @@ -70,23 +70,23 @@ {\ifcase\boundarycharactermode \or %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \languageparameter#1% + \hskip\hspaceamount\currentusedlanguage{#2}% + \usedlanguageparameter#1% %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% + \hskip\hspaceamount\currentusedlanguage{#2}% \or - \languageparameter#1% + \usedlanguageparameter#1% \fi \boundarycharactermode\plusone} \unexpanded\def\leftboundarycharacter#1#2% {\ifcase\boundarycharactermode \or - \languageparameter#1% + \usedlanguageparameter#1% \nobreak - \hskip\hspaceamount\currentlanguage{#2}% + \hskip\hspaceamount\currentusedlanguage{#2}% \or - \languageparameter#1% + \usedlanguageparameter#1% \fi \boundarycharactermode\plusone} @@ -94,10 +94,10 @@ {\ifcase\boundarycharactermode \or \prewordbreak %\nobreak - \hskip\hspaceamount\currentlanguage{#2}% - \languageparameter#1% + \hskip\hspaceamount\currentusedlanguage{#2}% + \usedlanguageparameter#1% \or - \languageparameter#1% + \usedlanguageparameter#1% \fi \boundarycharactermode\plusone} @@ -142,7 +142,7 @@ {\beforesubsentence \ifdim\lastkern=\d_typo_subsentence_signal \unskip - \kern\hspaceamount\currentlanguage{intersentence}% + \kern\hspaceamount\currentusedlanguage{intersentence}% \fi \global\advance\c_typo_subsentence_nesting\plusone \ifnum\c_typo_subsentence_nesting=\plusone @@ -166,7 +166,7 @@ \unexpanded\def\endofsubsentencespacing {\ifdim\lastkern=\d_typo_subsentence_signal \unskip - \hskip\hspaceamount\currentlanguage{intersentence}% + \hskip\hspaceamount\currentusedlanguage{intersentence}% % no good, actually language dependent: % \ignorespaces \else @@ -193,8 +193,8 @@ %definehspace [quote] [\zeropoint] %definehspace [speech] [\zeropoint] -\definehspace [quote] [\hspaceamount\currentlanguage{quotation}] -\definehspace [speech] [\hspaceamount\currentlanguage{quotation}] +\definehspace [quote] [\hspaceamount\currentusedlanguage{quotation}] +\definehspace [speech] [\hspaceamount\currentusedlanguage{quotation}] \definesymbol [\c!leftquotation] @@ -256,6 +256,7 @@ \def\typo_delimited_push#1% {\globalpushmacro\currentdelimitedtext \def\currentdelimitedtext{#1}% + \setlanguageparameter\delimitedtextparameter \let\currentparentdelimitedtext\currentdelimitedtext \global\advance\c_typo_delimited_nesting\plusone \edef\delimitedtextlevel{\number\c_typo_delimited_nesting}% @@ -543,7 +544,7 @@ \ifdim\wd\scratchbox>\zeropoint \ifdim\lastkern=\d_typo_delimited_signal \unkern - \hskip\hspaceamount\currentlanguage{interquotation}% + \hskip\hspaceamount\currentusedlanguage{interquotation}% \fi \ifhmode % else funny pagebeaks \penalty\plustenthousand @@ -563,10 +564,10 @@ \ifdim\wd\scratchbox>\zeropoint \ifdim\lastkern=\d_typo_delimited_signal \unkern - \hskip\hspaceamount\currentlanguage{interquotation}% + \hskip\hspaceamount\currentusedlanguage{interquotation}% \else\ifdim\lastskip=\d_typo_delimited_signal \unskip - \hskip\hspaceamount\currentlanguage{interquotation}% + \hskip\hspaceamount\currentusedlanguage{interquotation}% \fi\fi \strut % new, needed below \ifhmode % else funny pagebeaks @@ -588,11 +589,11 @@ \ifdim\lastkern=\d_typo_delimited_signal \unkern \penalty\plustenthousand - \hskip\hspaceamount\currentlanguage{interquotation}% + \hskip\hspaceamount\currentusedlanguage{interquotation}% \else\ifdim\lastskip=\d_typo_delimited_signal \unskip \penalty\plustenthousand - \hskip\hspaceamount\currentlanguage{interquotation}% + \hskip\hspaceamount\currentusedlanguage{interquotation}% \fi\fi \ifhmode % else funny pagebeaks \penalty\plustenthousand @@ -674,11 +675,11 @@ \def\typo_delimited_fontdriven_b {\dostarttaggedchained\t!delimited\currentdelimitedtext\??delimitedtext - \languageparameter{\c!left\currentparentdelimitedtext}% was: \currentdelimitedtext + \usedlanguageparameter{\c!left\currentparentdelimitedtext}% was: \currentdelimitedtext \usedelimitedtextstyleandcolor\c!style\c!color} \def\typo_delimited_fontdriven_e - {\languageparameter{\c!right\currentparentdelimitedtext}% was: \currentdelimitedtext + {\usedlanguageparameter{\c!right\currentparentdelimitedtext}% was: \currentdelimitedtext \dostoptagged \typo_delimited_pop} diff --git a/tex/context/base/typo-mar.lua b/tex/context/base/typo-mar.lua index b0906020e..bba8501d0 100644 --- a/tex/context/base/typo-mar.lua +++ b/tex/context/base/typo-mar.lua @@ -603,10 +603,10 @@ local function inject(parent,head,candidate) -- offset = offset + height end if stack == v_yes then - offset = offset + candidate.dy + offset = offset + candidate.dy -- always shift = shift + offset elseif stack == v_continue then - offset = offset + candidate.dy + offset = offset + candidate.dy -- always if firstonstack then offset = offset + getovershoot(location) end diff --git a/tex/context/base/util-dim.lua b/tex/context/base/util-dim.lua index bfffb1010..2bdb870e7 100644 --- a/tex/context/base/util-dim.lua +++ b/tex/context/base/util-dim.lua @@ -92,9 +92,9 @@ format (string) is implemented using this table.</p> --ldx]]-- local f_none = formatters["%s%s"] -local f_true = formatters["%0.5f%s"] +local f_true = formatters["%0.5F%s"] -local function numbertodimen(n,unit,fmt) +local function numbertodimen(n,unit,fmt) -- will be redefined later ! if type(n) == 'string' then return n else diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index 302b98441..a3ae01be0 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -333,7 +333,7 @@ end -- for mtx-context etc: aaaa bbbb cccc=dddd eeee=ffff -local str = C((1-whitespace-equal)^1) +local str = Cs(lpegpatterns.unquoted) + C((1-whitespace-equal)^1) local setting = Cf( Carg(1) * (whitespace^0 * Cg(str * whitespace^0 * (equal * whitespace^0 * str + Cc(""))))^1,rawset) local splitter = setting^1 @@ -524,7 +524,7 @@ function parsers.rfc4180splitter(specification) local field = escaped + non_escaped + Cc("") local record = Ct(field * (separator * field)^1) local headerline = record * Cp() - local wholeblob = Ct((newline^-1 * record)^0) + local wholeblob = Ct((newline^(specification.strict and -1 or 1) * record)^0) return function(data,getheader) if getheader then local header, position = lpegmatch(headerline,data) diff --git a/tex/context/base/x-asciimath.lua b/tex/context/base/x-asciimath.lua index ff9c5c3d6..20cbd14e4 100644 --- a/tex/context/base/x-asciimath.lua +++ b/tex/context/base/x-asciimath.lua @@ -21,6 +21,7 @@ ugly and unsatisfying code mess down here. Don't take this as an example.</p> local trace_mapping = false if trackers then trackers.register("modules.asciimath.mapping", function(v) trace_mapping = v end) end local trace_detail = false if trackers then trackers.register("modules.asciimath.detail", function(v) trace_detail = v end) end +local trace_digits = false if trackers then trackers.register("modules.asciimath.digits", function(v) trace_digits = v end) end local report_asciimath = logs.reporter("mathematics","asciimath") @@ -40,7 +41,7 @@ local rep, gmatch, gsub, find = string.rep, string.gmatch, string.gsub, string.f local utfchar = utf.char local lpegmatch, patterns = lpeg.match, lpeg.patterns -local S, P, R, C, V, Cc, Ct, Cs = lpeg.S, lpeg.P, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Ct, lpeg.Cs +local S, P, R, C, V, Cc, Ct, Cs, Carg = lpeg.S, lpeg.P, lpeg.R, lpeg.C, lpeg.V, lpeg.Cc, lpeg.Ct, lpeg.Cs, lpeg.Carg local sortedhash = table.sortedhash local sortedkeys = table.sortedkeys @@ -753,8 +754,83 @@ local isright = { local issimplified = { } +-- + +-- special mess + +local d_one = lpeg.R("09") +local d_two = d_one * d_one +local d_three = d_two * d_one +local d_spaced = (Carg(1) * d_three)^1 +local d_split = P(-1) + P(",") + +local digitized = Cs(( + d_three * d_spaced * d_split + + d_two * d_spaced * d_split + + d_one * d_spaced * d_split + + P(1) + )^1) + +-- print(lpeg.match(digitized,"1")) +-- print(lpeg.match(digitized,"12")) +-- print(lpeg.match(digitized,"123")) +-- print(lpeg.match(digitized,"1234")) +-- print(lpeg.match(digitized,"12345")) +-- print(lpeg.match(digitized,"123456")) +-- print(lpeg.match(digitized,"1234567")) +-- print(lpeg.match(digitized,"12345678")) +-- print(lpeg.match(digitized,"123456789")) + +-- print(lpeg.match(digitized,"1,1")) +-- print(lpeg.match(digitized,"12,12")) +-- print(lpeg.match(digitized,"123,123")) +-- print(lpeg.match(digitized,"1234,1234")) +-- print(lpeg.match(digitized,"12345,12345")) +-- print(lpeg.match(digitized,"123456,123456")) +-- print(lpeg.match(digitized,"1234567,1234567")) +-- print(lpeg.match(digitized,"12345678,12345678")) +-- print(lpeg.match(digitized,"123456789,123456789")) + +function asciimath.setup(settings) + local separator = settings.separator + if separator == interfaces.variables.yes then + digitseparator = utfchar(0x2008) + elseif separator and separator ~= "" then + digitseparator = separator + end +end + +local collected_digits = { } +local collected_filename = "asciimath-digits.lua" + +function numbermess(s) + if digitseparator then + local d = lpegmatch(digitized,s,1,digitseparator) + if d then + if trace_digits and s ~= d then + collected_digits[s] = d + end + return d + end + end + return s +end + +statistics.register("asciimath",function() + if trace_digits then + local n = table.count(collected_digits) + if n > 0 then + table.save(collected_filename,collected_digits) + return string.format("%s digit conversions saved in %s",n,collected_filename) + else + os.remove(collected_filename) + end + end +end) + local p_number_base = patterns.cpnumber or patterns.cnumber or patterns.number local p_number = C(p_number_base) +----- p_number = p_number_base local p_spaces = patterns.whitespace local p_utf_base = patterns.utf8character @@ -774,7 +850,8 @@ local real = digits * (S(".,") * digits)^-1 local float = real * (P("E") * integer)^-1 -- local number = C(float + integer) -local p_number = C(float) +-- local p_number = C(float) +local p_number = float / numbermess local k_reserved = sortedkeys(reserved) local k_commands = { } @@ -1682,7 +1759,8 @@ if not context then -- report_asciimath(cleanedup([[a "α" b]])) -- report_asciimath(cleanedup([[//4]])) -convert("4/18*100text(%)~~22,2") +-- convert("10000,00001") +-- convert("4/18*100text(%)~~22,2") -- convert([[sum x]]) -- convert([[sum^(1)_(2) x]]) @@ -1876,12 +1954,15 @@ function show.statistics() end end end + local NC = context.NC + local NR = context.NR + local EQ = context.EQ context.starttabulate { "|B||" } - context.NC() context("files") context.EQ() context(noffiles) context.NC() context.NR() - context.NC() context("formulas") context.EQ() context(nofokay+nofbad) context.NC() context.NR() - context.NC() context("uniques") context.EQ() context(#indexed) context.NC() context.NR() - context.NC() context("cleanedup") context.EQ() context(nofcleanedup) context.NC() context.NR() - context.NC() context("errors") context.EQ() context(nofbad) context.NC() context.NR() + NC() context("files") EQ() context(noffiles) NC() NR() + NC() context("formulas") EQ() context(nofokay+nofbad) NC() NR() + NC() context("uniques") EQ() context(#indexed) NC() NR() + NC() context("cleanedup") EQ() context(nofcleanedup) NC() NR() + NC() context("errors") EQ() context(nofbad) NC() NR() context.stoptabulate() end diff --git a/tex/context/base/x-asciimath.mkiv b/tex/context/base/x-asciimath.mkiv index c24377275..27d19693f 100644 --- a/tex/context/base/x-asciimath.mkiv +++ b/tex/context/base/x-asciimath.mkiv @@ -129,6 +129,8 @@ \usemodule[mathml-basics] +\startmodule[asciimath] + \unprotect \writestatus{asciimath}{beware, this is an experimental (m4all only) module} @@ -143,6 +145,16 @@ %D The core commands: +% if we need to set + +\installsetuponlycommandhandler {asciimath} {asciimath} + +\appendtoks + \ctxlua{moduledata.asciimath.setup { + separator = "\asciimathparameter\c!separator", + }}% +\to \everysetupasciimath + \unexpanded\def\asciimath#1% {\ctxcommand{asciimath(\!!bs\detokenize\expandafter{\normalexpanded{#1}}\!!es)}} @@ -258,10 +270,14 @@ \stopsetups +\stopmodule + \continueifinputfile{x-asciimath.mkiv} %D This will become an extra. +\showframe + \setups[asciimath:layout] % \enabletrackers[modules.asciimath.mapping] @@ -273,10 +289,10 @@ % % \ShowAsciiMathSave[e:/temporary/asciimath/asciimath.lua] % \stoptext -% \starttext -% \unexpanded\def\MyAsciiMath#1{\startformula\asciimath{#1}\stopformula} -% \startlines -% \MyAsciiMath{x^2 / 10 // z_12^34 / 20} +\starttext +\unexpanded\def\MyAsciiMath#1{\startformula\asciimath{#1}\stopformula} +\startlines +\MyAsciiMath{x^2 / 10 // z_12^34 / 20} % \MyAsciiMath{{:{:x^2:} / 10:} // {:{:z_12^34 :} / 20:}} % \MyAsciiMath{x^2+y_1+z_12^34} % \MyAsciiMath{sin^-1(x)} @@ -360,5 +376,5 @@ % \MyAsciiMath{x^ (-1 1/2) =1/x^ (1 1/2)=1/ (x^1*x^ (1/2)) =1/ (xsqrt(x))} % \MyAsciiMath{x^2(10 -x)>2 x^2} % \MyAsciiMath{x^4>x} -% \stoplines -% \stoptext +\stoplines +\stoptext diff --git a/tex/context/base/x-cals.lua b/tex/context/base/x-cals.lua index 13f0e2bbe..3af6106d8 100644 --- a/tex/context/base/x-cals.lua +++ b/tex/context/base/x-cals.lua @@ -6,6 +6,7 @@ if not modules then modules = { } end modules ['x-cals'] = { license = "see context related readme files" } +local next = next local format, lower = string.format, string.lower local xmlsprint, xmlcprint, xmlcollected, xmlelements = xml.sprint, xml.cprint, xml.collected, xml.elements local n_todimen, s_todimen = number.todimen, string.todimen diff --git a/tex/context/base/x-html.mkiv b/tex/context/base/x-html.mkiv index bcb36a7d6..e1806eb9e 100644 --- a/tex/context/base/x-html.mkiv +++ b/tex/context/base/x-html.mkiv @@ -38,6 +38,8 @@ \definehighlight[tt] [\c!command=\v!no,\c!style=\v!mono] \definehighlight[strong][\c!command=\v!no,\c!style=\v!bold] \definehighlight[u] [\c!command=\v!no,\c!style=\directsetbar{\v!underbar}] +\definehighlight[code] [\c!command=\v!no,\c!style=\v!mono] +\definehighlight[pre] [\c!command=\v!no] \protect @@ -114,6 +116,14 @@ \stopitem \stopxmlsetups +\startxmlsetups xml:html:code + \directhighlight{code}{\xmlflushspacewise{#1}} +\stopxmlsetups + +\startxmlsetups xml:html:pre + \directhighlight{pre}{\xmlflushspacewise{#1}} +\stopxmlsetups + \startxmlsetups xml:html:span \xmlflush{#1} \stopxmlsetups @@ -134,7 +144,7 @@ % todo: align % beware, the padding code is somewhat experimental, eventually the -% table will be done in cdl code +% table will be done in cld code % % we can also use \xmlmap for border etc diff --git a/tex/context/base/x-set-11.mkiv b/tex/context/base/x-set-11.mkiv index 12854dc92..c0575e625 100644 --- a/tex/context/base/x-set-11.mkiv +++ b/tex/context/base/x-set-11.mkiv @@ -369,7 +369,8 @@ } { \let\currentSETUPprefix\empty } - \edef\currentSETUPname{\xmlatt{#1}{name}} + % \edef\currentSETUPname{\xmlatt{#1}{name}} + \edef\currentSETUPname{\xmlattribute{#1}{/sequence/string[1]}{value}}% \doifelse {\xmlatt{#1}{generated}} {yes} { \def\currentSETUPgenerated{*} } { @@ -457,7 +458,7 @@ \def\showsetupindeed#1% {\startelement[setup][name=#1]% \startelement[noexport][comment={setup definition #1}] - \xmlfilterlist{\loadedsetups}{/interface/command['#1' == (@type=='environment' and 'start' or '') .. @name]/command(xml:setups:typeset)}% + \xmlfilterlist{\loadedsetups}{/interface/command['#1' == (@type=='environment' and '\e!start' or '') .. @name]/command(xml:setups:typeset)}% \stopelement \stopelement} @@ -469,7 +470,7 @@ %D Typesetting: \setupxml - [\c!method=mkiv, % mixed mode + [%\c!method=mkiv, % mixed mode \c!default=\v!hidden, % ignore elements that are not defined \c!compress=\v!yes, % strip comment \c!entities=\v!yes] % replace entities @@ -499,37 +500,41 @@ \xmlfilter{#1}{/sequence/first()} \ignorespaces \egroup - \xmldoif{#1}{/arguments} { - \bgroup - \enablemode[setups-pass-one] - \doglobal\newcounter\currentSETUPargument - \ignorespaces - \xmlfilter{#1}{/arguments/text()} - \egroup - } - \doif {\xmlatt{#1}{type}} {environment} { - \bgroup - \enablemode[setups-pass-one]% - \hskip.5em\unknown\hskip.5em - \doif {\xmlatt{#1}{generated}} {yes} { - \ttsl - } - \tex{\e!stop} - \xmlfilter{#1}{/sequence/first()} - \ignorespaces - \egroup - } - \endgraf - \xmldoif{#1}{/arguments} { - \bgroup - \enablemode[setups-pass-two] - \doglobal\newcounter\currentSETUPargument - %\blank[\v!line] % packed mode (we could do \startunpacked ...) - \godown[.75\lineheight] - \switchtobodyfont[\v!small] - \ignorespaces\xmlfilter{#1}{/arguments/text()}\endgraf - \egroup - } + \ifshortsetup + % nothing + \else + \xmldoif{#1}{/arguments} { + \bgroup + \enablemode[setups-pass-one] + \doglobal\newcounter\currentSETUPargument + \ignorespaces + \xmlfilter{#1}{/arguments/text()} + \egroup + } + \doif {\xmlatt{#1}{type}} {environment} { + \bgroup + \enablemode[setups-pass-one]% + \hskip.5em\unknown\hskip.5em + \doif {\xmlatt{#1}{generated}} {yes} { + \ttsl + } + \tex{\e!stop} + \xmlfilter{#1}{/sequence/first()} + \ignorespaces + \egroup + } + \endgraf + \xmldoif{#1}{/arguments} { + \bgroup + \enablemode[setups-pass-two] + \doglobal\newcounter\currentSETUPargument + %\blank[\v!line] % packed mode (we could do \startunpacked ...) + \godown[.75\lineheight] + \switchtobodyfont[\v!small] + \ignorespaces\xmlfilter{#1}{/arguments/text()}\endgraf + \egroup + } + \fi \getvalue{\e!stop setuptext} \stopxmlsetups diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index 4382cc5e6..477fa9caf 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -844,7 +844,7 @@ <cd:constant name='middletext' value='testocentro'/> <cd:constant name='midsentence' value='midsentence'/> <cd:constant name='min' value='min'/> - <cd:constant name='mindepth' value='mindeoth'/> + <cd:constant name='mindepth' value='mindepth'/> <cd:constant name='minheight' value='altezzamin'/> <cd:constant name='minwidth' value='ampiezzamin'/> <cd:constant name='moffset' value='moffset'/> diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 5e8bab3ce..3807ae464 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -291,15 +291,15 @@ <cd:variable name='mathematics' value='wiskunde'/> <cd:variable name='mathmatrix' value='wiskundematrix'/> <cd:variable name='max' value='max'/> - <cd:variable name='maxdepth' value='maxdepth'/> - <cd:variable name='maxheight' value='maxheight'/> - <cd:variable name='maxwidth' value='maxwidth'/> + <cd:variable name='maxdepth' value='maxdiepte'/> + <cd:variable name='maxheight' value='maxhoogte'/> + <cd:variable name='maxwidth' value='maxbreedte'/> <cd:variable name='may' value='mei'/> <cd:variable name='mediaeval' value='mediaeval'/> <cd:variable name='medium' value='middel'/> <cd:variable name='middle' value='midden'/> <cd:variable name='min' value='min'/> - <cd:variable name='mindepth' value='mindepth'/> + <cd:variable name='mindepth' value='mindiepte'/> <cd:variable name='minheight' value='minhoogte'/> <cd:variable name='minwidth' value='minbreedte'/> <cd:variable name='mirrored' value='gespiegeld'/> diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua index e7cdc7b39..c4d653604 100644 --- a/tex/generic/context/luatex/luatex-basics-gen.lua +++ b/tex/generic/context/luatex/luatex-basics-gen.lua @@ -15,8 +15,13 @@ local dummyfunction = function() end local dummyreporter = function(c) - return function(...) - (texio.reporter or texio.write_nl)(c .. " : " .. string.formatters(...)) + return function(f,...) + local r = texio.reporter or texio.write_nl + if f then + r(c .. " : " .. string.formatters(f,...)) + else + r("") + end end end diff --git a/tex/generic/context/luatex/luatex-fonts-cbk.lua b/tex/generic/context/luatex/luatex-fonts-cbk.lua index 414cafb25..ce19c8811 100644 --- a/tex/generic/context/luatex/luatex-fonts-cbk.lua +++ b/tex/generic/context/luatex/luatex-fonts-cbk.lua @@ -116,13 +116,14 @@ function nodes.handlers.nodepass(head) if basepass and #basefonts > 0 then for i=1,#basefonts do local range = basefonts[i] - local start, stop = range[1], range[2] + local start = range[1] + local stop = range[2] if stop then - ligaturing(start,stop) - kerning(start,stop) - else - ligaturing(start) - kerning(start) + start, stop = ligaturing(start,stop) + start, stop = kerning(start,stop) + elseif start then + start = ligaturing(start) + start = kerning(start) end end end diff --git a/tex/generic/context/luatex/luatex-fonts-inj.lua b/tex/generic/context/luatex/luatex-fonts-inj.lua index b1dce8cab..cb9ed891c 100644 --- a/tex/generic/context/luatex/luatex-fonts-inj.lua +++ b/tex/generic/context/luatex/luatex-fonts-inj.lua @@ -14,13 +14,12 @@ if not nodes.properties then return end local next, rawget = next, rawget local utfchar = utf.char +local fastcopy = table.fastcopy local trace_injections = false trackers.register("fonts.injections", function(v) trace_injections = v end) local report_injections = logs.reporter("fonts","injections") -report_injections("using experimental injector") - local attributes, nodes, node = attributes, nodes, node fonts = fonts @@ -81,19 +80,42 @@ function injections.resetcounts() keepregisteredcounts = false end +-- We need to make sure that a possible metatable will not kick in +-- unexpectedly. + function injections.reset(n) - local p = rawget(properties,start) - if p and p.injections then - -- todo: decrement counters? tricky as we then need to change the nof* to not increment - -- when we change a property - p.injections = nil -- should we keep the liga index? + local p = rawget(properties,n) + if p and rawget(p,"injections") then + p.injections = nil + end +end + +function injections.copy(target,source) + local sp = rawget(properties,source) + if sp then + local tp = rawget(properties,target) + local si = rawget(sp,"injections") + if si then + si = fastcopy(si) + if tp then + tp.injections = si + else + propertydata[target] = { + injections = si, + } + end + else + if tp then + tp.injections = nil + end + end end end function injections.setligaindex(n,index) local p = rawget(properties,n) if p then - local i = p.injections + local i = rawget(p,"injections") if i then i.ligaindex = index else @@ -113,9 +135,9 @@ end function injections.getligaindex(n,default) local p = rawget(properties,n) if p then - p = p.injections - if p then - return p.ligaindex or default + local i = rawget(p,"injections") + if i then + return i.ligaindex or default end end return default @@ -134,7 +156,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne -- local p = rawget(properties,start) if p then - local i = p.injections + local i = rawget(p,"injections") if i then i.cursiveanchor = true else @@ -151,7 +173,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne end local p = rawget(properties,nxt) if p then - local i = p.injections + local i = rawget(p,"injections") if i then i.cursivex = dx i.cursivey = dy @@ -185,14 +207,16 @@ function injections.setpair(current,factor,rlmode,r2lflag,spec,injection) -- r2l end local p = rawget(properties,current) if p then - local i = p.injections + local i = rawget(p,"injections") if i then - if leftkern ~= 0 or rightkern ~= 0 then - i.leftkern = i.leftkern or 0 + leftkern - i.rightkern = i.rightkern or 0 + rightkern + if leftkern ~= 0 then + i.leftkern = (i.leftkern or 0) + leftkern + end + if rightkern ~= 0 then + i.rightkern = (i.rightkern or 0) + rightkern end if yoffset ~= 0 then - i.yoffset = i.yoffset or 0 + yoffset + i.yoffset = (i.yoffset or 0) + yoffset end elseif leftkern ~= 0 or rightkern ~= 0 then p.injections = { @@ -240,9 +264,9 @@ function injections.setkern(current,factor,rlmode,x,injection) injection = "injections" end if p then - local i = p[injection] + local i = rawget(p,injection) if i then - i.leftkern = dx + i.leftkern or 0 + i.leftkern = dx + (i.leftkern or 0) else p[injection] = { leftkern = dx, @@ -270,7 +294,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase) -- ba=basean end local p = rawget(properties,start) if p then - local i = p.injections + local i = rawget(p,"injections") if i then i.markx = dx i.marky = dy @@ -313,18 +337,18 @@ local function show(n,what,nested,symbol) if n then local p = rawget(properties,n) if p then - local p = p[what] - if p then - local leftkern = p.leftkern or 0 - local rightkern = p.rightkern or 0 - local yoffset = p.yoffset or 0 - local markx = p.markx or 0 - local marky = p.marky or 0 - local markdir = p.markdir or 0 - local markbase = p.markbase or 0 -- will be markbasenode - local cursivex = p.cursivex or 0 - local cursivey = p.cursivey or 0 - local ligaindex = p.ligaindex or 0 + local i = rawget(p,what) + if i then + local leftkern = i.leftkern or 0 + local rightkern = i.rightkern or 0 + local yoffset = i.yoffset or 0 + local markx = i.markx or 0 + local marky = i.marky or 0 + local markdir = i.markdir or 0 + local markbase = i.markbase or 0 -- will be markbasenode + local cursivex = i.cursivex or 0 + local cursivey = i.cursivey or 0 + local ligaindex = i.ligaindex or 0 local margin = nested and 4 or 2 -- if rightkern ~= 0 or yoffset ~= 0 then @@ -355,9 +379,9 @@ local function showsub(n,what,where) report_injections("end subrun") end -local function trace(head) - report_injections("begin run: %s kerns, %s pairs, %s marks and %s cursives registered", - nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) +local function trace(head,where) + report_injections("begin run %s: %s kerns, %s pairs, %s marks and %s cursives registered", + where or "",nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) local n = head while n do local id = getid(n) @@ -414,10 +438,6 @@ local function collect_glyphs_1(head) local nf, tm = nil, nil for n in traverse_id(glyph_code,head) do -- only needed for relevant fonts if getsubtype(n) < 256 then - local pn = rawget(properties,n) - if pn then - pn = pn.injections - end local f = getfont(n) if f ~= nf then nf = f @@ -431,10 +451,14 @@ local function collect_glyphs_1(head) glyphs[nofglyphs] = n end -- yoffsets can influence curs steps - if pn then - local yoffset = pn.yoffset - if yoffset and yoffset ~= 0 then - setfield(n,"yoffset",yoffset) + local p = rawget(properties,n) + if p then + local i = rawget(p,"injections") + if i then + local yoffset = i.yoffset + if yoffset and yoffset ~= 0 then + setfield(n,"yoffset",yoffset) + end end end end @@ -470,21 +494,20 @@ local function inject_marks(marks,nofmarks) local n = marks[i] local pn = rawget(properties,n) if pn then - pn = pn.injections - end - if pn then - -- local markbase = pn.markbase - -- if markbase then - -- local p = markanchors[markbase] + pn = rawget(pn,"injections") + if pn then local p = pn.markbasenode if p then local px = getfield(p,"xoffset") local ox = 0 + local rightkern = nil local pp = rawget(properties,p) if pp then - pp = pp.injections + pp = rawget(pp,"injections") + if pp then + rightkern = pp.rightkern + end end - local rightkern = pp and pp.rightkern if rightkern then -- x and w ~= 0 if pn.markdir < 0 then -- kern(w-x) glyph(p) kern(x) mark(n) @@ -493,8 +516,13 @@ local function inject_marks(marks,nofmarks) else -- kern(x) glyph(p) kern(w-x) mark(n) -- ox = px - getfield(p,"width") + pn.markx - pp.leftkern - ox = px - pn.markx - pp.leftkern - -- report_injections("l2r case 1: %p",ox) + local leftkern = pp.leftkern + if leftkern then + ox = px - pn.markx + else + ox = px - pn.markx - leftkern + end +-- report_injections("l2r case 1: %p",ox) end else -- we need to deal with fonts that have marks with width @@ -528,10 +556,10 @@ local function inject_marks(marks,nofmarks) end setfield(n,"yoffset",oy) else - -- normally this can't happen (only when in trace mode which is a special case anyway) + -- normally this can't happen (only when in trace mode which is a special case anyway) -- report_injections("missing mark anchor %i",pn.markbase or 0) end - -- end + end end end end @@ -543,14 +571,14 @@ local function inject_cursives(glyphs,nofglyphs) local n = glyphs[i] local pn = rawget(properties,n) if pn then - pn = pn.injections + pn = rawget(pn,"injections") end if pn then local cursivex = pn.cursivex if cursivex then if cursiveanchor then if cursivex ~= 0 then - pn.leftkern = pn.leftkern or 0 + cursivex + pn.leftkern = (pn.leftkern or 0) + cursivex end if lastanchor then if maxc == 0 then @@ -625,16 +653,16 @@ local function inject_kerns(head,glyphs,nofglyphs) local n = glyphs[i] local pn = rawget(properties,n) if pn then - pn = pn.injections - end - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then - insert_node_before(head,n,newkern(leftkern)) -- type 0/2 - end - local rightkern = pn.rightkern - if rightkern and rightkern ~= 0 then - insert_node_after(head,n,newkern(rightkern)) -- type 0/2 + local i = rawget(pn,"injections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + insert_node_before(head,n,newkern(leftkern)) -- type 0/2 + end + local rightkern = i.rightkern + if rightkern and rightkern ~= 0 then + insert_node_after(head,n,newkern(rightkern)) -- type 0/2 + end end end end @@ -643,7 +671,7 @@ end local function inject_everything(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"everything") end local glyphs, nofglyphs, marks, nofmarks if nofregisteredpairs > 0 then @@ -655,7 +683,7 @@ local function inject_everything(head,where) if nofregisteredcursives > 0 then inject_cursives(glyphs,nofglyphs) end - if nofregisteredmarks > 0 then + if nofregisteredmarks > 0 then -- and nofmarks > 0 inject_marks(marks,nofmarks) end inject_kerns(head,glyphs,nofglyphs) @@ -674,7 +702,7 @@ end local function inject_kerns_only(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"kerns") end local n = head local p = nil @@ -687,10 +715,10 @@ local function inject_kerns_only(head,where) if p then local d = getfield(p,"post") if d then - local pn = pn.postinjections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"postinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then local t = find_tail(d) insert_node_after(d,t,newkern(leftkern)) end @@ -698,28 +726,28 @@ local function inject_kerns_only(head,where) end local d = getfield(p,"replace") if d then - local pn = pn.replaceinjections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"replaceinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then local t = find_tail(d) insert_node_after(d,t,newkern(leftkern)) end end else - local pn = pn.injections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"injections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then setfield(p,"replace",newkern(leftkern)) end end end else - local pn = pn.injections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"injections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then head = insert_node_before(head,n,newkern(leftkern)) end end @@ -737,12 +765,12 @@ local function inject_kerns_only(head,where) if getsubtype(n) < 256 then local pn = rawget(properties,n) if pn then - pn = pn.preinjections - end - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) + local i = rawget(pn,"preinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -760,12 +788,12 @@ local function inject_kerns_only(head,where) if getsubtype(n) < 256 then local pn = rawget(properties,n) if pn then - pn = pn.postinjections - end - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) + local i = rawget(pn,"postinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -783,12 +811,12 @@ local function inject_kerns_only(head,where) if getsubtype(n) < 256 then local pn = rawget(properties,n) -- why can it be empty { } if pn then - pn = pn.replaceinjections - end - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) + local i = rawget(pn,"replaceinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -817,7 +845,7 @@ end local function inject_pairs_only(head,where) head = tonut(head) if trace_injections then - trace(head) + trace(head,"pairs") end -- local n = head @@ -831,14 +859,14 @@ local function inject_pairs_only(head,where) if p then local d = getfield(p,"post") if d then - local pn = pn.postinjections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"postinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then local t = find_tail(d) insert_node_after(d,t,newkern(leftkern)) end - -- local rightkern = pn.rightkern + -- local rightkern = i.rightkern -- if rightkern and rightkern ~= 0 then -- insert_node_after(head,n,newkern(rightkern)) -- n = getnext(n) -- to be checked @@ -847,27 +875,27 @@ local function inject_pairs_only(head,where) end local d = getfield(p,"replace") if d then - local pn = pn.replaceinjections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"replaceinjections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then local t = find_tail(d) insert_node_after(d,t,newkern(leftkern)) end - -- local rightkern = pn.rightkern + -- local rightkern = i.rightkern -- if rightkern and rightkern ~= 0 then -- insert_node_after(head,n,newkern(rightkern)) -- n = getnext(n) -- to be checked -- end end else - local pn = pn.injections - if pn then - local leftkern = pn.leftkern - if leftkern ~= 0 then + local i = rawget(pn,"injections") + if i then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then setfield(p,"replace",newkern(leftkern)) end - -- local rightkern = pn.rightkern + -- local rightkern = i.rightkern -- if rightkern and rightkern ~= 0 then -- insert_node_after(head,n,newkern(rightkern)) -- n = getnext(n) -- to be checked @@ -876,17 +904,17 @@ local function inject_pairs_only(head,where) end else -- this is the most common case - local pn = pn.injections - if pn then - local yoffset = pn.yoffset + local i = rawget(pn,"injections") + if i then + local yoffset = i.yoffset if yoffset and yoffset ~= 0 then setfield(n,"yoffset",yoffset) end - local leftkern = pn.leftkern - if leftkern ~= 0 then + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then insert_node_before(head,n,newkern(leftkern)) end - local rightkern = pn.rightkern + local rightkern = i.rightkern if rightkern and rightkern ~= 0 then insert_node_after(head,n,newkern(rightkern)) n = getnext(n) -- to be checked @@ -904,23 +932,23 @@ local function inject_pairs_only(head,where) local h = d for n in traverse_id(glyph_code,d) do if getsubtype(n) < 256 then - local pn = rawget(properties,n) - if pn then - pn = pn.preinjections - end - if pn then - local yoffset = pn.yoffset - if yoffset and yoffset ~= 0 then - setfield(n,"yoffset",yoffset) - end - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) - end - local rightkern = pn.rightkern - if rightkern and rightkern ~= 0 then - insert_node_after(head,n,newkern(rightkern)) - n = getnext(n) -- to be checked + local p = rawget(properties,n) + if p then + local i = rawget(p,"preinjections") + if i then + local yoffset = i.yoffset + if yoffset and yoffset ~= 0 then + setfield(n,"yoffset",yoffset) + end + local leftkern = i.leftkern + if leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end + local rightkern = i.rightkern + if rightkern and rightkern ~= 0 then + insert_node_after(head,n,newkern(rightkern)) + n = getnext(n) -- to be checked + end end end else @@ -936,23 +964,23 @@ local function inject_pairs_only(head,where) local h = d for n in traverse_id(glyph_code,d) do if getsubtype(n) < 256 then - local pn = rawget(properties,n) - if pn then - pn = pn.postinjections - end - if pn then - local yoffset = pn.yoffset - if yoffset and yoffset ~= 0 then - setfield(n,"yoffset",yoffset) - end - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) - end - local rightkern = pn.rightkern - if rightkern and rightkern ~= 0 then - insert_node_after(head,n,newkern(rightkern)) - n = getnext(n) -- to be checked + local p = rawget(properties,n) + if p then + local i = rawget(p,"postinjections") + if i then + local yoffset = i.yoffset + if yoffset and yoffset ~= 0 then + setfield(n,"yoffset",yoffset) + end + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end + local rightkern = i.rightkern + if rightkern and rightkern ~= 0 then + insert_node_after(head,n,newkern(rightkern)) + n = getnext(n) -- to be checked + end end end else @@ -968,23 +996,23 @@ local function inject_pairs_only(head,where) local h = d for n in traverse_id(glyph_code,d) do if getsubtype(n) < 256 then - local pn = rawget(properties,n) - if pn then - pn = pn.replaceinjections - end - if pn then - local yoffset = pn.yoffset - if yoffset and yoffset ~= 0 then - setfield(n,"yoffset",yoffset) - end - local leftkern = pn.leftkern - if leftkern ~= 0 then - h = insert_node_before(h,n,newkern(leftkern)) - end - local rightkern = pn.rightkern - if rightkern and rightkern ~= 0 then - insert_node_after(head,n,newkern(rightkern)) - n = getnext(n) -- to be checked + local p = rawget(properties,n) + if p then + local i = rawget(pn,"replaceinjections") + if i then + local yoffset = i.yoffset + if yoffset and yoffset ~= 0 then + setfield(n,"yoffset",yoffset) + end + local leftkern = i.leftkern + if leftkern and leftkern ~= 0 then + h = insert_node_before(h,n,newkern(leftkern)) + end + local rightkern = i.rightkern + if rightkern and rightkern ~= 0 then + insert_node_after(head,n,newkern(rightkern)) + n = getnext(n) -- to be checked + end end end else diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c1951c8e7..6dba44785 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 : 02/03/15 23:55:34 +-- merge date : 03/09/15 19:27:36 do -- begin closure to overcome local limits and interference @@ -3374,8 +3374,13 @@ end local dummyfunction=function() end local dummyreporter=function(c) - return function(...) - (texio.reporter or texio.write_nl)(c.." : "..string.formatters(...)) + return function(f,...) + local r=texio.reporter or texio.write_nl + if f then + r(c.." : "..string.formatters(f,...)) + else + r("") + end end end statistics={ @@ -5794,13 +5799,13 @@ local function read_from_tfm(specification) properties.filename=specification.filename properties.format=fonts.formats.tfm parameters.size=size - shared.rawdata={} - shared.features=features - shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil tfmdata.properties=properties tfmdata.resources=resources tfmdata.parameters=parameters tfmdata.shared=shared + shared.rawdata={} + shared.features=features + shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil parameters.slant=parameters.slant or parameters[1] or 0 parameters.space=parameters.space or parameters[2] or 0 parameters.space_stretch=parameters.space_stretch or parameters[3] or 0 @@ -9840,9 +9845,9 @@ if not modules then modules={} end modules ['font-inj']={ if not nodes.properties then return end local next,rawget=next,rawget local utfchar=utf.char +local fastcopy=table.fastcopy local trace_injections=false trackers.register("fonts.injections",function(v) trace_injections=v end) local report_injections=logs.reporter("fonts","injections") -report_injections("using experimental injector") local attributes,nodes,node=attributes,nodes,node fonts=fonts local fontdata=fonts.hashes.identifiers @@ -9889,15 +9894,36 @@ function injections.resetcounts() keepregisteredcounts=false end function injections.reset(n) - local p=rawget(properties,start) - if p and p.injections then - p.injections=nil + local p=rawget(properties,n) + if p and rawget(p,"injections") then + p.injections=nil + end +end +function injections.copy(target,source) + local sp=rawget(properties,source) + if sp then + local tp=rawget(properties,target) + local si=rawget(sp,"injections") + if si then + si=fastcopy(si) + if tp then + tp.injections=si + else + propertydata[target]={ + injections=si, + } + end + else + if tp then + tp.injections=nil + end + end end end function injections.setligaindex(n,index) local p=rawget(properties,n) if p then - local i=p.injections + local i=rawget(p,"injections") if i then i.ligaindex=index else @@ -9916,9 +9942,9 @@ end function injections.getligaindex(n,default) local p=rawget(properties,n) if p then - p=p.injections - if p then - return p.ligaindex or default + local i=rawget(p,"injections") + if i then + return i.ligaindex or default end end return default @@ -9935,7 +9961,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne end local p=rawget(properties,start) if p then - local i=p.injections + local i=rawget(p,"injections") if i then i.cursiveanchor=true else @@ -9952,7 +9978,7 @@ function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmne end local p=rawget(properties,nxt) if p then - local i=p.injections + local i=rawget(p,"injections") if i then i.cursivex=dx i.cursivey=dy @@ -9985,14 +10011,16 @@ function injections.setpair(current,factor,rlmode,r2lflag,spec,injection) end local p=rawget(properties,current) if p then - local i=p.injections + local i=rawget(p,"injections") if i then - if leftkern~=0 or rightkern~=0 then - i.leftkern=i.leftkern or 0+leftkern - i.rightkern=i.rightkern or 0+rightkern + if leftkern~=0 then + i.leftkern=(i.leftkern or 0)+leftkern + end + if rightkern~=0 then + i.rightkern=(i.rightkern or 0)+rightkern end if yoffset~=0 then - i.yoffset=i.yoffset or 0+yoffset + i.yoffset=(i.yoffset or 0)+yoffset end elseif leftkern~=0 or rightkern~=0 then p.injections={ @@ -10034,9 +10062,9 @@ function injections.setkern(current,factor,rlmode,x,injection) injection="injections" end if p then - local i=p[injection] + local i=rawget(p,injection) if i then - i.leftkern=dx+i.leftkern or 0 + i.leftkern=dx+(i.leftkern or 0) else p[injection]={ leftkern=dx, @@ -10062,7 +10090,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase) end local p=rawget(properties,start) if p then - local i=p.injections + local i=rawget(p,"injections") if i then i.markx=dx i.marky=dy @@ -10102,18 +10130,18 @@ local function show(n,what,nested,symbol) if n then local p=rawget(properties,n) if p then - local p=p[what] - if p then - local leftkern=p.leftkern or 0 - local rightkern=p.rightkern or 0 - local yoffset=p.yoffset or 0 - local markx=p.markx or 0 - local marky=p.marky or 0 - local markdir=p.markdir or 0 - local markbase=p.markbase or 0 - local cursivex=p.cursivex or 0 - local cursivey=p.cursivey or 0 - local ligaindex=p.ligaindex or 0 + local i=rawget(p,what) + if i then + local leftkern=i.leftkern or 0 + local rightkern=i.rightkern or 0 + local yoffset=i.yoffset or 0 + local markx=i.markx or 0 + local marky=i.marky or 0 + local markdir=i.markdir or 0 + local markbase=i.markbase or 0 + local cursivex=i.cursivex or 0 + local cursivey=i.cursivey or 0 + local ligaindex=i.ligaindex or 0 local margin=nested and 4 or 2 if rightkern~=0 or yoffset~=0 then report_injections("%w%s pair: lx %p, rx %p, dy %p",margin,symbol,leftkern,rightkern,yoffset) @@ -10141,9 +10169,9 @@ local function showsub(n,what,where) end report_injections("end subrun") end -local function trace(head) - report_injections("begin run: %s kerns, %s pairs, %s marks and %s cursives registered", - nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) +local function trace(head,where) + report_injections("begin run %s: %s kerns, %s pairs, %s marks and %s cursives registered", + where or "",nofregisteredkerns,nofregisteredpairs,nofregisteredmarks,nofregisteredcursives) local n=head while n do local id=getid(n) @@ -10196,10 +10224,6 @@ local function collect_glyphs_1(head) local nf,tm=nil,nil for n in traverse_id(glyph_code,head) do if getsubtype(n)<256 then - local pn=rawget(properties,n) - if pn then - pn=pn.injections - end local f=getfont(n) if f~=nf then nf=f @@ -10212,10 +10236,14 @@ local function collect_glyphs_1(head) nofglyphs=nofglyphs+1 glyphs[nofglyphs]=n end - if pn then - local yoffset=pn.yoffset - if yoffset and yoffset~=0 then - setfield(n,"yoffset",yoffset) + local p=rawget(properties,n) + if p then + local i=rawget(p,"injections") + if i then + local yoffset=i.yoffset + if yoffset and yoffset~=0 then + setfield(n,"yoffset",yoffset) + end end end end @@ -10249,23 +10277,30 @@ local function inject_marks(marks,nofmarks) local n=marks[i] local pn=rawget(properties,n) if pn then - pn=pn.injections - end - if pn then + pn=rawget(pn,"injections") + if pn then local p=pn.markbasenode if p then local px=getfield(p,"xoffset") local ox=0 + local rightkern=nil local pp=rawget(properties,p) if pp then - pp=pp.injections + pp=rawget(pp,"injections") + if pp then + rightkern=pp.rightkern + end end - local rightkern=pp and pp.rightkern if rightkern then if pn.markdir<0 then ox=px-pn.markx-rightkern else - ox=px-pn.markx-pp.leftkern + local leftkern=pp.leftkern + if leftkern then + ox=px-pn.markx + else + ox=px-pn.markx-leftkern + end end else ox=px-pn.markx @@ -10286,6 +10321,7 @@ local function inject_marks(marks,nofmarks) setfield(n,"yoffset",oy) else end + end end end end @@ -10296,14 +10332,14 @@ local function inject_cursives(glyphs,nofglyphs) local n=glyphs[i] local pn=rawget(properties,n) if pn then - pn=pn.injections + pn=rawget(pn,"injections") end if pn then local cursivex=pn.cursivex if cursivex then if cursiveanchor then if cursivex~=0 then - pn.leftkern=pn.leftkern or 0+cursivex + pn.leftkern=(pn.leftkern or 0)+cursivex end if lastanchor then if maxc==0 then @@ -10367,16 +10403,16 @@ local function inject_kerns(head,glyphs,nofglyphs) local n=glyphs[i] local pn=rawget(properties,n) if pn then - pn=pn.injections - end - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then - insert_node_before(head,n,newkern(leftkern)) - end - local rightkern=pn.rightkern - if rightkern and rightkern~=0 then - insert_node_after(head,n,newkern(rightkern)) + local i=rawget(pn,"injections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + insert_node_before(head,n,newkern(leftkern)) + end + local rightkern=i.rightkern + if rightkern and rightkern~=0 then + insert_node_after(head,n,newkern(rightkern)) + end end end end @@ -10384,7 +10420,7 @@ end local function inject_everything(head,where) head=tonut(head) if trace_injections then - trace(head) + trace(head,"everything") end local glyphs,nofglyphs,marks,nofmarks if nofregisteredpairs>0 then @@ -10396,7 +10432,7 @@ local function inject_everything(head,where) if nofregisteredcursives>0 then inject_cursives(glyphs,nofglyphs) end - if nofregisteredmarks>0 then + if nofregisteredmarks>0 then inject_marks(marks,nofmarks) end inject_kerns(head,glyphs,nofglyphs) @@ -10414,7 +10450,7 @@ end local function inject_kerns_only(head,where) head=tonut(head) if trace_injections then - trace(head) + trace(head,"kerns") end local n=head local p=nil @@ -10427,10 +10463,10 @@ local function inject_kerns_only(head,where) if p then local d=getfield(p,"post") if d then - local pn=pn.postinjections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"postinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then local t=find_tail(d) insert_node_after(d,t,newkern(leftkern)) end @@ -10438,28 +10474,28 @@ local function inject_kerns_only(head,where) end local d=getfield(p,"replace") if d then - local pn=pn.replaceinjections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"replaceinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then local t=find_tail(d) insert_node_after(d,t,newkern(leftkern)) end end else - local pn=pn.injections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"injections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then setfield(p,"replace",newkern(leftkern)) end end end else - local pn=pn.injections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"injections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then head=insert_node_before(head,n,newkern(leftkern)) end end @@ -10477,12 +10513,12 @@ local function inject_kerns_only(head,where) if getsubtype(n)<256 then local pn=rawget(properties,n) if pn then - pn=pn.preinjections - end - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) + local i=rawget(pn,"preinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -10500,12 +10536,12 @@ local function inject_kerns_only(head,where) if getsubtype(n)<256 then local pn=rawget(properties,n) if pn then - pn=pn.postinjections - end - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) + local i=rawget(pn,"postinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -10523,12 +10559,12 @@ local function inject_kerns_only(head,where) if getsubtype(n)<256 then local pn=rawget(properties,n) if pn then - pn=pn.replaceinjections - end - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) + local i=rawget(pn,"replaceinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end end end else @@ -10555,7 +10591,7 @@ end local function inject_pairs_only(head,where) head=tonut(head) if trace_injections then - trace(head) + trace(head,"pairs") end local n=head local p=nil @@ -10568,10 +10604,10 @@ local function inject_pairs_only(head,where) if p then local d=getfield(p,"post") if d then - local pn=pn.postinjections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"postinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then local t=find_tail(d) insert_node_after(d,t,newkern(leftkern)) end @@ -10579,35 +10615,35 @@ local function inject_pairs_only(head,where) end local d=getfield(p,"replace") if d then - local pn=pn.replaceinjections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"replaceinjections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then local t=find_tail(d) insert_node_after(d,t,newkern(leftkern)) end end else - local pn=pn.injections - if pn then - local leftkern=pn.leftkern - if leftkern~=0 then + local i=rawget(pn,"injections") + if i then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then setfield(p,"replace",newkern(leftkern)) end end end else - local pn=pn.injections - if pn then - local yoffset=pn.yoffset + local i=rawget(pn,"injections") + if i then + local yoffset=i.yoffset if yoffset and yoffset~=0 then setfield(n,"yoffset",yoffset) end - local leftkern=pn.leftkern - if leftkern~=0 then + local leftkern=i.leftkern + if leftkern and leftkern~=0 then insert_node_before(head,n,newkern(leftkern)) end - local rightkern=pn.rightkern + local rightkern=i.rightkern if rightkern and rightkern~=0 then insert_node_after(head,n,newkern(rightkern)) n=getnext(n) @@ -10625,23 +10661,23 @@ local function inject_pairs_only(head,where) local h=d for n in traverse_id(glyph_code,d) do if getsubtype(n)<256 then - local pn=rawget(properties,n) - if pn then - pn=pn.preinjections - end - if pn then - local yoffset=pn.yoffset - if yoffset and yoffset~=0 then - setfield(n,"yoffset",yoffset) - end - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) - end - local rightkern=pn.rightkern - if rightkern and rightkern~=0 then - insert_node_after(head,n,newkern(rightkern)) - n=getnext(n) + local p=rawget(properties,n) + if p then + local i=rawget(p,"preinjections") + if i then + local yoffset=i.yoffset + if yoffset and yoffset~=0 then + setfield(n,"yoffset",yoffset) + end + local leftkern=i.leftkern + if leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end + local rightkern=i.rightkern + if rightkern and rightkern~=0 then + insert_node_after(head,n,newkern(rightkern)) + n=getnext(n) + end end end else @@ -10657,23 +10693,23 @@ local function inject_pairs_only(head,where) local h=d for n in traverse_id(glyph_code,d) do if getsubtype(n)<256 then - local pn=rawget(properties,n) - if pn then - pn=pn.postinjections - end - if pn then - local yoffset=pn.yoffset - if yoffset and yoffset~=0 then - setfield(n,"yoffset",yoffset) - end - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) - end - local rightkern=pn.rightkern - if rightkern and rightkern~=0 then - insert_node_after(head,n,newkern(rightkern)) - n=getnext(n) + local p=rawget(properties,n) + if p then + local i=rawget(p,"postinjections") + if i then + local yoffset=i.yoffset + if yoffset and yoffset~=0 then + setfield(n,"yoffset",yoffset) + end + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end + local rightkern=i.rightkern + if rightkern and rightkern~=0 then + insert_node_after(head,n,newkern(rightkern)) + n=getnext(n) + end end end else @@ -10689,23 +10725,23 @@ local function inject_pairs_only(head,where) local h=d for n in traverse_id(glyph_code,d) do if getsubtype(n)<256 then - local pn=rawget(properties,n) - if pn then - pn=pn.replaceinjections - end - if pn then - local yoffset=pn.yoffset - if yoffset and yoffset~=0 then - setfield(n,"yoffset",yoffset) - end - local leftkern=pn.leftkern - if leftkern~=0 then - h=insert_node_before(h,n,newkern(leftkern)) - end - local rightkern=pn.rightkern - if rightkern and rightkern~=0 then - insert_node_after(head,n,newkern(rightkern)) - n=getnext(n) + local p=rawget(properties,n) + if p then + local i=rawget(pn,"replaceinjections") + if i then + local yoffset=i.yoffset + if yoffset and yoffset~=0 then + setfield(n,"yoffset",yoffset) + end + local leftkern=i.leftkern + if leftkern and leftkern~=0 then + h=insert_node_before(h,n,newkern(leftkern)) + end + local rightkern=i.rightkern + if rightkern and rightkern~=0 then + insert_node_after(head,n,newkern(rightkern)) + n=getnext(n) + end end end else @@ -11217,6 +11253,7 @@ local setcursive=injections.setcursive local setkern=injections.setkern local setpair=injections.setpair local resetinjection=injections.reset +local copyinjection=injections.copy local setligaindex=injections.setligaindex local getligaindex=injections.getligaindex local cursonce=true @@ -11299,10 +11336,13 @@ local function copy_glyph(g) if components then setfield(g,"components",nil) local n=copy_node(g) + copyinjection(n,g) setfield(g,"components",components) return n else - return copy_node(g) + local n=copy_node(g) + copyinjection(n,g) + return n end end local function markstoligature(kind,lookupname,head,start,stop,char) @@ -15087,13 +15127,14 @@ function nodes.handlers.nodepass(head) if basepass and #basefonts>0 then for i=1,#basefonts do local range=basefonts[i] - local start,stop=range[1],range[2] + local start=range[1] + local stop=range[2] if stop then - ligaturing(start,stop) - kerning(start,stop) - else - ligaturing(start) - kerning(start) + start,stop=ligaturing(start,stop) + start,stop=kerning(start,stop) + elseif start then + start=ligaturing(start) + start=kerning(start) end end end diff --git a/tex/generic/context/luatex/luatex-fonts-otn.lua b/tex/generic/context/luatex/luatex-fonts-otn.lua index 32dc820d3..3f53078cc 100644 --- a/tex/generic/context/luatex/luatex-fonts-otn.lua +++ b/tex/generic/context/luatex/luatex-fonts-otn.lua @@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['font-otn'] = { license = "see context related readme files", } +-- todo: looks like we have a leak somewhere (probably in ligatures) +-- todo: copy attributes to disc + -- this is a context version which can contain experimental code, but when we -- have serious patches we also need to change the other two font-otn files @@ -243,6 +246,7 @@ local setcursive = injections.setcursive local setkern = injections.setkern local setpair = injections.setpair local resetinjection = injections.reset +local copyinjection = injections.copy local setligaindex = injections.setligaindex local getligaindex = injections.getligaindex @@ -354,13 +358,19 @@ local function copy_glyph(g) -- next and prev are untouched ! if components then setfield(g,"components",nil) local n = copy_node(g) + copyinjection(n,g) -- we need to preserve the lig indices setfield(g,"components",components) return n else - return copy_node(g) + local n = copy_node(g) + copyinjection(n,g) -- we need to preserve the lig indices + return n end end +-- + + -- start is a mark and we need to keep that one local function markstoligature(kind,lookupname,head,start,stop,char) -- cgit v1.2.3