diff options
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4397 -> 4385 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/publ-dat.lua | 70 | ||||
-rw-r--r-- | tex/context/base/publ-imp-apa.lua | 509 | ||||
-rw-r--r-- | tex/context/base/publ-ini.lua | 46 | ||||
-rw-r--r-- | tex/context/base/publ-ini.mkiv | 17 | ||||
-rw-r--r-- | tex/context/base/publ-tra.lua | 10 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24744 -> 24700 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 333269 -> 333279 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
11 files changed, 434 insertions, 224 deletions
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index aa2bf065e..2ab225435 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.06 14:55} +\newcontextversion{2014.11.06 23:46} %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 Binary files differindex 219bb4e8a..c6ba98466 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index f4ec1ee66..52bc6f378 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.06 14:55} +\edef\contextversion{2014.11.06 23:46} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/publ-dat.lua b/tex/context/base/publ-dat.lua index b8d8b3651..b801e3b30 100644 --- a/tex/context/base/publ-dat.lua +++ b/tex/context/base/publ-dat.lua @@ -24,8 +24,8 @@ end local chardata = characters.data local lowercase = characters.lower -local lower, gsub, find = string.lower, string.gsub, string.find -local concat = table.concat +local lower, find = string.lower, string.find +local concat, copy = table.concat, table.copy local next, type, rawget = next, type, rawget local utfchar = utf.char local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns @@ -152,6 +152,38 @@ local default = { local types = { "optional", "required", "virtual" } local virtuals = { "authoryear", "authoryears", "authornum", "num", "suffix" } -- defaults +local function checkfield(specification,category,data) + local fields = specification.fields + local list = setmetatableindex({},extrafields) + fields[category] = list + data.fields = list + data.category = category + local sets = data.sets or { } + if data.virtual == nil then -- so false is valid + data.virtual = specification.virtual + end + for i=1,#types do + local t = types[i] + local d = data[t] + if d then + for i=1,#d do + local di = d[i] + di = sets[di] or di + if type(di) == "table" then + for i=1,#di do + list[di[i]] = t + end + else + list[di] = t + end + end + else + data[t] = { } + end + end + return data +end + local specifications = setmetatableindex(function(t,name) if not name then return default -- initializer @@ -185,39 +217,21 @@ local specifications = setmetatableindex(function(t,name) end -- for category, data in next, categories do - local list = setmetatableindex({},extrafields) - fields[category] = list - data.fields = list - local sets = data.sets or { } - if data.virtual == nil then -- so false is valid - data.virtual = virtual - end - for i=1,#types do - local t = types[i] - local d = data[t] - if d then - for i=1,#d do - local di = d[i] - di = sets[di] or di - if type(di) == "table" then - for i=1,#di do - list[di[i]] = t - end - else - list[di] = t - end - end - else - data[t] = { } - end - end + categories[category] = checkfield(specification,category,copy(data)) -- we make sure we have no clones end + -- t[name] = specification + -- return specification end) publications.specifications = specifications +function publications.setcategory(target,category,data) + local specification = specifications[target] + specification.categories[category] = checkfield(specification,category,data) +end + function publications.parenttag(dataset,tag) if not dataset or not tag then report("error in specification, dataset %a, tag %a",dataset,tag) diff --git a/tex/context/base/publ-imp-apa.lua b/tex/context/base/publ-imp-apa.lua index f2625488e..3ee5a732e 100644 --- a/tex/context/base/publ-imp-apa.lua +++ b/tex/context/base/publ-imp-apa.lua @@ -1,207 +1,402 @@ --- category = { --- sets = { --- authors = { "author", "editor" }, --- }, --- required = { "authors", "title" }, --- optional = { "year", "journal", "editor", "volume", "number", "pages" }, --- virtual = { "authoryear", "authoryears", "authornum", "num", "suffix" }, --- } - --- category = { --- sets = { --- author = { "author", "editor" }, --- }, --- required = { "author", "title" }, --- optional = { "year", "journal", "editor", "volume", "number", "pages" }, --- virtual = { "authoryear", "authoryears", "authornum", "num", "suffix" }, --- } - -local article = { - required = { "authors" }, - optional = { "year", "subtitle", "type", "journal", "volume", "number", "pages", "note", "links", "file" }, - sets = { +local specification = { + -- + -- metadata + -- + name = "apa", + version = "1.00", + comment = "APA 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 = { + -- + -- list of fields that are interpreted as names: "NAME [and NAME]" where + -- NAME is one of the following: + -- + -- First vons Last + -- vons Last, First + -- vons Last, Jrs, First + -- Vons, Last, Jrs, First + -- + author = "author", + editor = "author", + artist = "author", + interpreter = "author", + composer = "author", + producer = "author", + }, + -- + -- 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", "note", "url" }, + optional = { "subtitle", "doi", "file" }, + }, + ["demo-b"] = { + sets = { + authors = { "author", "institution", "organization" }, + }, + required = { "authors", "title", "year", "note", "url" }, + optional = { "subtitle", "doi", "file" }, + }, + -- + -- more categories are added below + -- + }, +} + +-- Definition of recognized categories and the fields that they contain. +-- Required fields should be present; optional fields may also be rendered; +-- all other fields will be ignored. + +-- Sets contain either/or in order of precedence. + +local categories = specification.categories + +-- an article from a journal + +categories.article = { + sets = { authors = { "author", "editor", "title" }, links = { "doi", "url" }, }, + required = { + "authors" + }, + optional = { + "year", + "subtitle", "type", "file", + "journal", "volume", "number", "pages", + "note", "links", + }, } -local magazine = { - required = { "authors", "journal", "year" }, - optional = { "subtitle", "volume", "number", "pages", "month", "day", "note", "links", "file" }, - sets = article.sets, +-- an article from a magazine + +categories.magazine = { + sets = categories.article.sets, + required = { + "authors", + "year", + "journal", + }, + optional = { + "subtitle", "type", "file", + "volume", "number", "pages", + "month", "day", + "note", "links", + }, } -local book = { - required = { "authors" }, - optional = { "subtitle", "year", "month", "day", "type", "edition", "series", "volume", "number", "pages", "address", "url", "note", "ISBN", "file" }, - sets = { - authors = { "author", "editor", "publisher", "title" }, +categories.newspaper = categories.magazine + +-- (from jabref) to be identified and setup ... + +categories.periodical = { + sets = { + authors = { "editor", "publisher" }, + }, + required = { + "title", + "year", + }, + optional = { + "authors", + "subtitle", "file", + "series", "volume", "number", "month", + "organization", + "note", }, } -local inbook = { - required = { "authors", "title", "chapter", "pages", "year" }, - optional = { "subtitle", "volume", "number", "series", "type", "address", "edition", "month", "note", "ISBN", "file" }, - sets = book.sets, +-- (from jabref) to be identified and setup ... + +categories.standard = { + sets = { + authors = { "author", "institution", "organization" }, + }, + required = { + "authors", + "year", + "title", "subtitle", + "note", + "url", + }, + optional = { + "doi" + }, } -local booklet = { +-- a book with an explicit publisher. + +categories.book = { + sets = { + authors = { "author", "editor", "publisher", "title" }, + }, required = { "authors" }, - optional = { "subtitle", "howpublished", "address", "month", "year", "note", "file" }, - sets = { - authors = { "author", "title" }, + optional = { + "year", "month", "day", + "subtitle", "type", "file", + "edition", "series", "volume", "number", "pages", + "address", + "url", + "note", "ISBN" }, } -local incollection = { - required = { "authors", "title", "booktitle", "year" }, - optional = { "subtitle", "volume", "number", "series", "type", "chapter", "pages", "address", "edition", "month", "note", "ISBN", "file" }, - sets = { - authors = { "author", "editor", "publisher" }, +-- a part of a book, which may be a chapter (or section or whatever) and/or a range of pages. + +categories.inbook = { + sets = { + authors = { "author", "editor", "publisher", "title", "chapter", "pages" }, + }, + required = { + "authors", + "year" , + }, + optional = { + "subtitle", "type", "file", + "volume", "number", "series", + "edition", "month", + "address", + "note", "ISBN", }, } -local inproceedings = { - optional = { "subtitle", "volume", "number", "series", "pages", "address", "month", "organization", "note", "ISBN", "file" }, - required = incollection.required, - sets = incollection.sets, -} +-- a work that is printed and bound, but without a named publisher or sponsoring institution. -local manual = { - required = { "title" }, - optional = { "subtitle", "author", "organization", "address", "edition", "month", "year", "note", "file" }, +categories.booklet = { + sets = { + authors = { "author", "title" }, + }, + required = { + "authors" + }, + optional = { + "year", "month", + "subtitle", "type", "file", + "address", + "howpublished", + "note", + }, } -local thesis = { - required = { "author", "title", "school", "year", "type" }, - optional = { "subtitle", "address", "month", "note", "file" }, -} +-- a part of a book having its own title. -local misc = { - required = { }, - optional = { "author", "title", "subtitle", "howpublished", "month", "year", "note", "file" }, +categories.incollection = { + sets = { + authors = { "author", "editor", "publisher" }, + }, + required = { + "authors", + "title", "booktitle", + "year", + }, + optional = { + "subtitle", "type", "file", + "month", "edition", + "volume", "number", "series", + "chapter", "pages", + "address", + "note", "ISBN", + }, } -local periodical = { - required = { "title", "year" }, - optional = { "subtitle", "authors", "month", "note", "number", "organization", "series", "volume", "file" }, - sets = { - authors = { "editor", "publisher" }, +-- the proceedings of a conference. + +categories.proceedings = { + required = { + "title", + "year" + }, + optional = { + "editor", + "subtitle", "file", + "volume", "number", "series", "pages", + "month", + "address", "publisher", "organization", + "note", "ISBN" }, } -local proceedings = { - required = { "title", "year" }, - optional = { "subtitle", "editor", "volume", "number", "series", "address", "month", "organization", "publisher", "note", "pages", "ISBN", "file" }, +-- an article in a conference proceedings. + +categories.inproceedings = { + sets = categories.incollection.sets, + required = categories.incollection.required, + optional = { + "subtitle", "type", "file", + "month", + "volume", "number", "series", + "pages", + "address", "organization", + "note", "ISBN" + }, } -local techreport = { - required = { "author", "title", "institution", "year" }, - optional = { "subtitle", "type", "number", "address", "month", "note", "file" }, +categories.conference = categories.inproceedings + +-- a thesis (of course). + +categories.thesis = { + required = { + "author", + "title", + "school", + "year", + "type" + }, + optional = { + "subtitle", "file", + "month", + "address", + "note" + }, } -local other = { - required = { "author", "title", "year" }, - optional = { "subtitle", "note", "doi", "file" }, +categories.mastersthesis = categories.thesis +categories.phdthesis = categories.thesis + +-- a report published by a school or other institution, usually numbered within a series. + +categories.techreport = { + required = { + "author", + "title", + "institution", + "year" + }, + optional = { + "subtitle", "type", "file", + "number", "month", + "address", + "note" + }, } -local patent = { - required = { "nationality", "number", "year", "yearfiled" }, - optional = { "author", "title", "subtitle", "language", "assignee", "address", "type", "day", "dayfiled", "month", "monthfiled", "note", "file" }, +-- technical documentation. + +categories.manual = { + required = { + "title" + }, + optional = { + "subtitle", "file", + "author", "address", "organization", + "edition", "month", "year", + "note", + }, } -local electronic = { - required = { "title" }, - optional = { "subtitle", "address", "author", "howpublished", "month", "note", "organization", "year", "url", "doi", "type", "file" }, +-- a patent (of course). + +categories.patent = { + required = { + "nationality", + "number", + "year", "yearfiled" + }, + optional = { + "type", + --check this: "language", + "author", "assignee", + "title", "subtitle", "file", + "address", + "day", "dayfiled", "month", "monthfiled", + "note" + }, } -local standard = { - required = { "authors", "title", "subtitle", "year", "note", "url" }, - optional = { "doi", "file" }, - sets = { - authors = { "author", "institution", "organization" }, +-- a document having an author and title, but not formally published. + +categories.unpublished = { + required = { + "author", + "title", + "note" + }, + optional = { + "subtitle", "file", + "year", "month" }, } -local unpublished = { - required = { "author", "title", "note" }, - optional = { "subtitle", "month", "year", "file" }, +-- like misc below but includes organization. + +categories.electronic = { + required = { + "title" + }, + optional = { + "subtitle", "type", "file", + "year", "month", + "author", + "address", + "organization", + "howpublished", + "url", "doi", + "note" + }, } -local literal = { - required = { "key", "text" }, - optional = { }, - virtual = false, +-- use this type when nothing else fits. + +categories.misc = { + required = { + -- nothing is really important here + }, + optional = { + "author", + "title", "subtitle", "file", + "year", "month", + "howpublished", + "note" + }, } -return { - name = "apa", - version = "1.00", - comment = "APA specification.", - author = "Alan Braslau and Hans Hagen", - copyright = "ConTeXt development team", - virtual = { - -- all share the same default set - "authoryear", "authoryears", "authornum", "num", "suffix", +-- other (whatever jabref does not know!) + +categories.other = { + required = { + "author", + "title", + "year" }, - types = { - -- - -- list of fields that are interpreted as names: "NAME [and NAME]" where - -- NAME is one of the following: - -- - -- First vons Last - -- vons Last, First - -- vons Last, Jrs, First - -- Vons, Last, Jrs, First - -- - author = "author", - editor = "author", - artist = "author", - interpreter = "author", - composer = "author", - producer = "author", + optional = { + "subtitle", "file", + "note", + "doi" }, - categories = { - article = article, - magazine = magazine, - newspaper = magazine, - book = book, - inbook = inbook, - booklet = booklet, - incollection = incollection, - inproceedings = inproceedings, - conference = inproceedings, - manual = manual, - thesis = thesis, - mastersthesis = thesis, - phdthesis = thesis, - misc = misc, - periodical = periodical, - proceedings = proceedings, - techreport = techreport, - other = other, - patent = patent, - electronic = electronic, - standard = standard, - unpublished = unpublished, - literal = literal, - -- - -- the following fields are for documentation and testing purposes - -- - ["demo-a"] = { - required = { "author", "title", "year", "note", "url" }, - optional = { "subtitle", "doi", "file" }, - sets = { - author = { "author", "institution", "organization" }, - }, - }, - ["demo-b"] = { - required = { "authors", "title", "year", "note", "url" }, - optional = { "subtitle", "doi", "file" }, - sets = { - authors = { "author", "institution", "organization" }, - }, - }, +} + +-- if all else fails to match: + +categories.literal = { + required = { + "key", + "text" }, + optional = { + -- whatever comes up + }, + virtual = false, } +-- done + +return specification diff --git a/tex/context/base/publ-ini.lua b/tex/context/base/publ-ini.lua index 6485e880b..78c50677b 100644 --- a/tex/context/base/publ-ini.lua +++ b/tex/context/base/publ-ini.lua @@ -973,27 +973,22 @@ do end end - function commands.btxdetail(name,tag,field) + function commands.btxfield(name,tag,field) local dataset = rawget(datasets,name) if dataset then local fields = dataset.luadata[tag] if fields then - local details = dataset.details[tag] - if details then - local category = fields.category - if permitted(category,field) then - local manipulator, field = splitmanipulation(field) - local value = details[field] - if type(value) == "string" then - context(manipulator and applymanipulation(manipulator,value) or value) - else - report("%s %s %a in category %a for tag %a in dataset %a","unknown","detail",field,category,tag,name) - end + local category = fields.category + if permitted(category,field) then + local manipulator, field = splitmanipulation(field) + local value = fields[field] + if type(value) == "string" then + context(manipulator and applymanipulation(manipulator,value) or value) else - report("%s %s %a in category %a for tag %a in dataset %a","invalid","detail",field,category,tag,name) + report("%s %s %a in category %a for tag %a in dataset %a","unknown","field",field,category,tag,name) end else - report("no details for tag %a in dataset %a",tag,name) + report("%s %s %a in category %a for tag %a in dataset %a","invalid","field",field,category,tag,name) end else report("unknown tag %a in dataset %a",tag,name) @@ -1003,22 +998,27 @@ do end end - function commands.btxfield(name,tag,field) + function commands.btxdetail(name,tag,field) local dataset = rawget(datasets,name) if dataset then local fields = dataset.luadata[tag] if fields then - local category = fields.category - if permitted(category,field) then - local manipulator, field = splitmanipulation(field) - local value = fields[field] - if type(value) == "string" then - context(manipulator and applymanipulation(manipulator,value) or value) + local details = dataset.details[tag] + if details then + local category = fields.category + if permitted(category,field) then + local manipulator, field = splitmanipulation(field) + local value = details[field] + if type(value) == "string" then + context(manipulator and applymanipulation(manipulator,value) or value) + else + report("%s %s %a in category %a for tag %a in dataset %a","unknown","detail",field,category,tag,name) + end else - report("%s %s %a in category %a for tag %a in dataset %a","unknown","field",field,category,tag,name) + report("%s %s %a in category %a for tag %a in dataset %a","invalid","detail",field,category,tag,name) end else - report("%s %s %a in category %a for tag %a in dataset %a","invalid","field",field,category,tag,name) + report("no details for tag %a in dataset %a",tag,name) end else report("unknown tag %a in dataset %a",tag,name) diff --git a/tex/context/base/publ-ini.mkiv b/tex/context/base/publ-ini.mkiv index dc729abab..ddf922cf6 100644 --- a/tex/context/base/publ-ini.mkiv +++ b/tex/context/base/publ-ini.mkiv @@ -93,8 +93,7 @@ \installcorenamespace {btx} -\installsetuphandler \??btx {btx} -% \installcommandhandler \??btx {btx} \??btx +\installsimplecommandhandler \??btx {btx} \??btx % \setupbtx % [\c!alternative=apa] @@ -120,14 +119,8 @@ \unexpanded\def\loadbtxdefinitionfile[#1]% {\ctxcommand{loadbtxdefinitionfile("#1")}} -% \appendtoks -% \loadbtxdefinitionfile[\btxrenderingparameter\c!alternative] -% \to \everysetupbtxrendering - -\let\currentbtxalternative\empty - \appendtoks - \edef\currentbtxalternative{\btxrenderingparameter\c!alternative}% + \edef\currentbtxalternative{\btxparameter\c!alternative}% \ifcsname\??btxrenderingdefinition\currentbtxalternative\endcsname % maybe fall back on apa ? \else @@ -137,7 +130,8 @@ \to \everysetupbtx \def\btx_set_rendering_alternative - {\ctxcommand{setbtxspecification("\currentbtxalternative")}} + {\edef\currentbtxalternative{\btxparameter\c!alternative}% + \ctxcommand{setbtxspecification("\currentbtxalternative")}} % a dedicated construction mechanism @@ -1302,7 +1296,6 @@ \unexpanded\def\placecitation{\citation[entry]} % [#1] - \unexpanded\def\btxhandleciteentry {\dontleavehmode \begingroup @@ -1593,4 +1586,6 @@ \setupbtx [\c!alternative=apa] +% \letvalue{\??btxrenderingdefinition apa}\undefined % we will reload at runtime + \protect diff --git a/tex/context/base/publ-tra.lua b/tex/context/base/publ-tra.lua index 69117351f..f0b113295 100644 --- a/tex/context/base/publ-tra.lua +++ b/tex/context/base/publ-tra.lua @@ -25,6 +25,8 @@ local ctx_starttabulate, ctx_stoptabulate = context.starttabulate, context.stopt local privates = publications.tables.privates local specials = publications.tables.specials +local report = logs.reporter("publications","tracers") + function tracers.showdatasetfields(settings) local dataset = settings.dataset local current = datasets[dataset] @@ -248,8 +250,10 @@ function tracers.showfields(settings) for i=1,#li do validfields[li[i]] = true end - else + elseif li then validfields[li] = true + else + -- report("fatal error in showfields") end end end @@ -260,8 +264,10 @@ function tracers.showfields(settings) for k, v in next, list do makevalid(v,sets) end - else + elseif list then makevalid(list,sets) + else + -- can be false end end end diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex f5596fd1c..b0ee40cc2 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 347977e6e..784d658f4 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index a9f31df7f..3c77d78c7 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/06/14 14:55:16 +-- merge date : 11/06/14 23:46:33 do -- begin closure to overcome local limits and interference |