1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Bibliography Support Experimental BibTeX}
15
16\registerctxluafile{biblbib}{}
17
18\unprotect
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116\newtoks \everydefinebibtexsession
117\newtoks \everypreparebibtexsession
118\newtoks \everysetupbibtexsession
119\setfalse \tracebibtexformat
120
121\unexpanded\def\definebibtexsession{\dosingleargument\dodefinebibtexsession}
122\def\preparebibtexsession {\dodoubleempty \dopreparebibtexsession}
123\unexpanded\def\setupbibtexsession {\dodoubleargument\dosetupbibtexsession}
124
125\def\dodefinebibtexsession [#1]{\edef\currentbibtexsession{#1}
126 \ctxcommand{definebibtexsession("#1")}
127 \the\everydefinebibtexsession}
128
129\def\dopreparebibtexsession[#1][#2]{\edef\currentbibtexsession{#1}
130 \ctxcommand{preparebibtexsession("#1","bibtex:#1","#2")}
131 \the\everypreparebibtexsession}
132
133\def\dosetupbibtexsession [#1][#2]{\edef\currentbibtexsession{#1}
134 \getparameters[\??pb#1][#2]
135 \the\everysetupbibtexsession}
136
137\def\registerbibtexfile {\dodoubleargument\doregisterbibtexfile}
138\def\registerbibtexentry {\dodoubleargument\doregisterbibtexentry}
139\def\applytobibtexsession {\dodoubleargument\doapplytobibtexsession}
140
141\def\doregisterbibtexfile [#1][#2]{\ctxcommand{registerbibtexfile("#1","#2")}}
142\def\doregisterbibtexentry [#1][#2]{\ctxcommand{registerbibtexentry("#1","#2")}}
143\def\doapplytobibtexsession[#1][#2]{\xmlprocess{bibtex:#1}{#2}{#2}}
144
145\unexpanded\def\bibtexcommand#1
146 {\ifcsname\??pb:c:#1\endcsname \else
147 \fakebibtexcommand{#1}
148 \fi
149 \csname\??pb:c:#1\endcsname}
150
151\def\fakebibtexcommand#1
152 {\ifcsname#1\endcsname
153 \writestatus{bibtex}{unknown command: #1, using builtin context variant}
154 \setugvalue{\??pb:c:#1}{\dosomebibtexcommand{#1}}
155 \else
156 \writestatus{bibtex}{unknown command: #1}
157 \setugvalue{\??pb:c:#1}{\dofakebibtexcommand{#1}}
158 \fi}
159
160\let\dosomebibtexcommand \getvalue
161\def\dofakebibtexcommand#1{{\tttf#1}}
162
163\def\defbibtexcommand#1
164 {\setuvalue{\strippedcsname#1}}
165
166\def\bibxmldoifelse#1{\xmldoifelse\currentbibxmlnode{field[@name=#1]}}
167\def\bibxmldoif #1{\xmldoif \currentbibxmlnode{field[@name=#1]}}
168\def\bibxmldoifnot #1{\xmldoifnot \currentbibxmlnode{field[@name=#1]}}
169\def\bibxmlflush #1{\xmlcontext \currentbibxmlnode{field[@name=#1]}}
170\def\bibxmlsetup {\xmlsetup \currentbibxmlnode}
171
172\def\currentbibtexformat{apa}
173\def\currentbibxmlnode {unset}
174\def\currentbibxmltag {unset}
175
176\startxmlsetups bibtex
177 \xmlregistereddocumentsetups{#1}{}
178 \xmlsetsetup{#1}{bibtexentryfield}{bibtex:*}
179 \xmlmain{#1}
180\stopxmlsetups
181
182\startxmlsetups bibtex:format
183 \bibtexpublicationsparameter\c!before\relax
184 \edef\currentbibxmlnode {#1}
185 \edef\currentbibxmltag {\xmlatt{#1}{tag}}
186 \edef\currentbibxmlcategory{\xmlatt{#1}{category}}
187 \ifconditional\tracebibtexformat
188 \tracedbibxmlintro\currentbibxmltag
189 \tracedbibxmlintro\currentbibxmlcategory
190 \fi
191 \ignorespaces
192 \xmlcommand{#1}{.}{bibtex:\currentbibtexformat:\currentbibxmlcategory}
193 \removeunwantedspaces
194 \bibtexpublicationsparameter\c!after\relax
195\stopxmlsetups
196
197\startxmlsetups bibtex:list
198 \xmlfilter{#1}{bibtexentrycommand(bibtex:format)}
199\stopxmlsetups
200
201\startxmlsetups bibtex:bibtex
202 \xmlfilter{#1}{entrycommand(bibtex:format)}
203\stopxmlsetups
204
205
206
207\let\normalbibxmlflush\bibxmlflush
208
209\definecolor[bibtextracecolor:field] [darkred]
210\definecolor[bibtextracecolor:crossref][darkblue]
211\definecolor[bibtextracecolor:key] [darkgreen]
212
213\def\tracedbibxmlintro #1{{\tttf#1 > }}
214\def\tracedbibxmlflush #1{\color[bibtextracecolor:field] {\tttf[#1]}}
215\def\tracedbibxmltexts #1{\color[bibtextracecolor:field] {\tttf<#1>}}
216\def\tracedbibxmlcrossref#1{\color[bibtextracecolor:crossref]{\tttf#1}}
217\def\tracedbibxmlkey #1{\color[bibtextracecolor:key] {\tttf#1}}
218
219\def\tracedbibxmltext
220 {\ifconditional\tracebibtexformat
221 \expandafter\tracedbibxmltexts
222 \else
223 \expandafter\firstofoneargument
224 \fi}
225
226\def\bibxmlflush
227 {\ifconditional\tracebibtexformat
228 \expandafter\tracedbibxmlflush
229 \else
230 \expandafter\normalbibxmlflush
231 \fi}
232
233\startxmlsetups bibtex:format:crossref
234 \ifconditional\tracebibtexformat
235 \tracedbibxmlcrossref{\xmlfirst\currentbibxmlnode{field[@name=crossref]lower()}}
236 \else
237 \cite[\xmlfirst\currentbibxmlnode{field[@name=crossref]lower()}]
238 \fi
239\stopxmlsetups
240
241\startxmlsetups bibtex:format:key
242 \ifconditional\tracebibtexformat
243 \tracedbibxmlkey{\normalbibxmlflush{key}}
244 \else
245 \bibxmlflush{key}
246 \fi
247\stopxmlsetups
248
249\startxmlsetups bibtex:format:common:author
250 \ifconditional\tracebibtexformat
251 \bibxmlflush\currentbibtexvariant
252 \else
253 \xmlfilter{#1}{field[@name=\currentbibtexvariant]bibtexconcat(\currentbibtexvariant)}
254 \fi
255\stopxmlsetups
256
257\startxmlsetups bibtex:format:author
258 \begingroup
259 \def\currentbibtexvariant{author}
260 \xmlsetup{#1}{bibtex:format:common:author}
261 \endgroup
262\stopxmlsetups
263
264\startxmlsetups bibtex:format:artauthor
265 \begingroup
266 \def\currentbibtexvariant{artauthor}
267 \xmlsetup{#1}{bibtex:format:common:author}
268 \endgroup
269\stopxmlsetups
270
271\startxmlsetups bibtex:format:editor
272 \begingroup
273 \def\currentbibtexvariant{editor}
274 \xmlsetup{#1}{bibtex:format:common:author}
275 \endgroup
276\stopxmlsetups
277
278\startxmlsetups bibtex:format:doi
279
280 *doi*
281\stopxmlsetups
282
283\startxmlsetups bibtex:format:doi
284
285 *url*
286\stopxmlsetups
287
288\startxmlsetups bibtex:format:month
289
290
291
292
293
294
295 *month*
296\stopxmlsetups
297
298
299
300\def\bibtexlistprocessor
301 {\ctxlua{bibtex.hacks.add(structures.lists.uservalue("\currentlist",\currentlistindex,"bibref"),\currentlistindex)}}
302
303\appendtoks
304 \definelist[\currentbibtexsession]
305 \setuplist[\currentbibtexsession][\c!state=\v!start,\c!width=]
306 \installstructurelistprocessor{\currentbibtexsession:userdata}{\bibtexlistprocessor}
307\to \everydefinebibtexsession
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330\unexpanded\def\bibtexspace {\removeunwantedspaces\space}
331\unexpanded\def\bibtexperiod {\removeunwantedspaces.\space}
332\unexpanded\def\bibtexcomma {\removeunwantedspaces,\space}
333\unexpanded\def\bibtexlparent {\removeunwantedspaces\space(}
334\unexpanded\def\bibtexrparent {\removeunwantedspaces)\space}
335\unexpanded\def\bibtexlbracket{\removeunwantedspaces\space[}
336\unexpanded\def\bibtexrbracket{\removeunwantedspaces]\space}
337
338
339
340
341
342
343
344
345\ifdefined\bibtexblock \else \newcount\bibtexblock \fi \bibtexblock\plusone
346\ifdefined\bibtexcounter \else \newcount\bibtexcounter \fi
347
348\newtoks \everysetupbibtexpublications
349\newtoks \everysetupbibtexcitations
350
351\def\bibtexrefprefix{\number\bibtexblock:}
352
353\let\currentbibtexsession\s!default
354\let\currentbibtexvariant\s!default
355
356
357
358\def\bibtexpublicationsparameter#1
359 {\csname
360 \ifcsname\??pb\currentbibtexsession:\currentbibtexvariant#1\endcsname
361 \??pb\currentbibtexsession:\currentbibtexvariant#1
362 \else\ifcsname\??pb:\currentbibtexvariant#1\endcsname
363 \??pb:\currentbibtexvariant#1
364 \else\ifcsname\??pb\currentbibtexsession#1\endcsname
365 \??pb\currentbibtexsession#1
366 \else\ifcsname\??pb#1\endcsname
367 \??pb#1
368 \else
369 \s!empty
370 \fi\fi\fi\fi
371 \endcsname}
372
373\def\bibtexcitationparameter#1
374 {\csname
375 \ifcsname\??pv\currentbibtexsession:\currentbibtexvariant#1\endcsname
376 \??pv\currentbibtexsession:\currentbibtexvariant#1
377 \else\ifcsname\??pv:\currentbibtexvariant#1\endcsname
378 \??pv:\currentbibtexvariant#1
379 \else\ifcsname\??pv\currentbibtexsession#1\endcsname
380 \??pv\currentbibtexsession#1
381 \else\ifcsname\??pv#1\endcsname
382 \??pv#1
383 \else
384 \s!empty
385 \fi\fi\fi\fi
386 \endcsname}
387
388
389
390\unexpanded\def\setupbibtexpublications
391 {\let\currentpublicationclass\??pb
392 \let\everysetupbibtexwhatever\everysetupbibtexpublications
393 \dodoubleargument\dosetupbibtexwhatever}
394
395\unexpanded\def\setupbibtexcitations
396 {\let\currentpublicationclass\??pv
397 \let\everysetupbibtexwhatever\everysetupbibtexcitations
398 \dodoubleargument\dosetupbibtexwhatever}
399
400\unexpanded\def\setupbibtexpublicationvariants
401 {\let\currentpublicationclass\??pb
402 \let\everysetupbibtexwhatever\everysetupbibtexpublications
403 \dotripleargument\dosetupbibtexwhatevervariant}
404
405\unexpanded\def\setupbibtexcitationvariants
406 {\let\currentpublicationclass\??pv
407 \let\everysetupbibtexwhatever\everysetupbibtexcitations
408 \dotripleargument\dosetupbibtexwhatevervariant}
409
410\def\dosetupbibtexwhatever[#1][#2]
411 {\ifsecondargument
412
413 \def\dobtxcommand##1{\getparameters[\currentpublicationclass##1][#2]}
414 \processcommalist[#1]\dobtxcommand
415 \else
416
417 \getparameters[\currentpublicationclass][#1]
418 \the\everysetupbibtexwhatever
419 \fi}
420
421\def\dosetupbibtexwhatevervariant[#1][#2][#3]
422 {\ifthirdargument
423
424 \def\dobtxcommand##1
425 {\def\dodobtxcommand####1{\getparameters[\currentpublicationclass##1:####1][#3]}
426 \processcommalist[#2]\dodobtxcommand}
427 \processcommalist[#1]\docbtxommand
428 \else\ifsecondargument
429
430 \def\dobtxcommand##1{\getparameters[\currentpublicationclass:##1][#2]}
431 \processcommalist[#1]\dobtxcommand
432 \else
433
434 \getparameters[\currentpublicationclass][#1]
435 \the\everysetupbibtexwhatever
436 \fi\fi}
437
438
439
440\setupbibtexcitationvariants
441 [author,authoryear,authoryears]
442 [\c!namesep={, }]
443
444
445
446\def\doloadbibtexpublicationalternative
447 {\ifproductionrun
448 \edef\bibtexpublicationsalternative{\@@pbalternative}
449 \ifx\bibtexpublicationsalternative\empty \else
450 \processcommacommand[\bibtexpublicationsalternative]\dodoloadbibtexpublicationalternative
451 \let\@@pbalternative\empty
452 \fi
453 \fi}
454
455\def\dodoloadbibtexpublicationalternative#1
456 {\doonlyonce{#1}
457 {\startreadingfile
458 \readsysfile{bxml#1.mkiv}
459 {\showmessage\m!publications{6}{bxml#1}}
460 {\showmessage\m!publications{1}{bxml#1}}
461 \stopreadingfile}}
462
463\appendtoks
464 \doloadbibtexpublicationalternative
465\to \everysetupbibtexpublications
466
467
468
469
470
471
472
473
474
475
476
477\def\bibtexleftnumber#1{#1\hfill}
478
479
480
481
482
483\let\doifbibreferencefoundelse\secondofthreearguments
484
485
486
487\newtoks\everysetupbibtexlistplacement
488
489
490
491\appendtoks
492 \ctxlua {bibtex.authors.setsettings {
493 namesep = \!!bs\bibtexpublicationsparameter\c!namesep\!!es,
494 lastnamesep = \!!bs\bibtexpublicationsparameter\c!lastnamesep\!!es,
495 finalnamesep = \!!bs\bibtexpublicationsparameter\c!finalnamesep\!!es,
496 firstnamesep = \!!bs\bibtexpublicationsparameter\c!firstnamesep\!!es,
497 juniorsep = \!!bs\bibtexpublicationsparameter\c!juniorsep\!!es,
498 vonsep = \!!bs\bibtexpublicationsparameter\c!vonsep\!!es,
499 surnamesep = \!!bs\bibtexpublicationsparameter\c!surnamesep\!!es,
500 namesep = \!!bs\bibtexpublicationsparameter\c!namesep\!!es,
501 lastnamesep = \!!bs\bibtexpublicationsparameter\c!lastnamesep\!!es,
502 finalnamesep = \!!bs\bibtexpublicationsparameter\c!finalnamesep\!!es,
503 author = {
504 etallimit = \!!bs\bibtexpublicationsparameter\c!authoretallimit\!!es,
505 etaldisplay = \!!bs\bibtexpublicationsparameter\c!authoretaldisplay\!!es,
506 etaltext = \!!bs\bibtexpublicationsparameter\c!authoretaltext\!!es,
507 },
508 editor = {
509 etallimit = \!!bs\bibtexpublicationsparameter\c!editoretallimit\!!es,
510 etaldisplay = \!!bs\bibtexpublicationsparameter\c!editoretaldisplay\!!es,
511 etaltext = \!!bs\bibtexpublicationsparameter\c!editoretaltext\!!es,
512 },
513 artauthor = {
514 etallimit = \!!bs\bibtexpublicationsparameter\c!artauthoretallimit\!!es,
515 etaldisplay = \!!bs\bibtexpublicationsparameter\c!artauthoretaldisplay\!!es,
516 etaltext = \!!bs\bibtexpublicationsparameter\c!artauthoretaltext\!!es,
517 },
518 } }
519\to \everysetupbibtexlistplacement
520
521\def\completebibtexpublications{\dodoubleempty\docompletebibtexpublications}
522\unexpanded\def\placebibtexpublications {\dodoubleempty\doplacebibtexpublications}
523
524\def\docompletebibtexpublications[#1][#2]
525 {\begingroup
526 \edef\currentbibtexsession{#1}
527 \let\currentlist\currentbibtexsession
528 \setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]
529 \edef\currentbibtexsessiontitle{\namedlistparameter\currentbibtexsession\c!title}
530 \ifx\currentbibtexsessiontitle\empty
531 \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\headtext{\currentbibtexsession}}]}
532 \else
533 \normalexpanded{\startnamedsection[\v!chapter][\c!reference=\currentbibtexsession,\c!title={\currentbibtexsessiontitle}]}
534 \fi
535 \dodoplacebibtexpublications
536 \stopnamedsection
537 \endgroup}
538
539\def\doplacebibtexpublications[#1][#2]
540 {\begingroup
541 \edef\currentbibtexsession{#1}
542 \let\currentlist\currentbibtexsession
543 \setuplist[\currentbibtexsession][\c!criterium=\v!previous,#2]
544 \dodoplacebibtexpublications
545 \endgroup}
546
547\def\dodoplacebibtexpublications
548 {\determinelistcharacteristics[\currentbibtexsession]
549 \the\everysetupbibtexlistplacement
550 \forgetall
551 \typesetbibtexlist
552 \global\advance\bibtexblock\plusone}
553
554\setvalue{\??pb:\c!numbering:\v!short}#1
555 {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexgetshort\currentpublicationtag}}}
556
557\setvalue{\??pb:\c!numbering:\v!bib}#1
558 {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexgetnumber\currentpublicationtag}}}
559
560\setvalue{\??pb:\c!numbering:\s!unknown}#1
561 {\bibtexlistnumberbox{\bibtexpublicationsparameter\c!numbercommand{#1}}}
562
563\def\@@pblimitednumber
564 {\csname\??pb:\c!numbering:
565 \ifcsname\??pb:\c!numbering:\currentbibtexnumbering\endcsname
566 \currentbibtexnumbering
567 \else
568 \s!unknown
569 \fi
570 \endcsname}
571
572\appendtoks
573 \edef\currentbibtexnumbering{\bibtexpublicationsparameter\c!numbering}
574 \ifx\currentbibtexnumbering\v!no
575 \setuplist[\currentbibtexsession][\c!numbercommand=,\c!symbol=\v!none,\c!textcommand=\outdented]
576 \else
577 \setuplist[\currentbibtexsession][\c!numbercommand=\@@pblimitednumber]
578 \fi
579\to \everysetupbibtexlistplacement
580
581\newdimen\bibtexnumberwidth
582
583\def\bibtexlistnumberbox{\hbox \ifcase\bibtexnumberwidth\else to \bibtexnumberwidth\fi}
584
585\appendtoks
586 \doifelse{\bibtexpublicationsparameter\c!autohang}\v!yes
587 {\ifx\currentbibtexnumbering\v!short
588 \setbox\scratchbox\hbox{\bibtexpublicationsparameter\c!numbercommand{\bibtexpublicationsparameter\c!samplesize}}
589 \else
590 \setbox\scratchbox\hbox{\bibtexpublicationsparameter\c!numbercommand{\ctxlua{tex.write(structures.lists.size())}}}
591 \fi
592 \bibtexnumberwidth\wd\scratchbox
593 \setuplist[\currentbibtexsession][\c!distance=\zeropoint]}
594 {\doifelsenothing{\bibtexpublicationsparameter\c!width}
595 {\bibtexnumberwidth\zeropoint}
596 {\bibtexnumberwidth\bibtexpublicationsparameter\c!width}}
597 \setuplist[\currentbibtexsession][\c!width=\bibtexnumberwidth]
598\to \everysetupbibtexlistplacement
599
600\appendtoks
601 \let\maybeyear\gobbleoneargument
602 \let\noopsort \gobbleoneargument
603\to \everysetupbibtexlistplacement
604
605\appendtoks
606 \doifelse{\bibtexpublicationsparameter\c!maybeyear}\v!off
607 {\let\maybeyear\gobbleoneargument}
608 {\let\maybeyear\firstofoneargument}
609\to \everysetupbibtexlistplacement
610
611\appendtoks
612 \doifnot{\bibtexpublicationsparameter\c!option}\v!continue
613 {\global\bibtexcounter\zerocount}
614\to \everysetupbibtexlistplacement
615
616\appendtoks
617 \edef\currentbibtexcriterium{\namedlistparameter\currentbibtexsession\c!criterium}
618\to \everysetupbibtexlistplacement
619
620\def\typesetbibtexlist
621 {\begingroup
622 \startpacked[\v!blank]
623 \doif{\namedlistparameter\currentbibtexsession\c!criterium}\v!cite
624 {\setuplist[\currentbibtexsession][\c!criterium=\v!here]}
625 \doifelse{\bibtexpublicationsparameter\c!method}\v!local
626 {\ctxlua{bibtex.hacks.reset(1)}}
627 {\ctxlua{bibtex.hacks.reset(2)}}
628 \strc_lists_place_current
629 {\currentbibtexsession}
630 {\currentbibtexcriterium}
631 {}
632 {\namedlistparameter\currentbibtexsession\c!extras}
633 {\namedlistparameter\currentbibtexsession\c!order}
634 \ctxlua{bibtex.hacks.flush("\bibtexpublicationsparameter\c!sorttype")}
635 \stoppacked
636 \endgroup}
637
638\unexpanded\def\typesetbibtexpublication#1
639 {\edef\currentbibtexsessiontag{#1}
640 \ifx\currentbibtexsessiontag\empty
641
642 \else\ifx\currentbibtexcriterium\v!all
643 \dotypesetbibtexpublication
644 \else
645 \ctxlua{bibtex.hacks.doifalreadyplaced("\currentbibtexsessiontag")}
646 \donothing
647 \dotypesetbibtexpublication
648 \fi\fi}
649
650\def\dotypesetbibtexpublication
651 {\doifelsebibreferencefound\currentbibtexsessiontag
652 {\global\advance\bibtexcounter\plusone
653 \ctxlua{bibtex.hacks.registerplaced("\currentbibtexsessiontag")}
654 \let\currentlist\currentbibtexsession
655 \let\currentlistentrynumber \bibtexcounter
656 \let\currentlistentrytitle \thebibtexpublicationlistelement
657 \let\currentlistentrypagenumber\empty
658 \strc_lists_apply_renderingsetup}
659 {}}
660
661\def\thebibtexpublicationlistelement
662 {\strut
663 \expanded{\reference[\bibtexrefprefix\currentbibtexsessiontag]{\number\bibtexcounter}}
664 \dotypesetabibtexpublication\currentbibtexsessiontag
665 \strut}
666
667\def\dotypesetabibtexpublication#1
668 {\begingroup
669 \ignorespaces
670 \xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]command(bibtex:format)}
671 \removeunwantedspaces
672
673
674
675 \endgroup}
676
677\def\doprocessbibtexentry#1{\typesetbibtexpublication{#1}}
678
679
680
681\unexpanded\def\bibtexcitation[#1]
682 {\edef\currentbibtexsession{#1}
683 \strictdoifelsenextoptional\dobibtexcitation\dobibtexref}
684
685\def\dobibtexref#1
686 {\dodobibtexcitation[#1][]}
687
688\def\dobibtexcitation[#1]
689 {\strictdoifelsenextoptional{\dodobibtexcitation[#1]}{\dodobibtexcitation[#1][]}}
690
691\def\dodobibtexcitation[#1][#2]
692 {\dontleavehmode
693 \begingroup
694 \doifelsenothing{#2}\secondargumentfalse\secondargumenttrue
695 \ifsecondargument
696 \dowhateverbibtexcitation{#1}{#2}
697 \else
698 \donumberedbibtexcitation{#1}
699 \fi
700 \endgroup}
701
702\def\dowhatevercitation#1#2
703 {\processcommalist[#2]\dobibtexcitationindeed
704 \setupinteraction[\c!style=]
705 \doifelseassignment{#1}
706 {\getparameters[\??pb\??pb][\c!alternative=,\c!extras=,#1]
707 \edef\currentbibtexvariant{\@@pb@@pbalternative}
708 \ifx\currentbibtexvariant\empty
709 \edef\currentbibtexvariant{\bibtexpublicationparameter\c!refcommand}
710 \fi
711 \ifx\@@pb@@pbextras\empty
712 \setupcite[\currentbibtexvariant][#1]
713 \else
714 \edef\@@pb@@pbextras{{\@@pb@@pbextras\ifdefined\@@pb@@pbright\@@pb@@pbright\else\bibtexpublicationparameter\c!right\fi}}
715 \expanded{\setupcite[\currentbibtexvariant][#1,\c!right=\@@pb@@pbextras]}
716 \fi}
717 {\def\currentbibtexvariant{#1}}
718 \getvalue{bibtex\currentbibtexvariant ref}[#2]}
719
720\def\donumberedbibtexcitation#1
721 {\processcommalist[#1]\dobibtexcitationindeed
722 \setupinteraction[\c!style=]
723 \edef\currentbibtexvariant{\bibtexcitationparameter\c!refcommand}
724 \getvalue{bibtex\currentbibtexvariant ref}[#1]}
725
726\def\dobibtexcitationindeed#1
727 {\iftrialtypesetting \else
728 \expanded{\writedatatolist[\currentbibtexsession][bibref=#1]}
729 \fi}
730
731\def\nobibtexcitation[#1]
732 {\processcommalist[#1]\dobibtexcitationindeed}
733
734\def\bibtexnumref[#1]
735 {\dontleavehmode
736 \begingroup
737 \bibtexcitationparameter\v!left
738 \penalty\plustenthousand
739 \ctxlua{bibtex.hacks.resolve("","\number\bibtexblock","#1")}
740 \bibtexcitationparameter\v!right
741 \endgroup}
742
743\def\dowithbibtexnumrefconnector#1#2
744 {\ifnum#1>\plusone
745 \ifnum#2>\plusone
746 \ifnum#2=#1\relax
747 \bibtexpublicationsparameter\c!lastpubsep
748 \else
749 \bibtexpublicationsparameter\c!pubsep
750 \fi
751 \fi
752 \fi}
753
754\def\dowithbibtexnumref#1#2#3#4#5
755 {\dowithbibtexnumrefconnector{#1}{#2}
756 \def\bibtexrefprefix{#4:}
757 \inbiblink[#5]}
758
759\def\dowithbibtexnumrefrange#1#2#3#4#5#6#7
760 {\dowithbibtexnumrefconnector{#1}{#2}
761 \def\bibtexrefprefix{#4:}
762 \inbiblink[#5]
763 \endash
764 \def\bibtexrefprefix{#6:}
765 \inbiblink[#7]}
766
767\def\nobibtexnumref#1
768 {[#1]}
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799\setupbibtexpublications
800 [\c!monthconversion=,
801 \c!alternative=apa,
802 \c!method=\v!global,
803 \c!refcommand=num,
804 \c!numbercommand=\bibtexleftnumber]
805
806\setupbibtexcitations
807 [\c!refcommand=num]
808
809
810
811\unexpanded\def\doifelsebibtexinteraction
812 {\iflocation
813 \edef\temp{\bibtexcitationparameter\c!interaction}
814 \ifx\temp\v!stop
815 \doubleexpandafter\secondoftwoarguments
816 \else
817 \doubleexpandafter\firstoftwoarguments
818 \fi
819 \else
820 \expandafter\secondoftwoarguments
821 \fi}
822
823\let\doifbibtexinteractionelse\doifelsebibtexinteraction
824
825
826
827
828
829\newconditional\firstbibtexrefsep
830
831\def\bibtexresetrefsep
832 {\settrue\firstbibtexrefsep}
833
834\def\bibtexinsertrefsep
835 {\ifconditional\firstbibtexrefsep
836 \setfalse\firstbibtexrefsep
837 \else
838 \bibtexcitationparameter\c!pubsep
839 \fi}
840
841\def\inbibtexlink#1#2
842 {\doifelsereferencefound{\bibtexrefprefix#1}
843 {\goto{#2}[\bibtexrefprefix#1]}
844 {!#1!}}
845
846\def\dobibtexgotolink#1#2
847 {\doifelsereferencefound{\bibtexrefprefix#1}
848 {\goto{#2}[\bibtexrefprefix#1]}
849 {!#1!}}
850
851\def\dobibattexlink#1#2
852 {\doifelsereferencefound{\bibtexrefprefix#1}
853 {\at{#2}[\bibtexrefprefix#1]}
854 {!#1!}}
855
856\def\dobibtexurllink#1#2
857 {\expanded{\useURL[bibtex:url:#1][#2]}
858 \doifelsebibtexinteraction
859 {\goto{\url[bibtex:url:#1]}[url(bibtex:url:#1)]}
860 {\url[bibtex:url:#1]}}
861
862
863
864\unexpanded\def\bibtexdataref {\dodoubleargument\dobibtexdataref}
865\unexpanded\def\bibtextyperef {\dodoubleargument\dobibtextyperef}
866\unexpanded\def\bibtexkeyref {\dodoubleargument\dobibtexkeyref}
867\unexpanded\def\bibtexserialref {\dodoubleargument\dobibtexserialref}
868\unexpanded\def\bibtexurlref {\dodoubleargument\dobibtexurlref}
869\unexpanded\def\bibtexdoiref {\dodoubleargument\dobibtexdoiref}
870\unexpanded\def\bibtexpageref {\dodoubleargument\dobibtexpageref}
871\unexpanded\def\bibtexnoneref {\dodoubleargument\dobibtexnoneref}
872\unexpanded\def\bibtexshortref {\dodoubleargument\dobibtexshortref}
873\unexpanded\def\bibtexyearref {\dodoubleargument\dobibtexyearref}
874\unexpanded\def\bibtexauthorref {\dodoubleargument\dobibtexauthorref}
875\unexpanded\def\bibtexauthoryearref {\dodoubleargument\dobibtexauthoryearref}
876\unexpanded\def\bibtexauthoryearsref{\dodoubleargument\dobibtexauthoryearsref}
877
878\def\dobibtexdataref {\doprocessbibtexref\dodobibtexdataref {ref}}
879\def\dobibtextyperef {\doprocessbibtexref\dodobibtextyperef {type}}
880\def\dobibtexkeyref {\doprocessbibtexref\dodobibtexkeyref {key}}
881\def\dobibtexserialref {\doprocessbibtexref\dodobibtexserialref {serial}}
882\def\dobibtexurlref {\doprocessbibtexref\dodobibtexurlref {url}}
883\def\dobibtexdoiref {\doprocessbibtexref\dodobibtexdoiref {doi}}
884\def\dobibtexpageref {\doprocessbibtexref\dodobibtexpageref {page}}
885\def\dobibtexnoneref {\doprocessbibtexref\dodobibtexnoneref {none}}
886\def\dobibtexshortref {\doprocessbibtexref\dodobibtexshortref {short}}
887\def\dobibtexyearref {\doprocessbibtexref\dodobibtexyearref {year}}
888\def\dobibtexauthorref {\doprocessbibtexref\dodobibtexauthorref {author}}
889\def\dobibtexauthoryearref {\doprocessbibtexref\dodobibtexauthoryearref {authoryear}}
890\def\dobibtexauthoryearsref{\doprocessbibtexref\dodobibtexauthoryearsref{authoryears}}
891
892\def\doprocessbibtexref#1#2[#3][#4]
893 {\edef\currentbibtexsession{#3}
894 \edef\currentbibtexvariant{#2}
895 \def\dodoprocessbibtexref##1
896 {
897 \edef\currentbibtextag{##1}
898 \bibtexinsertrefsep
899 #1{##1}}
900 \bibtexresetrefsep
901 \bibtexcitationparameter\v!left
902 \processcommalist[#4]\dodoprocessbibtexref\relax
903 \bibtexcitationparameter\v!right}
904
905\def\dodobibtexdataref#1
906 {\dotypesetabibtexpublication{#1}}
907
908\def\dodobibtextyperef#1
909 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]attribute(category)}}
910 \bibtexrefcontent}
911
912\def\dodobibtexkeyref#1
913 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=key]context()}}
914 \dobibtexgotolink{#1}{\bibtexrefcontent}}
915
916\def\dodobibtexserialref#1
917 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]match()}}
918 \dobibtexgotolink{#1}{\bibtexrefcontent}}
919
920\def\dodobibtexurlref#1
921 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]field[@name=url]context()}}
922 \dobibtexurllink{#1}{\bibtexrefcontent}}
923
924\def\dodobibtexdoiref#1
925 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]field[@name=doi]context()}}
926 \dobibtexurllink{#1}{http:dx.doi.org\bibtexrefcontent}}
927
928\def\dodobibtexpageref#1
929 {\dobibtexatlink{#1}{}}
930
931\def\dodobibtexnoneref#1
932 {}
933
934\def\dodobibtexshortref#1
935 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]bibtexshort()}}
936 \dobibtexgotolink{#1}{\bibtexrefcontent}}
937
938\def\dodobibtexyearref#1
939 {\edef\bibtexrefcontent{\xmlfilter{bibtex:\currentbibtexsession}{bibtexentry[@tag=#1]field[@name=year]context()}}
940 \bibtexrefcontent}
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974\def\dodobibtexauthorref #1{\ctxlua{bibtex.authorref ("bibtex:\currentbibtexsession","#1","normal","author")}}
975\def\dodobibtexauthoryearref #1{\ctxlua{bibtex.authoryearref ("bibtex:\currentbibtexsession","#1","normal","author")}}
976\def\dodobibtexauthoryearsref#1{\ctxlua{bibtex.authoryearsref("bibtex:\currentbibtexsession","#1","normal","author")}}
977
978\unexpanded\def\bibtexsingularplural#1#2{\ctxlua{bibtex.singularorplural(\!!bs#1\!!es,\!!bs#2\!!es)}}
979
980\protect \endinput
981
982 |