use super::ListContext;
use super::utils::{
ListChildrenContext, add_list_leading_separator, add_nested_list_trailing_separator, calculate_list_nesting_depth,
is_loose_list, preceding_same_type_list_separator_comment, process_list_children,
};
use tl;
#[allow(clippy::too_many_arguments)]
pub fn handle_ul(node_handle: &tl::NodeHandle, parser: &tl::Parser, output: &mut String, context: ListContext<'_>) {
if super::render_itemless_list_as_div(node_handle, parser, output, context) {
return;
}
let ListContext {
options, ctx, dom_ctx, ..
} = context;
let separator_comment = preceding_same_type_list_separator_comment(*node_handle, parser, dom_ctx, "ul");
add_list_leading_separator(output, ctx, options);
if let Some(comment) = separator_comment {
output.push_str(&comment);
output.push_str("\n\n");
}
let nested_depth = calculate_list_nesting_depth(ctx);
let is_loose = is_loose_list(*node_handle, parser, dom_ctx);
#[allow(unused_variables)]
let tag = match node_handle.get(parser) {
Some(tl::Node::Tag(t)) => t,
_ => return,
};
#[cfg(feature = "visitor")]
let list_output_start = output.len();
#[cfg(feature = "visitor")]
let list_start_custom = match super::visit_list_start(node_handle, tag, parser, output, context, false) {
super::ListStartResult::Continue(custom) => custom,
super::ListStartResult::Stop => return,
};
if !ctx.in_table_cell {
if let Some(ref sc) = ctx.structure_collector {
sc.borrow_mut().push_list_start(false);
}
}
process_list_children(
*node_handle,
parser,
output,
ListChildrenContext {
list: context,
ordered: false,
loose: is_loose,
nested_depth,
start_counter: 1,
delimiter: None,
},
);
if !ctx.in_table_cell {
if let Some(ref sc) = ctx.structure_collector {
sc.borrow_mut().push_list_end();
}
}
add_nested_list_trailing_separator(output, ctx);
#[cfg(feature = "visitor")]
super::visit_list_end(
node_handle,
tag,
parser,
output,
context,
super::ListVisitorOutput {
start: list_output_start,
custom_start: list_start_custom,
ordered: false,
},
);
}
pub use handle_ul as handle;