html: skip href attr when url empty

This commit is contained in:
Noah Hellman 2023-01-16 23:31:47 +01:00
parent d3a98e6626
commit a4511db0a8

View file

@ -91,7 +91,13 @@ impl<'s, I: Iterator<Item = Event<'s>>, W: std::fmt::Write> Writer<I, W> {
Container::DescriptionTerm => self.out.write_str("<dt")?,
Container::CodeBlock { .. } => self.out.write_str("<pre")?,
Container::Span | Container::Math { .. } => self.out.write_str("<span")?,
Container::Link(dst, ..) => write!(self.out, r#"<a href="{}""#, dst)?,
Container::Link(dst, ..) => {
if dst.is_empty() {
self.out.write_str("<a")?;
} else {
write!(self.out, r#"<a href="{}""#, dst)?;
}
}
Container::Image(..) => {
self.text_only = true;
self.out.write_str("<img")?;