yaml 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -230,7 +230,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
230
230
  }
231
231
  function plainString(item, ctx, onComment, onChompKeep) {
232
232
  const { type, value } = item;
233
- const { actualString, implicitKey, indent, inFlow } = ctx;
233
+ const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
234
234
  if ((implicitKey && /[\n[\]{},]/.test(value)) ||
235
235
  (inFlow && /[[\]{},]/.test(value))) {
236
236
  return quotedString(value, ctx);
@@ -254,9 +254,14 @@ function plainString(item, ctx, onComment, onChompKeep) {
254
254
  // Where allowed & type not set explicitly, prefer block style for multiline strings
255
255
  return blockString(item, ctx, onComment, onChompKeep);
256
256
  }
257
- if (indent === '' && containsDocumentMarker(value)) {
258
- ctx.forceBlockIndent = true;
259
- return blockString(item, ctx, onComment, onChompKeep);
257
+ if (containsDocumentMarker(value)) {
258
+ if (indent === '') {
259
+ ctx.forceBlockIndent = true;
260
+ return blockString(item, ctx, onComment, onChompKeep);
261
+ }
262
+ else if (implicitKey && indent === indentStep) {
263
+ return quotedString(value, ctx);
264
+ }
260
265
  }
261
266
  const str = value.replace(/\n+/g, `$&\n${indent}`);
262
267
  // Verify that output will be parsed as a string, as e.g. plain numbers and
@@ -232,7 +232,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
232
232
  }
233
233
  function plainString(item, ctx, onComment, onChompKeep) {
234
234
  const { type, value } = item;
235
- const { actualString, implicitKey, indent, inFlow } = ctx;
235
+ const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
236
236
  if ((implicitKey && /[\n[\]{},]/.test(value)) ||
237
237
  (inFlow && /[[\]{},]/.test(value))) {
238
238
  return quotedString(value, ctx);
@@ -256,9 +256,14 @@ function plainString(item, ctx, onComment, onChompKeep) {
256
256
  // Where allowed & type not set explicitly, prefer block style for multiline strings
257
257
  return blockString(item, ctx, onComment, onChompKeep);
258
258
  }
259
- if (indent === '' && containsDocumentMarker(value)) {
260
- ctx.forceBlockIndent = true;
261
- return blockString(item, ctx, onComment, onChompKeep);
259
+ if (containsDocumentMarker(value)) {
260
+ if (indent === '') {
261
+ ctx.forceBlockIndent = true;
262
+ return blockString(item, ctx, onComment, onChompKeep);
263
+ }
264
+ else if (implicitKey && indent === indentStep) {
265
+ return quotedString(value, ctx);
266
+ }
262
267
  }
263
268
  const str = value.replace(/\n+/g, `$&\n${indent}`);
264
269
  // Verify that output will be parsed as a string, as e.g. plain numbers and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",