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.1
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.1.tar.gz | 68.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djot_py-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 169.0 kB
Release files / djot_py-0.1.1.tar.gz
| Download URL | djot_py-0.1.1.tar.gz |
|---|---|
| Size | 68.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
148994956e499e3460d0174eac20050907e625c9c11ff7fea329a5d0753784de
|
|
BLAKE2b-256 checksum How to use checksums |
49219beb98a95ff82b3b2f2a593093b0a756272061238227954d1b0121b3823b
|
| 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.1-py3-none-any.whl
| Download URL | djot_py-0.1.1-py3-none-any.whl |
|---|---|
| Size | 100.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a53928c72ce479a991dd9d61adfea1c74722b72be7a6f4626214d8faa65add3
|
|
BLAKE2b-256 checksum How to use checksums |
97b43fcbde1dd37935c654706fccd6b292a8d48040159f85a5a07931dc174ce2
|
| 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}
|