pub fn handle(
_tag_name: &str,
node_handle: &tl::NodeHandle,
parser: &tl::Parser,
output: &mut String,
options: &crate::options::ConversionOptions,
ctx: &super::Context,
depth: usize,
dom_ctx: &super::DomContext,
) {
if let Some(tl::Node::Tag(tag)) = node_handle.get(parser) {
if ctx.convert_as_inline {
let children = tag.children();
{
for child_handle in children.top().iter() {
super::walk_node(child_handle, parser, output, options, ctx, depth + 1, dom_ctx);
}
}
return;
}
let mut content = String::with_capacity(256);
let children = tag.children();
{
let section_ctx = crate::converter::list::utils::nested_block_context(output, ctx, options);
for child_handle in children.top().iter() {
super::walk_node(
child_handle,
parser,
&mut content,
options,
§ion_ctx,
depth + 1,
dom_ctx,
);
}
}
crate::converter::main_helpers::strip_trailing_backslash_breaks_from_fresh_buffer(
&mut content,
options.newline_style,
);
if content.trim().is_empty() {
return;
}
if ctx.in_list_item && !ctx.in_table_cell && !output.is_empty() {
crate::converter::list::utils::start_block_in_list_item(output, ctx, 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, 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");
}
}
}