1HXCITE-MKBIB(1) HTML-XML-utils HXCITE-MKBIB(1)
2
3
4
6 hxcite-mkbib - expand references and create bibliography
7
9 hxcite-mkbib [ -b base ] [ -p pattern ] [ -s separator ] bibfile [ file
10 ]
11
13 The hxcite-mkbib commands copies file to standard output, looking for
14 strings of the form "[[label]]" and for a template for a bibliography.
15 The label may not include white space and the double pair of square
16 brackets must enclose the label without any spaces in between. If
17 hxcite-mkbib finds the label in the bibfile, the string is replaced by
18 the pattern. The pattern can include certain variables. If the label
19 is not found in bibfile, it is left unchanged.
20
21 The default pattern replaces the string with a hyperlink, but if the -p
22 option is used, the replacement can be any pattern. The input doesn't
23 even have to be HTML.
24
25 The file consists of three parts:
26
27 preamble The preamble is the part up to the first occurrence of %{.
28 The preamble is copied to the output once (with bracketed
29 labels ("[[label]]") expanded). The character % is treated
30 specially. To create a single % in the output, there must be
31 two in the preamble (%%). All other occurrences of % followed
32 by another letter are not copied, but are collected into a
33 string called the "sort order." and used to sort the entries,
34 as explained below.
35
36 template The template starts with %{L: and ends with a matching %}.
37 The text in between is copied as often as there are biblio‐
38 graphic entries in bibfile that correspond to bracketed
39 labels in file. Variables in the template are replaced by
40 the corresponding field in the bibliographic entry: all
41 occurrences of %x will be replaced by the field %x of the
42 entry. Parts of the text may be enclosed in %{x: and %}.
43 This means that the text in between should only be output if
44 the current entry has a field x. Text that is enclosed in
45 %{!x: and %} will only be output if the entry does not have a
46 field x. Both kinds of conditional sections may also be
47 nested.
48
49 postamble The text after the %} is copied unchanged to the output,
50 after all bibliographic entries have been processed.
51
52 By default bibliographic entries are copied to the output in the order
53 of the labels in file, except that labels that occur more than once are
54 only used once. If the preamble contains occurrences of %x (where x is
55 neither "%" nor "{") then these together determine the sort order.
56 E.g., if the preamble contains %A%D then the entries will be sorted
57 first on field A (author) and then on field D (date).
58
59 Here is an example of a file that creates a bibliography in HTML for‐
60 mat:
61
62 <html>
63 <title>Bibliography</title>
64 ... text with [[references]] here...
65 <!--%A%D sorted on author, then date -->
66 <dl>
67 %{L:
68 <dt id="%L">%{A:A%}%{!A:%{E:E%}%{!E:%{Q:Q%}%{!Q:-%}%}%}</dt>
69 <dd>%{B:"%T"
70 in: %{E:%E (eds)
71 %}<cite>%B.</cite>%{V: %V.%}
72 %}%{J:"%T"
73 in: %{E:%E (eds)
74 %}<cite>%J.</cite>%{V: %V.%}%{N: %N.%}%{P: pp. %P.%}
75 %}%{!B:%{!J:<cite>%T.</cite>
76 %}%}%{I:%I.
77 %}%{D:%D.
78 %}%{C:%C.
79 %}%{R:%R.
80 %}%{S:%S.
81 %}%{O:%O
82 %}%{U:<a href="%U">%U</a>
83 %}</dd>
84 %}
85 </dl>
86 </html>
87
88 This template starts with four lines of preamble, including the sort
89 string %A%D on line 3. The sort string itself will not be output, but
90 the rest of the comment will.
91
92 From the line %{L: to the line %} is the template. E.g., the line that
93 starts with <dt id=... contains a complex conditional text that prints
94 the authors (%A) if there are any, otherwise the editors (%E) if there
95 are any, otherwise the institution that is the author (%Q), if any, and
96 a dash otherwise. Note how the parts are nested, Most of the text is
97 inside %{!A:...%}, meaning that that part will only be effective if
98 there is no author field (%A).
99
100 The final two lines are the postamble and will simply be copied
101 unchanged.
102
103 A bibliographic entry that looks like this in bibfile:
104
105 %L Java
106 %A Gosling, James
107 %A Joy, Bill
108 %A Steele, Guy
109 %T The Java language specification
110 %D 1998
111 %I Addison-Wesley
112 %U http://java.sun.com/docs/books/jls/index.html
113
114 will be printed by the template above as:
115
116 <dt id="Java">Gosling, James; Joy, Bill; Steele, Guy</dt>
117 <dd><cite>The Java language specification.</cite>
118 Addison-Wesley.
119 1998.
120 <a href="http://java.sun.com/docs/books/jls/index.html">http://java.sun.com/docs/books/jls/index.html</a>
121 </dd>
122
123
125 The following options are supported:
126
127 -p pattern
128 Specifies the pattern by which the string [[label]] is
129 replaced. The pattern may include the variables %b (which
130 will be replaced by the value of the -b option) and %L (which
131 will be replaced by the label). The default pattern is
132
133 <a href="%b#%L" rel="biblioentry">[%L]</a>
134
135
136 -b base Sets the value for the %b variable in the pattern. Typically
137 this is set to a relative or absolute URL. By default this
138 value is an empty string.
139
140 -s separator
141 If there are multiple authors or editors in an entry, their
142 names will be listed with a separator in between. By default
143 the separator is "; " (i.e., a semicolon and a space). With
144 this option the separator can be changed.
145
147 The following operands are supported:
148
149 bibfile The name of a bibliographic database must be given. It must
150 be a file in refer(1) format and every entry must have at
151 least a %L field, which is compared to the bracketed labels.
152 (Entries without such a field will be ignored.)
153
154 file The name of the input file is optional. If absent, hxmkbib(1)
155 will read the template from stdin.
156
158 The following exit values are returned:
159
160 0 Successful completion.
161
162 > 0 An error occurred. Usually this is because a file could not
163 be opened or because the %{ and %} pairs are not properly
164 nested. Very rarely it may also be an out of memory error.
165 Some of the possible error messages:
166
167 missing ':' in pattern
168 hxmkbib found a %{ but the second or third letter after it
169 was not a colon.
170
171 no '%{' in template file
172 The template file is unusable, because it contains no tem‐
173 plate.
174
175 unbalanced %{..%} in pattern
176 There are more %{ than %}.
177
179 asc2xml(1), hxcite(1), hxmkbib(1), hxnormalize(1), hxnum(1),
180 hxprune(1), hxtoc(1), hxunent(1), xml2asc(1), UTF-8 (RFC 2279)
181
183 Sorting is primitive: the program doesn't parse dates or names and sim‐
184 ply sorts "Jan 2000" under the letter "J" and "Albert Camus" under the
185 letter "A". For the moment the only work-around is to put names in the
186 bibfile as "Camus, Albert".
187
188 The program simply lists all authors or editors. There is no way to
189 generate an "et. al." after the third one. The work-around is to put
190 the "et. al." in the bibfile. Putting commas between the first authors
191 and the word "and" before the final one is also not possible.
192
193 The program doesn't try to interpret names of authors or editors and
194 they cannot be reformatted. It is impossible to write a name that is
195 specified as "Sartre, Jean-Paul" in the bibfile as "J. Sartre" or as
196 "Jean-Paul Sartre" in the output.
197
198 There is no way to suppress a period after a field if the field already
199 ends with a period. E.g., the template "%{A:A.%}" may generate "A. Per‐
200 son Jr.." if the author is "A. Person Jr." The only option is to either
201 not put periods in the bibfile or not put periods in the template.
202
203 Entries in the bibfile can only be used if they have a %L (label)
204 field. The program cannot find entries by searching for keywords, like
205 refer(1).
206
207 hxmkbib will replace any ampersands (&) and less-than (<) and greater-
208 than (>) signs that occur in the bibfile by their XML entities &
209 < > on the assumption that the template is HTML/XML. This may not
210 be appropriate for other formats.
211
212 hxcite-mkbib is a (bash) shell script that calls hxcite(1) and hxmk‐
213 bib(1), and is therefore not portable to all platforms.
214
215
216
2175.x 21 Nov 2008 HXCITE-MKBIB(1)