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.5.tar.gz (18.8 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.5-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pybtex_apa7_style-0.1.5.tar.gz
  • Upload date:
  • Size: 18.8 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.5.tar.gz
Algorithm Hash digest
SHA256 3c2107746d49d1523e8d1319594b6eb84affaeea2525d507944c836d8edc60d6
MD5 390b1644417e521b02e1ec81047123ef
BLAKE2b-256 9795e0f2707f3b697363031a8b885c4e7421f13262d7d52d2ef6fc148bc3822d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pybtex_apa7_style-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 09c30e44e710449d8884b52b68fee036051114ecdd59df87a7c308070091f234
MD5 999902a647ff6d93f516603373629f75
BLAKE2b-256 75daf69198d7e7d071207d2e81b7572a30e36ea79be0805c98c74ea599a0bcda

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

0.1.4

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