@@ -266,7 +266,7 @@ function plainString(
266
266
onChompKeep ?: ( ) => void
267
267
) {
268
268
const { type, value } = item
269
- const { actualString, implicitKey, indent, inFlow } = ctx
269
+ const { actualString, implicitKey, indent, indentStep , inFlow } = ctx
270
270
if (
271
271
( implicitKey && / [ \n [ \] { } , ] / . test ( value ) ) ||
272
272
( inFlow && / [ [ \] { } , ] / . test ( value ) )
@@ -298,9 +298,13 @@ function plainString(
298
298
// Where allowed & type not set explicitly, prefer block style for multiline strings
299
299
return blockString ( item , ctx , onComment , onChompKeep )
300
300
}
301
- if ( indent === '' && containsDocumentMarker ( value ) ) {
302
- ctx . forceBlockIndent = true
303
- return blockString ( item , ctx , onComment , onChompKeep )
301
+ if ( containsDocumentMarker ( value ) ) {
302
+ if ( indent === '' ) {
303
+ ctx . forceBlockIndent = true
304
+ return blockString ( item , ctx , onComment , onChompKeep )
305
+ } else if ( implicitKey && indent === indentStep ) {
306
+ return quotedString ( value , ctx )
307
+ }
304
308
}
305
309
const str = value . replace ( / \n + / g, `$&\n${ indent } ` )
306
310
// Verify that output will be parsed as a string, as e.g. plain numbers and
0 commit comments