Skip to main content

cff2coins

Creates COinS tags from CFF files. Can be used to help Zotero cite your software and datasets.

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install cff2coins

Usage

This module allows software developers to generate COinS tags, which are HTML span tags containing citation metadata, from CFF files (e.g., CITATION.cff). They can embed these COinS tags into the views of their web applications so that their software and datasets are citable by citation managers, like Zotero. You can embed multiple COinS tag on a single page and then Zotero will read these tags and allow the user to select which items to import. This module uses the coins-parser module, which can also be used to dynamically create COinS tags for different resources in Python applications.

Convert CFF to a COinS tag

from cff2coins import CffCoinSpan
from pathlib import Path


# print COinS tag from CITATION.cff (e.g., your software or dataset) 
# if you add this span element to your HTML page, then Zotero can read it.
c: CffCoinSpan = CffCoinSpan.from_cff(cff_file_path = Path('CITATION.cff'))
print(c.to_html_string())

Convert CFF references to COinS tags

# print COinS span elements for references in CITATION.cff (e.g., the software dependencies of your software). if you add these span elements to your HTML page, 
# then Zotero can read them and users can pick which resources they want to add to Zotero.

for r in c.references:
    # r is also a CffCoinSpan
    print(r.to_html_string())

Create COinS tags directly

You can also create a CffCoinSpan object directly from a list of tuples containing the metadata. CffCoinSpan uses the CoinSpan type from coins-parser. The CoinSpan is equivalent to list[tuple[str, str]].

from cff2coins import CoinSpan
coin_span: CoinSpan = [
    ("url_ver", "Z39.88-2004"),
    ("ctx_ver", "Z39.88-2004"),
    ("rfr_id", "info:sid/zotero.org:2"),
    ("rft_val_fmt", "info:ofi/fmt:kev:mtx:dc"),
    ("rft.type", "computerProgram"),
    ("rft.title", "MyApp"),
    ("rft.publisher", "Some Company"),
    ("rft.description", "This is an example dummy software for testing."),
    ("rft.identifier", "https://zenodo.org/records/somenumber1"),
    ("rft.aufirst", "Willa"),
    ("rft.aulast", "Biley"),
    ("rft.au", "Willa Biley"),
    ("rft.au", "Wilò Rilü"),
    ("rft.au", "Jil van Hilo"),
    ("rft.date", "2025-04-15"),
]

cff_coin_span: CffCoinSpan = CffCoinSpan.from_coin_span(coin_span=coin_span)

Parse COinS tags from HTML

You can use the CoinsParser class from the coins-parser module directly to parse COinS metadata from an html tag.

from cff2coins import CoinsParser, CoinSpanList

# note that this returns a list of lists, 
# where each list is data for a coins span.
coin_spans: CoinSpanList = CoinsParser.parse(html)
for coin_span in coin_spans:
    cff_coin_span = CffCoinSpan.from_coin_span(coin_span=coin_span)
    print(cff_coin_span.to_html_string())

License

cff2coins is distributed under the terms of the Apache 2.0 license

Contribution

Contributions in the form of feature requests, bug reports, bug fixes, tests, and feature implementations are welcome. To contribute code, please fork the project, and then do a pull request.

Developer Notes

Building Locally

To build the tool locally, please follow the general advice from here.

python3 -m pip install --upgrade build
python3 -m build

Deploying

To deploy the tool, use the Github Action defined in .github/workflows/python-publish.yml

Release files for cff2coins 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cff2coins 1.0.0
File Size Uploaded
cff2coins-1.0.0.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cff2coins 1.0.0
File Interpreter ABI Platform
cff2coins-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / cff2coins-1.0.0.tar.gz

Download URL cff2coins-1.0.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d55eb424d13e31281e7546353fc577bbfed3dba974163d2ffd11251b2817bae7
BLAKE2b-256 checksum
How to use checksums
911006367a9c920927415bc89e8e570a63c47c69ac99009e9c914e3772650663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release files / cff2coins-1.0.0-py3-none-any.whl

Download URL cff2coins-1.0.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de0772555456962267250e355ac02a30884857541d1a2ac7740411043c283705
BLAKE2b-256 checksum
How to use checksums
a3770aafc458249839efd75e02607f0b13afe2f9cf578dad8fec39a19245a7fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.22

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release 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