jotkey
Types
A renderer for a djot document, knows how to turn each block or inline element into some custom view. That view could be anything, but it’s typically a Lustre element.
Some ideas for other renderers include:
- A renderer that turns a djot document into a JSON object
- A renderer that generates a table of contents
- A renderer that generates Nakai elements instead of Lustre ones
This renderer is compatible with v1.0.2 of the jot package.
For more advanced usage check examples implementing context aware renderers
pub type Renderer(view, context) {
Renderer(
codeblock: fn(
Dict(String, String),
Option(String),
String,
context,
) ->
view,
emphasis: fn(List(view), context) -> view,
heading: fn(Dict(String, String), Int, List(view), context) ->
view,
link: fn(
jot.Destination,
Dict(String, String),
List(view),
context,
) ->
view,
paragraph: fn(Dict(String, String), List(view), context) ->
view,
strong: fn(List(view), context) -> view,
text: fn(String, context) -> view,
code: fn(String, context) -> view,
image: fn(jot.Destination, String, context) -> view,
linebreak: fn(context) -> view,
)
}
Constructors
-
Renderer( codeblock: fn( Dict(String, String), Option(String), String, context, ) -> view, emphasis: fn(List(view), context) -> view, heading: fn(Dict(String, String), Int, List(view), context) -> view, link: fn( jot.Destination, Dict(String, String), List(view), context, ) -> view, paragraph: fn(Dict(String, String), List(view), context) -> view, strong: fn(List(view), context) -> view, text: fn(String, context) -> view, code: fn(String, context) -> view, image: fn(jot.Destination, String, context) -> view, linebreak: fn(context) -> view, )
Functions
pub fn default_renderer() -> Renderer(Element(a), b)
The default renderer generates some sensible Lustre elements from a djot document. You can use this if you need a quick drop-in renderer for some markup in a Lustre project.