publ-imp-cite.mkvi /size: 7611 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=publ-imp-cite,
3%D        version=2013.12.24,
4%D          title=\CONTEXT\ Publication Support,
5%D       subtitle=Citations,
6%D         author=Alan Braslau and Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16\starttexdefinition mutable protected btx:cite:inject #content
17    \ifconditional\btxinteractive
18        \ifx\currentbtxinternal\empty
19            #content
20        \else
21            \goto {
22                #content
23            } [
24                \s!internal(\currentbtxinternal)
25            ]
26        \fi
27    \else
28        #content
29    \fi
30\stoptexdefinition
31
32\starttexdefinition mutable protected btx:cite:checkconcat
33    \ifnum\currentbtxcount>\zerocount
34        \let\currentbtxinternal\empty
35        \let\currentbtxbacklink\empty
36    \fi
37\stoptexdefinition
38
39% The null case:
40
41\startsetups btx:cite:none
42    \btxcitereference
43    % dummy
44\stopsetups
45
46\startsetups btx:cite:nocite
47    \dontleavehmode
48    \btxcitereference
49\stopsetups
50
51\startsetups btx:cite:unknown
52    \begingroup
53        \tttf
54        \btxcitereference
55        \currentbtxfirst
56    \endgroup
57\stopsetups
58
59\startsetups btx:cite:empty
60    \btxcitereference
61    <empty>
62\stopsetups
63
64\startsetups btx:cite:lefttext
65  \ifx\currentbtxlefttext\empty \else
66    \startbtxrunningstyleandcolor
67        \setbtxparameterset{\s!cite}{lefttext}
68        \btxparameter\c!left
69            \currentbtxlefttext
70        \btxparameter\c!right
71    \stopbtxrunningstyleandcolor
72  \fi
73\stopsetups
74
75\startsetups btx:cite:righttext
76    \ifx\currentbtxrighttext\empty \else
77        \startbtxrunningstyleandcolor
78            \setbtxparameterset{\s!cite}{righttext}
79            \btxparameter\c!left
80                \currentbtxrighttext
81            \btxparameter\c!right
82        \stopbtxrunningstyleandcolor
83    \fi
84\stopsetups
85
86\startsetups btx:cite:invalid
87     \btxcitereference
88     {\tt <\currentbtxreference>}
89\stopsetups
90
91\startsetups btx:cite:concat
92    \startbtxrunningstyleandcolor
93        \btxparameter{\c!separator:\number\currentbtxconcat}
94    \stopbtxrunningstyleandcolor
95\stopsetups
96
97% when we have an author-year combination, the first and seconds is not
98% fields data but something more complex (that itself calls for a setup)
99
100\startsetups btx:cite:normal
101    \fastsetup{\s!btx:\s!cite:concat}
102    \fastsetup{\s!btx:\s!cite:lefttext}
103    \ifx\currentbtxfirst\empty
104        \fastsetup{\s!btx:\s!cite:\s!empty}
105    \else\ifx\currentbtxsecond\empty
106        \texdefinition {\s!btx:\s!cite:inject} {
107            \btxcitereference
108            \btxusecommand [\currentbtxspecification:cite:\currentbtxcitealternative] {
109                \currentbtxfirst
110                \btxflushsuffix
111            }
112        }
113    \else
114        \texdefinition {\s!btx:\s!cite:inject} {
115            \btxcitereference
116            \btxusecommand [\currentbtxspecification:cite:\currentbtxcitealternative] {
117                \currentbtxfirst
118                \btxparameter\c!inbetween
119                \currentbtxsecond
120                \btxflushsuffix
121             }
122        }
123    \fi\fi
124    \fastsetup{\s!btx:\s!cite:righttext}
125\stopsetups
126
127\startsetups btx:cite:range
128    \fastsetup{\s!btx:\s!cite:concat}
129    \fastsetup{\s!btx:\s!cite:lefttext}
130    \ifx\currentbtxfirst\empty
131        \fastsetup{\s!btx:\s!cite:\s!empty}
132    \else
133        \texdefinition {\s!btx:\s!cite:inject} {
134            \btxcitereference
135            \btxusecommand [\currentbtxspecification:cite:\currentbtxcitealternative] {
136                \currentbtxfirst
137                \ifx\currentbtxsecond\empty \else
138                    \btxparameter\c!range
139                    \currentbtxsecond
140                \fi
141                \btxflushsuffix
142            }
143        }
144    \fi
145    \fastsetup{\s!btx:\s!cite:righttext}
146\stopsetups
147
148% somehow related to keywords:
149
150\startsetups btx:cite:listelement
151    \fastsetup{\s!btx:\s!cite:concat}
152    \fastsetup{\s!btx:\s!cite:lefttext}
153    \ifx\currentbtxfirst\empty
154        \fastsetup{\s!btx:\s!cite:\s!empty}
155    \else
156       \texdefinition {\s!btx:\s!cite:inject} {
157           \btxcitereference
158           \currentbtxfirst
159       }
160    \fi
161    \fastsetup{\s!btx:\s!cite:righttext}
162\stopsetups
163
164\startsetups \s!btx:\s!cite:entry
165    \fastsetup{\s!btx:\s!cite:concat}
166    \fastsetup{\s!btx:\s!cite:lefttext}
167    \btxhandleciteentry
168    \fastsetup{\s!btx:\s!cite:righttext}
169\stopsetups
170
171\startsetups \s!btx:\s!cite:footnote
172    \startfootnote
173        \fastsetup{btx:cite:entry}
174    \stopfootnote
175\stopsetups
176
177% these three are goodies to get something but are not set up as it makes no
178% sense to have something root for combinations like this (esp not because one
179% gets default anyway
180
181% AB: not so sure about that. Why define them in default rather than here?
182
183\startsetups \s!btx:\s!cite:author
184    \fastsetup{\s!btx:\s!cite:normal}
185\stopsetups
186\startsetups \s!btx:\s!cite:authoryear
187    \fastsetup{\s!btx:\s!cite:normal}
188\stopsetups
189\startsetups \s!btx:\s!cite:authoryears
190    \fastsetup{\s!btx:\s!cite:normal}
191\stopsetups
192\startsetups \s!btx:\s!cite:authornum
193    \fastsetup{\s!btx:\s!cite:normal}
194\stopsetups
195\startsetups \s!btx:\s!cite:num
196    \fastsetup{\s!btx:\s!cite:range}
197\stopsetups
198\startsetups \s!btx:\s!cite:default
199    \fastsetup{\s!btx:\s!cite:num}
200\stopsetups
201\startsetups \s!btx:\s!cite:textnum
202    \fastsetup{\s!btx:\s!cite:num}
203\stopsetups
204\startsetups \s!btx:\s!cite:year
205    \fastsetup{\s!btx:\s!cite:range}
206\stopsetups
207\startsetups \s!btx:\s!cite:author:num
208    \fastsetup{\s!btx:\s!cite:range}
209\stopsetups
210\startsetups \s!btx:\s!cite:author:year
211    \fastsetup{\s!btx:\s!cite:range}
212\stopsetups
213\startsetups \s!btx:\s!cite:author:years
214    \fastsetup{\s!btx:\s!cite:range}
215\stopsetups
216
217\startsetups \s!btx:\s!cite:index
218    \fastsetup{\s!btx:\s!cite:range}
219\stopsetups
220\startsetups \s!btx:\s!cite:category
221    \fastsetup{\s!btx:\s!cite:normal}
222\stopsetups
223\startsetups \s!btx:\s!cite:short
224    \fastsetup{\s!btx:\s!cite:normal}
225\stopsetups
226\startsetups \s!btx:\s!cite:tag
227    \fastsetup{\s!btx:\s!cite:normal}
228\stopsetups
229
230% the following correspond to fields, but can be used in many renderings
231
232\startsetups \s!btx:\s!cite:keywords
233    \fastsetup{\s!btx:\s!cite:list}
234\stopsetups
235\startsetups \s!btx:\s!cite:title
236    \fastsetup{\s!btx:\s!cite:normal}
237\stopsetups
238\startsetups \s!btx:\s!cite:pages
239    \fastsetup{\s!btx:\s!cite:range}
240\stopsetups
241
242% is the next one used?
243% Yes, bibtex is a mess and one can have pages or sometimes page
244
245\startsetups \s!btx:\s!cite:page
246    \fastsetup{\s!btx:\s!cite:normal}
247\stopsetups
248
249% the following are kind of specific, but can be used in many renderings
250
251\startsetups btx:cite:url
252    \ifx\currentbtxfirst\empty
253        \fastsetup{\s!btx:\s!cite:\s!empty}
254    \else\ifconditional\btxinteractive
255        \goto {
256            \btxcitereference
257            \hyphenatedurl{\currentbtxfirst}
258        } [
259            url(\currentbtxfirst)
260        ]
261    \else
262        \btxcitereference
263        \hyphenatedurl{\currentbtxfirst}
264    \fi\fi
265\stopsetups
266
267\startsetups btx:cite:doi
268    \ifx\currentbtxfirst\empty
269        \fastsetup{\s!btx:\s!cite:\s!empty}
270    \else\ifconditional\btxinteractive
271        \goto {
272            \btxcitereference
273            \hyphenatedurl{doi:\currentbtxfirst}
274        } [
275            url(http://dx.doi.org/\currentbtxfirst)
276        ]
277    \else
278        \btxcitereference
279        \hyphenatedurl{doi:\currentbtxfirst}
280    \fi\fi
281\stopsetups
282
283\protect
284