djot-fmt
Automatic formatter for djot markup files.
Overview
djot-fmt is a command-line tool that automatically formats djot files, focusing primarily on fixing common list formatting issues:
- Missing newlines between list items
- Incorrect indentation for nested lists
- Blank line spacing before nested content
Installation
go install github.com/KyleKing/djot-fmt@latest
Or from PyPI, which ships the same formatter as a shared library bound with ctypes:
uv tool install djot-fmt # or: pipx install djot-fmt
uvx djot-fmt file.dj # run without installing
The Python wheels carry a compiled library rather than a reimplementation, so output is byte-identical to the Go binary. Formatting runs in-process, which costs about 9 microseconds for a small document against roughly 3 milliseconds to spawn the CLI.
Python API
import djot_fmt
djot_fmt.format('- a\n- b\n') # '- a\n- b\n'
djot_fmt.format(source, wrap_sentences=False)
format raises djot_fmt.DjotFormatError on input the formatter rejects. Calls are
serialized internally because the underlying djot parser is not goroutine-safe.
The shared library is opened on the first call rather than at import, so a process
that imports djot_fmt and then forks stays safe. Calling into it before forking
does not, because the Go runtime does not survive fork() without exec(). Use the
spawn or forkserver start method with multiprocessing.
Usage
Basic Usage
# Format stdin to stdout
cat file.dj | djot-fmt
# Format file and write back
djot-fmt -w file.dj
# Format multiple files and write back
djot-fmt -w file1.dj file2.dj file3.dj
# Check if file is formatted (exit 1 if not)
djot-fmt -c file.dj
# Check multiple files
djot-fmt -c file1.dj file2.dj file3.dj
# Format to different file
djot-fmt -o output.dj input.dj
Batch Processing
# Format all .dj files in current directory
fd -e dj -x djot-fmt -w
# Format all .dj files in specific directory
fd -e dj . content/ -x djot-fmt -w
# Check formatting for all .dj files
fd -e dj -x djot-fmt -c
# Using find (alternative to fd)
find . -name "*.dj" -exec djot-fmt -w {} \;
Options
-w, --write- Write result to source file(s) instead of stdout-c, --check- Check if file(s) are formatted (exit 1 if not)-o, --output FILE- Write output to FILE instead of stdout (single input file only)-h, --help- Show help message-v, --version- Show version information
SLW (Semantic Line Wrap) Options
--no-wrap-sentences- Disable semantic line wrapping--slw-markers TEXT- Characters that mark sentence endings (default: ".!?")--slw-wrap INTEGER- Maximum line width for wrapping (default: 88, set to 0 to disable)--slw-min-line INTEGER- Minimum line length before wrapping (default: 40, set to 0 for aggressive mode)
Development
This project uses mise for tool management and hk for git hooks.
Setup
# Install mise (if not already installed)
# See: https://mise.jdx.dev/getting-started.html
# Install project tools
mise install
# Install git hooks
hk install --mise
Common Commands
# Run all checks (linting, tests)
mise run ci
# Format code
mise run fmt
# Run tests
mise run test
# Build binary
mise run build
# Install locally
mise run install
Python bindings
# Build the wheel (compiles bindings/cshared with -buildmode=c-shared)
uv build --wheel
# Run the Python tests against the built wheel
uv run --isolated --with dist/*.whl --with pytest pytest bindings/python/tests
bindings/cshared/lib.go is the cgo boundary. Every exported function there recovers
from panics, because a panic crossing into C terminates the host process, which for a
Python caller means killing the interpreter. Strings allocated on the Go side are freed
through DjotFree.
Roadmap
Future enhancements under consideration:
- Support for all djot node types (ordered lists, tables, code blocks, etc.)
- Configurable formatting options (indentation width, line wrapping)
- Semantic line wrapping (similar to mdformat-slw)
- Code block formatting integration
License
MIT
Credits
Built using godjot for djot parsing and AST manipulation.
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 djot_fmt-0.1.1.tar.gz.
File metadata
- Download URL: djot_fmt-0.1.1.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cf6f77536476ad7ad4bc8aca42fedb75d8d768f1f9c3c316fa0a5c78ff38d04
|
|
| MD5 |
fb44123b7b4e48122696067f4630a498
|
|
| BLAKE2b-256 |
e1cc26d7ef9cb67853aed54af73a0ef20760681b147bb6003539d5ecd1052e67
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1.tar.gz:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1.tar.gz -
Subject digest:
3cf6f77536476ad7ad4bc8aca42fedb75d8d768f1f9c3c316fa0a5c78ff38d04 - Sigstore transparency entry: 2349148611
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-win_arm64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-win_arm64.whl
- Upload date:
- Size: 769.6 kB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3878a1ffa410719b8e912ea36bd5b77c871c20ce6b0ac28bb81a63a2a925add1
|
|
| MD5 |
4840f9ae1c40a232c487d577826107e3
|
|
| BLAKE2b-256 |
a9853e3a5467a2fabdabe105c6a08e7a32e4a3027a61dcaaebef20352feb96be
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-win_arm64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-win_arm64.whl -
Subject digest:
3878a1ffa410719b8e912ea36bd5b77c871c20ce6b0ac28bb81a63a2a925add1 - Sigstore transparency entry: 2349149307
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-win_amd64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-win_amd64.whl
- Upload date:
- Size: 843.9 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1075957003b7946c85a18dbd3e5db5a9c93194e86b2ac82ec4fb664d4e39362
|
|
| MD5 |
883f6c6a288c5a6c7aaa3d5550cf91a2
|
|
| BLAKE2b-256 |
70299176503d35a3b95977c3c373dff32802a277167800d0dd89aefd416c8143
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-win_amd64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-win_amd64.whl -
Subject digest:
b1075957003b7946c85a18dbd3e5db5a9c93194e86b2ac82ec4fb664d4e39362 - Sigstore transparency entry: 2349148917
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 785.4 kB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0803e168c140e3266ab381ec37761608b5e76d0f58081859ef772c87793102b1
|
|
| MD5 |
a054ec59d007ee3eb2d936dd7ceca722
|
|
| BLAKE2b-256 |
f33647572903384c018b0a0489dd80a255af276a24aca0226a8724ff089b4756
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl -
Subject digest:
0803e168c140e3266ab381ec37761608b5e76d0f58081859ef772c87793102b1 - Sigstore transparency entry: 2349149514
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 848.7 kB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
355832b6f9edd67489bc29af7d47bbcf9482045354adb3752befe22717fac394
|
|
| MD5 |
cea2d9692ec75ccf30dff54adff827b3
|
|
| BLAKE2b-256 |
065eb44ca0c4432fca6adea77ea8b452f7a47efaa0c888ccbb10fa1cfacaf0a5
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
355832b6f9edd67489bc29af7d47bbcf9482045354adb3752befe22717fac394 - Sigstore transparency entry: 2349148724
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-macosx_15_0_x86_64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-macosx_15_0_x86_64.whl
- Upload date:
- Size: 846.8 kB
- Tags: Python 3, macOS 15.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a04cb6482c1af9cfc10169213c617b123eb8c31d2e1585fae3abe3abe1b8f11
|
|
| MD5 |
b0a4237b33627aa79a5370ef0d217faa
|
|
| BLAKE2b-256 |
68b55add4c6c3d0f19acea038768f37c0b246f42d25c7bbafc3c8ae35951ff46
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-macosx_15_0_x86_64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-macosx_15_0_x86_64.whl -
Subject digest:
7a04cb6482c1af9cfc10169213c617b123eb8c31d2e1585fae3abe3abe1b8f11 - Sigstore transparency entry: 2349149108
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file djot_fmt-0.1.1-py3-none-macosx_15_0_arm64.whl.
File metadata
- Download URL: djot_fmt-0.1.1-py3-none-macosx_15_0_arm64.whl
- Upload date:
- Size: 797.9 kB
- Tags: Python 3, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6bfc374a652eb5fb31984514cdb006d111a399aa047330188828bffc8c7b10
|
|
| MD5 |
f333e31fce723ff5ebedd0e278c2f3c8
|
|
| BLAKE2b-256 |
7dc15240ddd05872a3a7a7d7beb5cdb2eb127a120f6b5a154f5c431ea65b7653
|
Provenance
The following attestation bundles were made for djot_fmt-0.1.1-py3-none-macosx_15_0_arm64.whl:
Publisher:
publish.yml on KyleKing/djot-fmt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djot_fmt-0.1.1-py3-none-macosx_15_0_arm64.whl -
Subject digest:
8f6bfc374a652eb5fb31984514cdb006d111a399aa047330188828bffc8c7b10 - Sigstore transparency entry: 2349149749
- Sigstore integration time:
-
Permalink:
KyleKing/djot-fmt@08a08525e110fb0c9daee836176da0b4d500a7be -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KyleKing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08a08525e110fb0c9daee836176da0b4d500a7be -
Trigger Event:
workflow_dispatch
-
Statement type: