Building the plain list item context.
This commit is contained in:
@@ -14,8 +14,6 @@ use nom::multi::many1_count;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use crate::parser::element::element;
|
||||
use crate::parser::error::CustomError;
|
||||
use crate::parser::error::MyError;
|
||||
use crate::parser::object::standard_set_object;
|
||||
use crate::parser::parser_context::ChainBehavior;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
@@ -28,7 +26,7 @@ use super::object::Object;
|
||||
use super::parser_with_context::parser_with_context;
|
||||
use super::source::Source;
|
||||
use super::util::get_consumed;
|
||||
use super::util::get_one_before;
|
||||
use super::util::start_of_line;
|
||||
use super::util::trailing_whitespace;
|
||||
use super::Context;
|
||||
|
||||
@@ -117,7 +115,6 @@ fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Hea
|
||||
not(|i| context.check_exit_matcher(i))(input)?;
|
||||
let (remaining, (star_count, _ws, title, _ws2)) = headline(context, input)?;
|
||||
let section_matcher = parser_with_context!(section)(context);
|
||||
// TODO: This needs to only match headings below the current level
|
||||
let heading_matcher = parser_with_context!(heading)(context);
|
||||
let (remaining, children) = many0(alt((
|
||||
map(
|
||||
@@ -159,26 +156,6 @@ fn headline<'r, 's>(
|
||||
Ok((remaining, (star_count, ws, title, ws2)))
|
||||
}
|
||||
|
||||
fn headline_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
fn headline_end<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
alt((line_ending, eof))(input)
|
||||
}
|
||||
|
||||
/// Check that we are at the start of a line
|
||||
fn start_of_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||
let document_root = context.get_document_root().unwrap();
|
||||
let preceding_character = get_one_before(document_root, input)
|
||||
.map(|slice| slice.chars().next())
|
||||
.flatten();
|
||||
match preceding_character {
|
||||
Some('\n') => {}
|
||||
Some(_) => {
|
||||
// Not at start of line, cannot be a heading
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Not at start of line",
|
||||
))));
|
||||
}
|
||||
// If None, we are at the start of the file which allows for headings
|
||||
None => {}
|
||||
};
|
||||
Ok((input, ()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user