html: do not emit newline in beginning
This commit is contained in:
parent
7a26476315
commit
2811493c34
1 changed files with 4 additions and 1 deletions
|
@ -78,6 +78,7 @@ struct Writer<'s, I: Iterator<Item = Event<'s>>, W> {
|
||||||
encountered_footnote: bool,
|
encountered_footnote: bool,
|
||||||
footnote_number: Option<std::num::NonZeroUsize>,
|
footnote_number: Option<std::num::NonZeroUsize>,
|
||||||
footnote_backlink_written: bool,
|
footnote_backlink_written: bool,
|
||||||
|
first_line: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
|
impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
|
||||||
|
@ -91,6 +92,7 @@ impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
|
||||||
encountered_footnote: false,
|
encountered_footnote: false,
|
||||||
footnote_number: None,
|
footnote_number: None,
|
||||||
footnote_backlink_written: false,
|
footnote_backlink_written: false,
|
||||||
|
first_line: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +100,7 @@ impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
|
||||||
while let Some(e) = self.events.next() {
|
while let Some(e) = self.events.next() {
|
||||||
match e {
|
match e {
|
||||||
Event::Start(c, attrs) => {
|
Event::Start(c, attrs) => {
|
||||||
if c.is_block() {
|
if c.is_block() && !self.first_line {
|
||||||
self.out.write_char('\n')?;
|
self.out.write_char('\n')?;
|
||||||
}
|
}
|
||||||
if self.text_only && !matches!(c, Container::Image(..)) {
|
if self.text_only && !matches!(c, Container::Image(..)) {
|
||||||
|
@ -427,6 +429,7 @@ impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<'s, I, W> {
|
||||||
self.out.write_str(">")?;
|
self.out.write_str(">")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.first_line = false;
|
||||||
}
|
}
|
||||||
if self.encountered_footnote {
|
if self.encountered_footnote {
|
||||||
self.out.write_str("\n</ol>\n</section>")?;
|
self.out.write_str("\n</ol>\n</section>")?;
|
||||||
|
|
Loading…
Reference in a new issue