sphinxcontrib_bibtex_urn.styles¶
Pybtex style mixin and pre-built styles with URN field support.
Attributes¶
Classes¶
Mixin that adds a |
|
|
|
|
|
|
|
|
Functions¶
|
Return |
Module Contents¶
- sphinxcontrib_bibtex_urn.styles.logger¶
- sphinxcontrib_bibtex_urn.styles.resolve_urn(raw: str) tuple[str, str] | None¶
Return
(url, display_text)for a URN value.Handles both bare identifiers (e.g.,
URN:NBN:…) and full resolver URLs.Supports country-specific NBN resolvers for: AT, CZ, FI, HR, HU, IT, NL, NO, SE, SI. Other NBNs (
URN:NBN:…) resolve viahttps://nbn-resolving.org/.- Args:
raw: The raw URN value, either as a bare identifier or a full URL.
- Returns:
A tuple of
(url, display_text), or None if the URN type is not supported.
- class sphinxcontrib_bibtex_urn.styles.UrnStyleMixin¶
Mixin that adds a
urnBibTeX field to any pybtex formatting style.When an entry contains a
urnfield the mixin appends a hyperlinked URN identifier to the formatted reference. Supported URN namespaces include:URN:NBN:fi:...- Finnish NBNs (resolves viahttps://urn.fi/).URN:NBN:<CC>:...- Country-specific NBNs (e.g. AT, CZ, HR, HU, IT, NL, NO, SE, SI).URN:NBN:...- Other NBNs (resolves viahttps://nbn-resolving.org/).
Note: only
URN:NBNidentifiers are officially supported. Other URN types will log a warning.The Sphinx extension (
sphinxcontrib_bibtex_urn) dynamically wraps your configured style at build time, so it works with any pybtex formatting style, including third-party ones.If the entry also carries a
urlfield whose value points at the same resolver URL the redundant URL is suppressed automatically. The comparison is case-insensitive per RFC 8141.- format_entry(label: str, entry: pybtex.database.Entry) pybtex.style.FormattedEntry¶
Format an entry, appending a URN hyperlink when the field exists.
- Args:
label: The entry label. entry: The BibTeX entry to format.
- Returns:
The formatted entry with URN support.
- class sphinxcontrib_bibtex_urn.styles.PlainUrn(label_style=None, name_style=None, sorting_style=None, abbreviate_names=False, min_crossrefs=2, **kwargs)¶
Bases:
UrnStyleMixin,pybtex.style.formatting.plain.Styleplainstyle with URN support.
- class sphinxcontrib_bibtex_urn.styles.UnsrtUrn(label_style=None, name_style=None, sorting_style=None, abbreviate_names=False, min_crossrefs=2, **kwargs)¶
Bases:
UrnStyleMixin,pybtex.style.formatting.unsrt.Styleunsrtstyle with URN support.
- class sphinxcontrib_bibtex_urn.styles.AlphaUrn(label_style=None, name_style=None, sorting_style=None, abbreviate_names=False, min_crossrefs=2, **kwargs)¶
Bases:
UrnStyleMixin,pybtex.style.formatting.alpha.Stylealphastyle with URN support.
- class sphinxcontrib_bibtex_urn.styles.UnsrtAlphaUrn(label_style=None, name_style=None, sorting_style=None, abbreviate_names=False, min_crossrefs=2, **kwargs)¶
Bases:
UrnStyleMixin,pybtex.style.formatting.unsrtalpha.Styleunsrtalphastyle with URN support.