Skip to main content

This library supports bidirectional conversion between APA 6th, IEEE, and other paper reference formats and BibTeX.

Project description

TransTex (Python)

Reference conversion helpers for BibTeX plus APA 6th/7th, IEEE, MLA 9th, Chicago (author-date), and Vancouver styles.

Features

  • Parse BibTeX entries into structured Reference objects.
  • Serialize references back to clean BibTeX.
  • Convert formatted citations between supported styles.
  • Handle common book/chapters and web sources in addition to journal articles.
  • Provide runnable examples and unit tests.

Project layout

src/        # Library source code (transtex package)
tests/      # Unit tests built with unittest
examples/   # Small runnable scripts demonstrating the API

Getting started

Use uv to run commands without mutating the base environment:

uv run python examples/format_from_bibtex.py

You can also round-trip formatted citations back into BibTeX:

uv run python examples/citation_to_bibtex.py

Convert citations across styles (APA → IEEE/Chicago/MLA, and back):

uv run python examples/convert_citation_styles.py

See book/web coverage:

uv run python examples/book_and_web_examples.py

Usage

Format a Reference in multiple styles:

from transtex import (
    Reference,
    format_apa,
    format_apa7,
    format_ieee,
    format_mla,
    format_chicago,
    format_vancouver,
    reference_to_bibtex,
)

ref = Reference(
    entry_type="article",
    cite_key="doe2020deep",
    title="Deep Learning for Everything",
    authors=["John Doe", "Jane Smith"],
    journal="Journal of Omniscience",
    year="2020",
    volume="42",
    issue="7",
    pages="1-10",
    doi="10.1000/j.jo.2020.01.001",
)

print(format_apa(ref))
print(format_apa7(ref))
print(format_ieee(ref))
print(format_mla(ref))
print(format_chicago(ref))
print(format_vancouver(ref))

print(reference_to_bibtex(ref))

Parse a formatted citation back to BibTeX:

from transtex import citation_to_bibtex

ieee_text = 'J. Doe and J. Smith, "Deep Learning for Everything," Journal of Omniscience, vol. 42, no. 7, pp. 1–10, 2020, doi: 10.1000/j.jo.2020.01.001.'
bibtex = citation_to_bibtex("ieee", ieee_text)
print(bibtex)

Book / web example

from transtex import Reference, format_apa, format_ieee

book_ref = Reference(
    entry_type="book",
    cite_key="turing1950",
    title="Computing Machinery and Intelligence",
    authors=["Alan M. Turing"],
    publisher="Oxford University Press",
    place="Oxford, UK",
    year="1950",
    edition="2nd ed.",
    pages="1-120",
)

web_ref = Reference(
    entry_type="misc",
    cite_key="ada1843",
    title="Sketch of the Analytical Engine",
    authors=["Ada Lovelace"],
    year="1843",
    url="https://example.org/analytical-engine",
    accessed_date="2024-02-10",
)

print(format_apa(book_ref))
print(format_ieee(web_ref))

Running tests

uv run python -m unittest

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

transtex-1.0.1.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

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

transtex-1.0.1-py3-none-any.whl (81.2 kB view details)

Uploaded Python 3

File details

Details for the file transtex-1.0.1.tar.gz.

File metadata

  • Download URL: transtex-1.0.1.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for transtex-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ad7f0406509d132daab544170dc14fa5790764cbd791ce1e3d8400b496a90a98
MD5 30a71846471ef4afedf4770846c3fdcc
BLAKE2b-256 df2df02fa1fd156ce785fac39218967108ba629cde6878b60008c2f64735e684

See more details on using hashes here.

File details

Details for the file transtex-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: transtex-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 81.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for transtex-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac8d53037515caa89d0cc552a0f9d2766a83d0cebf0af26d4a9d91410f371e5c
MD5 08b867e202589997e2131e1f01f58d76
BLAKE2b-256 99b01f9937a58a1f7a3015f1a7044a2783cbbfeaa790928a2fb7a02b5796af43

See more details on using hashes here.

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