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.
  • Format references using simplified APA 6th/7th, IEEE, MLA 9th, Chicago (author-date), and Vancouver styles that follow CITATION_RULE.md.
  • 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

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)

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-0.1.0.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

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

transtex-0.1.0-py3-none-any.whl (70.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for transtex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4451f70b07450b0423886339cb9ddfc89c9f6fd7c4a158526e8f4354f0cc6534
MD5 de08fa5571069781ed9ef9b4bd0bbae3
BLAKE2b-256 32daeea98974a4245589c70484164019bf6f4c4b26267aa61fe4111529fa2be2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for transtex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95142ea0ca445a7920f1ed6a7d73dba2815c364255aaa20f0cf7cd1479118e70
MD5 303f67aaacf04c595ba4f3626cb10a7c
BLAKE2b-256 e61abf35d9178efb6280221b1ea99508b8bf3b441496c1d3c111adbe98babd9d

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