A ToSlice version of scanBlockScalarBreaks.
This commit is contained in:
parent
537c3c06f3
commit
0aa321f8c5
|
@ -1178,9 +1178,9 @@ final class Scanner
|
|||
else
|
||||
{
|
||||
indent += increment - 1;
|
||||
auto scalarBreaks = scanBlockScalarBreaks(indent);
|
||||
breaks = scalarBreaks[0];
|
||||
endMark = scalarBreaks[1];
|
||||
reader_.sliceBuilder.begin();
|
||||
endMark = scanBlockScalarBreaksToSlice(indent);
|
||||
breaks = reader_.sliceBuilder.finish();
|
||||
}
|
||||
|
||||
dchar[] lineBreak = ""d.dup;
|
||||
|
@ -1376,6 +1376,25 @@ final class Scanner
|
|||
return tuple(reader_.sliceBuilder.finish(), endMark);
|
||||
}
|
||||
|
||||
/// Scan line breaks at lower or specified indentation in a block scalar.
|
||||
///
|
||||
/// Assumes that the caller is building a slice in Reader, and puts the scanned
|
||||
/// characters into that slice.
|
||||
Mark scanBlockScalarBreaksToSlice(const uint indent) @trusted pure nothrow @nogc
|
||||
{
|
||||
Mark endMark = reader_.mark;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
while(reader_.column < indent && reader_.peek() == ' ') { reader_.forward(); }
|
||||
if(!"\n\r\u0085\u2028\u2029"d.canFind(reader_.peek())) { break; }
|
||||
reader_.sliceBuilder.write(scanLineBreak());
|
||||
endMark = reader_.mark;
|
||||
}
|
||||
|
||||
return endMark;
|
||||
}
|
||||
|
||||
/// Scan a qouted flow scalar token with specified quotes.
|
||||
///
|
||||
/// In case of an error, error_ is set. Use throwIfError() to handle this.
|
||||
|
|
Loading…
Reference in a new issue