From eeb6935cd762417068287ca41920469a329dfe2a Mon Sep 17 00:00:00 2001 From: Context Git Mirror Bot Date: Tue, 4 Nov 2014 01:15:04 +0100 Subject: 2014-11-04 00:47:00 --- tex/context/base/back-exp.lua | 7 +- tex/context/base/bibl-bib.mkiv | 2 +- tex/context/base/bibl-tra.mkiv | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4381 -> 4383 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/font-ctx.lua | 8 +- tex/context/base/font-ott.lua | 2 +- tex/context/base/meta-ini.mkiv | 33 +- tex/context/base/publ-imp-apa.lua | 71 +- tex/context/base/publ-imp-apa.mkvi | 746 ++------------------- tex/context/base/publ-imp-author.mkvi | 6 +- tex/context/base/publ-ini.lua | 7 +- tex/context/base/publ-ini.mkiv | 118 ++-- tex/context/base/status-files.pdf | Bin 24692 -> 24710 bytes tex/context/base/status-lua.pdf | Bin 333913 -> 333931 bytes tex/context/base/strc-bkm.lua | 8 +- tex/context/base/strc-blk.lua | 20 +- tex/context/base/strc-lst.lua | 633 +++++++++++------ tex/context/base/strc-lst.mkvi | 16 +- tex/context/base/strc-reg.lua | 1 + tex/context/base/util-prs.lua | 24 +- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 23 files changed, 669 insertions(+), 1041 deletions(-) (limited to 'tex') diff --git a/tex/context/base/back-exp.lua b/tex/context/base/back-exp.lua index 76b95e388..0873e46b2 100644 --- a/tex/context/base/back-exp.lua +++ b/tex/context/base/back-exp.lua @@ -483,7 +483,7 @@ local function makebreaklist(list) t[i] = l[i] end end - t[#t+1] = "break>" .. nofbreaks -- maybe no number + t[#t+1] = "break>" .. nofbreaks -- maybe no number or 0 return { taglist = t } end @@ -1026,7 +1026,8 @@ do element = "mtext", data = { content = "" }, nature = "inline", - comment = "dummy nucleus" + comment = "dummy nucleus", + fulltag = "mtext>0" } local function accentchar(d) @@ -1804,7 +1805,7 @@ do local function begintag(result,element,nature,di,skip) local index = di.n local fulltag = di.fulltag - local specification = specifications[fulltag] + local specification = specifications[fulltag] or { } -- we can have a dummy local comment = di.comment local detail = specification.detail if skip == "comment" then diff --git a/tex/context/base/bibl-bib.mkiv b/tex/context/base/bibl-bib.mkiv index d9010294d..9af409158 100644 --- a/tex/context/base/bibl-bib.mkiv +++ b/tex/context/base/bibl-bib.mkiv @@ -628,7 +628,7 @@ \strc_lists_place_current {\currentbibtexsession} {\currentbibtexcriterium} - {\namedlistparameter\currentbibtexsession\c!number}% + {}% {\namedlistparameter\currentbibtexsession\c!extras}% {\namedlistparameter\currentbibtexsession\c!order}% \ctxlua{bibtex.hacks.flush("\bibtexpublicationsparameter\c!sorttype")}% diff --git a/tex/context/base/bibl-tra.mkiv b/tex/context/base/bibl-tra.mkiv index 06af7e11d..092d21ca7 100644 --- a/tex/context/base/bibl-tra.mkiv +++ b/tex/context/base/bibl-tra.mkiv @@ -765,7 +765,7 @@ \strc_lists_place_current {pubs}% {\listparameter\c!criterium}% - {\listparameter\c!number}% + {}% {\listparameter\c!extras}% {\listparameter\c!order}}% \ctxlua{bibtex.hacks.flush("\@@pbsorttype")}% diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index bbf30e64a..d9ffe0bbd 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2014.11.02 17:27} +\newcontextversion{2014.11.04 00:45} %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 8b4897abc..6b9e4cdb6 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 3e42a97e7..da312231f 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2014.11.02 17:27} +\edef\contextversion{2014.11.04 00:45} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index b49c16489..ac0de42ec 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -907,11 +907,11 @@ local separator = S(";,") local equal = P("=") local spaces = space^0 local sometext = C((1-equal-space-separator)^1) -local truevalue = P("+") * spaces * sometext * Cc(true) -- "yes" -local falsevalue = P("-") * spaces * sometext * Cc(false) -- "no" +local truevalue = P("+") * spaces * sometext * Cc(true) +local falsevalue = P("-") * spaces * sometext * Cc(false) +local somevalue = sometext * spaces * Cc(true) local keyvalue = sometext * spaces * equal * spaces * sometext -local somevalue = sometext * spaces * Cc(true) -- "yes" -local pattern = Cf(Ct("") * (space + separator + Cg(keyvalue + falsevalue + truevalue + somevalue))^0, rawset) +local pattern = Cf(Ct("") * (space + separator + Cg(falsevalue + truevalue + keyvalue + somevalue))^0, rawset) local function colonized(specification) specification.features.normal = normalize_features(lpegmatch(pattern,specification.detail)) diff --git a/tex/context/base/font-ott.lua b/tex/context/base/font-ott.lua index 348672491..1f9a1ac04 100644 --- a/tex/context/base/font-ott.lua +++ b/tex/context/base/font-ott.lua @@ -869,7 +869,7 @@ function otf.features.normalize(features) uv = b end else - uv = v + uv = value end if not rawget(features,k) then k = rawget(verbosefeatures,k) or k diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index de5def983..b6eab747d 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -217,15 +217,21 @@ \def\currentMPinstance {\defaultMPinstance} \def\currentMPformat {\currentMPinstance} -\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] -\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] -\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] -\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] -\defineMPinstance[decimalfun][\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] -\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] -\defineMPinstance[metapost] [\s!format=mpost] -\defineMPinstance[megapost] [\s!format=mpost,\c!method=\s!decimal] -\defineMPinstance[nofun] [\s!format=mpost] +\defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[extrafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[doublefun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!double] +\defineMPinstance[binaryfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!binary] +\defineMPinstance[decimalfun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes,\c!method=\s!decimal] + +\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] + +\defineMPinstance[metapost] [\s!format=mpost] +\defineMPinstance[nofun] [\s!format=mpost] +\defineMPinstance[doublepost] [\s!format=mpost,\c!method=\s!double] +\defineMPinstance[binarypost] [\s!format=mpost,\c!method=\s!binary] +\defineMPinstance[decimalpost][\s!format=mpost,\c!method=\s!decimal] + +%defineMPinstance[megapost] [\s!format=mpost,\c!method=\s!decimal] \newconditional\c_meta_include_initializations @@ -1226,8 +1232,13 @@ \startMPdefinitions {metapost} if unknown context_bare : input mp-bare.mpiv ; fi ; \stopMPdefinitions - -\startMPdefinitions {megapost} +\startMPdefinitions {binarypost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions +\startMPdefinitions {decimalpost} + if unknown context_bare : input mp-bare.mpiv ; fi ; +\stopMPdefinitions +\startMPdefinitions {doublepost} if unknown context_bare : input mp-bare.mpiv ; fi ; \stopMPdefinitions diff --git a/tex/context/base/publ-imp-apa.lua b/tex/context/base/publ-imp-apa.lua index 6d2bfdea4..821c09607 100644 --- a/tex/context/base/publ-imp-apa.lua +++ b/tex/context/base/publ-imp-apa.lua @@ -1,7 +1,6 @@ -- to be checked local virtual = { "authoryear", "authoryears", "authornum", "num", "suffix" } -local authors = { "author", "editor", "publisher" } return { name = "apa", @@ -14,50 +13,50 @@ return { required = { { "author", "editor" }, "title" }, optional = { "year", "type", "journal", "volume", "number", "pages", "url", "note", "doi" }, virtual = virtual, - author = authors, + author = { "author", "editor" }, }, magazine = { required = { { "author", "editor" }, "title", "journal", "year" }, optional = { "volume", "number", "pages", "month", "day", "note", "url", "doi" }, virtual = virtual, - author = authors, + author = { "author", "editor" }, }, newspaper = { required = { { "author", "editor" }, "title", "journal", "year" }, optional = { "volume", "number", "pages", "month", "day", "note", "url", "doi" }, virtual = virtual, - author = authors, + author = { "author", "editor" }, }, book = { virtual = { "authoryear" }, required = { { "author", "editor", "publisher" }, "title" }, optional = { "year", "month", "day", "title", "type", "edition", "series", "volume", "number", "pages", "address", "publisher", "url", "note", "ISBN" }, virtual = virtual, - author = authors, + author = { "author", "editor", "publisher" }, }, booklet = { required = { "title" }, optional = { "author", "howpublished", "address", "month", "year", "note" }, virtual = virtual, - author = authors, + author = { "author" }, }, inbook = { - required = { { "author", "editor", "publisher" }, "title", "chapter", "pages","year" }, + required = { { "author", "editor", "publisher" }, "title", "chapter", "pages", "year" }, optional = { "volume", "number", "series", "type", "address", "edition", "month", "note", "ISBN" }, virtual = virtual, - author = authors, + author = { "author", "editor", "publisher" }, }, incollection = { required = { "author", "title", "booktitle", "publisher", "year" }, optional = { "editor", "volume", "number", "series", "type", "chapter", "pages", "address", "edition", "month", "note", "ISBN" }, virtual = virtual, - author = authors, + author = { "author", "editor", "publisher" }, }, inproceedings = { required = { "author", "title", "booktitle", "year" }, optional = { "editor", "volume", "number", "series", "pages", "address", "month", "organization", "publisher", "note", "ISBN" }, virtual = virtual, - author = authors, + author = { "author", "editor", "publisher" }, }, conference = "inproceedings", -- Alan: does this work? Hans: I just made it work. @@ -65,19 +64,31 @@ return { required = { "title" }, optional = { "author", "organization", "address", "edition", "month", "year", "note" }, virtual = virtual, - author = authors, + author = { "author" }, }, mastersthesis = { required = { "author", "title", "school", "year" }, optional = { "type", "address", "month", "note" }, virtual = virtual, - author = authors, + author = { "author" }, + }, + phdthesis = { + required = { "author", "title", "school", "year" }, + optional = { "type", "address", "month", "note" }, + virtual = virtual, + author = { "author" }, + }, + thesis = { + required = { "author", "title", "school", "year", "type" }, + optional = { "address", "month", "note" }, + virtual = virtual, + author = { "author" }, }, misc = { required = { }, optional = { "author", "title", "howpublished", "month", "year", "note" }, virtual = virtual, - author = authors, + author = { "author" }, }, -- Not sure yet how "periodical" is used... but "jabref" includes it as standard. -- strangely, "jabref" does not include "author" as required nor optional.. @@ -85,36 +96,50 @@ return { required = { "title", "year" }, optional = { "author", "editor", "month", "note", "number", "organization", "series", "volume" }, virtual = virtual, - author = authors, - }, - phdthesis = { - required = { "author", "title", "school", "year" }, - optional = { "type", "address", "month", "note" }, - virtual = virtual, + author = { "author", "editor" }, }, proceedings = { required = { "title", "year" }, optional = { "editor", "volume", "number", "series", "address", "month", "organization", "publisher", "note", "pages", "ISBN" }, virtual = virtual, - author = authors, + author = { "editor", "publisher" }, }, techreport = { required = { "author", "title", "institution", "year" }, optional = { "type", "number", "address", "month", "note" }, virtual = virtual, - author = authors, + author = { "author" }, + }, + other = { + required = { { "author", "title" }, "year" }, + optional = { "note", "doi" }, + virtual = virtual, + author = { "author" }, }, patent = { required = { "nationality", "number", "year", "yearfiled" }, optional = { "author", "title", "language", "assignee", "address", "type", "day", "dayfiled", "month", "monthfiled", "note", }, virtual = virtual, - author = authors, + author = { "author" }, + }, + electronic = { + required = { "title" }, + optional = { "address", "author", "howpublished", "month", "note", "organization", "year", "url", "doi", "type" }, + virtual = virtual, + author = { "author" }, + }, + -- check this! + standard = { + required = { { "author", "institution", "organization" }, "title", "year", "note", "url" }, + optional = { "doi", }, + virtual = virtual, + author = { "author", "institution", "organization" }, }, unpublished = { required = { "author", "title", "note" }, optional = { "month", "year" }, virtual = virtual, - author = authors, + author = { "author" }, }, literal = { required = { "key", "text", }, diff --git a/tex/context/base/publ-imp-apa.mkvi b/tex/context/base/publ-imp-apa.mkvi index d3f6dda73..27ebbfa29 100644 --- a/tex/context/base/publ-imp-apa.mkvi +++ b/tex/context/base/publ-imp-apa.mkvi @@ -40,13 +40,14 @@ % does not work here: \setupbtxcitevariant [alternative=authoryear,sorttype=authoryear] -\setupbtxlistvariant - [lastnamesep={\nobreakspace\textampersand\space}, - finalnamesep={\nobreakspace\textampersand\space}] - -\setupbtxlistvariant - [author] - [author=invertedshort] +% moved to publ-ini.mkiv for now... +%\setupbtxlistvariant +% [lastnamesep={\nobreakspace\textampersand\space}, +% finalnamesep={\nobreakspace\textampersand\space}] +% +%\setupbtxlistvariant +% [author] +% [author=invertedshort] % Should the following be loaded by default? @@ -189,51 +190,23 @@ apa:Retrieved={Accessible online}, apa:others={et al.}] -%D The variables control the shared code for which we use a tex definition with -%D one argument, specifying the field name. - -%\setvariables -% [btx:apa:publisher] -% [left=\btxspace, -% right=\btxperiod] -% -%\setvariables -% [btx:apa:organization] -% [left=\btxspace, -% right=\btxperiod] -% -%\setvariables -% [btx:apa:school] -% [left=\btxcomma, -% right=\btxperiod, -% otherwise=\btxperiod] -% -%\setvariables -% [btx:apa:institution] -% [left=\btxcomma, -% right=\btxperiod, -% otherwise=\btxperiod] +%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. % First some helpers: -% If month (and day) are present, they will (optionally) be used. - -\starttexdefinition btx:apa:suffixedyear #date +\starttexdefinition btx:apa:suffixeddate \btxleftparenthesis \btxdoifelse {year} { \btxflush{year} - \btxdoif {suffix} { - \btxflush{suffix} - } - \doif {#date} {date} { - \btxdoif {month} { - \btxcomma - % language issue here? - \btxflush{month} - \btxdoif {day} { - \btxspace - \btxflush{day} - } + \btxflush{suffix} + \btxdoif {month} { + \btxcomma + % language issue here (monthconversion)? + \btxflush{month} + \btxdoif {day} { + \btxspace + \btxflush{day} } } } { @@ -246,15 +219,16 @@ \btxrightparenthesisperiod \stoptexdefinition -\starttexdefinition btx:apa:title-subtitle-including- #type +\starttexdefinition btx:apa:title-subtitle-type \btxdoif {title} { \setmode{btx:apa:title-placed} \btxflush{Word -> title} + % subtitle is not bibtex and currently is ignored. \btxdoif {subtitle} { \btxcolon \btxflush{Word -> subtitle} } - \doifelse {#type} {type} { + \doifnotmode {btx:apa:thesis} { \btxdoifelse{type} { \btxleftbracket \btxflush{Word -> type} @@ -268,11 +242,11 @@ } \stoptexdefinition -\starttexdefinition btx:apa:author-or-title-including- #type +\starttexdefinition btx:apa:author-or-title \btxdoifelse {author} { \btxflushauthor[invertedshort]{author} } { - \texdefinition{btx:apa:title-subtitle-including-}{#type} + \texdefinition{btx:apa:title-subtitle-type} } \stoptexdefinition @@ -299,9 +273,7 @@ \btxflush{#publisher} } { \doif {#title} {title} { - \texdefinition{btx:apa:title-subtitle-including-} - \doifelse {#publisher} {institution}%->techreport - {type} {} + \texdefinition{btx:apa:title-subtitle-type} } } } @@ -317,7 +289,7 @@ \btxflush{organization} } { \doif {#title} {title} { - \texdefinition{btx:apa:title-subtitle-including-}{type} + \texdefinition{btx:apa:title-subtitle-type} } } } @@ -330,11 +302,11 @@ \doifelse {#it} {it} { \begingroup \it - \texdefinition{btx:apa:title-subtitle-including-}{#type} + \texdefinition{btx:apa:title-subtitle-type} \italiccorrection \endgroup } { - \texdefinition{btx:apa:title-subtitle-including-}{#type} + \texdefinition{btx:apa:title-subtitle-type} } } } @@ -667,12 +639,13 @@ % Then by category % An article from a journal -% Required fields: author or title, journal, (year). +% 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 - \texdefinition{btx:apa:author-or-title-including-}{type} - \texdefinition{btx:apa:suffixedyear}{} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:journal-volume-number-pages}{} \texdefinition{btx:apa:url-note-doi} @@ -683,8 +656,8 @@ % Optional fields: volume, number, pages, type, month, day, doi, url, note. \startsetups btx:apa:magazine - \texdefinition{btx:apa:author-or-title-including-}{type} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:journal-volume-number-pages}{} \texdefinition{btx:apa:url-note-doi} @@ -695,8 +668,8 @@ % Optional fields: volume, number, pages, type, month, day, doi, url, note. \startsetups btx:apa:newspaper - \texdefinition{btx:apa:author-or-title-including-}{type} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:journal-volume-number-pages}{pp} \texdefinition{btx:apa:url-note-doi} @@ -711,7 +684,7 @@ \startsetups btx:apa:book \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{publisher} - \texdefinition{btx:apa:suffixedyear}{} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \texdefinition{btx:apa:edition-volume-number-pages}{edition} \texdefinition{btx:apa:wherefrom-publisher-author-is-}{author} @@ -727,7 +700,7 @@ \startsetups btx:apa:inbook \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{}{publisher} - \texdefinition{btx:apa:suffixedyear}{} + \texdefinition{btx:apa:suffixeddate} \btxdoif {chapter} { \btxflush{Word -> chapter} \btxspace @@ -747,7 +720,7 @@ \startsetups btx:apa:incollection \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{publisher} - \texdefinition{btx:apa:suffixedyear}{} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:editor}{booktitle} \texdefinition{btx:apa:edition-volume-number-pages}{edition} @@ -762,7 +735,7 @@ \startsetups btx:apa:proceedings \texdefinition{btx:apa:editor-or-organization}{title} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:edition-volume-number-pages}{edition} \btxdoifelse {editor} { @@ -785,7 +758,7 @@ \startsetups btx:apa:inproceedings \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{publisher} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{} \texdefinition{btx:apa:editor}{booktitle} \texdefinition{btx:apa:edition-volume-number-pages}{edition} @@ -807,9 +780,10 @@ % Optional fields: type, address, month, note. \startsetups btx:apa:thesis + \setmode{btx:apa:thesis} % unlikely not to have author! - \texdefinition{btx:apa:author-or-title-including-}{} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \btxleftparenthesis \btxdoifelse {type} { @@ -817,23 +791,24 @@ } { \btxlabeltext{apa:\currentbtxcategory} } - \btxrightparenthesisperiod + \btxrightparenthesis \btxdoif {school} { + \btxperiod \btxflush{school} - \btxdoif {address} { + } + \btxdoif {address} { + \btxdoifelse {school} { \btxcomma } { \btxperiod } - } - \btxdoif {address} { \btxflush{address} \btxdoif {country} { \btxcomma \btxflush{country} } - \btxperiod } + \btxperiod \texdefinition{btx:apa:url-note-doi} \stopsetups @@ -850,8 +825,8 @@ % Optional fields: author, howpublished, address, month, year, note. \startsetups btx:apa:booklet - \texdefinition{btx:apa:author-or-title-including-}{} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \texdefinition{btx:apa:wherefrom-publisher-author-is-}{howpublished} \texdefinition{btx:apa:url-note-doi} @@ -863,7 +838,7 @@ \startsetups btx:apa:manual \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{organization} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \texdefinition{btx:apa:edition-volume-number-pages}{edition} \texdefinition{btx:apa:wherefrom-publisher-author-is-}{organization} @@ -876,7 +851,7 @@ \startsetups btx:apa:techreport \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{institution} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{}{it} \texdefinition{btx:apa:edition-volume-number-pages}{type} \texdefinition{btx:apa:wherefrom-publisher-author-is-}{institution} @@ -888,8 +863,8 @@ % Optional fields: month, year. \startsetups btx:apa:unpublished - \texdefinition{btx:apa:author-or-title-including-}{} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{}{it} \texdefinition{btx:apa:url-note-doi} \stopsetups @@ -903,7 +878,7 @@ \startsetups btx:apa:patent \texdefinition{btx:apa:author-or-editor-or-publisher-or-}{title}{assignee} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \begingroup \it @@ -962,8 +937,8 @@ % Like Misc below but includes organization. \startsetups btx:apa:electronic - \texdefinition{btx:apa:author-or-title-including-}{type} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{type}{it} \btxdoif {organization} { \btxspace @@ -983,8 +958,8 @@ % Optional fields: note, doi, url \startsetups btx:apa:other - \texdefinition{btx:apa:author-or-title-including-}{} - \texdefinition{btx:apa:suffixedyear}{} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{}{it} \texdefinition{btx:apa:url-note-doi} \stopsetups @@ -994,8 +969,8 @@ % Optional fields: author, title, howpublished, month, year, note. \startsetups btx:apa:misc - \texdefinition{btx:apa:author-or-title-including-}{} - \texdefinition{btx:apa:suffixedyear}{date} + \texdefinition{btx:apa:author-or-title} + \texdefinition{btx:apa:suffixeddate} \texdefinition{btx:apa:title-if-not-placed-including-}{}{it} \btxdoif {howpublished} { \btxspace @@ -1024,598 +999,3 @@ \stopsetups \stopbtxrenderingdefinitions - - -%\starttexdefinition btx:apa:wherefrom #field -% \btxdoifelse {address} { -% \btxspace -% \btxflush{address} -% \btxdoif {country} { -% \btxcomma -% \btxflush{country} -% } -% \btxdoif {#field} { -% \btxcolon -% \texdefinition{btx:apa:author-editor-other}{#field} -% } -% \btxperiod -% } { -% \btxdoifelse {country} { -% \btxspace -% \btxflush{country} -% \btxdoif {#field} { -% \btxcolon -% \texdefinition{btx:apa:author-editor-other}{#field} -% } -% \btxperiod -% } { -% \btxdoifelse {#field} { -% \getvariable{btx:apa:#field}{left} -% \texdefinition{btx:apa:author-editor-other}{#field} -% \getvariable{btx:apa:#field}{right} -% } { -% % check that this is needed! -% \getvariable{btx:apa:#field}{otherwise} -% } -% } -% } -%\stoptexdefinition -% -%\starttexdefinition btx:apa:title-and-series -% \btxdoif {title} { -% \btxspace -% \btxflush{Word -> title} -% \btxdoif {series} { -% \btxleftparenthesis -% \btxflush{series} -% \btxrightparenthesis -% } -% \btxperiod -% } -%\stoptexdefinition -% -%\starttexdefinition btx:apa:title-and-series-it -% \btxdoif {title} { -% \btxspace -% \texdefinition{btx:apa:italic}{Word -> title} -% \btxdoif {series} { -% \btxleftparenthesis -% \btxflush{series} -% \btxrightparenthesis -% } -% \btxperiod -% } -%\stoptexdefinition -% -%\disablemode[btx:apa:edited-book] % hm, ugly -% -%\starttexdefinition btx:apa:author-and-year -% \btxdoif {author} { -% \btxflushauthor{author} -% } -% \texdefinition{btx:apa:suffixedyear}{} -% \btxperiod -%\stoptexdefinition -% -%\starttexdefinition btx:apa:author-or-key-and-year -% \btxdoifelse {author} { -% \btxflushauthor{author} -% } { -% \btxdoif {key} { -% \btxleftbracket -% \btxsetup{btx:format:key} -% \btxrightbracket -% } -% } -% \texdefinition{btx:apa:suffixedyear}{} -% \btxperiod -%\stoptexdefinition -% -%\starttexdefinition btx:apa:author-editors-crossref-year -% % TODO: if there is no author or editor, then use publisher... -% \btxdoifelse {author} { -% \btxflushauthor{author} -% } { -% \btxdoifelse {editor} { -% \setmode{btx:apa:edited-book} -% \btxflushauthor{editor} -% \btxcomma -% \btxsingularplural {editor} { -% \btxlabeltext{apa:Editor} -% } { -% \btxlabeltext{apa:Editors} -% } -% } { -% % weird period -% \btxdoif {crossref} { -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% \btxperiod -% } -% } -% } -% \texdefinition{btx:apa:suffixedyear}{} -% \btxperiod -%\stoptexdefinition -% -%\starttexdefinition btx:apa:editor-or-key-and-year -% \btxdoifelse {editor} { -% \setmode{btx:apa:edited-book} -% \btxflushauthor{editor} -% \btxcomma -% \btxsingularplural {editor} { -% \btxlabeltext{apa:Editor} -% } { -% \btxlabeltext{apa:Editors} -% } -% } { -% \btxdoif {key} { -% \btxleftbracket -% \btxsetup{btx:format:key} -% \btxrightbracket -% } -% } -% \texdefinition{btx:apa:suffixedyear}{} -% \btxperiod -%\stoptexdefinition -% -%\starttexdefinition btx:apa:pages -% \btxdoif {pages} { -% \btxspace -% \btxflush{pages} -% \btxperiod -% } -%\stoptexdefinition -% -%\starttexdefinition btx:apa:pages:p -% \btxdoif {pages} { -% \btxspace -% \btxoneorrange {pages} { -% \btxlabeltext{apa:p} -% } { -% \btxlabeltext{apa:pp} -% } -% \btxperiod -% \btxnbsp -% \btxflush{pages} -% \btxperiod -% } -%\stoptexdefinition -% -%\starttexdefinition btx:apa:pages:pp -% \btxdoif {pages} { -% \btxspace -% \btxflush{pages} -% \btxnbsp -% \btxlabeltext{apa:pp} -% \btxperiod -% } -%\stoptexdefinition -% -% this does not seem to comply with APA style - need to verify! -% -%\starttexdefinition btx:apa:pages:pages -% \btxdoif {pages} { -% \btxcomma -% \btxlabeltext{apa:pages} -% \btxnbsp -% \btxflush{pages} -% \btxperiod -% } -%\stoptexdefinition -% -%\starttexdefinition btx:apa:edition:sentence -% \btxdoif {edition} { -% \btxspace -% \btxflush{edition} -% \btxspace -% \btxlabeltext{apa:edition} -% \btxperiod -% } -%\stoptexdefinition -% -% check when the next is used (no period) -% -% \starttexdefinition btx:apa:edition -% \btxdoif {edition} { -% \btxspace -% \btxflush{edition} -% \btxspace -% \btxlabeltext{apa:edition} -% } -% \stoptexdefinition -% -% specific -% -%\startsetups btx:apa:book -% \texdefinition{btx:apa:author-editors-crossref-year} -% \btxdoif {title} { -% %texdefinition{btx:apa:italic}{converters.Word -> title} -% \texdefinition{btx:apa:italic}{Word -> title} -% \doifmodeelse {btx:apa:edited-book} { -% \btxdoifelse {volume} { -% \btxspace -% \btxlabeltext{apa:Number} -% \btxnbsp -% \btxflush{volume} -% \btxdoifelse {series} { -% \btxspace -% \btxlabeltext{apa:in} -% \btxnbsp -% \btxflush{series} -% \btxperiod -% } { -% \btxdoifelse {crossref} { -% \btxspace -% \btxlabeltext{apa:in} -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% } { -% \btxperiod -% } -% } -% } { -% \btxdoif {series} { -% \btxspace -% \btxflush{series} -% } -% \btxperiod -% } -% } { -% \btxdoifelse {crossref} { -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% } -% \texdefinition{btx:apa:pages:pages} -% \btxperiod -% \btxdoif {volume} { -% \btxlabeltext{apa:Volume} -% \btxnbsp -% \btxflush{volume} -% \btxspace -% \btxlabeltext{apa:of} -% \btxnbsp -% } -% } { -% \btxdoif {volume} { -% \btxcomma -% \btxlabeltext{apa:volume} -% \btxnbsp -% \btxflush{volume} -% \btxdoif {series} { -% \btxspace -% \btxlabeltext{apa:of} -% \btxnbsp -% \texdefinition{btx:apa:italic}{series} -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% } -% \texdefinition{btx:apa:pages:pages} -% } -% \btxperiod -% } -% } -% } -% \texdefinition{btx:apa:edition:sentence} -% \texdefinition{btx:apa:wherefrom}{publisher} -% \texdefinition{btx:apa:pages:pp}% twice? -% \texdefinition{btx:apa:url-note-doi} -%\stopsetups -% -%\startsetups btx:apa:inbook -% \texdefinition{btx:apa:author-editors-crossref-year} -% \btxdoifelse {title} { -% %texdefinition{btx:apa:italic}{converters.Word -> title} -% \texdefinition{btx:apa:italic}{Word -> title} -% } { -% \doifmodeelse {btx:apa:edited-book} { -% \btxdoifelse {volume} { -% \btxspace -% \btxlabeltext{apa:number} -% \btxnbsp -% \btxflush{volume} -% \btxdoifelse {series} { -% \btxspace -% \btxlabeltext{apa:in} -% \btxnbsp -% \btxflush{series} -% \btxperiod -% } { -% \btxdoifelse {crossref} { -% \btxspace -% \btxlabeltext{apa:in} -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% } { -% \btxperiod -% } -% } -% } { -% \btxdoif {series} { -% \btxspace -% \btxflush{series} -% \btxperiod -% } -% } -% } { -% \btxdoifelse {crossref} { -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% } -% \texdefinition{btx:apa:pages:pages} -% \btxdoif {volume} { -% \btxlabeltext{apa:Volume} -% \btxnbsp -% \btxflush{volume} -% \btxspace -% \btxlabeltext{apa:of} -% \btxnbsp -% } -% \btxdoif {crossref} { -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% } -% } { -% \btxdoif {volume} { -% \btxcomma -% \btxlabeltext{apa:volume} -% \btxnbsp -% \btxflush{volume} -% \btxdoif {series} { -% \btxspace -% \btxlabeltext{apa:of} -% \btxnbsp -% \texdefinition{btx:apa:italic}{series} -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% } -% \texdefinition{btx:apa:pages:pages} -% \btxperiod -% } -% } -% } -% } -% \btxspace -% \texdefinition{btx:apa:edition:sentence} -% \texdefinition{btx:apa:wherefrom}{publisher} -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:booklet -% \texdefinition{btx:apa:author-or-key-and-year} -% \texdefinition{btx:apa:title-it-and-series} -% \texdefinition{btx:apa:edition:sentence} -% \texdefinition{btx:apa:publication:sentence} -% \texdefinition{btx:apa:pages:p} -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:manual -% \texdefinition{btx:apa:author-or-key-and-year} -% \texdefinition{btx:apa:title-it-and-series} -% \texdefinition{btx:apa:edition:sentence} -% \texdefinition{btx:apa:wherefrom}{organization} -% \texdefinition{btx:apa:pages:p} -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:incollection -% \texdefinition{btx:apa:author-and-year} -% \btxdoifelse {arttitle} { -% %btxflush{converters.Word -> arttitle} -% \btxflush{Word -> arttitle} -% \btxperiod -% } { -% \btxdoif {title} { -% %btxflush{converters.Word -> title} -% \btxflush{Word -> title} -% \btxperiod -% } -% } -% \btxlabeltext{apa:In} -% \btxspace -% \btxdoifelse {booktitle} { -% \btxdoif {editor} { -% \btxflushauthor{editor} -% \btxcomma -% } -% %texdefinition{btx:apa:italic}{converters.Word -> booktitle} -% \texdefinition{btx:apa:italic}{Word -> booktitle} -% \btxdoif {series} { -% \btxdoif {volume} { -% \btxspace -% \btxlabeltext{apa:number} -% \btxspace -% \btxflush{volume} -% \btxspace -% \btxlabeltext{apa:in} -% } -% \btxspace -% \btxspace\btxflush{series} -% \btxcomma -% } -% \btxdoif {chapter} { -% \btxspace -% \btxflush{chapter} -% } -% \btxspace -% \texdefinition{btx:apa:pages:pages} -% \btxdoif {edition} { -% \btxspace -% \btxflush{edition} -% \btxspace -% \btxlabeltext{apa:edition} -% \btxspace -% } -% \texdefinition{btx:apa:wherefrom}{publisher} -% } { -% \btxdoif {crossref} { -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% } -% \btxspace -% \texdefinition{btx:apa:pages:pages} -% } -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:inproceedings -% \texdefinition{btx:apa:author-and-year} -% \btxdoif {arttitle} { -% %btxflush{converters.Word -> arttitle} -% \btxflush{Word -> arttitle} -% \btxperiod -% } -% \btxlabeltext{apa:In} -% \btxspace -% \btxdoifelse {title} { -% \btxdoif {editor} { -% \btxflush{btx:apa:format:editors} -% \btxcomma -% \btxsingularplural {editor} { -% \btxlabeltext{apa:Editor} -% } { -% \btxlabeltext{apa:Editors} -% } -% \btxcomma -% } -% %texdefinition{btx:apa:italic}{converters.Word -> title} -% \texdefinition{btx:apa:italic}{Word -> title} -% \btxdoif {series} { -% \btxdoif {volume} { -% \btxcomma -% \btxlabeltext{apa:number} -% \btxspace -% \btxflush{crossref} -% \btxflush{volume} -% \btxspace -% \btxlabeltext{apa:in} -% } -% \btxspace -% \btxflush{series} -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% \btxspace -% } -% \texdefinition{btx:apa:pages:pages} -% \btxperiod -% \texdefinition{btx:apa:wherefrom}{organization} -% } { -% \btxdoif {crossref} { -% \btxleftbracket -% \btxsetup{btx:format:crossref} -% \btxrightbracket -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% \btxspace -% } -% \texdefinition{btx:apa:pages:pages} -% \btxperiod -% } -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:proceedings -% \texdefinition{btx:apa:editor-or-key-and-year} -% \btxdoif {title} { -% %texdefinition{btx:apa:italic}{converters.Word -> title} -% \texdefinition{btx:apa:italic}{Word -> title} -% \btxdoif {volume} { -% \btxcomma -% \btxlabeltext{apa:number} -% \btxspace -% \btxflush{volume} -% \btxspace -% \btxlabeltext{apa:in} -% \btxspace -% } -% \btxdoif {chapter} { -% \btxcomma -% \btxflush{chapter} -% \btxspace -% } -% \texdefinition{btx:apa:pages:pages} -% \btxperiod -% \texdefinition{btx:apa:wherefrom}{organization} -% } -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\starttexdefinition btx:apa:thesis -% \texdefinition{btx:apa:author-and-year} -% \texdefinition{btx:apa:title-it-and-series} -% \btxdoifelse {type} { -% \btxflush{type} -% } { -% \btxlabeltext{apa:\currentbtxcategory} -% } -% \texdefinition{btx:apa:wherefrom}{school} -% \texdefinition{btx:apa:pages:p} -% \texdefinition{btx:apa:note} -%\stoptexdefinition -% -%\startsetups btx:apa:mastersthesis -% \texdefinition{btx:apa:thesis} -%\stopsetups -% -%\startsetups btx:apa:phdthesis -% \texdefinition{btx:apa:thesis} -%\stopsetups -% -%\startsetups btx:apa:techreport -% \texdefinition{btx:apa:author-and-year} -% \texdefinition{btx:apa:title-and-series} -% \btxdoifelse {type} { -% \btxflush{type} -% \btxdoif {volume} { -% \btxspace -% \btxflush{volume} -% } -% } { -% \btxspace -% \btxlabeltext{apa:technicalreport} -% } -% \btxcomma -% \texdefinition{btx:apa:wherefrom}{institution} -% \texdefinition{btx:apa:pages:p} -% \texdefinition{btx:apa:url-note-doi} -%\stopsetups -% -%\startsetups btx:apa:misc -% \texdefinition{btx:apa:author-and-year} -% \texdefinition{btx:apa:title-and-series} -% \texdefinition{btx:apa:wherefrom}{publisher} -% \texdefinition{btx:apa:pages:p} -% \texdefinition{btx:apa:note} -%\stopsetups -% -%\startsetups btx:apa:unpublished -% \texdefinition{btx:apa:author-and-year} -% \texdefinition{btx:apa:title-and-series} -% \texdefinition{btx:apa:pages:p} -% \btxdoif {type} { -% \btxleftparenthesis -% \btxflush{type} -% \btxrightparenthesis -% } -% \texdefinition{btx:apa:note} -%\stopsetups diff --git a/tex/context/base/publ-imp-author.mkvi b/tex/context/base/publ-imp-author.mkvi index 41eb6fda2..61672aedb 100644 --- a/tex/context/base/publ-imp-author.mkvi +++ b/tex/context/base/publ-imp-author.mkvi @@ -150,8 +150,10 @@ \currentbtxsurnames \ifcase\currentbtxauthorstate \else % potential clash of names so we force initials - \btxcitevariantparameter\c!surnameinitialsep - \currentbtxinitials + \ifx\currentbtxinitials\empty \else + \btxcitevariantparameter\c!surnameinitialsep + \currentbtxinitials + \fi \fi \fastsetup{\s!btx:\s!cite:\s!author:others} \stopsetups diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 5902fc36e..313d4d727 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -5,6 +5,9 @@ if not modules then modules = { } end modules ['publ-ini'] = { copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } + +-- plug the list sorted in the list mechanism (specification.sortorder) + -- todo: delay details till alternative is known so that potential author -- fields are known @@ -1151,7 +1154,7 @@ local methods = { } lists.methods = methods methods[v_dataset] = function(dataset,rendering,keyword) - -- why only once inless criterium=all? + -- why only once unless criterium=all? local luadata = datasets[dataset].luadata local list = rendering.list for tag, data in sortedhash(luadata) do @@ -1631,7 +1634,7 @@ function commands.btxhandlenocite(specification) local markentry = specification.markentry ~= false local internal = specification.internal or "" -- - local prefix, rest = lpegmatch(prefixsplitter,tag) + local prefix, rest = lpegmatch(prefixsplitter,reference) if rest then dataset = prefix reference = rest diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index 6f9a06f97..d6c34bfe2 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -699,8 +699,8 @@ \ctxcommand{btxcollectlistentries { names = "btx", criterium = "\currentbtxcriterium", + reference = "\btxrenderingparameter\c!reference", method = "\btxrenderingparameter\c!method", - number = "\btxrenderingparameter\c!number", btxdataset = "\currentbtxdataset", keyword = "\btxrenderingparameter\c!keyword", sorttype = "\btxrenderingparameter\c!sorttype", @@ -1343,32 +1343,32 @@ %\c!saveinlist=\v!no, % maybe for before/after \c!textstate=\v!start, \c!width=\v!auto, - \c!separator={; }, + \c!separator={;\space}, \c!distance=1.5\emwidth] \definebtxrendering [\v!standard] \setupbtxlistvariant - [\c!namesep={, }, + [\c!namesep={,\space}, \c!lastnamesep={,\nobreakspace\textampersand\space}, \c!finalnamesep={,\nobreakspace\textampersand\space}, - \c!firstnamesep={ }, - % \c!andtext={ \btxlabeltext{\currentbtxalternative:and} }, - \c!otherstext={ \btxlabeltext{\currentbtxalternative:others}}, - \c!juniorsep={ }, - \c!vonsep={ }, - \c!initialsep={ }, % between initials and lastname - %\c!initialssep={ }, % between multiple initials + \c!firstnamesep=\space, + % \c!andtext={\space\btxlabeltext{\currentbtxalternative:and}\space}, + \c!otherstext={\space\btxlabeltext{\currentbtxalternative:others}}, + \c!juniorsep=\space, + \c!vonsep=\space, + \c!initialsep=\space, % between initials and lastname + %\c!initialssep=\space, % between multiple initials %\c!initialsterminator={.}, - \c!surnamesep={, }, - \c!surnameinitialsep={, }, - \c!surnamefirstnamesep={, }, + \c!surnamesep={,\space}, + \c!surnameinitialsep={,\space}, + \c!surnamefirstnamesep={,\space}, \c!etallimit=5, \c!etaldisplay=\btxlistvariantparameter\c!etallimit, %c!journalconversion=\v!normal, \c!monthconversion=\v!number, - \c!authorconversion=\v!normal] + \c!authorconversion=\v!invertedshort] \definebtxlistvariant [author] @@ -1389,11 +1389,11 @@ % \c!setups=btx:cite:initialize, \c!alternative=num, % APA 2013 section 6.16 (p. 177) - \c!pubsep={, }, - \c!lastpubsep={ \btxlabeltext{\currentbtxalternative:and} }, - \c!finalpubsep={ \btxlabeltext{\currentbtxalternative:and} }, + \c!pubsep={,\space}, + \c!lastpubsep={\space\btxlabeltext{\currentbtxalternative:and}\space}, + \c!finalpubsep={\space\btxlabeltext{\currentbtxalternative:and}\space}, \c!compress=\v!no, - \c!inbetween={ }, + \c!inbetween=\space, \c!range=\endash, \c!left=, \c!middle=, @@ -1407,28 +1407,28 @@ [authornum] [author] [\c!left={(}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={)}] \definebtxcitevariant [authoryear] [\c!compress=\v!yes, - \c!inbetween={, }, + \c!inbetween={,\space}, \c!left={(}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={)}, - \c!pubsep={; }, - \c!lastpubsep={; }, - \c!finalpubsep={; }] + \c!pubsep={;\space}, + \c!lastpubsep={;\space}, + \c!finalpubsep={;\space}] \definebtxcitevariant [authoryears] [authoryear] [\c!left=, - \c!inbetween={ (}, - \c!pubsep={); }, - \c!lastpubsep={); }, - \c!finalpubsep={); }] + \c!inbetween={\space(}, + \c!pubsep={);\space}, + \c!lastpubsep={);\space}, + \c!finalpubsep={);\space}] \definebtxcitevariant [author:num] @@ -1455,20 +1455,20 @@ \definebtxcitevariant [year] [\c!left={(}, - %\c!middle={, }, - \c!pubsep={, }, - \c!lastpubsep={, }, - \c!finalpubsep={, }, + %\c!middle={,\space}, + \c!pubsep={,\space}, + \c!lastpubsep={,\space}, + \c!finalpubsep={,\space}, \c!right={)}] \definebtxcitevariant [title] - %[\c!middle={, }] + %[\c!middle={,\space}] \definebtxcitevariant [tag] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant @@ -1478,13 +1478,13 @@ \definebtxcitevariant [serial] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant [page] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant @@ -1497,13 +1497,13 @@ \definebtxcitevariant [short] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant [category] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant @@ -1513,26 +1513,26 @@ \definebtxcitevariant [doi] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant [url] [\c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}] \definebtxcitevariant [page] [\c!left=, - %\c!middle={, }, + %\c!middle={,\space}, \c!right=] \definebtxcitevariant [num] [\c!compress=\v!yes, \c!left={[}, - %\c!middle={, }, + %\c!middle={,\space}, \c!right={]}, \c!pubsep={,}, \c!lastpubsep={,}, @@ -1541,37 +1541,35 @@ % These cannot, for some reason, be folded-in above... \setupbtxcitevariant - [\c!namesep={, }, + [\c!namesep={,\space}, \c!lastnamesep={,\nobreakspace\textampersand\space}, - \c!finalnamesep={,\nobreakspace\textampersand\space}, - \c!firstnamesep={ }, - %\c!andtext={ \btxlabeltext{\currentbtxalternative:and} }, - \c!otherstext={ \btxlabeltext{\currentbtxalternative:others}}, - \c!juniorsep={ }, - \c!vonsep={ }, - \c!initialsep={ }, - %\c!initialssep={ }, % used? + \c!finalnamesep={\nobreakspace\textampersand\space}, % no comma! + \c!firstnamesep=\space, + %\c!andtext={\space\btxlabeltext{\currentbtxalternative:and}\space}, + \c!otherstext={\space\btxlabeltext{\currentbtxalternative:others}}, + \c!juniorsep=\space, + \c!vonsep=\space, + \c!initialsep=\space, + %\c!initialssep=\space, % used? %\c!initialsterminator={.}, - \c!surnamesep={, }, - \c!surnameinitialsep={, }, - \c!surnamefirstnamesep={, }, + \c!surnamesep={,\space}, + \c!surnameinitialsep={,\space}, + \c!surnamefirstnamesep={,\space}, \c!etallimit=5, % when 2-4, show all first time, etaldisplay subsequently... \c!etaldisplay=1, \c!monthconversion=\v!number, \c!authorconversion=\v!name] -% And why these here: - \setupbtxcitevariant [author] - [\c!lastnamesep={, \btxlabeltext{\currentbtxalternative:and} }, - \c!finalnamesep={, \btxlabeltext{\currentbtxalternative:and} }, + [\c!lastnamesep={,\space\btxlabeltext{\currentbtxalternative:and}\space}, + \c!finalnamesep={\space\btxlabeltext{\currentbtxalternative:and}\space}, % no comma! \c!authorconversion=\v!name] \setupbtxcitevariant [authoryears] - [\c!lastnamesep={, \btxlabeltext{\currentbtxalternative:and} }, - \c!finalnamesep={, \btxlabeltext{\currentbtxalternative:and} }, + [\c!lastnamesep={,\space\btxlabeltext{\currentbtxalternative:and}\space}, + \c!finalnamesep={\space\btxlabeltext{\currentbtxalternative:and}\space}, % no comma! \c!authorconversion=\v!name] % Do we want these in the format? Loading them delayed is somewhat messy. diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 02c569a6c..2d8f0568d 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 1da6867c2..f918ba5c4 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 848fe8b93..cfba5860e 100644 --- a/tex/context/base/strc-bkm.lua +++ b/tex/context/base/strc-bkm.lua @@ -111,9 +111,13 @@ function bookmarks.place() local nofblocks = #lists.sectionblocks -- always >= 1 local showblocktitle = toboolean(numberspec.showblocktitle,true) for i=1,nofblocks do - local block = lists.sectionblocks[i] + local block = lists.sectionblocks[i] local blockdone = nofblocks == 1 - local list = lists.filtercollected(names,block..":all",nil,lists.collected,forced) + local list = lists.filter { + names = names, + criterium = block .. ":all", + forced = forced, + } for i=1,#list do local li = list[i] local metadata = li.metadata diff --git a/tex/context/base/strc-blk.lua b/tex/context/base/strc-blk.lua index ce3304d59..837921972 100644 --- a/tex/context/base/strc-blk.lua +++ b/tex/context/base/strc-blk.lua @@ -78,13 +78,19 @@ end function blocks.select(state,name,tag,criterium) criterium = criterium or "text" - if find(tag,"=",1,true) then tag = "" end - local names = settings_to_set(name) - local all = tag == "" - local tags = not all and settings_to_set(tag) - local hide = state == "process" - local n = sections.numberatdepth(criterium) - local result = lists.filtercollected("all", criterium, n, collected, { }) + if find(tag,"=",1,true) then + tag = "" + end + local names = settings_to_set(name) + local all = tag == "" + local tags = not all and settings_to_set(tag) + local hide = state == "process" + local result = lists.filter { + names = "all", + criterium = criterium, + number = sections.numberatdepth(criterium), -- not needed + collected = collected, + } for i=1,#result do local ri = result[i] local metadata = ri.metadata diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index 570a8b126..02a7e6d29 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -15,12 +15,16 @@ if not modules then modules = { } end modules ['strc-lst'] = { -- -- move more to commands -local format, gmatch, gsub = string.format, string.gmatch, string.gsub local tonumber, type = tonumber, type -local concat, insert, remove = table.concat, table.insert, table.remove +local concat, insert, remove, sort = table.concat, table.insert, table.remove, table.sort local lpegmatch = lpeg.match -local simple_hash_to_string, settings_to_hash = utilities.parsers.simple_hash_to_string, utilities.parsers.settings_to_hash -local allocate, checked = utilities.storage.allocate, utilities.storage.checked + +local setmetatableindex = table.setmetatableindex +local sortedkeys = table.sortedkeys + +local settings_to_set = utilities.parsers.settings_to_set +local allocate = utilities.storage.allocate +local checked = utilities.storage.checked local trace_lists = false trackers.register("structures.lists", function(v) trace_lists = v end) @@ -29,14 +33,11 @@ local report_lists = logs.reporter("structure","lists") local context = context local commands = commands -local texgetcount = tex.getcount - local structures = structures local lists = structures.lists local sections = structures.sections local helpers = structures.helpers local documents = structures.documents -local pages = structures.pages local tags = structures.tags local references = structures.references @@ -59,13 +60,32 @@ lists.sectionblocks = sectionblocks references.specials = references.specials or { } -local variables = interfaces.variables local matchingtilldepth = sections.matchingtilldepth local numberatdepth = sections.numberatdepth +local getsectionlevel = sections.getlevel +local typesetnumber = sections.typesetnumber +local autosectiondepth = sections.autodepth --- -- -- -- -- -- +local variables = interfaces.variables -local function zerostrippedconcat(t,separator) -- for the moment not public +local v_all = variables.all +local v_reference = variables.reference +local v_number = variables.reference +local v_command = variables.command +local v_text = variables.text +local v_current = variables.current +local v_previous = variables.previous +local v_next = variables.next +local v_intro = variables.intro +local v_here = variables.here +local v_component = variables.component +local v_reference = variables.reference +local v_local = variables["local"] +local v_default = variables.default + +-- for the moment not public -- + +local function zerostrippedconcat(t,separator) local f, l = 1, #t for i=f,l do if t[i] == 0 then @@ -85,11 +105,11 @@ end local function initializer() -- create a cross reference between internal references -- and list entries - local collected = lists.collected - local internals = checked(references.internals) - local ordered = lists.ordered + local collected = lists.collected + local internals = checked(references.internals) + local ordered = lists.ordered local usedinternals = references.usedinternals - local blockdone = { } + local blockdone = { } for i=1,#collected do local c = collected[i] local m = c.metadata @@ -147,7 +167,7 @@ end job.register('structures.lists.collected', tobesaved, initializer, finalizer) -local groupindices = table.setmetatableindex("table") +local groupindices = setmetatableindex("table") function lists.groupindex(name,group) local groupindex = groupindices[name] @@ -221,7 +241,10 @@ end local enhanced = { } -local synchronizepage = function(r) synchronizepage = references.synchronizepage return synchronizepage(r) end -- bah ... will move +local synchronizepage = function(r) -- bah ... will move + synchronizepage = references.synchronizepage + return synchronizepage(r) +end function lists.enhance(n) local l = cached[n] @@ -269,51 +292,66 @@ end local nesting = { } function lists.pushnesting(i) - local parent = lists.result[i] - local name = parent.metadata.name + local parent = lists.result[i] + local name = parent.metadata.name local numberdata = parent and parent.numberdata - local numbers = numberdata and numberdata.numbers - local number = numbers and numbers[sections.getlevel(name)] or 0 - insert(nesting, { number = number, name = name, result = lists.result, parent = parent }) + local numbers = numberdata and numberdata.numbers + local number = numbers and numbers[getsectionlevel(name)] or 0 + insert(nesting, { + number = number, + name = name, + result = lists.result, + parent = parent + }) end function lists.popnesting() local old = remove(nesting) - lists.result = old.result + if old then + lists.result = old.result + else + report_lists("nesting error") + end end --- will be split - -- Historically we had blocks but in the mkiv approach that could as well be a level -- which would simplify things a bit. -local splitter = lpeg.splitat(":") - --- this will become filtercollected(specification) and then we'll also have sectionblock as key +local splitter = lpeg.splitat(":") -- maybe also :: or have a block parameter local sorters = { - [variables.command] = function(a,b) + [v_command] = function(a,b) if a.metadata.kind == "command" or b.metadata.kind == "command" then return a.references.internal < b.references.internal else return a.references.order < b.references.order end end, - [variables.all] = function(a,b) + [v_all] = function(a,b) return a.references.internal < b.references.internal end, } --- some day soon we will pass a table .. also split the function +-- was: names, criterium, number, collected, forced, nested, sortorder + +local filters = setmetatableindex(function(t,k) return t[v_default] end) -local function filtercollected(names, criterium, number, collected, forced, nested, sortorder) -- names is hash or string - local numbers, depth = documents.data.numbers, documents.data.depth - local result, nofresult, detail = { }, 0, nil - local block = false -- all - criterium = gsub(criterium or ""," ","") -- not needed - -- new, will be applied stepwise +local function filtercollected(specification) + -- + local names = specification.names or { } + local criterium = specification.criterium or v_default + local number = 0 -- specification.number + local reference = specification.reference or "" + local collected = specification.collected or lists.collected + local forced = specification.forced or { } + local nested = specification.nested or false + local sortorder = specification.sortorder or specification.order + -- + local numbers = documents.data.numbers + local depth = documents.data.depth + local block = false -- all local wantedblock, wantedcriterium = lpegmatch(splitter,criterium) -- block:criterium - if wantedblock == "" or wantedblock == variables.all or wantedblock == variables.text then + if wantedblock == "" or wantedblock == v_all or wantedblock == v_text then criterium = wantedcriterium ~= "" and wantedcriterium or criterium elseif not wantedcriterium then block = documents.data.block @@ -323,65 +361,86 @@ local function filtercollected(names, criterium, number, collected, forced, nest if block == "" then block = false end --- print(">>",block,criterium) - -- - forced = forced or { } -- todo: also on other branched, for the moment only needed for bookmarks if type(names) == "string" then - names = settings_to_hash(names) + names = settings_to_set(names) end - local all = not next(names) or names[variables.all] or false + local all = not next(names) or names[v_all] or false + -- + specification.names = names + specification.criterium = criterium + specification.number = 0 -- obsolete + specification.reference = reference -- new + specification.collected = collected + specification.forced = forced -- todo: also on other branched, for the moment only needed for bookmarks + specification.nested = nested + specification.sortorder = sortorder + specification.numbers = numbers + specification.depth = depth + specification.block = block + -- if trace_lists then - report_lists("filtering names %a, criterium %a, block %a, number %a",names,criterium,block or "*",number) + report_lists("filtering names %,t, criterium %a, block %a",sortedkeys(names), criterium, block or "*") end - if criterium == variables.intro then - -- special case, no structure yet - for i=1,#collected do - local v = collected[i] - local r = v.references - if r and r.section == 0 then - nofresult = nofresult + 1 - result[nofresult] = v + local result = filters[criterium](specification) + if trace_lists then + report_lists("criterium %a, block %a, found %a",specification.criterium, specification.block or "*", #result) + end + -- + if sortorder then -- experiment + local sorter = sorters[sortorder] + if sorter then + if trace_lists then + report_lists("sorting list using method %a",sortorder) end - end - elseif all or criterium == variables.all or criterium == variables.text then - for i=1,#collected do - local v = collected[i] - local r = v.references - if r and (not block or not r.block or block == r.block) then - local metadata = v.metadata - if metadata then - local name = metadata.name or false - local sectionnumber = (r.section == 0) or sections.collected[r.section] - if forced[name] or (sectionnumber and not metadata.nolist and (all or names[name])) then -- and not sectionnumber.hidenumber then - nofresult = nofresult + 1 - result[nofresult] = v - end - end + for i=1,#result do + result[i].references.order = i end + sort(result,sorter) end - elseif criterium == variables.current then - if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) - else + end + -- + return result +end + +filters[v_intro] = function(specification) + local collected = specification.collected + local result = { } + local nofresult = #result + for i=1,#collected do + local v = collected[i] + local r = v.references + if r and r.section == 0 then + nofresult = nofresult + 1 + result[nofresult] = v + end + end + return result +end + +filters[v_reference] = function(specification) + local collected = specification.collected + local result = { } + local nofresult = #result + local names = specification.names + local sections = sections.collected + local reference = specification.reference + if reference ~= "" then + local prefix, rest = lpegmatch(references.prefixsplitter,reference) -- p::r + local r = prefix and rest and references.derived[prefix][rest] or references.derived[""][reference] + local s = r and r.numberdata -- table ref ! + if s then + local depth = getsectionlevel(r.metadata.name) + local numbers = s.numbers for i=1,#collected do local v = collected[i] local r = v.references if r and (not block or not r.block or block == r.block) then - local sectionnumber = sections.collected[r.section] - if sectionnumber then -- and not sectionnumber.hidenumber then - local cnumbers = sectionnumber.numbers - local metadata = v.metadata - if cnumbers then - if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers > depth then - local ok = true - for d=1,depth do - local cnd = cnumbers[d] - if not (cnd == 0 or cnd == numbers[d]) then - ok = false - break - end - end - if ok then + local metadata = v.metadata + if metadata then + if names[metadata.name or false] then + local sectionnumber = (r.section == 0) or sections[r.section] + if sectionnumber then + if matchingtilldepth(depth,numbers,sectionnumber.numbers) then nofresult = nofresult + 1 result[nofresult] = v end @@ -390,164 +449,294 @@ local function filtercollected(names, criterium, number, collected, forced, nest end end end - end - elseif criterium == variables.here then - -- this is quite dirty ... as cnumbers is not sparse we can misuse #cnumbers - if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) else - for i=1,#collected do - local v = collected[i] - local r = v.references - if r then -- and (not block or not r.block or block == r.block) then - local sectionnumber = sections.collected[r.section] - if sectionnumber then -- and not sectionnumber.hidenumber then - local cnumbers = sectionnumber.numbers - local metadata = v.metadata - if cnumbers then - if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers >= depth then - local ok = true - for d=1,depth do - local cnd = cnumbers[d] - if not (cnd == 0 or cnd == numbers[d]) then - ok = false - break - end - end - if ok then - nofresult = nofresult + 1 - result[nofresult] = v - end - end - end - end + report_lists("unknown reference %a specified",reference) + end + else + report_lists("no reference specified") + end + return result +end + +filters[v_all] = function(specification) + local collected = specification.collected + local result = { } + local nofresult = #result + local block = specification.block + local all = specification.all + local forced = specification.forced + local names = specification.names + local sections = sections.collected + for i=1,#collected do + local v = collected[i] + local r = v.references + if r and (not block or not r.block or block == r.block) then + local metadata = v.metadata + if metadata then + local name = metadata.name or false + local sectionnumber = (r.section == 0) or sections[r.section] + if forced[name] or (sectionnumber and not metadata.nolist and (all or names[name])) then -- and not sectionnumber.hidenumber then + nofresult = nofresult + 1 + result[nofresult] = v end end end - elseif criterium == variables.previous then - if depth == 0 then - return filtercollected(names,variables.intro,number,collected,forced,false,sortorder) - else - for i=1,#collected do - local v = collected[i] - local r = v.references - if r and (not block or not r.block or block == r.block) then - local sectionnumber = sections.collected[r.section] - if sectionnumber then -- and not sectionnumber.hidenumber then - local cnumbers = sectionnumber.numbers - local metadata = v.metadata - if cnumbers then - if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers >= depth then - local ok = true - for d=1,depth-1 do - local cnd = cnumbers[d] - if not (cnd == 0 or cnd == numbers[d]) then - ok = false - break - end - end - if ok then - nofresult = nofresult + 1 - result[nofresult] = v - end + end + return result +end + +filters[v_text] = filters[v_all] + +filters[v_current] = function(specification) + if specification.depth == 0 then + specification.nested = false + specification.criterium = v_intro + return filters[v_intro](specification) + end + local collected = specification.collected + local result = { } + local nofresult = #result + local depth = specification.depth + local block = specification.block + local all = specification.all + local names = specification.names + local numbers = specification.numbers + local sections = sections.collected + for i=1,#collected do + local v = collected[i] + local r = v.references + if r and (not block or not r.block or block == r.block) then + local sectionnumber = sections[r.section] + if sectionnumber then -- and not sectionnumber.hidenumber then + local cnumbers = sectionnumber.numbers + local metadata = v.metadata + if cnumbers then + if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers > depth then + local ok = true + for d=1,depth do + local cnd = cnumbers[d] + if not (cnd == 0 or cnd == numbers[d]) then + ok = false + break end end + if ok then + nofresult = nofresult + 1 + result[nofresult] = v + end end end end end - elseif criterium == variables["local"] then -- not yet ok - local nested = nesting[#nesting] - if nested then - return filtercollected(names,nested.name,nested.number,collected,forced,nested,sortorder) - elseif sections.autodepth(documents.data.numbers) == 0 then - return filtercollected(names,variables.all,number,collected,forced,false,sortorder) - else - return filtercollected(names,variables.current,number,collected,forced,false,sortorder) - end - elseif criterium == variables.component then - -- special case, no structure yet - local component = resolvers.jobs.currentcomponent() or "" - if component ~= "" then - for i=1,#collected do - local v = collected[i] - local r = v.references - local m = v.metadata - if r and r.component == component and (m and names[m.name] or all) then - nofresult = nofresult + 1 - result[nofresult] = v + end + return result +end + +filters[v_here] = function(specification) + -- this is quite dirty ... as cnumbers is not sparse we can misuse #cnumbers + if specification.depth == 0 then + specification.nested = false + specification.criterium = v_intro + return filters[v_intro](specification) + end + local collected = specification.collected + local result = { } + local nofresult = #result + local depth = specification.depth + local block = specification.block + local all = specification.all + local names = specification.names + local numbers = specification.numbers + local sections = sections.collected + for i=1,#collected do + local v = collected[i] + local r = v.references + if r then -- and (not block or not r.block or block == r.block) then + local sectionnumber = sections[r.section] + if sectionnumber then -- and not sectionnumber.hidenumber then + local cnumbers = sectionnumber.numbers + local metadata = v.metadata + if cnumbers then + if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers >= depth then + local ok = true + for d=1,depth do + local cnd = cnumbers[d] + if not (cnd == 0 or cnd == numbers[d]) then + ok = false + break + end + end + if ok then + nofresult = nofresult + 1 + result[nofresult] = v + end + end end end end - else -- sectionname, number - -- not the same as register - local depth = sections.getlevel(criterium) - local number = tonumber(number) or numberatdepth(depth) or 0 - if trace_lists then - local t = sections.numbers() - detail = format("depth %s, number %s, numbers %s, startset %s",depth,number,(#t>0 and concat(t,".",1,depth)) or "?",#collected) - end - if number > 0 then - local pnumbers = nil - local pblock = block - local parent = nested and nested.parent - if parent then - pnumbers = parent.numberdata.numbers or pnumbers -- so local as well as nested - pblock = parent.references.block or pblock - end - for i=1,#collected do - local v = collected[i] - local r = v.references - if r and (not block or not r.block or pblock == r.block) then - local sectionnumber = sections.collected[r.section] - if sectionnumber then - local metadata = v.metadata - local cnumbers = sectionnumber.numbers - if cnumbers then - if (all or names[metadata.name or false]) and #cnumbers >= depth and matchingtilldepth(depth,cnumbers,pnumbers) then - nofresult = nofresult + 1 - result[nofresult] = v + end + return result +end + +filters[v_previous] = function(specification) + if specification.depth == 0 then + specification.nested = false + specification.criterium = v_intro + return filters[v_intro](specification) + end + local collected = specification.collected + local result = { } + local nofresult = #result + local block = specification.block + local all = specification.all + local names = specification.names + local numbers = specification.numbers + local sections = sections.collected + local depth = specification.depth + for i=1,#collected do + local v = collected[i] + local r = v.references + if r and (not block or not r.block or block == r.block) then + local sectionnumber = sections[r.section] + if sectionnumber then -- and not sectionnumber.hidenumber then + local cnumbers = sectionnumber.numbers + local metadata = v.metadata + if cnumbers then + if metadata and not metadata.nolist and (all or names[metadata.name or false]) and #cnumbers >= depth then + local ok = true + for d=1,depth-1 do + local cnd = cnumbers[d] + if not (cnd == 0 or cnd == numbers[d]) then + ok = false + break end end + if ok then + nofresult = nofresult + 1 + result[nofresult] = v + end end end end end end - if trace_lists then - report_lists("criterium %a, block %a, found %a, detail %a",criterium,block or "*",#result,detail) + return result +end + +filters[v_local] = function(specification) + local numbers = specification.numbers + local nested = nesting[#nesting] + if nested then + -- filtercollected(names,nested.name,nested.number,collected,forced,nested,sortorder) + return filtercollected { + names = specification.names, + criterium = nested.name, + reference = nested.number, + collected = specification.collected, + forced = specification.forced, + nested = nested, + sortorder = specification.sortorder, + } + elseif autosectiondepth(numbers) == 0 then + specification.nested = false + specification.criterium = v_all + return filters[v_all](specification) + else + specification.nested = false + specification.criterium = v_current + return filters[v_current](specification) end +end - if sortorder then -- experiment - local sorter = sorters[sortorder] - if sorter then - if trace_lists then - report_lists("sorting list using method %a",sortorder) - end - for i=1,#result do - result[i].references.order = i +filters[v_component] = function(specification) + -- special case, no structure yet + local collected = specification.collected + local result = { } + local nofresult = #result + local all = specification.all + local names = specification.names + local component = resolvers.jobs.currentcomponent() or "" + if component ~= "" then + for i=1,#collected do + local v = collected[i] + local r = v.references + local m = v.metadata + if r and r.component == component and (m and names[m.name] or all) then + nofresult = nofresult + 1 + result[nofresult] = v end - table.sort(result,sorter) end end - return result end -lists.filtercollected = filtercollected +-- local number = tonumber(number) or numberatdepth(depth) or 0 +-- if number > 0 then +-- ... +-- end -function lists.filter(specification) - return filtercollected( - specification.names, - specification.criterium, - specification.number, - lists.collected, - specification.forced, - false, - specification.order - ) +filters[v_default] = function(specification) -- is named + local collected = specification.collected + local result = { } + local nofresult = #result + ----- depth = specification.depth + local block = specification.block + local criterium = specification.criterium + local all = specification.all + local names = specification.names + local numbers = specification.numbers + local sections = sections.collected + local reference = specification.reference + -- + if reference then + reference = tonumber(reference) + end + -- + local depth = getsectionlevel(criterium) + local pnumbers = nil + local pblock = block + local parent = nested and nested.parent + -- + if parent then + pnumbers = parent.numberdata.numbers or pnumbers -- so local as well as nested + pblock = parent.references.block or pblock + report_lists("filtering by block %a and section %a",pblock,criterium) + end + -- + for i=1,#collected do + local v = collected[i] + local r = v.references + if r and (not block or not r.block or pblock == r.block) then + local sectionnumber = sections[r.section] + if sectionnumber then + local metadata = v.metadata + local cnumbers = sectionnumber.numbers + if cnumbers then + if all or names[metadata.name or false] then + if reference then + -- filter by number + if reference == cnumbers[depth] then + nofresult = nofresult + 1 + result[nofresult] = v + end + else + if #cnumbers >= depth and matchingtilldepth(depth,cnumbers,pnumbers) then + nofresult = nofresult + 1 + result[nofresult] = v + end + end + end + end + end + end + end + return result end +-- names, criterium, number, collected, forced, nested, sortorder) -- names is hash or string + +lists.filter = filtercollected + lists.result = { } function lists.getresult(r) @@ -555,8 +744,8 @@ function lists.getresult(r) end function lists.process(specification) - lists.result = lists.filter(specification) - local specials = utilities.parsers.settings_to_hash(specification.extras or "") + lists.result = filtercollected(specification) + local specials = settings_to_set(specification.extras or "") specials = next(specials) and specials or nil for i=1,#lists.result do local r = lists.result[i] @@ -567,7 +756,7 @@ function lists.process(specification) end function lists.analyze(specification) - lists.result = lists.filter(specification) + lists.result = filtercollected(specification) end function lists.userdata(name,r,tag) -- to tex (todo: xml) @@ -607,7 +796,7 @@ function lists.sectionnumber(name,n,spec) local data = lists.result[n] local sectiondata = sections.collected[data.references.section] -- hm, prefixnumber? - sections.typesetnumber(sectiondata,"prefix",spec,sectiondata) -- data happens to contain the spec too + typesetnumber(sectiondata,"prefix",spec,sectiondata) -- data happens to contain the spec too end -- some basics (todo: helpers for pages) @@ -684,7 +873,7 @@ function lists.number(name,n,spec) if data then local numberdata = data.numberdata if numberdata then - sections.typesetnumber(numberdata,"number",spec or false,numberdata or false) + typesetnumber(numberdata,"number",spec or false,numberdata or false) end end end @@ -695,7 +884,7 @@ function lists.prefixednumber(name,n,prefixspec,numberspec) helpers.prefix(data,prefixspec) local numberdata = data.numberdata if numberdata then - sections.typesetnumber(numberdata,"number",numberspec or false,numberdata or false) + typesetnumber(numberdata,"number",numberspec or false,numberdata or false) end end end @@ -771,7 +960,7 @@ function commands.savedlistnumber(name,n) if data then local numberdata = data.numberdata if numberdata then - sections.typesetnumber(numberdata,"number",numberdata or false) + typesetnumber(numberdata,"number",numberdata or false) end end end @@ -792,7 +981,7 @@ end -- local numberdata = data.numberdata -- if numberdata then -- helpers.prefix(data,data.prefixdata) --- sections.typesetnumber(numberdata,"number",numberdata or false) +-- typesetnumber(numberdata,"number",numberdata or false) -- end -- end -- end @@ -809,7 +998,7 @@ function commands.savedlistprefixednumber(name,n) local numberdata = lists.reordered(data) if numberdata then helpers.prefix(data,data.prefixdata) - sections.typesetnumber(numberdata,"number",numberdata or false) + typesetnumber(numberdata,"number",numberdata or false) end end end @@ -818,8 +1007,6 @@ commands.discardfromlist = lists.discard -- new and experimental and therefore off by default -local sort, setmetatableindex = table.sort, table.setmetatableindex - lists.autoreorder = false -- true local function addlevel(t,k) diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi index 3a2526315..d617721b5 100644 --- a/tex/context/base/strc-lst.mkvi +++ b/tex/context/base/strc-lst.mkvi @@ -47,7 +47,7 @@ \c!state=\v!start, \c!coupling=\v!off, \c!criterium=\v!local, - \c!number=\zerocount, + \c!reference=,% was number which was sort of obsolete \c!width=3\emwidth, %\c!maxwidth=, \c!distance=\zeropoint, @@ -244,7 +244,7 @@ \strc_lists_place_current % maybe inline {#list}% {\listparameter\c!criterium}% - {\listparameter\c!number}% + {\listparameter\c!reference}% {\listparameter\c!extras}% {\listparameter\c!order}% % \stoplistreferences @@ -288,7 +288,7 @@ {\dotripleempty\strc_lists_combined_define} \def\strc_lists_combined_define[#tag][#list][#settings]% - {\definelist[#tag][\c!criterium=\v!local,\c!number=0,\c!alternative=,\c!list={#list},#settings]% inherits from root + {\definelist[#tag][\c!criterium=\v!local,\c!reference=,\c!alternative=,\c!list={#list},#settings]% inherits from root \setvalue{\e!setup #tag\e!endsetup}{\dodoubleempty\strc_lists_combined_setup [#tag]}% \setvalue{\e!place #tag}{\dodoubleempty\strc_lists_combined_place [#tag]}% \setvalue{\e!complete #tag}{\dodoubleempty\strc_lists_combined_complete[#tag]}} @@ -401,22 +401,22 @@ % TODO: pass extra tag name (contents, figures, bibliography ...) -\unexpanded\def\strc_lists_place_current#list#criterium#number#extras#order% beware, not a user command +\unexpanded\def\strc_lists_place_current#list#criterium#reference#extras#order% beware, not a user command {\dostarttaggedchained\t!list\empty\??list \ctxcommand{processlist{ names = "#list", criterium = "#criterium", - number = "#number", + reference = "#reference", extras = "#extras", order = "#order" }}% \dostoptagged} -\unexpanded\def\strc_lists_analyze#list#criterium#number% +\unexpanded\def\strc_lists_analyze#list#criterium#reference% {\ctxcommand{analyzelist{ names = "#list", criterium = "#criterium", - number = "#number" + reference = "#reference", }}} \def\firststructureelementinlist#list% @@ -1324,7 +1324,7 @@ \let\listlength\!!zerocount \else \setupcurrentlist[#settings]% - \strc_lists_analyze{#list}{\listparameter\c!criterium}{\listparameter\c!number}% + \strc_lists_analyze{#list}{\listparameter\c!criterium}{\listparameter\c!reference}% \normalexpanded{\endgroup\noexpand\edef\noexpand\listlength{\structurelistsize}}% \fi \strc_lists_set_mode} diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua index c14198239..0d59cc321 100644 --- a/tex/context/base/strc-reg.lua +++ b/tex/context/base/strc-reg.lua @@ -300,6 +300,7 @@ local function filtercollected(names,criterium,number,collected,prevmode) end else -- sectionname, number -- beware, this works ok for registers + -- to be redone with reference instead local depth = sections.getlevel(criterium) local number = tonumber(number) or numberatdepth(depth) or 0 if trace_registers then diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index f51f6fc75..642968ccb 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -275,15 +275,25 @@ function parsers.array_to_string(a,separator) end end -function parsers.settings_to_set(str,t) -- tohash? -- todo: lpeg -- duplicate anyway - t = t or { } --- for s in gmatch(str,"%s*([^, ]+)") do -- space added - for s in gmatch(str,"[^, ]+") do -- space added - t[s] = true - end - return t +-- function parsers.settings_to_set(str,t) -- tohash? -- todo: lpeg -- duplicate anyway +-- if str then +-- t = t or { } +-- for s in gmatch(str,"[^, ]+") do -- space added +-- t[s] = true +-- end +-- return t +-- else +-- return { } +-- end +-- end + +local pattern = Cf(Ct("") * Cg(C((1-S(", "))^1) * S(", ")^0 * Cc(true))^1,rawset) + +function utilities.parsers.settings_to_set(str,t) + return str and lpegmatch(pattern,str) or { } end + function parsers.simple_hash_to_string(h, separator) local t, tn = { }, 0 for k, v in sortedhash(h) do diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 3ec20849b..e3f3f2394 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 11/02/14 17:27:40 +-- merge date : 11/04/14 00:45:31 do -- begin closure to overcome local limits and interference -- cgit v1.2.3