Skip to main content

APA7 Style for Pybtex

This is a fork of naeka's pybtex-apa-style, which targeted APA6.

This plugin provides APA7 style for Pybtex.

Pybtex provides Python support for interacting with bibTeX bibliography data. Style plugins provide support for formatting bibliographies, similar to the role that csl files play for LaTeX.

Installation

$ pip install pybtex pybtex-apa7-style

Usage

Pybtex uses Python's plugin system. To use APA7, load it as a plugin as shown in the example below.

from pybtex.plugin import find_plugin
from pybtex.database import parse_file
APA = find_plugin('pybtex.style.formatting', 'apa7')()
HTML = find_plugin('pybtex.backends', 'html')()

def bib_to_apa7_html(bibfile):
    bibliography = parse_file(bibfile, 'bibtex')
    formatted_bib = APA.format_bibliography(bibliography)
    return "<br>".join(entry.text.render(HTML) for entry in formatted_bib)

Other output formats

APA.format_bibliography(...) returns Pybtex's own rich-text representation, which is independent of any particular output format. Rendering to HTML above is just one choice; swap in a different Pybtex backend to get plaintext, Markdown, or LaTeX output instead:

TXT = find_plugin('pybtex.backends', 'text')()
MD = find_plugin('pybtex.backends', 'markdown')()
LATEX = find_plugin('pybtex.backends', 'latex')()

entry.text.render(TXT)    # 'Ackermann, E. (2001). ...'
entry.text.render(MD)     # 'Ackermann, E\\. \\(2001\\)\\. ...'
entry.text.render(LATEX)  # 'Ackermann, E. (2001). ...'

The Markdown backend escapes characters like ., (, and ) that are meaningful in Markdown syntax, which is correct behavior for a Markdown renderer but can look noisy if you only want plain text. If you just want plaintext, prefer the text backend over markdown.

Contributing

This is a work in progres; APA style is not fully-specified and has endless edge cases. I would be delighted to receive examples of bibTeX entries which are not formatted correctly in APA.

If you clone this project's repository, you can add bibTeX exemplars in tests/examples and then run python tests/test_visual_results.py. Open tests/results.html to see the resulting APA-formatted HTML.

Download files

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

Source Distribution

pybtex_apa7_style-0.1.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

pybtex_apa7_style-0.1.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pybtex_apa7_style-0.1.4.tar.gz.

File metadata

  • Download URL: pybtex_apa7_style-0.1.4.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pybtex_apa7_style-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b673e016b6a9581ec456b65bcf091fd3fbd825a5d452fee79e5275dc662c8831
MD5 f398d3db31da1f9f9741a3d88fa470c7
BLAKE2b-256 966c2f1c19ad4b48c21a4fae22ebb28b9f001151a19dc1bdf6bd2ca91fc3f9f0

See more details on using hashes here.

File details

Details for the file pybtex_apa7_style-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pybtex_apa7_style-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pybtex_apa7_style-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d8bdd8de6a42dad7ac91269bff6fad8af4fabf65b95218e82f246f3aec89c8e1
MD5 f6a83ca906b410be244c010f036b11af
BLAKE2b-256 857ca07f8804fdaffd4543682ce7b8cf41456c141d41dc45ad28aab8f472d996

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page