Commits

Ross Light committed f262957

Strip indents in block literal scalar trailing newlines

  • Participants
  • Parent commits 69b09f1

Comments (0)

Files changed (2)

 		}
 	case chompKeep:
 		// keep-empty
-		// TODO: This should strip indents
-		i := s.index
 		for s.tryEmptyLine(indent, blockIn) {
+			val = append(val, '\n')
 		}
-		val = s.buf[i:s.index]
 	}
 	s.tryTrailComments(indent)
 	return

File scanner_test.go

 		},
 	},
 	{
+		"Block literal scalar (keep trailing newlines)",
+		" |+\n  A\n\n   B\n  C\n \n",
+		[]Token{
+			{TokenScalar, Position{1, 1, 2}, Position{20, 7, 1}, "A\n\n B\nC\n\n"},
+			{TokenStreamEnd, Position{20, 7, 1}, Position{20, 7, 1}, ""},
+		},
+	},
+	{
 		"Block folded scalar",
 		">\n A\n\n B\n C\n",
 		[]Token{