From a9ce70aae3e5f6ab7e12e9574deb5f38afa2b988 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Sun, 22 Jan 2023 17:42:47 +0100 Subject: [PATCH] html: render tight lists --- src/html.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/html.rs b/src/html.rs index 9956392..f9b772b 100644 --- a/src/html.rs +++ b/src/html.rs @@ -71,6 +71,7 @@ struct Writer<'s, I: Iterator>, W> { out: W, raw: Raw, text_only: bool, + list_tightness: Vec, encountered_footnote: bool, footnote_number: Option, footnote_backlink_written: bool, @@ -83,6 +84,7 @@ impl<'s, I: Iterator>, W: std::fmt::Write> Writer<'s, I, W> { out, raw: Raw::None, text_only: false, + list_tightness: Vec::new(), encountered_footnote: false, footnote_number: None, footnote_backlink_written: false, @@ -147,7 +149,12 @@ impl<'s, I: Iterator>, W: std::fmt::Write> Writer<'s, I, W> { Container::Table => self.out.write_str(" self.out.write_str(" self.out.write_str(" self.out.write_str(" { + if matches!(self.list_tightness.last(), Some(true)) { + continue; + } + self.out.write_str(" write!(self.out, " self.out.write_str(" self.out.write_str(">, W: std::fmt::Write> Writer<'s, I, W> { kind: ListKind::Unordered | ListKind::Task, .. } => { + self.list_tightness.pop(); self.out.write_str("")?; } Container::List { @@ -298,6 +306,9 @@ impl<'s, I: Iterator>, W: std::fmt::Write> Writer<'s, I, W> { Container::TableRow => self.out.write_str("")?, Container::Div { .. } => self.out.write_str("")?, Container::Paragraph => { + if matches!(self.list_tightness.last(), Some(true)) { + continue; + } if let Some(num) = self.footnote_number { if matches!( self.events.peek(),