djot-py
A Python library for parsing the light markup format djot.
This implementation is based on and modified from djot.js.
Usage
pip install djot-py
API
To parse text into an AST, call parse:
from djot import parse
ast = parse("hi there\nfriend\n\nnew para")
To parse text into events:
from djot import EventParser
text = "hello *world*\n\nfoo"
parser = EventParser(text)
# The parse method returns an iterator of events.
for event in parser.parse():
print(event)
There are no rendering features available currently. Will be added in the future.
Differences from Djot.js
- Comment is not supported yet.
- Multi-line attributes is not supported yet.
My personal view on the above not-yet-implemented features
Comment
Comment should not be mixed with attributes.
I hope there's a specific comment syntax in the future. For example, there could be two types of comments:
- Line comment appeared at the end of each line, using symbols like
%% - Block comment wrapped in
%%%, similar to code block.
Multi-line attributes
Djot.js current implementation to support multi-line attributes involves a lot of backtracing, which is in direct conflict with the philosophy of djot. To support multi-line attributes, there needs a fundamental change in the line-based parsing algorithm.
List
This is not hard to implement. However, too much choices might introduce future ambiguity.
I prefere simplicity rather than feature-rich. For example, Typst style simply uses - and +. Leave styling to a renderer. And block attributes could be used to convey some basic styling information.
Metadata
Release files for djot-py 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| djot_py-0.1.2.tar.gz | 68.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djot_py-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 169.5 kB
Release files / djot_py-0.1.2.tar.gz
| Download URL | djot_py-0.1.2.tar.gz |
|---|---|
| Size | 68.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31766fbaafd1cbabb47915a13d446b7efb960c7d6384c1c08c2db3bde35ab4d9
|
|
BLAKE2b-256 checksum How to use checksums |
ecc3a2826706762467e1708df6fb4753995914a42e1cc76e75e927868b2d8c60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / djot_py-0.1.2-py3-none-any.whl
| Download URL | djot_py-0.1.2-py3-none-any.whl |
|---|---|
| Size | 101.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afef33f523fbb31cc89d8cefb5d527751f41c0065313f6c40d37a8f1f65c8e6c
|
|
BLAKE2b-256 checksum How to use checksums |
05f480658ee49442d43d502edfea8b8b2f41440c72b26b250f936ddf98b6ebfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|