diff --git a/YamlDotNet/Core/Emitter.cs b/YamlDotNet/Core/Emitter.cs index 9364f837f..53542f72a 100644 --- a/YamlDotNet/Core/Emitter.cs +++ b/YamlDotNet/Core/Emitter.cs @@ -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) @@ -403,6 +405,7 @@ private void AnalyzeScalar(Scalar scalar) if (previousBreak) { breakSpace = true; + lineOfSpaces = true; } previousSpace = true; @@ -425,6 +428,11 @@ private void AnalyzeScalar(Scalar scalar) spaceBreak = true; } + if (lineOfSpaces) + { + linesOfSpaces = true; + } + previousSpace = false; previousBreak = true; } @@ -432,6 +440,7 @@ private void AnalyzeScalar(Scalar scalar) { previousSpace = false; previousBreak = false; + lineOfSpaces = false; } preceededByWhitespace = buffer.IsWhiteBreakOrZero(); @@ -472,6 +481,9 @@ private void AnalyzeScalar(Scalar scalar) scalarData.isFlowPlainAllowed = false; scalarData.isBlockPlainAllowed = false; scalarData.isSingleQuotedAllowed = false; + } + if (linesOfSpaces) + { scalarData.isBlockAllowed = false; }