Fix possible misindent in block scalar.
This commit is contained in:
parent
0a1aebaf3c
commit
0b58be1458
2 changed files with 16 additions and 7 deletions
|
@ -681,7 +681,10 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
|||
self.fetch_document_indicator(TokenType::DocumentEnd)?;
|
||||
self.skip_ws_to_eol(SkipTabs::Yes);
|
||||
if !is_breakz(self.ch()) {
|
||||
return Err(ScanError::new(self.mark, "invalid content after document end marker"));
|
||||
return Err(ScanError::new(
|
||||
self.mark,
|
||||
"invalid content after document end marker",
|
||||
));
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -1690,7 +1693,18 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
|||
}
|
||||
}
|
||||
|
||||
*indent = max_indent.max((self.indent + 1) as usize).max(1);
|
||||
// In case a yaml looks like:
|
||||
// ```yaml
|
||||
// |
|
||||
// foo
|
||||
// bar
|
||||
// ```
|
||||
// We need to set the indent to 0 and not 1. In all other cases, the indent must be at
|
||||
// least 1. When in the above example, `self.indent` will be set to -1.
|
||||
*indent = max_indent.max((self.indent + 1) as usize);
|
||||
if self.indent > 0 {
|
||||
*indent = (*indent).max(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_flow_scalar(&mut self, single: bool) -> ScanResult {
|
||||
|
|
|
@ -297,11 +297,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
|
|||
|
||||
#[rustfmt::skip]
|
||||
static EXPECTED_FAILURES: &[&str] = &[
|
||||
// Bare document after end marker
|
||||
"M7A3",
|
||||
// Scalar marker on document start line
|
||||
"DK3J",
|
||||
"FP8R",
|
||||
// Comments on nonempty lines need leading space
|
||||
"9JBA",
|
||||
"CVW2",
|
||||
|
|
Loading…
Reference in a new issue