make headings contain links to themselves

This commit is contained in:
りき萌 2025-09-15 23:22:06 +02:00
parent 6ae6076f0d
commit 5a0b46690e

View file

@ -311,6 +311,9 @@ impl<'a> Writer<'a> {
} }
match c { match c {
Container::Heading { id, .. } => {
write!(out, r##"><a href="#{id}">"##)?;
}
Container::TableCell { alignment, .. } Container::TableCell { alignment, .. }
if !matches!(alignment, Alignment::Unspecified) => if !matches!(alignment, Alignment::Unspecified) =>
{ {
@ -445,7 +448,7 @@ impl<'a> Writer<'a> {
} }
out.push_str("</p>"); out.push_str("</p>");
} }
Container::Heading { level, .. } => write!(out, "</h{level}>")?, Container::Heading { level, .. } => write!(out, "</a></h{level}>")?,
Container::TableCell { head: false, .. } => out.push_str("</td>"), Container::TableCell { head: false, .. } => out.push_str("</td>"),
Container::TableCell { head: true, .. } => out.push_str("</th>"), Container::TableCell { head: true, .. } => out.push_str("</th>"),
Container::Caption => out.push_str("</caption>"), Container::Caption => out.push_str("</caption>"),