Skip to content

hellux/jotdown

Repository files navigation

Jotdown

API documentation | Online demo | Crate | Repository

Jotdown is a pull parser Rust library for the Djot markup language. It parses a Djot document into a sequence of events and may also render the events to HTML.

Jotdown aims to be fast and efficient, using a minimal number of allocations. The API should use idiomatic Rust and be easy to use and flexible. The event interface allows clients to e.g. construct an AST or generate any type of output format. It also allows one to perform filters on the document before generating the output. Jotdown aims to be feature complete and match the syntax reference and the reference implementation in terms of output.

Another goal is to keep the implementation minimal and build times low. The current implementation has zero dependencies, if major non-essential features are added or larger dependencies are utilized, these should be optional using feature flags.

Jotdown supports Rust edition 2021, i.e. Rust 1.56 and above.

Usage

Jotdown is primarily a parsing library but also has a minimal CLI implementation and a simple web demo version.

Library

The Jotdown API is inspired by pulldown-cmark and is overall very similar. The Jotdown crate contains in-source documentation, a rendered version is available at https://docs.rs/jotdown.

While Jotdown is usable, it is still in early development and breaking changes to the API may occur frequently. The Djot syntax is also in quite early stages and may also change significantly.

CLI

The Jotdown crate contains a minimal implementation of a CLI that simply reads from standard input and writes HTML to standard output. It can be built from this repository and run locally with cargo:

$ cargo build --release
$ echo "hello world" | ./target/release/djot
<p>hello world</p>

Alternatively, it can be installed from the crates.io repository using simply:

$ cargo install jotdown

It will be placed in ~/.cargo/bin/jotdown.

Web demo

The web demo is a version of Jotdown compiled to WebAssembly and runnable in a web browser. It is useful for experimenting with the djot syntax and exploring what events are emitted or what output is rendered.

An online version is available at https://hllmn.net/projects/jotdown/demo. It can also be run locally:

$ cd examples/jotdown_wasm
$ make run

You may need to install