Skip to main content

Parses and creates COinS metadata tags. Can be used with Zotero.

Project description

coins-parser

Parses and creates COinS metadata tags. Can be used with Zotero.

PyPI - Version Python Version from PEP 621 TOML


Table of Contents

Installation

pip install coins-parser

Usage

Zotero allows you to export references as COinS tags. You can use this package to parse them and use them in your Python packages. This package offers a CoinsParser class that can parse an HTML string containing COinS tags into a Python list. This list contains a list of COinS metadata for each COinS span tag found in the HTML string.

# parse a single COinS tag
from coins_parser import CoinsParser

html_with_coins_tags: str = ""

# print metadata for each COinS tag
coins = CoinsParser.parse(html_with_coins_tags)
for coin in coins:
    print(coin)

You can also specify the HTML parser used to any parser supported by beautifulsoup4. By default, the HTML parser is 'html.parser', which does not require installing additional packages. However, if you want to use a different HTML parser, like 'lxml', you will first need to install it as described in the previous link.

### parse the COinS tags using the lxml parser
coins = CoinsParser.parse(html_with_coins_tags, beautiful_soup_parser='lxml')

You can covert COinS objects back into HTML. This can be useful if you want to inject one or more COinS span tags into your webpage so Zotero can recognize one or more items on a single page.

# Create two COinS objects
from coins_parser import CoinsParser

coin_1: list[tuple[str, str]] = [
    ("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"),
]

coin_2: list[tuple[str, str]] = [
    ("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", "MyOtherApp"),
    ("rft.publisher", "Some Company"),
    ("rft.description", "This is another example dummy software for testing."),
    ("rft.identifier", "https://zenodo.org/records/somenumber2"),
    ("rft.aufirst", "Willa"),
    ("rft.aulast", "Biley"),
    ("rft.au", "Willa Biley"),
    ("rft.au", "Wilò Rilü"),
    ("rft.au", "Jil van Hilo"),
    ("rft.date", "2025-04-11"),
]
coins: list[list[tuple[str, str]]] = [coin_1, coin_2]
html: str = CoinsParser.html(coins)  
print(html)

License

coins-parser 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

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

coins_parser-1.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

coins_parser-1.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file coins_parser-1.1.0.tar.gz.

File metadata

  • Download URL: coins_parser-1.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for coins_parser-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5f7384df3753baa87fee041d0081d74a6343a741df5a88ee0c5dbcb90d1ddad1
MD5 604dee224c3ebbe0dde714479b6d9fc2
BLAKE2b-256 059042df2ed5516c95db2555d573c9a065763c77b6383cca79643649ac126b38

See more details on using hashes here.

File details

Details for the file coins_parser-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: coins_parser-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for coins_parser-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3613304c095e14f8e0d3ae31d9f14887a43fed7f4cdda37af91673341de56d1
MD5 22a8eec4802169b2d932e77c647649f0
BLAKE2b-256 5a0ffa5427dc8541325bb67b58050e4f07180bdf669aa952586415a633a687f8

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