Make the empty drawer honor an immediate exit condition.
This commit is contained in:
parent
189edaa24a
commit
cade02eb72
@ -5,6 +5,7 @@ use nom::bytes::complete::take_while;
|
|||||||
use nom::character::complete::line_ending;
|
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::not;
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
@ -55,20 +56,24 @@ pub fn drawer<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
|
|
||||||
let element_matcher = parser_with_context!(element(true))(&parser_context);
|
let element_matcher = parser_with_context!(element(true))(&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) =
|
let (remaining, children) = match tuple((
|
||||||
match tuple((blank_line, many_till(blank_line, exit_matcher)))(remaining) {
|
not(exit_matcher),
|
||||||
Ok((remain, (first_line, (_trailing_whitespace, _exit_contents)))) => {
|
blank_line,
|
||||||
let mut element = Element::Paragraph(Paragraph::of_text(first_line));
|
many_till(blank_line, exit_matcher),
|
||||||
let source = get_consumed(remaining, remain);
|
))(remaining)
|
||||||
element.set_source(source);
|
{
|
||||||
(remain, vec![element])
|
Ok((remain, (_not_immediate_exit, first_line, (_trailing_whitespace, _exit_contents)))) => {
|
||||||
}
|
let mut element = Element::Paragraph(Paragraph::of_text(first_line));
|
||||||
Err(_) => {
|
let source = get_consumed(remaining, remain);
|
||||||
let (remaining, (children, _exit_contents)) =
|
element.set_source(source);
|
||||||
many_till(element_matcher, exit_matcher)(remaining)?;
|
(remain, vec![element])
|
||||||
(remaining, children)
|
}
|
||||||
}
|
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, _end) = drawer_end(&parser_context, remaining)?;
|
||||||
|
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
@ -1 +1,6 @@
|
|||||||
foo *bar* baz
|
[fn:1] footnote.
|
||||||
|
:drawername:
|
||||||
|
|
||||||
|
|
||||||
|
:end:
|
||||||
|
Is this still in the footnote?
|
||||||
|
Loading…
Reference in New Issue
Block a user