yaml
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
@@ -157,3 +157,15 @@ "use strict"; | ||
ch = src[offset]; | ||
atLineStart = false; | ||
atLineStart = false; // Need to reset lineStart here if preceding node's range has advanced to | ||
// check the current line's indentation level -- eemeli/yaml#10 | ||
if (ch && ch !== '\n' && ch !== '#') { | ||
var ls = offset - 1; | ||
var prev = src[ls]; | ||
while (prev === ' ' || prev === '\t') { | ||
prev = src[--ls]; | ||
} | ||
if (prev === '\n') lineStart = ls + 1; | ||
} | ||
} | ||
@@ -160,0 +172,0 @@ |
@@ -8,2 +8,6 @@ "use strict"; | ||
var _Node = _interopRequireDefault(require("./ast/Node")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -35,2 +39,6 @@ | ||
if (!message || !(source instanceof _Node.default)) { | ||
throw new Error('Invalid arguments for new YAMLReferenceError'); | ||
} | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(YAMLReferenceError).call(this)); | ||
@@ -58,2 +66,6 @@ _this.name = 'YAMLReferenceError'; | ||
if (!message || !(source instanceof _Node.default)) { | ||
throw new Error('Invalid arguments for new YAMLSemanticError'); | ||
} | ||
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(YAMLSemanticError).call(this)); | ||
@@ -81,2 +93,6 @@ _this2.name = 'YAMLSemanticError'; | ||
if (!message || !(source instanceof _Node.default)) { | ||
throw new Error('Invalid arguments for new YAMLSyntaxError'); | ||
} | ||
_this3 = _possibleConstructorReturn(this, _getPrototypeOf(YAMLSyntaxError).call(this)); | ||
@@ -104,2 +120,6 @@ _this3.name = 'YAMLSyntaxError'; | ||
if (!message || !(source instanceof _Node.default)) { | ||
throw new Error('Invalid arguments for new YAMLWarning'); | ||
} | ||
_this4 = _possibleConstructorReturn(this, _getPrototypeOf(YAMLWarning).call(this)); | ||
@@ -106,0 +126,0 @@ _this4.name = 'YAMLWarning'; |
@@ -153,4 +153,4 @@ "use strict"; | ||
var nextItem = map.items[i + 1]; | ||
if (!nextItem || nextItem.type !== _Node.Type.MAP_VALUE) this.doc.errors.push(new _errors.YAMLSemanticError(item.node, 'Implicit map keys need to be followed by map values')); | ||
if (item.valueRangeContainsNewline) this.doc.errors.push(new _errors.YAMLSemanticError(item.node, 'Implicit map keys need to be on a single line')); | ||
if (!nextItem || nextItem.type !== _Node.Type.MAP_VALUE) this.doc.errors.push(new _errors.YAMLSemanticError(item, 'Implicit map keys need to be followed by map values')); | ||
if (item.valueRangeContainsNewline) this.doc.errors.push(new _errors.YAMLSemanticError(item, 'Implicit map keys need to be on a single line')); | ||
} | ||
@@ -198,2 +198,7 @@ } | ||
keyStart = null; | ||
if (item === ',') { | ||
next = ':'; | ||
continue; | ||
} | ||
} | ||
@@ -204,3 +209,3 @@ } | ||
if (i === map.items.length - 1) continue; | ||
} else if (item === next || next === ':' && item === ',') { | ||
} else if (item === next) { | ||
next = ':'; | ||
@@ -225,2 +230,3 @@ continue; | ||
if (map.items[map.items.length - 1] !== '}') this.doc.errors.push(new _errors.YAMLSemanticError(map, 'Expected flow map to end with }')); | ||
if (key !== undefined) this.items.push(new _Pair.default(key)); | ||
@@ -227,0 +233,0 @@ } |
@@ -64,12 +64,21 @@ "use strict"; | ||
var valueStr = doc.schema.stringify(doc, value, opt, onComment); | ||
var vcb = value && value.commentBefore ? " #".concat(value.commentBefore.replace(/\n+(?!\n|$)/g, "$&".concat(opt.indent, "#"))) : ''; | ||
if (explicitKey) { | ||
return "? ".concat(keyStr, "\n").concat(indent, ": ").concat(valueStr); | ||
return "? ".concat(keyStr, "\n").concat(indent, ":").concat(vcb ? "".concat(vcb, "\n").concat(opt.indent) : ' ').concat(valueStr); | ||
} else if (value instanceof _Collection.default) { | ||
return "".concat(keyStr, ":\n").concat(opt.indent).concat(valueStr); | ||
return "".concat(keyStr, ":").concat(vcb, "\n").concat(opt.indent).concat(valueStr); | ||
} else { | ||
return "".concat(keyStr, ": ").concat(valueStr); | ||
return "".concat(keyStr, ":").concat(vcb ? "".concat(vcb, "\n").concat(opt.indent) : ' ').concat(valueStr); | ||
} | ||
} | ||
}, { | ||
key: "commentBefore", | ||
get: function get() { | ||
return this.key && this.key.commentBefore; | ||
}, | ||
set: function set(cb) { | ||
return this.key && this.key.commentBefore; | ||
} | ||
}, { | ||
key: "comment", | ||
@@ -76,0 +85,0 @@ get: function get() { |
{ | ||
"name": "yaml", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
199921
4369