Skip to content

Commit

Permalink
html: rework RenderMode into ChildRendering; simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Feb 25, 2025
1 parent 2f3792b commit 791da72
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 137 deletions.
6 changes: 3 additions & 3 deletions examples/custom_formatter.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use comrak::html::ChildRendering;
use comrak::{create_formatter, nodes::NodeValue};
use std::io::Write;

Expand All @@ -10,15 +11,14 @@ create_formatter!(CustomFormatter, {
}
},
NodeValue::Strong => |context, entering| {
use std::io::Write;
context.write_all(if entering { b"<b>" } else { b"</b>" })?;
},
NodeValue::Image(ref nl) => |context, node, entering, suppress_children| {
NodeValue::Image(ref nl) => |context, node, entering| {
assert!(node.data.borrow().sourcepos == (3, 1, 3, 18).into());
if entering {
context.write_all(nl.url.to_uppercase().as_bytes())?;
*suppress_children = true;
}
return Ok(ChildRendering::Skip);
},
});

Expand Down
Loading

0 comments on commit 791da72

Please sign in to comment.