use crate::converter::walk::Open;
use crate::dom::{NodeHandle, Parser};
use crate::options::ConversionOptions;
type Context = crate::converter::Context;
type DomContext = crate::converter::DomContext;
#[derive(Clone, Copy)]
pub struct HandlerContext<'a> {
pub options: &'a ConversionOptions,
pub ctx: &'a Context,
pub depth: usize,
pub dom_ctx: &'a DomContext,
}
impl<'a> HandlerContext<'a> {
pub const fn new(options: &'a ConversionOptions, ctx: &'a Context, depth: usize, dom_ctx: &'a DomContext) -> Self {
Self {
options,
ctx,
depth,
dom_ctx,
}
}
}
pub fn open_children(node_handle: &NodeHandle, parser: &Parser, children: &mut Vec<NodeHandle>) -> Option<Open> {
let Some(crate::dom::Node::Tag(tag)) = node_handle.get(parser) else {
return None;
};
children.extend(tag.children().top().iter().copied());
Some(Open::children_only())
}
pub fn handle_passthrough(node_handle: &NodeHandle, parser: &Parser, output: &mut String, handler: HandlerContext<'_>) {
crate::converter::main::walk_opened(parser, output, handler, |_, children| {
open_children(node_handle, parser, children)
});
}
#[inline]
pub const fn handle_noop() {}