Error-tolerant USFM 3.x parser
Project description
usfm3
usfm3 is a Python binding for the Rust usfm3 parser.
It exposes a staged API so live-editor code can stay on tokens/CST until it actually needs AST-backed output.
Installation
pip install usfm3
Quick Start
import usfm3
parsed = usfm3.parse(text)
tokens = usfm3.tokenize(text)
cst = usfm3.parse_cst(text)
ast_document = usfm3.parse_ast(text, diagnostics=True)
ast = parsed.ast()
source_map = parsed.source_map()
diagnostics = parsed.diagnostics
usj = parsed.to_usj()
usj_with_spans = parsed.to_usj(spans=True)
usx = parsed.to_usx()
usfm = parsed.to_usfm()
vref = parsed.to_vref()
API
usfm3.parse(usfm: str, diagnostics: bool = False) -> ParsedDocument
Returns a lazy parsed handle.
usfm3.parse_cst(usfm: str) -> dict
Returns a JSON-friendly CST tree.
usfm3.parse_ast(usfm: str, diagnostics: bool = False) -> dict
Returns:
{
"ast": ...,
"source_map": ...,
"diagnostics": list | None,
}
usfm3.tokenize(usfm: str) -> list[dict]
Returns token spans suitable for editor tooling.
ParsedDocument
cst() -> dictast() -> dictsource_map() -> dictto_usj(spans: bool = False) -> dictto_usx() -> strto_usfm() -> strto_vref() -> dict[str, str]diagnostics -> list[dict] | None
Notes
- Diagnostics are only computed when
diagnostics=True. - Diagnostics are a flat list with
severity,code,message,span, and optionalanchor_cst. - AST nodes do not include spans.
spans=Trueonto_usj()derives inline span data from the source map.
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 usfm3-0.2.1.tar.gz.
File metadata
- Download URL: usfm3-0.2.1.tar.gz
- Upload date:
- Size: 81.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a7f0c5a18f2a39f09ebb666bd10389d28844d42aada10ffe90bf7a714744c55
|
|
| MD5 |
d27e1d6285c8648329daecf05cb06cc8
|
|
| BLAKE2b-256 |
1452017a60d3bb6d07a529596bdef5a346acbf68ccea3eaf90ed244c8d1f856b
|
Provenance
The following attestation bundles were made for usfm3-0.2.1.tar.gz:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.2.1.tar.gz -
Subject digest:
2a7f0c5a18f2a39f09ebb666bd10389d28844d42aada10ffe90bf7a714744c55 - Sigstore transparency entry: 1511459883
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@da23f604fb0defe5c9d174e936902337e156f179 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@da23f604fb0defe5c9d174e936902337e156f179 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.2.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: usfm3-0.2.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 292.3 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21f84a2e331c4acdebfae2a70c25eaf0e9d44089d25b73616154f9198720064c
|
|
| MD5 |
9e6f16a65b6d64707f3c97a7f414c708
|
|
| BLAKE2b-256 |
c5c01b43af749b6bb17b50b055cdb4a8f724e1648c21689f3601379da19eccca
|
Provenance
The following attestation bundles were made for usfm3-0.2.1-cp313-cp313-win_amd64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.2.1-cp313-cp313-win_amd64.whl -
Subject digest:
21f84a2e331c4acdebfae2a70c25eaf0e9d44089d25b73616154f9198720064c - Sigstore transparency entry: 1511460191
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@da23f604fb0defe5c9d174e936902337e156f179 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@da23f604fb0defe5c9d174e936902337e156f179 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: usfm3-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 442.4 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5d7f76a702147b5ac7b2b7e72d83575d9abb6ac6f78c6339710005d579fc705
|
|
| MD5 |
28a04e2c43a68c8cc9406100a9bfa711
|
|
| BLAKE2b-256 |
c9d4041112910d637bad950798000d25632a4a7a1cdebead81e8ba1d6a668279
|
Provenance
The following attestation bundles were made for usfm3-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
f5d7f76a702147b5ac7b2b7e72d83575d9abb6ac6f78c6339710005d579fc705 - Sigstore transparency entry: 1511460069
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@da23f604fb0defe5c9d174e936902337e156f179 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@da23f604fb0defe5c9d174e936902337e156f179 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: usfm3-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 434.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ef68e1f631f09ce77fb12299219e6feb6c62e4102dfea3b71e6095994acb29
|
|
| MD5 |
f078c426f621e29a334a54a6e598127f
|
|
| BLAKE2b-256 |
b13bf613c49bc638f79b9397a7e61467301d96815b4e3cb4cfd335ec4c285356
|
Provenance
The following attestation bundles were made for usfm3-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.2.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
03ef68e1f631f09ce77fb12299219e6feb6c62e4102dfea3b71e6095994acb29 - Sigstore transparency entry: 1511460390
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@da23f604fb0defe5c9d174e936902337e156f179 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@da23f604fb0defe5c9d174e936902337e156f179 -
Trigger Event:
push
-
Statement type:
File details
Details for the file usfm3-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: usfm3-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 389.6 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06a26637ff9711ad43ba60365f626a1749301ea0fe7d18c8a1be5056b1bd2b1e
|
|
| MD5 |
427c657ba71e473651dfa6ae061e7e93
|
|
| BLAKE2b-256 |
30f549228d5080d990c87c47a64d491fec644b53a2142a2a17401340d9ed7dec
|
Provenance
The following attestation bundles were made for usfm3-0.2.1-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish-pypi.yml on jcuenod/usfm3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usfm3-0.2.1-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
06a26637ff9711ad43ba60365f626a1749301ea0fe7d18c8a1be5056b1bd2b1e - Sigstore transparency entry: 1511460293
- Sigstore integration time:
-
Permalink:
jcuenod/usfm3@da23f604fb0defe5c9d174e936902337e156f179 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/jcuenod
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@da23f604fb0defe5c9d174e936902337e156f179 -
Trigger Event:
push
-
Statement type: