#![forbid(unsafe_code)]
pub mod forbid_h1;
pub mod forbidden_sections;
pub mod required_sections;
pub mod section_order;
use mdtype_core::nodes::{AstNode, NodeValue};
use mdtype_core::BodyRuleFactory;
pub(crate) fn heading_text<'a>(heading: &'a AstNode<'a>) -> String {
let mut buf = String::new();
for desc in heading.descendants().skip(1) {
let data = desc.data.borrow();
match &data.value {
NodeValue::Text(t) => buf.push_str(t),
NodeValue::Code(c) => buf.push_str(&c.literal),
_ => {}
}
}
buf
}
#[must_use]
pub fn register_stdlib() -> Vec<Box<dyn BodyRuleFactory>> {
vec![
Box::new(forbid_h1::Factory),
Box::new(required_sections::Factory),
Box::new(section_order::Factory),
Box::new(forbidden_sections::Factory),
]
}