Skip to main content

ChordPro file format parser and renderer

Project description

ChordSketch

chordsketch

ChordSketch Python bindings — parse and render ChordPro files from Python via native Rust extensions generated by UniFFI.

Native extension — no pure-Python fallback. The library compiles to a platform wheel; prebuilt wheels for common platforms are published to PyPI so no Rust toolchain is needed to install.

Installation

pip install chordsketch

Requires Python 3.8+ (CPython or PyPy).

Quick Start

import chordsketch

source = """{title: Amazing Grace}
{key: G}

[G]Amazing [G7]grace, how [C]sweet the [G]sound"""

html = chordsketch.parse_and_render_html(source)
text = chordsketch.parse_and_render_text(source)
pdf  = chordsketch.parse_and_render_pdf(source)   # bytes

print(chordsketch.version())

API

Rendering

All render functions accept the same three arguments:

Parameter Type Description
input str ChordPro source text
config_json str | None Preset name ("guitar", "ukulele") or inline RRJSON; None for defaults
transpose int | None Semitone offset (-128..127); None defaults to 0
Function Returns Description
parse_and_render_text(input, config_json, transpose) str Plain text output
parse_and_render_html(input, config_json, transpose) str Full HTML document
parse_and_render_pdf(input, config_json, transpose) bytes Raw PDF bytes

Validation

errors = chordsketch.validate(source)  # list[str] — empty if clean
for msg in errors:
    print(msg)

Utility

print(chordsketch.version())  # e.g. "0.2.0"

Options

# Transpose up 2 semitones with the ukulele preset
html = chordsketch.parse_and_render_html(source, "ukulele", 2)

# Inline RRJSON configuration
html = chordsketch.parse_and_render_html(
    source,
    '{"settings": {"notation": "solfege"}}',
    None,
)

Error handling

Functions raise chordsketch.ChordSketchError on invalid configuration:

try:
    html = chordsketch.parse_and_render_html(source, "{ bad json !!!", None)
except chordsketch.ChordSketchError as e:
    print(e)

ChordSketchError has two variants:

  • NoSongsFound — the input produced no parseable songs (rare with lenient parsing)
  • InvalidConfig — the config_json argument is not a known preset and not valid RRJSON

Parse errors in the ChordPro input are not raised — the renderer is lenient and produces a best-effort result. Call validate() to surface diagnostics.

Links

License

MIT

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

chordsketch-0.2.2.tar.gz (5.8 MB view details)

Uploaded Source

Built Distributions

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

chordsketch-0.2.2-py3-none-win_amd64.whl (6.0 MB view details)

Uploaded Python 3Windows x86-64

chordsketch-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

chordsketch-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

chordsketch-0.2.2-py3-none-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

chordsketch-0.2.2-py3-none-macosx_10_12_x86_64.whl (6.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file chordsketch-0.2.2.tar.gz.

File metadata

  • Download URL: chordsketch-0.2.2.tar.gz
  • Upload date:
  • Size: 5.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for chordsketch-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3e8bb9b357616bbc759eb0c5f160a230f7390092c7119ae09c90b5d3bf49d59c
MD5 2dfaf087a865c3ea345d8808c5e7c076
BLAKE2b-256 33b815f0b09cd208ea694d3405d141b488aa0212a2f53affd54c79cf26e55104

See more details on using hashes here.

File details

Details for the file chordsketch-0.2.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for chordsketch-0.2.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a65de6b0e38afda812d96e1cf42adf274504902eedd98379319c70e9dda265fa
MD5 ff3411d20e099b616742eb95b0873c83
BLAKE2b-256 3c4e6025686458d584bad2936e0bb6ac0e8074dbaad50e9e11fe9cab4fed8084

See more details on using hashes here.

File details

Details for the file chordsketch-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chordsketch-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 23dfa103696ac9c264cca14d4677d93942420a61a931878ee1e0f4170bf739b8
MD5 d762d250c53318779781200e669acecb
BLAKE2b-256 41afb70a01c91387b67bd1bb0f720185774f349ab94625629059931b620b470a

See more details on using hashes here.

File details

Details for the file chordsketch-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chordsketch-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f3d7e7fbc69f612369df57abd6db155607e649f51ce9e79fa05126c416570aff
MD5 047fb643cbf821c4adf116d034470f43
BLAKE2b-256 08f4cdaa1f3a679ac0d6d103507353135aad653a0efcf24bb80b37484517c74e

See more details on using hashes here.

File details

Details for the file chordsketch-0.2.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chordsketch-0.2.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11ec306a3212bc284fdd8408c1b92648ff68af1d80a783e49f953b763d2527f8
MD5 44a3e7555e236ce1e0a1cb855ef6403d
BLAKE2b-256 6090b97e644f952a79b289e68b18b6d2203c9abaf276518f1cd5dd39df931c57

See more details on using hashes here.

File details

Details for the file chordsketch-0.2.2-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chordsketch-0.2.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 173b34986bc12a6ce1cbc92fbb9427ccf20008b6dfc8788456c021aafe517efe
MD5 9fbd18c883a225395ca71bce419e13d5
BLAKE2b-256 68ec3978aa513987f39c5480d7f837d6876840794bb658a40c32e61d41fdc222

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