Skip to content

Render to Djot from events #97

@declanvk

Description

@declanvk

Hello, thank you for the jotdown library!

I'd like to add a new Render implementation that outputs the events back to djot format.

My motivation is I've been using jotdown as part of a simple static site generator. As part of the generator, I have a couple passes which modify the content of each djot document. For example one pass will try to find a starting raw block like:

```{=json}
{
    "draft": true
}
```

And read and remove it to be used as frontmatter (since djot hasn't standardized on frontmatter yet [I think]). Right now I use the .into_offset_iter() function to find the offset of the "frontmatter" block and remove it from the original string.

The problem comes up when I'd like to write more complex transformations, like replacing symbols or rewriting links. I'd like to render the modified events back to a djot string and the re-parse if needed.

I realize an alternative would be to store the modified events in a Vec or something and modify that array before the final rendering to HTML. Let me know what your thoughts are! I can also maintain this outside of the jotdown crate to start.

Thanks again,
Declan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions