pub fn handle_hgroup(
_tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
if let Some(crate::dom::Node::Tag(tag)) = node_handle.get(parser) {
super::walk_tag_children(tag, parser, output, handler);
}
}
pub fn handle_dl(
_tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
if let Some(crate::dom::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::new();
super::walk_tag_children(tag, parser, &mut content, handler);
crate::converter::main_helpers::strip_trailing_backslash_breaks_from_fresh_buffer(
&mut content,
handler.options.newline_style,
);
let trimmed = content.trim();
if !trimmed.is_empty() {
if !output.is_empty() && !output.ends_with("\n\n") {
output.push_str("\n\n");
}
output.push_str(trimmed);
output.push_str("\n\n");
}
}
}
pub fn handle_dt(
_tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
if let Some(crate::dom::Node::Tag(tag)) = node_handle.get(parser) {
let mut content = String::with_capacity(64);
super::walk_tag_children(tag, parser, &mut content, handler);
crate::converter::main_helpers::strip_trailing_backslash_breaks_from_fresh_buffer(
&mut content,
handler.options.newline_style,
);
let trimmed = content.trim();
if !trimmed.is_empty() {
if handler.ctx.convert_as_inline {
output.push_str(trimmed);
} else {
output.push_str(trimmed);
output.push_str("\n\n");
}
}
}
}
pub fn handle_dd(
_tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
if let Some(crate::dom::Node::Tag(tag)) = node_handle.get(parser) {
let mut content = String::with_capacity(128);
super::walk_tag_children(tag, parser, &mut content, handler);
crate::converter::main_helpers::strip_trailing_backslash_breaks_from_fresh_buffer(
&mut content,
handler.options.newline_style,
);
let trimmed = content.trim();
if handler.ctx.convert_as_inline {
if !trimmed.is_empty() {
output.push_str(trimmed);
}
} else if !trimmed.is_empty() {
output.push_str(trimmed);
output.push_str("\n\n");
}
}
}
pub fn handle_menu(
_tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
let menu_options = crate::options::ConversionOptions {
bullets: "-".to_string(),
..handler.options.clone()
};
crate::converter::block::div::handle(
node_handle,
parser,
output,
crate::converter::block::container::HandlerContext::new(
&menu_options,
handler.ctx,
handler.depth,
handler.dom_ctx,
),
);
}
pub fn handle(
tag_name: &str,
node_handle: &crate::dom::NodeHandle,
parser: &crate::dom::Parser,
output: &mut String,
handler: super::HandlerContext<'_>,
) {
match tag_name {
"hgroup" => handle_hgroup(tag_name, node_handle, parser, output, handler),
"dl" => handle_dl(tag_name, node_handle, parser, output, handler),
"dt" => handle_dt(tag_name, node_handle, parser, output, handler),
"dd" => handle_dd(tag_name, node_handle, parser, output, handler),
"menu" => handle_menu(tag_name, node_handle, parser, output, handler),
_ => {}
}
}