From 50d05b99bea4cadca676f9301815edfda85ab9bd Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 15 Apr 2023 17:08:22 -0400 Subject: [PATCH] Require space after hash in comment if comment line is not empty. --- src/parser/comment.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser/comment.rs b/src/parser/comment.rs index f304ac8e..34c2ee0a 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -3,6 +3,7 @@ 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; @@ -38,8 +39,8 @@ pub fn comment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, fn comment_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { start_of_line(context, input)?; let (remaining, _indent) = space0(input)?; - let (remaining, (_hash, _leading_whitespace, _content, _line_ending)) = - tuple((tag("#"), space0, opt(is_not("\r\n")), alt((line_ending, eof))))(remaining)?; + let (remaining, (_hash, _leading_whitespace_and_content, _line_ending)) = + tuple((tag("#"), opt(tuple((space1, is_not("\r\n")))), alt((line_ending, eof))))(remaining)?; let source = get_consumed(input, remaining); Ok((remaining, source)) }