Skip to main content

Sphinx/pybtex plugin for URN:NBN identifier support in bibliographies

Project description

sphinxcontrib-bibtex-urn

Test Status Build Status HTML Docs PDF Docs PyPI version Python version PyPI downloads ZeroVer License Ruff

A Sphinx plugin that extends sphinxcontrib-bibtex with support for URN identifiers (specifically National Bibliography Numbers).

BibTeX entries containing a urn field are rendered with a hyperlinked identifier, similar to how doi fields work:

[Sav23] Niko Savola. Design and modelling of long-coherence qubits using energy participation ratios. Master's thesis, Aalto University, May 2023. URN:NBN:fi:aalto-202305213270.

where URN:NBN:fi:aalto-202305213270 is a clickable link pointing to https://urn.fi/URN:NBN:fi:aalto-202305213270.

Features

Installation

uv add sphinxcontrib-bibtex-urn          # or: pip install sphinxcontrib-bibtex-urn

Usage

Option A – Sphinx extension (recommended)

Add the extension to your conf.py after sphinxcontrib.bibtex. It automatically wraps whatever bibtex_default_style you have configured:

extensions = [
    "sphinxcontrib.bibtex",
    "sphinxcontrib_bibtex_urn",
]

bibtex_default_style = "alpha"    # any pybtex style works
bibtex_bibfiles = ["refs.bib"]

Option B – Direct pybtex style

If you prefer not to use the Sphinx extension, select one of the pre-built styles directly:

extensions = [
    "sphinxcontrib.bibtex",
]

bibtex_default_style = "urn_alpha"   # or urn_plain, urn_unsrt, urn_unsrtalpha
bibtex_bibfiles = ["refs.bib"]

BibTeX entries

Add a urn field to your .bib entries. All URN:NBN namespaces are supported:

% URN:NBN:fi – Finnish National Bibliography Number
@mastersthesis{Sav23,
  author = {Niko Savola},
  title  = {Design and modelling of long-coherence qubits using energy
            participation ratios},
  school = {Aalto University},
  year   = {2023},
  month  = {5},
  urn    = {URN:NBN:fi:aalto-202305213270},
}

% URN:NBN:de – German National Bibliography Number
@book{Example23,
  author    = {Author, Example},
  title     = {An Example German Book},
  publisher = {Springer},
  year      = {2023},
  urn       = {URN:NBN:de:101:1-202301011234},
}

The identifier is rendered as a hyperlink pointing to the appropriate national resolver or the general nbn-resolving.org service. For instance, URN:NBN:fi:aalto-202305213270 links to https://urn.fi/URN:NBN:fi:aalto-202305213270.

URNs in the url field

If the urn field is missing, the plugin also scans the url field. If it contains a link to a supported URN resolver (e.g., https://urn.fi/... or https://nbn-resolving.org/...), it is automatically "promoted" and formatted as a hyperlinked URN identifier.

If the entry contains both a urn field and a url field pointing at the same resolver, the redundant URL is automatically suppressed to avoid duplication. The comparison is case-insensitive (per RFC 8141) and handles both http:// and https:// resolver URLs.

How it works

The plugin provides UrnStyleMixin, a pybtex style mixin that overrides format_entry to append a hyperlinked URN when the field is present. 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.

Development

For information on how to set up the development environment, run tests, and contribute to the project, please see CONTRIBUTING.md.

All participants are expected to follow the Code of Conduct.

See the Security Policy for information on how to report vulnerabilities.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinxcontrib_bibtex_urn-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinxcontrib_bibtex_urn-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file sphinxcontrib_bibtex_urn-0.1.1.tar.gz.

File metadata

File hashes

Hashes for sphinxcontrib_bibtex_urn-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5601b5b2b5ace71aea976bb306d16a9c4e43c08ce870ac746f9d2ef5728b67b3
MD5 bfcbdd4da685775c5e8764f32e60b22f
BLAKE2b-256 30af339d2ce345394ad6ce8e37752c9e4c78dd1b591b6c7dddd3139b782e4456

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinxcontrib_bibtex_urn-0.1.1.tar.gz:

Publisher: release.yml on nikosavola/sphinxcontrib-bibtex-urn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinxcontrib_bibtex_urn-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinxcontrib_bibtex_urn-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3668869ba7c6d6739763293ee326e3cdfb350405f3f1f5b61adb8f567bfcfcd7
MD5 2fef301dd87ab157258863f195479b5c
BLAKE2b-256 d9504e0a2b568c6a69ba07490009feadbd81ab861fb8bc5f55246d5b86f84287

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinxcontrib_bibtex_urn-0.1.1-py3-none-any.whl:

Publisher: release.yml on nikosavola/sphinxcontrib-bibtex-urn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page