parent
750c992121
commit
11cffc6df8
2 changed files with 31 additions and 1 deletions
|
@ -1853,7 +1853,10 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
|||
while !self.buffer.is_empty() && self.mark.col < indent && self.ch() == ' ' {
|
||||
self.skip_blank();
|
||||
}
|
||||
if !(!self.buffer.is_empty() && self.mark.col < indent && self.ch() == ' ') {
|
||||
// If we reached our indent, we can break. We must also break if we have
|
||||
// reached content or EOF; that is, the buffer is not empty and the next
|
||||
// character is not a space.
|
||||
if self.mark.col == indent || (!self.buffer.is_empty() && self.ch() != ' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,6 +201,33 @@ foobar";
|
|||
]
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_large_block_scalar_indent() {
|
||||
// https://github.com/Ethiraric/yaml-rust2/issues/29
|
||||
// https://github.com/saphyr-rs/saphyr-parser/issues/2
|
||||
// Tests the `loop` fallback of `skip_block_scalar_indent`. The indent in the YAML string must
|
||||
// be greater than `BUFFER_LEN - 2`. The second line is further indented with spaces, and the
|
||||
// resulting string should be "a\n b".
|
||||
let s = "
|
||||
a: |-
|
||||
a
|
||||
b
|
||||
";
|
||||
|
||||
assert_eq!(
|
||||
run_parser(s).unwrap(),
|
||||
[
|
||||
Event::StreamStart,
|
||||
Event::DocumentStart,
|
||||
Event::MappingStart(0, None),
|
||||
Event::Scalar("a".to_string(), TScalarStyle::Plain, 0, None),
|
||||
Event::Scalar("a\n b".to_string(), TScalarStyle::Literal, 0, None),
|
||||
Event::MappingEnd,
|
||||
Event::DocumentEnd,
|
||||
Event::StreamEnd,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bad_docstart() {
|
||||
|
|
Loading…
Reference in a new issue