Skip to main content

A powerful Python library for generating academic citations from various sources

Project description

CitationLib

A powerful Python library for generating academic citations from various sources including DOIs, arXiv papers, PubMed articles, and web pages. The library supports multiple citation styles and output formats.

Features

  • Multiple Citation Styles

    • APA (7th edition)
    • MLA (9th edition)
    • Chicago (17th edition)
  • Various Output Formats

    • Plain text
    • HTML
    • Markdown
    • LaTeX
    • BibTeX
  • Source Support

    • DOI (Digital Object Identifier)
    • arXiv papers
    • PubMed articles
    • PMC articles
    • General web pages
    • News articles

Installation

pip install citationlib

Quick Start

from citationlib import create_citation, Style, Format

# Basic usage - defaults to APA style and plain text format
citation = create_citation("https://doi.org/10.1038/s41586-021-03819-2")
print(citation)

# Using different citation styles
mla_citation = create_citation(
    "https://arxiv.org/abs/2303.08774",
    style=Style.MLA
)
print(mla_citation)

# Different output formats
latex_citation = create_citation(
    "https://www.nature.com/articles/s41586-021-03819-2",
    style=Style.CHICAGO,
    output_format=Format.LATEX
)
print(latex_citation)

# BibTeX output
bibtex_entry = create_citation(
    "https://arxiv.org/abs/1706.03762",
    output_format=Format.BIBTEX
)
print(bibtex_entry)

Detailed Usage

Citation Styles

The library supports three major citation styles:

from citationlib import create_citation, Style

# APA (7th edition)
apa_citation = create_citation(url, style=Style.APA)

# MLA (9th edition)
mla_citation = create_citation(url, style=Style.MLA)

# Chicago (17th edition)
chicago_citation = create_citation(url, style=Style.CHICAGO)

Output Formats

Choose from five different output formats:

from citationlib import create_citation, Format

# Plain text (default)
text_citation = create_citation(url, output_format=Format.PLAIN)

# HTML
html_citation = create_citation(url, output_format=Format.HTML)

# Markdown
md_citation = create_citation(url, output_format=Format.MARKDOWN)

# LaTeX
latex_citation = create_citation(url, output_format=Format.LATEX)

# BibTeX
bibtex_citation = create_citation(url, output_format=Format.BIBTEX)

Example with Different Sources

The library supports various types of academic sources:

# Academic paper from Nature
doi_citation = create_citation("https://doi.org/10.1038/s41586-021-03819-2")

# ArXiv preprint
arxiv_citation = create_citation("https://arxiv.org/abs/1706.03762")

# News article
news_citation = create_citation("https://www.theguardian.com/us-news/2025/feb/09/democrats-aggressive-stand-against-trump")

# Research website
website_citation = create_citation("https://research.google/pubs/fairness-and-optimality-in-routing/")

Error Handling

The library provides proper error handling for various scenarios:

from citationlib import create_citation

try:
    citation = create_citation("https://example.com/invalid-paper")
except Exception as e:
    print(f"Failed to create citation: {e}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

citationlib-0.2.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

citationlib-0.2.1-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file citationlib-0.2.1.tar.gz.

File metadata

  • Download URL: citationlib-0.2.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for citationlib-0.2.1.tar.gz
Algorithm Hash digest
SHA256 103dadfa56fe7ba486556bc0d938b22491a2ac0573933aa7337a0a895a200ce1
MD5 da66fb9be2fb8c9bdf54c2814ca0f706
BLAKE2b-256 75bf1cba03581e727f78f2316c891b785c76f2904ff61411e7ed36e38a4a5b02

See more details on using hashes here.

File details

Details for the file citationlib-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: citationlib-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for citationlib-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ac99c37192ade7f5628de5f38c267db290a171e43f4ce787715a938d810938d
MD5 770b69c5eb92acc2268f9a1b7dd9f7c2
BLAKE2b-256 cdba4768d799c66f719f797dcb78990380f613b7df77ba92322eba9171b636c8

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