This commit is contained in:
Cameron Ross 2020-09-19 18:27:24 -03:00 committed by The Dlang Bot
parent fb6d30e50e
commit bd549ca017
2 changed files with 20 additions and 2 deletions

View file

@ -385,3 +385,11 @@ struct Loader
auto rootNode = loader.load();
}
//Issue #258 - https://github.com/dlang-community/D-YAML/issues/258
@safe unittest
{
auto yaml = "{\n\"root\": {\n\t\"key\": \"value\"\n }\n}";
auto doc = Loader.fromString(yaml).load();
assert(doc.isValid);
}

View file

@ -57,6 +57,8 @@ alias isBreakOrSpace = among!(' ', '\0', '\n', '\r', '\u0085', '\u2028', '\u2029
alias isWhiteSpace = among!(' ', '\t', '\0', '\n', '\r', '\u0085', '\u2028', '\u2029');
alias isNonLinebreakWhitespace = among!(' ', '\t');
alias isNonScalarStartCharacter = among!('-', '?', ':', ',', '[', ']', '{', '}',
'#', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`', ' ', '\t', '\0', '\n',
'\r', '\u0085', '\u2028', '\u2029');
@ -800,8 +802,16 @@ struct Scanner
for(;;)
{
findNextNonSpace();
//All whitespace in flow context is ignored, even whitespace
// not allowed in other contexts
if (flowLevel_ > 0)
{
while(reader_.peekByte().isNonLinebreakWhitespace) { reader_.forward(); }
}
else
{
findNextNonSpace();
}
if(reader_.peekByte() == '#') { scanToNextBreak(); }
if(scanLineBreak() != '\0')
{