pub fn handle(
_tag_name: &str,
node_handle: &tl::NodeHandle,
parser: &tl::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
if let Some(tl::Node::Tag(tag)) = node_handle.get(parser) {
if handler.ctx.convert_as_inline {
super::walk_tag_children(tag, parser, output, handler);
return;
}
let mut content = String::with_capacity(256);
let section_ctx = crate::converter::list::utils::nested_block_context(output, handler.ctx, handler.options);
super::walk_tag_children(
tag,
parser,
&mut content,
super::HandlerContext::new(handler.options, §ion_ctx, handler.depth, handler.dom_ctx),
);
crate::converter::main_helpers::strip_trailing_backslash_breaks_from_fresh_buffer(
&mut content,
handler.options.newline_style,
);
if content.trim().is_empty() {
return;
}
if handler.ctx.in_list_item && !handler.ctx.in_table_cell && !output.is_empty() {
crate::converter::list::utils::start_block_in_list_item(output, handler.ctx, handler.options);
} else if !output.is_empty() && !output.ends_with("\n\n") {
output.push_str("\n\n");
}
crate::converter::block::horizontal_rule::separate_leading_rule(output, &content, handler.ctx);
output.push_str(&content);
if content.ends_with('\n') && !content.ends_with("\n\n") {
output.push('\n');
} else if !content.ends_with('\n') {
output.push_str("\n\n");
}
}
}