publ-imp-apa.lua /size: 12 Kb    last modification: 2023-12-21 09:44
1local specification = {
2    --
3    -- metadata
4    --
5    name      = "apa",
6    version   = "1.00",
7    comment   = "APA specification",
8    author    = "Alan Braslau and Hans Hagen",
9    copyright = "ConTeXt development team",
10    --
11    -- derived (combinations of) fields (all share the same default set)
12    --
13    virtual = {
14        "authoryear",
15        "authoryears",
16        "authornum",
17        "num",
18        "suffix",
19    },
20    --
21    -- special datatypes
22    --
23    types = {
24        --
25        -- list of fields that are interpreted as names: "NAME [and NAME]" where
26        -- NAME is one of the following:
27        --
28        -- First vons Last
29        -- vons Last, First
30        -- vons Last, Jrs, First
31        -- Vons, Last, Jrs, First
32        --
33        author      = "author", -- interpreted as name(s)
34        withauthor  = "author",
35        editor      = "author",
36        translator  = "author",
37        artist      = "author",
38        composer    = "author",
39        producer    = "author",
40        director    = "author",
41        doi         = "url",        -- an external link
42        url         = "url",
43        page        = "pagenumber", -- number or range: f--t
44        pages       = "pagenumber",
45        volume      = "range",
46        number      = "range",
47        keywords    = "keyword",    -- comma|-|separated list
48        year        = "number",
49    },
50    --
51    -- categories with their specific fields
52    --
53    categories = {
54        --
55        -- categories are added below
56        --
57    },
58}
59
60local generic = {
61    --
62    -- A set returns the first field (in order of position below) that is found
63    -- present in an entry. A set having the same name as a field conditionally
64    -- allows the substitution of an alternate field.
65    --
66    -- note that anything can get assigned a doi or be available online.
67    doi        = { "doi", "url" },
68    editionset = { "edition", "volume", "number", "pages" },
69}
70
71-- Definition of recognized categories and the fields that they contain.
72-- Required fields should be present; optional fields may also be rendered;
73-- all other fields will be ignored.
74
75-- Sets contain either/or in order of precedence.
76--
77-- For a category *not* defined here yet present in the dataset, *all* fields
78-- are taken as optional. This allows for flexibility in the addition of new
79-- categories.
80
81local categories = specification.categories
82
83-- an article from a journal
84
85categories.article = {
86    sets = {
87        author = { "author", "organization", "editor", "title" },
88        doi    = generic.doi,
89    },
90    required = {
91        "author", -- a set
92    },
93    optional = {
94        "withauthor", "translator",
95        "year",
96        "subtitle", "type", "file",
97        "journal", "volume", "number", "pages",
98        "doi", "issn", "note",
99     -- APA ignores this: 
100     -- 
101     -- "month",
102     -- 
103    },
104}
105
106-- an article from a magazine
107
108categories.magazine = {
109    sets = categories.article.sets,
110    required = {
111        "author",
112        "year",
113        "journal",
114    },
115    optional = {
116        "withauthor", "translator",
117        "subtitle", "type", "file",
118        "number",
119        "month", "day",
120        "doi", "issn", "note",
121    },
122}
123
124categories.newspaper = categories.magazine
125
126-- (from jabref) to be identified and setup ...
127
128categories.periodical = {
129    sets = {
130        author = { "editor", "publisher", "organization", },
131        doi    = generic.doi,
132    },
133    required = {
134        "title",
135        "year",
136    },
137    optional = {
138        "author", "withauthor", "translator",
139        "subtitle", "file",
140        "series", "volume", "number", "month",
141        "organization",
142        "doi", "issn", "note",
143    },
144}
145
146-- (from jabref) to be identified and setup ...
147
148categories.standard = {
149    sets = {
150        author = { "author", "institution", "organization" },
151        doi    = generic.doi,
152    },
153    required = {
154        "author",
155        "year",
156        "title", "subtitle",
157        "doi", "isbn", "note",
158    },
159    optional = {
160        "withauthor", "translator",
161    },
162}
163
164-- a book with an explicit publisher.
165
166categories.book = {
167    sets = {
168        author     = { "author", "editor", "publisher", "title" },
169        ineditor   = { "editor" },
170        editionset = generic.editionset,
171        doi        = generic.doi,
172    },
173    required = { "author" },
174    optional = {
175        "ineditor",
176        "withauthor", "translator",
177        "year", "month", "day",
178        "subtitle", "type",  "file",
179        "editionset", "series",
180        "address",
181        "doi", "isbn", "note",
182        "abstract",
183    },
184}
185
186-- a part of a book, which may be a chapter (or section or whatever) and/or a range of pages.
187
188categories.inbook = {
189    sets = {
190        author     = { "author", "organization", "editor", "publisher", "title", },
191        ineditor   = { "editor" },
192        editionset = generic.editionset,
193        doi        = generic.doi,
194    },
195    required = {
196        "author",
197        "year" ,
198    },
199    optional = {
200        "ineditor",
201        "withauthor", "translator",
202        "subtitle", "type", "file",
203        "booktitle", "subbooktitle",
204        -- APA ignores this: "chapter",
205        "editionset", "series",
206        "month",
207        "address",
208        "doi", "isbn", "note",
209    },
210}
211
212-- a book having its own title as part of a collection.
213-- (like inbook, but we here make booktitle required)
214
215categories.incollection = {
216    sets = {
217        author     = { "author", "editor", "publisher", "title", },
218        ineditor   = { "editor" },
219        editionset = generic.editionset,
220        doi        = generic.doi,
221    },
222    required = {
223        "author",
224        "booktitle",
225        "year",
226    },
227    optional = {
228        "ineditor",
229        "withauthor", "translator",
230        "subtitle", "type", "file",
231        "subbooktitle",
232        "editionset", "series",
233        -- APA ignores this: "chapter",
234        "month",
235        "address",
236        "doi", "isbn", "note",
237    },
238}
239
240-- a work that is printed and bound, but without a named publisher or sponsoring institution.
241
242categories.booklet = {
243    sets = {
244        author = { "author", "title", },
245        publisher = { "howpublished" }, -- no "publisher"!
246        doi    = generic.doi,
247    },
248    required = {
249        "author"
250    },
251    optional = {
252        "withauthor", "translator",
253        "publisher",
254        "year", "month",
255        "subtitle", "type", "file",
256        "address",
257        "doi", "isbn", "note",
258     },
259}
260
261-- the proceedings of a conference.
262
263categories.proceedings = {
264    sets = {
265        author     = { "editor", "organization", "publisher", "title" }, -- no "author"!
266        publisher  = { "publisher", "organization" },
267        editionset = generic.editionset,
268        doi        = generic.doi,
269    },
270    required = {
271        "author",
272        "year"
273    },
274    optional = {
275        "withauthor", "translator",
276        "publisher",
277        "subtitle", "file",
278        "editionset", "series",
279        "month",
280        "address",
281        "doi", "isbn", "note",
282    },
283}
284
285-- an article in a conference proceedings.
286
287categories.inproceedings = {
288    sets     = categories.incollection.sets,
289    required = categories.incollection.required,
290    optional = {
291        "withauthor", "translator",
292        "subtitle", "type", "file",
293        "month",
294        "edition", "series",
295        "address", "organization",
296        "doi", "isbn", "note",
297    },
298}
299
300categories.conference = categories.inproceedings
301
302-- a thesis (of course).
303
304categories.thesis = {
305    sets = {
306        doi = generic.doi,
307    },
308    required = {
309        "author",
310        "title",
311        "school",
312        "year",
313        "type"
314    },
315    optional = {
316        "withauthor", "translator",
317        "subtitle", "file",
318        "month",
319        "address",
320        "doi", "isbn", "note",
321    },
322}
323
324categories.mastersthesis = {
325    sets     = categories.thesis.sets,
326    required = {
327        "author",
328        "title",
329        "school",
330        "year"
331    },
332    optional = {
333        "withauthor", "translator",
334        "type",
335        "subtitle", "file",
336        "month",
337        "address",
338        "doi", "isbn", "note",
339    },
340}
341categories.phdthesis = categories.mastersthesis
342
343-- a report published by a school or other institution, usually numbered within a series.
344
345categories.techreport = {
346    sets = {
347        author     = { "author", "institution", "publisher", "title" },
348        publisher  = { "publisher", "institution", },
349        editionset = { "type", "volume", "number", "pages" }, -- no "edition"!
350        doi        = generic.doi,
351    },
352    required = {
353        "author",
354        "title",
355        "institution",
356        "year"
357    },
358    optional = {
359        "withauthor", "translator",
360        "publisher",
361        "address",
362        "subtitle", "file",
363        "editionset",
364        "month",
365        "doi", "isbn", "note",
366    },
367}
368
369-- technical documentation.
370
371categories.manual = {
372    sets = {
373        author     = { "author", "organization", "publisher", "title" },
374        publisher  = { "publisher", "organization", },
375        editionset = generic.editionset,
376        doi        = generic.doi,
377    },
378    required = {
379        "title"
380    },
381    optional = {
382        "author", "publisher",
383        "withauthor", "translator",
384        "address",
385        "subtitle", "file",
386        "editionset", "month", "year",
387        "doi", "isbn", "note",
388--         "abstract",
389    },
390}
391
392-- a patent (of course).
393
394categories.patent = {
395    sets = {
396        author = { "author", "assignee", },
397        publisher = { "publisher", "assignee", },
398        year = { "year", "yearfiled", },
399        month = { "month", "monthfiled", },
400        day = { "day", "dayfiled", },
401        doi = generic.doi,
402    },
403    required = {
404        "nationality",
405        "number",
406        "year",
407    },
408    optional = {
409        "type",
410        --check this: "language",
411        "author", "publisher",
412        "withauthor", "translator",
413        "title", "subtitle", "file",
414        "address",
415        "day", "month",
416        "doi", "note"
417    },
418}
419
420-- a document having an author and title, but not formally published.
421
422categories.unpublished = {
423    sets = {
424        doi = generic.doi,
425    },
426    required = {
427        "author",
428        "title",
429        "note"
430    },
431    optional = {
432        "withauthor", "translator",
433        "subtitle", "file",
434        "year", "month",
435        "doi"
436    },
437}
438
439-- like misc below but includes organization.
440
441categories.electronic = {
442    sets = {
443        doi = generic.doi,
444        author = { "author", "organization", },
445    },
446    required = {
447        "title"
448    },
449    optional = {
450        "subtitle", "type", "file",
451        "year", "month",
452        "author", "withauthor", "translator",
453        "address",
454        "organization",
455        "howpublished",
456        "doi", "note"
457    },
458}
459
460-- not bibtex categories...
461
462categories.film = {
463    sets = {
464        doi = generic.doi,
465        author = { "author", "producer", "director", },
466    },
467    required = {
468        "author",
469        "title",
470        "year",
471        "address", "publisher", -- aka studio
472    },
473    optional = {
474        "withauthor", "translator",
475        "type",
476        "note",
477        "doi",
478    },
479}
480
481categories.music = {
482    sets = {
483        doi = generic.doi,
484        author  = { "composer", "artist", "title", "album" },
485        title   = { "title", "album", },
486    },
487    required = {
488        "author",
489        "title",
490        "year",
491        "address", "publisher", -- aka label
492    },
493    optional = {
494        "withauthor", "translator",
495        "type",
496        "note",
497        "doi",
498    },
499}
500
501-- use this type when nothing else fits.
502
503categories.misc = {
504    sets = {
505        doi  = generic.doi,
506    },
507    required = {
508        -- nothing is really important here
509    },
510    optional = {
511        "author", "withauthor", "translator",
512        "title", "subtitle", "file",
513        "year", "month",
514        "howpublished",
515        "doi", "isbn", "note",
516    },
517}
518
519-- other (whatever jabref does not know!)
520
521categories.other = {
522    sets = {
523        doi  = generic.doi,
524    },
525    required = {
526        "author",
527        "title",
528        "year"
529    },
530    optional = {
531        "withauthor", "translator",
532        "subtitle", "file",
533        "doi", "isbn", "note",
534    },
535}
536
537-- if all else fails to match:
538
539categories.literal = {
540    sets = {
541        author = { "key" },
542        doi    = generic.doi,
543    },
544    required = {
545        "author",
546        "text"
547    },
548    optional = {
549        "withauthor", "translator",
550        "doi", "note"
551    },
552    virtual = false,
553}
554
555-- done
556
557return specification
558