use html5ever::tendril::TendrilSink;
use markup5ever_rcdom::{NodeData, RcDom};
use moli_html2md::{Dom, NodeKind};
/// An independent test adapter. Parsing and copying happen only in tests;
/// the production converter sees the same four borrowed queries as NativeDom.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Tree {
pub nodes: Vec,
pub root: usize,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Node {
pub tag: Option,
pub text: Option,
pub attrs: Vec<(String, String)>,
pub first: Option,
pub next: Option,
}
impl Tree {
pub fn parse(html: &str) -> Self {
let parsed = html5ever::parse_document(RcDom::default(), Default::default()).one(format!(
"{html}"
));
let mut nodes: Vec = Vec::new();
let mut root = 0;
// RcDom's destructor clears descendants even when handles survive.
// Keep the parsed document alive until the complete arena is copied.
let mut stack = vec![(parsed.document.clone(), None::)];
let mut last_children: Vec