fixup! wip djot -> html

This commit is contained in:
Noah Hellman 2023-02-04 19:37:33 +01:00
parent 0420aad0a5
commit 7a26476315
2 changed files with 8 additions and 6 deletions

View file

@ -1,3 +1,5 @@
//! An HTML renderer that takes an iterator of [`Event`]s and emits HTML.
use crate::Alignment;
use crate::Atom;
use crate::Container;
@ -5,18 +7,18 @@ use crate::Event;
use crate::ListKind;
use crate::OrderedListNumbering::*;
/// Generate HTML from parsed events and push it to a unicode-accepting buffer or stream.
pub fn push<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write>(out: W, events: I) {
/// Generate HTML and push it to a unicode-accepting buffer or stream.
pub fn push<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write>(events: I, out: W) {
Writer::new(events, out).write().unwrap();
}
/// Generate HTML from parsed events and write it to a byte sink, encoded as UTF-8.
/// Generate HTML and write it 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`].
pub fn write<'s, I: Iterator<Item = Event<'s>>, W: std::io::Write>(
mut out: W,
events: I,
mut out: W,
) -> std::io::Result<()> {
struct Adapter<'a, T: ?Sized + 'a> {
inner: &'a mut T,

View file

@ -6,7 +6,7 @@ fn main() {
.read_to_string(&mut src)
.expect("failed to read utf-8 file");
let p = jotdown::Parser::new(&src);
let events = jotdown::Parser::new(&src);
let mut out = std::io::BufWriter::new(std::io::stdout());
jotdown::html::write(&mut out, p).unwrap();
jotdown::html::write(events, &mut out).unwrap();
}