Fix parsing of # comments in text
This commit is contained in:
+8
-6
@@ -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)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user