You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It should be trivial to configure different output renderers (HTML, RTF, ODT, LaTeX, etc.), and to create new ones (like Typst). I'm a bit uncertain on the ideal design ATM, however.
pluggable output renderers, starting with basic string, and maybe Djot integration #86
Here's how one uses jotdown, which has a Render trait to offer configurable output.
use jotdown::Render;let djot_input = "hello *world*!";let events = jotdown::Parser::new(djot_input);letmut html = String::new();
jotdown::html::Renderer::default().push(events,&mut html);assert_eq!(html,"<p>hello <strong>world</strong>!</p>\n");
While that's an event-based processor (hence the push method), and this isn't, here's how they define that trait:
pubtraitRender{/// Push owned [`Event`]s to a unicode-accepting buffer or stream.fnpush<'s,I,W>(&self,events:I,out:W) -> fmt::ResultwhereI:Iterator<Item = Event<'s>>,W: fmt::Write;/// Write owned [`Event`]s to a byte sink, encoded as UTF-8.////// NOTE: This performs many small writes, so IO writes should be buffered with e.g./// [`std::io::BufWriter`].fnwrite<'s,I,W>(&self,events:I,out:W) -> io::Result<()>whereI:Iterator<Item = Event<'s>>,W: io::Write,{letmut out = WriteAdapter{inner: out,error:Ok(()),};self.push(events,&mut out).map_err(|_| match out.error{Err(e) => e,
_ => io::Error::new(io::ErrorKind::Other,"formatter error"),})}
I can't figure out how I want to do #105, so just added a basic
refs_to_string function, so I have some final rendering.
Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
I can't figure out how I want to do #105, so just added a basic
refs_to_string function, so I have some final rendering.
Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
I can't figure out how I want to do #105, so just added a basic
refs_to_string function, so I have some final rendering.
Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
I can't figure out how I want to do #105, so just added a basic
refs_to_string function, so I have some final rendering.
Signed-off-by: Bruce D'Arcus <bdarcus@gmail.com>
It should be trivial to configure different output renderers (HTML, RTF, ODT, LaTeX, etc.), and to create new ones (like Typst). I'm a bit uncertain on the ideal design ATM, however.
Here's how one uses jotdown, which has a
Render
trait to offer configurable output.While that's an event-based processor (hence the
push
method), and this isn't, here's how they define that trait:Here's the stanza
Renderer
trait, and it's markdown implementation:The text was updated successfully, but these errors were encountered: