organic/src/parser/property_drawer.rs

64 lines
2.3 KiB
Rust
Raw Normal View History

use super::Context;
use crate::parser::error::CustomError;
use crate::parser::error::MyError;
use crate::parser::error::Res;
use crate::parser::greater_element::PropertyDrawer;
use crate::parser::util::immediate_in_section;
#[tracing::instrument(ret, level = "debug")]
pub fn property_drawer<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, PropertyDrawer<'s>> {
if immediate_in_section(context, "property-drawer") {
return Err(nom::Err::Error(CustomError::MyError(MyError(
"Cannot nest objects of the same element",
))));
}
// start_of_line(context, input)?;
// let (remaining, _leading_whitespace) = space0(input)?;
// let (remaining, (_open_colon, drawer_name, _close_colon, _new_line)) = tuple((
// tag(":"),
// name,
// tag(":"),
// recognize(tuple((space0, line_ending))),
// ))(remaining)?;
// let parser_context = context
// .with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
// .with_additional_node(ContextElement::Context("drawer"))
// .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
// class: ExitClass::Alpha,
// exit_matcher: &drawer_end,
// }));
// let element_matcher = parser_with_context!(element)(&parser_context);
// let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
// let (remaining, children) = match consumed(many_till(blank_line, exit_matcher))(remaining) {
// Ok((remaining, (whitespace, (_children, _exit_contents)))) => (
// remaining,
// vec![Element::Paragraph(Paragraph::of_text(whitespace))],
// ),
// Err(_) => {
// let (remaining, (children, _exit_contents)) =
// many_till(element_matcher, exit_matcher)(remaining)?;
// (remaining, children)
// }
// };
// let (remaining, _end) = drawer_end(&parser_context, remaining)?;
// let (remaining, _trailing_ws) =
// maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
// let source = get_consumed(input, remaining);
// Ok((
// remaining,
// Drawer {
// source,
// name: drawer_name,
// children,
// },
// ))
todo!()
}