Finish property drawer parser but node property is unstarted.
This commit is contained in:
parent
2137b08e42
commit
f7f29e7a56
3
org_mode_samples/property_drawer/empty.org
Normal file
3
org_mode_samples/property_drawer/empty.org
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
|
||||||
|
:END:
|
@ -13,6 +13,7 @@ use super::lesser_element::Comment;
|
|||||||
use super::lesser_element::Paragraph;
|
use super::lesser_element::Paragraph;
|
||||||
use super::paragraph::paragraph;
|
use super::paragraph::paragraph;
|
||||||
use super::plain_list::plain_list;
|
use super::plain_list::plain_list;
|
||||||
|
use super::property_drawer::property_drawer;
|
||||||
use super::source::Source;
|
use super::source::Source;
|
||||||
use super::Context;
|
use super::Context;
|
||||||
use super::Drawer;
|
use super::Drawer;
|
||||||
@ -122,6 +123,7 @@ pub fn non_paragraph_element<'r, 's>(
|
|||||||
let dynamic_block_matcher = parser_with_context!(dynamic_block)(context);
|
let dynamic_block_matcher = parser_with_context!(dynamic_block)(context);
|
||||||
let footnote_definition_matcher = parser_with_context!(footnote_definition)(context);
|
let footnote_definition_matcher = parser_with_context!(footnote_definition)(context);
|
||||||
let comment_matcher = parser_with_context!(comment)(context);
|
let comment_matcher = parser_with_context!(comment)(context);
|
||||||
|
let property_drawer_matcher = parser_with_context!(property_drawer)(context);
|
||||||
let drawer_matcher = parser_with_context!(drawer)(context);
|
let drawer_matcher = parser_with_context!(drawer)(context);
|
||||||
alt((
|
alt((
|
||||||
map(plain_list_matcher, Element::PlainList),
|
map(plain_list_matcher, Element::PlainList),
|
||||||
@ -129,6 +131,7 @@ pub fn non_paragraph_element<'r, 's>(
|
|||||||
map(dynamic_block_matcher, Element::DynamicBlock),
|
map(dynamic_block_matcher, Element::DynamicBlock),
|
||||||
map(footnote_definition_matcher, Element::FootnoteDefinition),
|
map(footnote_definition_matcher, Element::FootnoteDefinition),
|
||||||
map(comment_matcher, Element::Comment),
|
map(comment_matcher, Element::Comment),
|
||||||
|
map(property_drawer_matcher, Element::PropertyDrawer),
|
||||||
map(drawer_matcher, Element::Drawer),
|
map(drawer_matcher, Element::Drawer),
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,13 @@ pub struct Drawer<'s> {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PropertyDrawer<'s> {
|
pub struct PropertyDrawer<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub name: &'s str,
|
pub children: Vec<NodeProperty<'s>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct NodeProperty<'s> {
|
||||||
|
pub source: &'s str,
|
||||||
|
pub indentation: usize,
|
||||||
|
pub bullet: &'s str,
|
||||||
pub children: Vec<Element<'s>>,
|
pub children: Vec<Element<'s>>,
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ use nom::character::complete::line_ending;
|
|||||||
use nom::character::complete::space0;
|
use nom::character::complete::space0;
|
||||||
use nom::combinator::eof;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::Context;
|
use super::Context;
|
||||||
@ -12,11 +13,15 @@ use crate::parser::error::CustomError;
|
|||||||
use crate::parser::error::MyError;
|
use crate::parser::error::MyError;
|
||||||
use crate::parser::error::Res;
|
use crate::parser::error::Res;
|
||||||
use crate::parser::exiting::ExitClass;
|
use crate::parser::exiting::ExitClass;
|
||||||
|
use crate::parser::greater_element::NodeProperty;
|
||||||
use crate::parser::greater_element::PropertyDrawer;
|
use crate::parser::greater_element::PropertyDrawer;
|
||||||
use crate::parser::parser_context::ContextElement;
|
use crate::parser::parser_context::ContextElement;
|
||||||
use crate::parser::parser_context::ExitMatcherNode;
|
use crate::parser::parser_context::ExitMatcherNode;
|
||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
|
use crate::parser::util::exit_matcher_parser;
|
||||||
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::immediate_in_section;
|
use crate::parser::util::immediate_in_section;
|
||||||
|
use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
@ -48,34 +53,17 @@ pub fn property_drawer<'r, 's>(
|
|||||||
exit_matcher: &property_drawer_end,
|
exit_matcher: &property_drawer_end,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// let element_matcher = parser_with_context!(element)(&parser_context);
|
let element_matcher = parser_with_context!(node_property)(&parser_context);
|
||||||
// let exit_matcher = parser_with_context!(exit_matcher_parser)(&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) {
|
let (remaining, (children, _exit_contents)) =
|
||||||
// Ok((remaining, (whitespace, (_children, _exit_contents)))) => (
|
many_till(element_matcher, exit_matcher)(remaining)?;
|
||||||
// remaining,
|
let (remaining, _end) = property_drawer_end(&parser_context, 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) =
|
let (remaining, _trailing_ws) =
|
||||||
// maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
// let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
|
||||||
// Ok((
|
Ok((remaining, PropertyDrawer { source, children }))
|
||||||
// remaining,
|
|
||||||
// Drawer {
|
|
||||||
// source,
|
|
||||||
// name: drawer_name,
|
|
||||||
// children,
|
|
||||||
// },
|
|
||||||
// ))
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
@ -88,3 +76,11 @@ fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
|||||||
alt((line_ending, eof)),
|
alt((line_ending, eof)),
|
||||||
)))(input)
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
|
pub fn node_property<'r, 's>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
) -> Res<&'s str, NodeProperty<'s>> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user