Support multiple commas when escaping lines.

This commit is contained in:
Tom Alexander 2023-10-04 16:03:45 -04:00
parent d059afef07
commit da5dcd4c1b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 13 additions and 4 deletions

View File

@ -1,7 +1,7 @@
#+begin_example
,* foo
,** bar
,*** baz
,,,** bar
,*** baz
lorem
, ipsum
,#+begin_src dolar

View File

@ -476,8 +476,17 @@ fn content_line<'s>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, (Option<OrgSource<'s>>, OrgSource<'s>)> {
let (remaining, pre_escape_whitespace) = opt(map(
tuple((space0, tag(","), peek(alt((tag("#+"), tag("*")))))),
|(pre_comma, _, _)| pre_comma,
tuple((
recognize(tuple((
space0,
many_till(
tag(","),
peek(tuple((tag(","), alt((tag("#+"), tag("*")))))),
),
))),
tag(","),
)),
|(pre_comma, _)| pre_comma,
))(input)?;
let (remaining, line_post_escape) = recognize(many_till(anychar, line_ending))(remaining)?;
Ok((remaining, (pre_escape_whitespace, line_post_escape)))