Expand description
A pull parser for Djot.
The main entry is through Parser
which implements an Iterator
of Event
s. The events
can then be used to traverse the document structure in order to e.g. construct an AST or
directly generate to some output format. This crate provides an html
module that can be
used to render the events to HTML.
Feature flags
html
(default): build the html module and a binary that converts djot to HTML.
Examples
Generate HTML from Djot input:
use jotdown::Render;
let djot_input = "hello *world*!";
let events = jotdown::Parser::new(djot_input);
let mut html = String::new();
jotdown::html::Renderer::default().push(events, &mut html);
assert_eq!(html, "<p>hello <strong>world</strong>!</p>\n");
Apply some filter to a specific type of element:
let events =
jotdown::Parser::new("a [link](https://example.com)").map(|e| match e {
Event::Start(Link(dst, ty), attrs) => {
Event::Start(Link(dst.replace(".com", ".net").into(), ty), attrs)
}
e => e,
});
let mut html = String::new();
jotdown::html::Renderer::default().push(events, &mut html);
assert_eq!(html, "<p>a <a href=\"https://example.net\">link</a></p>\n");
Modules
- An HTML renderer that takes an iterator of
Event
s and emits HTML.
Structs
- Stores an attribute value that supports backslash escapes of ASCII punctuation upon displaying, without allocating.
- An iterator over the parts of an
AttributeValue
that should be displayed. - A collection of attributes, i.e. a key-value map.
- An iterator that is identical to a
Parser
, except that it also emits the location of each event within the input. - A parser that generates
Event
s from a Djot document.
Enums
- Alignment of a table column.
- A container that may contain other elements.
- A Djot event.
- The type of an inline link.
- The type of a list.
- Numbering type of an ordered list.
- Style of an ordered list.
- The type of an inline span link.
Traits
- A trait for rendering
Event
s to an output format.