HXMKBIB(1)
β¨ HXMKBIB(1) β¨
okay bestie, meet hxmkbib π she hangs out with the HTML-XML-utils crew π and she will literally build you an entire bibliography out of a template. no cap. it's giving "librarian but make it fashion" π
π NAME π
hxmkbib β create bibliography from a template π¦
π SYNOPSIS π
hxmkbib [ -s separator ] [ -a auxfile ] [ -n maxauthors ] [ -r moreauthors ] bibfile [ templatefile ]
π DESCRIPTION π
so here's the vibe, bestie: hxmkbib reads a list of bibliographic keys (aka labels) out of auxfile, goes hunting for the matching entries in bibfile, and then builds you a whole bibliography using templatefile as the model β¨
the auxfile might've been made by hxcite(1), iykyk. it's just labels, one per line. and bibfile is a refer(1) style database. hxmkbib looks for entries whose %L field equals a key in the auxfile π
the templatefile is made of three parts, and honestly all three are main characters:
πΈ preamble πΈ
the preamble is everything up to the first time %{ shows up. it gets copied to the output totally unchanged β except for any occurrences of %. to get a single % in the output, you gotta write two of them in the preamble (%%) π. every other occurrence of % followed by another letter does not get copied β instead those get collected into a string called the "sort order." and used to sort the entries, as explained down below β¬οΈ
π¦ template π¦
the template starts with %{L: and ends with a matching %}. the text in between gets copied as many times as there are bibliographic entries in bibfile that correspond to keys in auxfile π
variables in the template get replaced by the matching field from the bibliographic entry: every occurrence of %x gets swapped for the field %x of the entry. parts of the text can be wrapped in %{x: and %}, which means only output the text in between if the current entry actually has a field x. and text wrapped in %{!x: and %} only gets output if the entry does not have a field x π
ββοΈ both kinds of conditional sections can be nested too, like lil matryoshka dolls πͺ
π« postamble π«
the text after the %} gets copied unchanged to the output, once all the bibliographic entries have been processed. periodt π
by default, bibliographic entries land in the output in the order of the keys in auxfile, except keys that show up more than once only get used once (we don't do duplicates here π). but if the preamble contains occurrences of %x (where x is neither "%" nor "{"), then those together decide the sort order π₯ e.g., if the preamble contains %A%D then the entries get sorted first on field A (author) and then on field D (date).
here's an example template file that creates a bibliography in HTML format, she's iconic honestly β¨:
<html>
<title>Bibliography</title>
<!--%A%D sorted on author, then date -->
<dl>
%{L:
<dt id="%L">%{A:%A%}%{!A:%{E:%E%}%{!E:%{Q:%Q%}%{!Q:-%}%}%}</dt>
<dd>%{B:"%T"
in: %{E:%E (eds)
%}<cite>%B.</cite>%{V: %V.%}
%}%{J:"%T"
in: %{E:%E (eds)
%}<cite>%J.</cite>%{V: %V.%}%{N: %N.%}%{P: pp. %P.%}
%}%{!B:%{!J:<cite>%T.</cite>
%}%}%{I:%I.
%}%{D:%D.
%}%{C:%C.
%}%{R:%R.
%}%{S:%S.
%}%{O:%O
%}%{U:<a href="%U">%U</a>
%}</dd>
%}
</dl>
</html>
this template starts with four lines of preamble, including the sort string %A%D on line 3. the sort string itself will not be output, but the rest of the comment will be π
from the line %{L: to the line %} is the template. e.g., that line starting with <dt id=... has a super complex conditional text that prints the authors (%A) if there are any, otherwise the editors (%E) if there are any, otherwise the institution that is the author (%Q) if any, and a dash otherwise π notice how the parts are nested. most of the text is inside %{!A:...%}, meaning that part only kicks in if there's no author field (%A) π
the final two lines are the postamble and get copied unchanged, simple as that π«Ά
a bibliographic entry that looks like this in bibfile:
%L Java
%A Gosling, James
%A Joy, Bill
%A Steele, Guy
%T The Java language specification
%D 1998
%I Addison-Wesley
%U http://java.sun.com/docs/books/jls/index.html
will be printed by the template above as:
<dt id="Java">Gosling, James; Joy, Bill; Steele, Guy</dt>
<dd><cite>The Java language specification.</cite>
Addison-Wesley.
1998.
<a href="http://java.sun.com/docs/books/jls/index.html">http://java.sun.com/docs/books/jls/index.html</a>
</dd>
β¨ OPTIONS β¨
the following options are supported, bestie:
-aauxfile β the file that contains the list of keys (labels) you want bibliographic entries printed for. if you skip this option, the name of the file gets formed from the templatefile argument by removing the last extension and adding.auxπ. and if no templatefile is given either, the default auxfile isaux.auxπ-sseparator β if there are multiple authors or editors in an entry, their names get listed with a separator in between. by default that separator is"; "(i.e., a semicolon and a space). with this option you can change it β¨-nmaxauthors β if there are more than maxauthors authors in an entry, only the first author gets printed and the others get replaced by the moreauthors string π. the default is3.-rmoreauthors β the string to print when there are more than maxauthors authors. the default is"et al."π
π§ OPERANDS π§
the following operands are supported:
- bibfile β the name of a bibliographic database, and you must give it. it has to be a file in
refer(1)format and every entry must have at least a%Lfield, which is used as the key π (entries without such a field get ignored, rip π) - templatefile β the name of the input file, and this one's optional. if it's absent,
hxmkbibwill read the template from stdin πΈ
π©Ί DIAGNOSTICS π©Ί
the following exit values are returned:
0β successful completion, slay π> 0β an error occurred π usually this is because a file couldn't be opened or because the%{and%}pairs aren't properly nested. very rarely it may also be an out of memory error. some of the possible error messages:missing ':' in patternβhxmkbibfound a%{but the second or third letter after it wasn't a colon π ββοΈno '%{' in template fileβ the template file is unusable because it contains no template πunbalanced %{..%} in patternβ there are more%{than%}π΅βπ«
π SEE ALSO π
asc2xml(1), hxcite(1), hxnormalize(1), hxnum(1), hxprune(1), hxtoc(1), hxunent(1), xml2asc(1), UTF-8 (RFC 2279) π¦
π BUGS π
bestie, read these before you get your hopes up. she's cute but she has limits.
- sorting is primitive, ngl: the program doesn't parse dates or names and simply sorts
"Jan 2000"under the letter"J"and"Albert Camus"under the letter"A"π. for the moment the only work-around is to put names in the bibfile as"Camus, Albert". - the program simply lists all authors or editors. there is no way to generate an
"et. al."after the third one. the work-around is to put the"et. al."in the bibfile π. putting commas between the first authors and the word"and"before the final one is also not possible. - the program doesn't try to interpret names of authors or editors, and they cannot be reformatted. it is impossible to write a name that is specified as
"Sartre, Jean-Paul"in the bibfile as"J. Sartre"or as"Jean-Paul Sartre"in the output π - there is no way to suppress a period after a field if the field already ends with a period. e.g., the template
"%{A:A.%}"may generate"A. Person Jr.."if the author is"A. Person Jr."π the only option is to either not put periods in the bibfile or not put periods in the template. - entries in the bibfile can only be used if they have a
%L(label) field. the program cannot find entries by searching for keywords, likerefer(1)does π« hxmkbibwill replace any ampersands (&) and less-than (<) and greater-than (>) signs that occur in the bibfile by their XML entities&<>on the assumption that the template is HTML/XML π. this may not be appropriate for other formats.
okay that's the whole tea, bestie π this lil guide was brought to you by version 7.x, dated 10 Jul 2011 β yeah she's a vintage queen but she still eats π π go forth and cite responsibly β¨
π¦ where this page comes from
- alpine 3.24: html-xml-utils-doc 8.7-r0 Β· W3C
- arch rolling: html-xml-utils 8.8-1 Β· W3C
- debian bookworm: html-xml-utils 7.7-1.1 Β· W3C
- debian trixie: html-xml-utils 7.7-1.1+b1 Β· W3C
- fedora 43: html-xml-utils 8.6-2.fc41 Β· W3C AND BSD-3-Clause
- fedora 44: html-xml-utils 8.7-1.fc44 Β· W3C AND BSD-3-Clause
- nixos 26.05: html-xml-utils 8.7
- nixpkgs unstable: html-xml-utils 8.7
- opensuse-leap 16.0: html-xml-utils 8.6-bp160.1.12 Β· W3C
- opensuse-leap 16.0: html-xml-utils 8.6-bp160.1.12 Β· W3C
- opensuse-leap 16.0: html-xml-utils 8.6-bp160.1.12 Β· W3C
- opensuse-leap 16.0: html-xml-utils 8.6-bp160.1.12 Β· W3C
- ubuntu jammy: html-xml-utils 7.7-1.1 Β· W3C
- ubuntu noble: html-xml-utils 7.7-1.1build2 Β· W3C
- ubuntu questing: html-xml-utils 7.7-1.1build2
- ubuntu resolute: html-xml-utils 7.7-1.3 Β· W3C
- ubuntu stonking: html-xml-utils 7.7-1.3 Β· W3C
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms