yaml 2.2.1 → 2.2.2
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.
- package/browser/dist/errors.js +1 -1
- package/browser/dist/stringify/stringifyCollection.js +1 -1
- package/browser/dist/stringify/stringifyString.js +6 -6
- package/dist/errors.js +1 -1
- package/dist/stringify/stringifyCollection.js +1 -1
- package/dist/stringify/stringifyString.js +6 -6
- package/package.json +1 -1
package/browser/dist/errors.js
CHANGED
|
@@ -47,7 +47,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
47
47
|
let count = 1;
|
|
48
48
|
const end = error.linePos[1];
|
|
49
49
|
if (end && end.line === line && end.col > col) {
|
|
50
|
-
count = Math.min(end.col - col, 80 - ci);
|
|
50
|
+
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
51
51
|
}
|
|
52
52
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
53
53
|
error.message += `:\n\n${lineStr}\n${pointer}\n`;
|
|
@@ -133,7 +133,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
if (comment) {
|
|
136
|
-
str += lineComment(str, commentString(comment)
|
|
136
|
+
str += lineComment(str, indent, commentString(comment));
|
|
137
137
|
if (onComment)
|
|
138
138
|
onComment();
|
|
139
139
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Scalar } from '../nodes/Scalar.js';
|
|
2
2
|
import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js';
|
|
3
3
|
|
|
4
|
-
const getFoldOptions = (ctx) => ({
|
|
5
|
-
indentAtStart: ctx.indentAtStart,
|
|
4
|
+
const getFoldOptions = (ctx, isBlock) => ({
|
|
5
|
+
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
6
6
|
lineWidth: ctx.options.lineWidth,
|
|
7
7
|
minContentWidth: ctx.options.minContentWidth
|
|
8
8
|
});
|
|
@@ -115,7 +115,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
115
115
|
str = start ? str + json.slice(start) : json;
|
|
116
116
|
return implicitKey
|
|
117
117
|
? str
|
|
118
|
-
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
|
|
118
|
+
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
119
119
|
}
|
|
120
120
|
function singleQuotedString(value, ctx) {
|
|
121
121
|
if (ctx.options.singleQuote === false ||
|
|
@@ -127,7 +127,7 @@ function singleQuotedString(value, ctx) {
|
|
|
127
127
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
128
128
|
return ctx.implicitKey
|
|
129
129
|
? res
|
|
130
|
-
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
130
|
+
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
131
131
|
}
|
|
132
132
|
function quotedString(value, ctx) {
|
|
133
133
|
const { singleQuote } = ctx.options;
|
|
@@ -225,7 +225,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
225
225
|
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
226
226
|
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
227
227
|
.replace(/\n+/g, `$&${indent}`);
|
|
228
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx));
|
|
228
|
+
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
229
229
|
return `${header}\n${indent}${body}`;
|
|
230
230
|
}
|
|
231
231
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
@@ -275,7 +275,7 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
275
275
|
}
|
|
276
276
|
return implicitKey
|
|
277
277
|
? str
|
|
278
|
-
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
278
|
+
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
279
279
|
}
|
|
280
280
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
281
281
|
const { implicitKey, inFlow } = ctx;
|
package/dist/errors.js
CHANGED
|
@@ -49,7 +49,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
49
49
|
let count = 1;
|
|
50
50
|
const end = error.linePos[1];
|
|
51
51
|
if (end && end.line === line && end.col > col) {
|
|
52
|
-
count = Math.min(end.col - col, 80 - ci);
|
|
52
|
+
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
53
53
|
}
|
|
54
54
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
55
55
|
error.message += `:\n\n${lineStr}\n${pointer}\n`;
|
|
@@ -135,7 +135,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
if (comment) {
|
|
138
|
-
str += stringifyComment.lineComment(str, commentString(comment)
|
|
138
|
+
str += stringifyComment.lineComment(str, indent, commentString(comment));
|
|
139
139
|
if (onComment)
|
|
140
140
|
onComment();
|
|
141
141
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var Scalar = require('../nodes/Scalar.js');
|
|
4
4
|
var foldFlowLines = require('./foldFlowLines.js');
|
|
5
5
|
|
|
6
|
-
const getFoldOptions = (ctx) => ({
|
|
7
|
-
indentAtStart: ctx.indentAtStart,
|
|
6
|
+
const getFoldOptions = (ctx, isBlock) => ({
|
|
7
|
+
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
8
8
|
lineWidth: ctx.options.lineWidth,
|
|
9
9
|
minContentWidth: ctx.options.minContentWidth
|
|
10
10
|
});
|
|
@@ -117,7 +117,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
117
117
|
str = start ? str + json.slice(start) : json;
|
|
118
118
|
return implicitKey
|
|
119
119
|
? str
|
|
120
|
-
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
|
|
120
|
+
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
121
121
|
}
|
|
122
122
|
function singleQuotedString(value, ctx) {
|
|
123
123
|
if (ctx.options.singleQuote === false ||
|
|
@@ -129,7 +129,7 @@ function singleQuotedString(value, ctx) {
|
|
|
129
129
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
130
130
|
return ctx.implicitKey
|
|
131
131
|
? res
|
|
132
|
-
: foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
|
|
132
|
+
: foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
133
133
|
}
|
|
134
134
|
function quotedString(value, ctx) {
|
|
135
135
|
const { singleQuote } = ctx.options;
|
|
@@ -227,7 +227,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
227
227
|
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
228
228
|
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
229
229
|
.replace(/\n+/g, `$&${indent}`);
|
|
230
|
-
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx));
|
|
230
|
+
const body = foldFlowLines.foldFlowLines(`${start}${value}${end}`, indent, foldFlowLines.FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
231
231
|
return `${header}\n${indent}${body}`;
|
|
232
232
|
}
|
|
233
233
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
@@ -277,7 +277,7 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
277
277
|
}
|
|
278
278
|
return implicitKey
|
|
279
279
|
? str
|
|
280
|
-
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
|
|
280
|
+
: foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx, false));
|
|
281
281
|
}
|
|
282
282
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
283
283
|
const { implicitKey, inFlow } = ctx;
|