2023-10-24 00:36:08 -04:00
|
|
|
use crate::error::CustomError;
|
|
|
|
|
2023-10-27 14:43:06 -04:00
|
|
|
use super::registry::Registry;
|
2023-10-27 13:05:34 -04:00
|
|
|
use super::IObject;
|
2023-10-24 00:51:28 -04:00
|
|
|
|
2023-10-24 00:36:08 -04:00
|
|
|
#[derive(Debug)]
|
2023-10-27 13:05:34 -04:00
|
|
|
pub(crate) struct IHeading {
|
2023-10-27 12:47:12 -04:00
|
|
|
pub(crate) level: organic::types::HeadlineLevel,
|
2023-10-27 13:05:34 -04:00
|
|
|
pub(crate) title: Vec<IObject>,
|
2023-10-24 00:51:28 -04:00
|
|
|
}
|
2023-10-24 00:36:08 -04:00
|
|
|
|
2023-10-27 13:05:34 -04:00
|
|
|
impl IHeading {
|
2023-10-27 15:55:19 -04:00
|
|
|
pub(crate) async fn new<'parse>(
|
2023-10-27 14:54:54 -04:00
|
|
|
registry: &mut Registry<'parse>,
|
|
|
|
heading: &organic::types::Heading<'parse>,
|
2023-10-27 14:43:06 -04:00
|
|
|
) -> Result<IHeading, CustomError> {
|
2023-10-27 15:55:19 -04:00
|
|
|
let title = {
|
|
|
|
let mut ret = Vec::new();
|
|
|
|
for obj in heading.title.iter() {
|
|
|
|
ret.push(IObject::new(registry, obj).await?);
|
|
|
|
}
|
|
|
|
ret
|
|
|
|
};
|
2023-10-27 13:05:34 -04:00
|
|
|
Ok(IHeading {
|
2023-10-27 12:14:07 -04:00
|
|
|
title,
|
|
|
|
level: heading.level,
|
|
|
|
})
|
2023-10-24 00:36:08 -04:00
|
|
|
}
|
|
|
|
}
|