Support trailing whitespace in fixed-width areas.

This commit is contained in:
Tom Alexander 2023-09-14 03:15:31 -04:00
parent 876d33239e
commit 22681b6a58
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -3,15 +3,17 @@ use nom::bytes::complete::is_not;
use nom::bytes::complete::tag;
use nom::character::complete::line_ending;
use nom::character::complete::space0;
use nom::character::complete::space1;
use nom::combinator::eof;
use nom::combinator::not;
use nom::combinator::opt;
use nom::combinator::recognize;
use nom::multi::many0;
use nom::sequence::preceded;
use nom::sequence::tuple;
use super::org_source::OrgSource;
use super::util::org_line_ending;
use super::util::org_spaces0;
use super::util::org_spaces1;
use crate::context::parser_with_context;
use crate::context::RefContext;
use crate::error::Res;
@ -47,10 +49,10 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>(
) -> Res<OrgSource<'s>, OrgSource<'s>> {
start_of_line(input)?;
let (remaining, _indent) = space0(input)?;
let (remaining, (_colon, _leading_whitespace_and_content, _line_ending)) = tuple((
let (remaining, _) = tuple((
tag(":"),
opt(tuple((space1, is_not("\r\n")))),
alt((line_ending, eof)),
alt((recognize(tuple((org_spaces1, is_not("\r\n")))), org_spaces0)),
org_line_ending,
))(remaining)?;
let source = get_consumed(input, remaining);
Ok((remaining, source))