Fix parsing of # comments in text

This commit is contained in:
2026-01-23 03:15:27 -08:00
parent 4f6f8fbc1a
commit d1a1801ef8
+8 -6
View File
@@ -485,10 +485,12 @@ fn parse_keys(s: &str) -> [bool; 7] {
keys keys
} }
/// Check if the next non-whitespace is a section header. /// Check if the next non-whitespace/non-comment is a section header.
fn peek_section(input: &str) -> bool { fn peek_section(input: &str) -> bool {
let trimmed = input.trim_start(); match ws(input) {
trimmed.starts_with('[') Ok((rest, _)) => rest.starts_with('['),
Err(_) => false,
}
} }
/// Check if input is at end or only has whitespace/comments. /// Check if input is at end or only has whitespace/comments.
@@ -862,9 +864,9 @@ fn parse_board_section(input: &str) -> Result<(&str, Board), ParseError> {
// Parse stats // Parse stats
while !at_end(input) { while !at_end(input) {
// Check if next section is a stat // Check if next section is a stat (skip whitespace and comments first)
let trimmed = input.trim_start(); let after_ws = ws(input).map(|(rest, _)| rest).unwrap_or(input);
if !trimmed.starts_with("[stat") { if !after_ws.starts_with("[stat") {
break; break;
} }
let (next, stat) = parse_stat_section(input, &board.tiles)?; let (next, stat) = parse_stat_section(input, &board.tiles)?;