ChordPro file format parser and renderer
Project description
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— theconfig_jsonargument 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
- Project: https://github.com/koedame/chordsketch
- Playground: https://chordsketch.koeda.me
- Issues: https://github.com/koedame/chordsketch/issues
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chordsketch-0.2.1.tar.gz.
File metadata
- Download URL: chordsketch-0.2.1.tar.gz
- Upload date:
- Size: 5.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b5d4d188f68d56c4f2aa6e2d3ccc23ae2b3885502bc6cbb29f3a7e739e2909b
|
|
| MD5 |
151b661f11d612aa3f6186011381c27f
|
|
| BLAKE2b-256 |
2b14ae7afede9c373c10004b8c26afd9100bfb2b2cb9bb9178484613065a960f
|
File details
Details for the file chordsketch-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: chordsketch-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 6.0 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c6d47e91f6ecef1cf0be507551c3e73f947d4a442b4b02301ab078b5c372a3e
|
|
| MD5 |
7b85b3534e90c9b87a5e1ae7fb429489
|
|
| BLAKE2b-256 |
5fa830093aef8af8c89f9261fba729948b0603f603c5017d410f7c36b0a6f5ca
|
File details
Details for the file chordsketch-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: chordsketch-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30bb7daea045feb981b4b5d49fb36641646d7b76f1de5495755c43ed5c1b28ea
|
|
| MD5 |
2785a5b148c001960f14ff77c8ace376
|
|
| BLAKE2b-256 |
0d9bd6f829c27d162a5e1714acaf27f1658f921ea3ec755b0b3a1ee02ed6948f
|
File details
Details for the file chordsketch-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: chordsketch-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 6.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c75d131971ea76db7a25423de56d78e9fd6515a2ce657a2c29315b0f0aec02a
|
|
| MD5 |
c95ea04beacaca5223b14a7784f499db
|
|
| BLAKE2b-256 |
4610d440f541e9093dbd6d15e8ae96ea9817cd2f71f1d6129c4b411064bf2986
|
File details
Details for the file chordsketch-0.2.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: chordsketch-0.2.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa1d5a65e9f38f17cadf213cbe1171dfaab183f66b6076f4ba778e1674e0968d
|
|
| MD5 |
894b18d8a02a41764e7fdd9ad23649cb
|
|
| BLAKE2b-256 |
d9c6cd2a7edad6cf1662011d56ca9cecbb0376ebc120e45d8d132e07f1a80ca2
|
File details
Details for the file chordsketch-0.2.1-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: chordsketch-0.2.1-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 6.1 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f7dd0a7411f2e64a7abde6b1a5cc8665e8575fd8d6145392afa7248e7bf4906
|
|
| MD5 |
ded86ed69ef948df41659e6cabfffb00
|
|
| BLAKE2b-256 |
ad75005bef062e475cf17b517334563128679e144cf67dafaca3cbfcb8043c88
|