Capture the trailing whitespace for the file as regular trailing whitespace for elements.
This makes our ranges for sections and headlines match up with the emacs org-mode parser for the example at org_mode_samples/sections_and_headings/sections_and_headings.org.
This commit is contained in:
parent
a456acd1e9
commit
4dbf8b9c69
@ -1,9 +1,8 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use nom::combinator::eof;
|
||||||
use nom::IResult;
|
use nom::IResult;
|
||||||
|
|
||||||
use crate::parser::util::whitespace_eof;
|
|
||||||
|
|
||||||
use super::error::CustomError;
|
use super::error::CustomError;
|
||||||
use super::error::MyError;
|
use super::error::MyError;
|
||||||
use super::error::Res;
|
use super::error::Res;
|
||||||
@ -25,7 +24,7 @@ impl<'r, 's> ContextTree<'r, 's> {
|
|||||||
|
|
||||||
pub fn branch_from(trunk: &Rc<Node<ContextElement<'r, 's>>>) -> Self {
|
pub fn branch_from(trunk: &Rc<Node<ContextElement<'r, 's>>>) -> Self {
|
||||||
ContextTree {
|
ContextTree {
|
||||||
tree: List::branch_from(trunk)
|
tree: List::branch_from(trunk),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ impl<'r, 's> ContextTree<'r, 's> {
|
|||||||
i: &'s str,
|
i: &'s str,
|
||||||
) -> IResult<&'s str, &'s str, CustomError<&'s str>> {
|
) -> IResult<&'s str, &'s str, CustomError<&'s str>> {
|
||||||
// Special check for EOF. We don't just make this a document-level exit matcher since the IgnoreParent ChainBehavior could cause early exit matchers to not run.
|
// Special check for EOF. We don't just make this a document-level exit matcher since the IgnoreParent ChainBehavior could cause early exit matchers to not run.
|
||||||
let at_end_of_file = whitespace_eof(i);
|
let at_end_of_file = eof(i);
|
||||||
if at_end_of_file.is_ok() {
|
if at_end_of_file.is_ok() {
|
||||||
return at_end_of_file;
|
return at_end_of_file;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user