Add support for indenting greater blocks.
This commit is contained in:
parent
ab329f367f
commit
42fca12e41
@ -15,6 +15,7 @@ use nom::branch::alt;
|
||||
use nom::bytes::complete::is_not;
|
||||
use nom::bytes::complete::tag_no_case;
|
||||
use nom::character::complete::line_ending;
|
||||
use nom::character::complete::space0;
|
||||
use nom::character::complete::space1;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::opt;
|
||||
@ -27,6 +28,8 @@ pub fn greater_block<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, GreaterBlock<'s>> {
|
||||
start_of_line(context, input)?;
|
||||
let (remaining, _leading_whitespace) = space0(input)?;
|
||||
// TODO: Not handling indentation before start of block
|
||||
let (remaining, (_begin, name)) = tuple((
|
||||
tag_no_case("#+begin_"),
|
||||
@ -34,7 +37,7 @@ pub fn greater_block<'r, 's>(
|
||||
"comment" | "example" | "export" | "src" | "verse" => false,
|
||||
_ => true,
|
||||
}),
|
||||
))(input)?;
|
||||
))(remaining)?;
|
||||
let (remaining, parameters) = opt(tuple((space1, parameters)))(remaining)?;
|
||||
let (remaining, _nl) = line_ending(remaining)?;
|
||||
let parser_context = context
|
||||
@ -81,11 +84,12 @@ fn greater_block_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'
|
||||
let current_name: &str = get_context_greater_block_name(context).ok_or(nom::Err::Error(
|
||||
CustomError::MyError(MyError("Not inside a greater block")),
|
||||
))?;
|
||||
let (remaining, _leading_whitespace) = space0(input)?;
|
||||
let (remaining, (_begin, _name, _ws)) = tuple((
|
||||
tag_no_case("#+end_"),
|
||||
tag_no_case(current_name),
|
||||
alt((eof, line_ending)),
|
||||
))(input)?;
|
||||
))(remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((remaining, source))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user