feat: introduce Token struct
This commit is contained in:
parent
9004de9930
commit
6c27a9257f
23 changed files with 586 additions and 262 deletions
|
|
@ -168,10 +168,8 @@ impl Traverser for HtmlExport {
|
|||
#[tracing::instrument(skip(self, ctx))]
|
||||
fn snippet(&mut self, event: WalkEvent<&Snippet>, ctx: &mut TraversalContext) {
|
||||
if let WalkEvent::Enter(snippet) = event {
|
||||
if matches!(snippet.name(), Some(name) if name.text().eq_ignore_ascii_case("html")) {
|
||||
if let Some(value) = snippet.value() {
|
||||
self.output += value.text()
|
||||
}
|
||||
if snippet.backend().eq_ignore_ascii_case("html") {
|
||||
self.output += &snippet.value();
|
||||
}
|
||||
return ctx.skip();
|
||||
};
|
||||
|
|
@ -238,17 +236,16 @@ impl Traverser for HtmlExport {
|
|||
match event {
|
||||
WalkEvent::Enter(link) => {
|
||||
let path = link.path();
|
||||
let path = path.as_ref().map(|path| path.text()).unwrap_or_default();
|
||||
|
||||
if link.is_image() {
|
||||
let _ = write!(&mut self.output, r#"<img src="{}">"#, HtmlEscape(path));
|
||||
let _ = write!(&mut self.output, r#"<img src="{}">"#, HtmlEscape(&path));
|
||||
return ctx.skip();
|
||||
}
|
||||
|
||||
let _ = write!(&mut self.output, r#"<a href="{}">"#, HtmlEscape(path));
|
||||
let _ = write!(&mut self.output, r#"<a href="{}">"#, HtmlEscape(&path));
|
||||
|
||||
if !link.has_description() {
|
||||
let _ = write!(&mut self.output, "{}</a>", HtmlEscape(path));
|
||||
let _ = write!(&mut self.output, "{}</a>", HtmlEscape(&path));
|
||||
return ctx.skip();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue