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