feat: handle <thead> in html export

This commit is contained in:
PoiScript 2023-11-15 12:55:35 +08:00
parent 1362624083
commit db7fb70724
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
5 changed files with 300 additions and 14 deletions

View file

@ -30,12 +30,15 @@ impl Traverser for MyHtmlHandler {
let level = title.headline().and_then(|h| h.level()).unwrap_or(1);
let level = min(level, 6);
let raw = title.syntax().to_string();
self.0.output += &format!("<h{level}><a id=\"{0}\" href=\"#{0}\">", slugify!(&raw));
self.0.push_str(format!(
"<h{level}><a id=\"{0}\" href=\"#{0}\">",
slugify!(&raw)
));
}
WalkEvent::Leave(title) => {
let level = title.headline().and_then(|h| h.level()).unwrap_or(1);
let level = min(level, 6);
self.0.output += &format!("</a></h{level}>");
self.0.push_str(format!("</a></h{level}>"));
}
}
}