![]() |
The built-in functions | ![]() |
The BibTEX style language has a few built-in functions which operate on LaTeX strings. The TeXmacs styles need the same operations on TeXmacs trees, since the field values have already been converted (see parsing). They are implemented in C++ in
Plugins/Bibtex/bibtex_functions.cpp
and exported to Scheme by
Scheme/Glue/build-glue-basic.scm
. All of them take Scheme trees, convert them to TeXmacs trees and simplify them with simplify_correct before working, and most return a Scheme tree. The descriptions below are meant for style writers who need to know the exact behaviour; the list of functions is also in writing TeXmacs bibliography styles.
Returns the value of the field name of a bib-entry, or "" if there is no such field or if entry is not a well formed entry (three children, the last one a document). Field names are compared literally; since the parser lower-cases them, they should be given in lower case.
True if bib-field returns "". A field whose value is a non-atomic tree without text (for instance an empty concat) is not considered empty; use bib-null? from
bibtex/bib-utils.scm
for such tests.
Returns the concatenated text of t: atomic strings are kept, with contributes its body, keepcase, concat and document their children, and every other tag is dropped together with its contents. Unlike purify$, punctuation is not removed and no character is replaced by a space. Used to build sort keys.
Meant to return the length of the text of t. For an atomic tree it returns the number of bytes, so that a Cork entity such as <alpha> counts as seven characters. For any compound tree it currently returns 0 (see the pitfalls). The shipped styles use it to choose between a space and a non-breaking space after short volume and number fields.
Returns, as a string, the first n bytes of the text of t, collected from atomic strings and the children of concat and document. The special value "others" (the BibTEX convention for “and others”) gives "+". Bytes, not characters, are counted, so the result may end in the middle of a Cork entity, and the body of a with is ignored. Used by the alpha style to build labels.
Replaces every word of the text of t by its first character followed by dot, and separates the abbreviated words by sep. A Cork entity counts as one character. In hyphenated words, every part is abbreviated and the hyphens are kept, so Jean-Pierre becomes J.-P. with dot equal to ".". The result is a concat. The styles call it as (bib-abbreviate first "." '(nbsp)).
Looks at the last non-space character of the last non-empty atomic string of t. If it is a comma or a semicolon, it is replaced by a period; if it is ., ! or ?, nothing happens; otherwise a period is appended. Replacing commas and semicolons is a difference with BibTEX, which only appends.
Case changes respect the keepcase tags produced by the parser from BibTEX brace groups, and never touch verbatim, slink, math, typewriter text (font-family tt) and text with a math-font. They use the Unicode aware functions uni_locase_all, uni_upcase_all, uni_locase_first and uni_upcase_first, so accented Cork characters are handled.
Change the case of all text, except inside keepcase. The keepcase tags themselves are removed (their contents are kept as they are), so the result can be displayed directly. This is the analogue of change.case$ with "l" and "u".
Change the case of the first character of the first non-blank atomic string (for with, of its body). Since keepcase is not skipped specially here, the first character inside a keepcase is changed as well.
Only simplifies the tree; keepcase tags are kept.
Despite its name, changes no case: it removes the keepcase tags (keeping their contents) and is what bib-format-field applies to every field it formats.
The analogue of change.case$ with "t" (title case conversion: lower case except the first letter) is obtained in the styles by combining these functions, for instance bib-format-field-Locase in
bibtex/bib-utils.scm
is (bib-upcase-first (bib-locase field)).
The header also declares bib_preamble, bib_strings_dict, bib_subst_vars, bib_entries, bib_parse_fields and bib_field_pages, which are used by the parser and by generate_bibliography but have no glue. In particular the contents of @preamble items are not available to the Scheme styles. The C++ function bib_num_names (the analogue of num.names$) is defined but not used anywhere; styles count the children of bib-names instead.