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