fixup! wip djot -> html
This commit is contained in:
parent
0420aad0a5
commit
7a26476315
2 changed files with 8 additions and 6 deletions
10
src/html.rs
10
src/html.rs
|
@ -1,3 +1,5 @@
|
||||||
|
//! An HTML renderer that takes an iterator of [`Event`]s and emits HTML.
|
||||||
|
|
||||||
use crate::Alignment;
|
use crate::Alignment;
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use crate::Container;
|
use crate::Container;
|
||||||
|
@ -5,18 +7,18 @@ use crate::Event;
|
||||||
use crate::ListKind;
|
use crate::ListKind;
|
||||||
use crate::OrderedListNumbering::*;
|
use crate::OrderedListNumbering::*;
|
||||||
|
|
||||||
/// Generate HTML from parsed events and push it to a unicode-accepting buffer or stream.
|
/// 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>(out: W, events: I) {
|
pub fn push<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write>(events: I, out: W) {
|
||||||
Writer::new(events, out).write().unwrap();
|
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.
|
/// NOTE: This performs many small writes, so IO writes should be buffered with e.g.
|
||||||
/// [`std::io::BufWriter`].
|
/// [`std::io::BufWriter`].
|
||||||
pub fn write<'s, I: Iterator<Item = Event<'s>>, W: std::io::Write>(
|
pub fn write<'s, I: Iterator<Item = Event<'s>>, W: std::io::Write>(
|
||||||
mut out: W,
|
|
||||||
events: I,
|
events: I,
|
||||||
|
mut out: W,
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
struct Adapter<'a, T: ?Sized + 'a> {
|
struct Adapter<'a, T: ?Sized + 'a> {
|
||||||
inner: &'a mut T,
|
inner: &'a mut T,
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
.read_to_string(&mut src)
|
.read_to_string(&mut src)
|
||||||
.expect("failed to read utf-8 file");
|
.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());
|
let mut out = std::io::BufWriter::new(std::io::stdout());
|
||||||
jotdown::html::write(&mut out, p).unwrap();
|
jotdown::html::write(events, &mut out).unwrap();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue