Crate jotdown

Source
Expand description

A pull parser for Djot.

The main entry is through Parser which constructs an Iterator of Events. The events can then be processed before rendering them via the Render trait. This crate provides an html module that implements an HTML renderer.

§Feature flags

  • html (default): build the html module and a binary that converts djot to HTML.

§Examples

Generate HTML from Djot input:

let djot_input = "hello *world*!";
let events = jotdown::Parser::new(djot_input);
let html = jotdown::html::render_to_string(events);
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 html = jotdown::html::render_to_string(events);
assert_eq!(html, "<p>a <a href=\"https://example.net\">link</a></p>\n");

Modules§

html
An HTML renderer that takes an iterator of Events and emits HTML.

Structs§

AttributeValue
Stores an attribute value that supports backslash escapes of ASCII punctuation upon displaying, without allocating.
AttributeValueParts
An iterator over the parts of an AttributeValue that should be displayed.
Attributes
A set of attributes, with order, duplicates and comments preserved.
OffsetIter
An iterator that is identical to a Parser, except that it also emits the location of each event within the input.
ParseAttributesError
Parser
A parser that generates Events from a Djot document.

Enums§

Alignment
Alignment of a table column.
AttributeKind
The kind of an element within an attribute set.
Container
A container that may contain other elements.
Event
A Djot event.
LinkType
The type of an inline link.
ListBulletType
Character used to create an unordered list item.
ListKind
The type of a list.
OrderedListNumbering
Numbering type of an ordered list.
OrderedListStyle
Style of an ordered list.
SpanLinkType
The type of an inline span link.

Traits§

Render
A trait for rendering Events to an output format.