Skip to content

Commit

Permalink
Allow block style in multiline scalars with trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Himura2la committed Oct 27, 2020
1 parent 7714d0d commit 5326a7f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions YamlDotNet/Core/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,13 @@ private void AnalyzeScalar(Scalar scalar)
var spaceBreak = false;
var previousSpace = false;
var previousBreak = false;
var lineOfSpaces = false;

var lineBreaks = false;

var specialCharacters = !ValueIsRepresentableInOutputEncoding(value);
var singleQuotes = false;
var linesOfSpaces = false;

var isFirst = true;
while (!buffer.EndOfInput)
Expand Down Expand Up @@ -403,6 +405,7 @@ private void AnalyzeScalar(Scalar scalar)
if (previousBreak)
{
breakSpace = true;
lineOfSpaces = true;
}

previousSpace = true;
Expand All @@ -425,13 +428,19 @@ private void AnalyzeScalar(Scalar scalar)
spaceBreak = true;
}

if (lineOfSpaces)
{
linesOfSpaces = true;
}

previousSpace = false;
previousBreak = true;
}
else
{
previousSpace = false;
previousBreak = false;
lineOfSpaces = false;
}

preceededByWhitespace = buffer.IsWhiteBreakOrZero();
Expand Down Expand Up @@ -472,6 +481,9 @@ private void AnalyzeScalar(Scalar scalar)
scalarData.isFlowPlainAllowed = false;
scalarData.isBlockPlainAllowed = false;
scalarData.isSingleQuotedAllowed = false;
}
if (linesOfSpaces)
{
scalarData.isBlockAllowed = false;
}

Expand Down

0 comments on commit 5326a7f

Please sign in to comment.