Skip to content

Commit 68cfee5

Browse files
committed
Prepare 0.2.9 release
1 parent e1796d4 commit 68cfee5

17 files changed

+248
-154
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "yaml.js",
33
"main": "dist/yaml.js",
4-
"version": "0.2.3",
4+
"version": "0.2.9",
55
"homepage": "https://github.com/jeremyfa/yaml.js",
66
"authors": [
77
"Jeremy Faivre <contact@jeremyfa.com>"

dist/yaml.debug.js

Lines changed: 75 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/yaml.js

Lines changed: 74 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Dumper = (function() {
5353
module.exports = Dumper;
5454

5555

56-
},{"./Inline":5,"./Utils":9}],2:[function(require,module,exports){
56+
},{"./Inline":6,"./Utils":10}],2:[function(require,module,exports){
5757
var Escaper, Pattern;
5858

5959
Pattern = require('./Pattern');
@@ -111,7 +111,7 @@ Escaper = (function() {
111111
module.exports = Escaper;
112112

113113

114-
},{"./Pattern":7}],3:[function(require,module,exports){
114+
},{"./Pattern":8}],3:[function(require,module,exports){
115115
var DumpException,
116116
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
117117
hasProp = {}.hasOwnProperty;
@@ -170,7 +170,36 @@ module.exports = ParseException;
170170

171171

172172
},{}],5:[function(require,module,exports){
173-
var DumpException, Escaper, Inline, ParseException, Pattern, Unescaper, Utils,
173+
var ParseMore,
174+
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
175+
hasProp = {}.hasOwnProperty;
176+
177+
ParseMore = (function(superClass) {
178+
extend(ParseMore, superClass);
179+
180+
function ParseMore(message, parsedLine, snippet) {
181+
this.message = message;
182+
this.parsedLine = parsedLine;
183+
this.snippet = snippet;
184+
}
185+
186+
ParseMore.prototype.toString = function() {
187+
if ((this.parsedLine != null) && (this.snippet != null)) {
188+
return '<ParseMore> ' + this.message + ' (line ' + this.parsedLine + ': \'' + this.snippet + '\')';
189+
} else {
190+
return '<ParseMore> ' + this.message;
191+
}
192+
};
193+
194+
return ParseMore;
195+
196+
})(Error);
197+
198+
module.exports = ParseMore;
199+
200+
201+
},{}],6:[function(require,module,exports){
202+
var DumpException, Escaper, Inline, ParseException, ParseMore, Pattern, Unescaper, Utils,
174203
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
175204

176205
Pattern = require('./Pattern');
@@ -183,6 +212,8 @@ Utils = require('./Utils');
183212

184213
ParseException = require('./Exception/ParseException');
185214

215+
ParseMore = require('./Exception/ParseMore');
216+
186217
DumpException = require('./Exception/DumpException');
187218

188219
Inline = (function() {
@@ -391,7 +422,7 @@ Inline = (function() {
391422
var i, match, output;
392423
i = context.i;
393424
if (!(match = this.PATTERN_QUOTED_SCALAR.exec(scalar.slice(i)))) {
394-
throw new ParseException('Malformed inline YAML string (' + scalar.slice(i) + ').');
425+
throw new ParseMore('Malformed inline YAML string (' + scalar.slice(i) + ').');
395426
}
396427
output = match[0].substr(1, match[0].length - 2);
397428
if ('"' === scalar.charAt(i)) {
@@ -443,7 +474,7 @@ Inline = (function() {
443474
}
444475
++i;
445476
}
446-
throw new ParseException('Malformed inline YAML string ' + sequence);
477+
throw new ParseMore('Malformed inline YAML string ' + sequence);
447478
};
448479

449480
Inline.parseMapping = function(mapping, context) {
@@ -511,7 +542,7 @@ Inline = (function() {
511542
}
512543
}
513544
}
514-
throw new ParseException('Malformed inline YAML string ' + mapping);
545+
throw new ParseMore('Malformed inline YAML string ' + mapping);
515546
};
516547

517548
Inline.evaluateScalar = function(scalar, context) {
@@ -654,8 +685,8 @@ Inline = (function() {
654685
module.exports = Inline;
655686

656687

657-
},{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Pattern":7,"./Unescaper":8,"./Utils":9}],6:[function(require,module,exports){
658-
var Inline, ParseException, Parser, Pattern, Utils;
688+
},{"./Escaper":2,"./Exception/DumpException":3,"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Pattern":8,"./Unescaper":9,"./Utils":10}],7:[function(require,module,exports){
689+
var Inline, ParseException, ParseMore, Parser, Pattern, Utils;
659690

660691
Inline = require('./Inline');
661692

@@ -665,6 +696,8 @@ Utils = require('./Utils');
665696

666697
ParseException = require('./Exception/ParseException');
667698

699+
ParseMore = require('./Exception/ParseMore');
700+
668701
Parser = (function() {
669702
Parser.prototype.PATTERN_FOLDED_SCALAR_ALL = new Pattern('^(?:(?<type>![^\\|>]*)\\s+)?(?<separator>\\||>)(?<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?<comments> +#.*)?$');
670703

@@ -684,13 +717,13 @@ Parser = (function() {
684717

685718
Parser.prototype.PATTERN_TRAILING_LINES = new Pattern('(\n*)$');
686719

687-
Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n');
720+
Parser.prototype.PATTERN_YAML_HEADER = new Pattern('^\\%YAML[: ][\\d\\.]+.*\n', 'm');
688721

689-
Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+');
722+
Parser.prototype.PATTERN_LEADING_COMMENTS = new Pattern('^(\\#.*?\n)+', 'm');
690723

691-
Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n');
724+
Parser.prototype.PATTERN_DOCUMENT_MARKER_START = new Pattern('^\\-\\-\\-.*?\n', 'm');
692725

693-
Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$');
726+
Parser.prototype.PATTERN_DOCUMENT_MARKER_END = new Pattern('^\\.\\.\\.\\s*$', 'm');
694727

695728
Parser.prototype.PATTERN_FOLDED_SCALAR_BY_INDENTATION = {};
696729

@@ -979,18 +1012,16 @@ Parser = (function() {
9791012
if (indent === newIndent) {
9801013
removeComments = !removeCommentsPattern.test(this.currentLine);
9811014
}
982-
if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) {
983-
this.moveToPreviousLine();
984-
break;
1015+
if (removeComments && this.isCurrentLineComment()) {
1016+
continue;
9851017
}
9861018
if (this.isCurrentLineBlank()) {
9871019
data.push(this.currentLine.slice(newIndent));
9881020
continue;
9891021
}
990-
if (removeComments && this.isCurrentLineComment()) {
991-
if (indent === newIndent) {
992-
continue;
993-
}
1022+
if (isItUnindentedCollection && !this.isStringUnIndentedCollectionItem(this.currentLine) && indent === newIndent) {
1023+
this.moveToPreviousLine();
1024+
break;
9941025
}
9951026
if (indent >= newIndent) {
9961027
data.push(this.currentLine.slice(newIndent));
@@ -1019,7 +1050,7 @@ Parser = (function() {
10191050
};
10201051

10211052
Parser.prototype.parseValue = function(value, exceptionOnInvalidType, objectDecoder) {
1022-
var e, error, error1, foldedIndent, matches, modifiers, pos, ref, ref1, val;
1053+
var e, error, foldedIndent, matches, modifiers, pos, ref, ref1, val;
10231054
if (0 === value.indexOf('*')) {
10241055
pos = value.indexOf('#');
10251056
if (pos !== -1) {
@@ -1046,25 +1077,26 @@ Parser = (function() {
10461077
return val;
10471078
}
10481079
}
1049-
try {
1050-
return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1051-
} catch (error) {
1052-
e = error;
1053-
if (((ref1 = value.charAt(0)) === '[' || ref1 === '{') && e instanceof ParseException && this.isNextLineIndented()) {
1054-
value += "\n" + this.getNextEmbedBlock();
1080+
if ((ref1 = value.charAt(0)) === '[' || ref1 === '{' || ref1 === '"' || ref1 === "'") {
1081+
while (true) {
10551082
try {
10561083
return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
1057-
} catch (error1) {
1058-
e = error1;
1059-
e.parsedLine = this.getRealCurrentLineNb() + 1;
1060-
e.snippet = this.currentLine;
1061-
throw e;
1084+
} catch (error) {
1085+
e = error;
1086+
if (e instanceof ParseMore && this.moveToNextLine()) {
1087+
value += "\n" + Utils.trim(this.currentLine, ' ');
1088+
} else {
1089+
e.parsedLine = this.getRealCurrentLineNb() + 1;
1090+
e.snippet = this.currentLine;
1091+
throw e;
1092+
}
10621093
}
1063-
} else {
1064-
e.parsedLine = this.getRealCurrentLineNb() + 1;
1065-
e.snippet = this.currentLine;
1066-
throw e;
10671094
}
1095+
} else {
1096+
if (this.isNextLineIndented()) {
1097+
value += "\n" + this.getNextEmbedBlock();
1098+
}
1099+
return Inline.parse(value, exceptionOnInvalidType, objectDecoder);
10681100
}
10691101
};
10701102

@@ -1258,7 +1290,7 @@ Parser = (function() {
12581290
module.exports = Parser;
12591291

12601292

1261-
},{"./Exception/ParseException":4,"./Inline":5,"./Pattern":7,"./Utils":9}],7:[function(require,module,exports){
1293+
},{"./Exception/ParseException":4,"./Exception/ParseMore":5,"./Inline":6,"./Pattern":8,"./Utils":10}],8:[function(require,module,exports){
12621294
var Pattern;
12631295

12641296
Pattern = (function() {
@@ -1366,7 +1398,7 @@ Pattern = (function() {
13661398
count = 0;
13671399
while (this.regex.test(str) && (limit === 0 || count < limit)) {
13681400
this.regex.lastIndex = 0;
1369-
str = str.replace(this.regex, '');
1401+
str = str.replace(this.regex, replacement);
13701402
count++;
13711403
}
13721404
return [str, count];
@@ -1379,7 +1411,7 @@ Pattern = (function() {
13791411
module.exports = Pattern;
13801412

13811413

1382-
},{}],8:[function(require,module,exports){
1414+
},{}],9:[function(require,module,exports){
13831415
var Pattern, Unescaper, Utils;
13841416

13851417
Utils = require('./Utils');
@@ -1464,7 +1496,7 @@ Unescaper = (function() {
14641496
module.exports = Unescaper;
14651497

14661498

1467-
},{"./Pattern":7,"./Utils":9}],9:[function(require,module,exports){
1499+
},{"./Pattern":8,"./Utils":10}],10:[function(require,module,exports){
14681500
var Pattern, Utils,
14691501
hasProp = {}.hasOwnProperty;
14701502

@@ -1680,7 +1712,7 @@ Utils = (function() {
16801712
}
16811713
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
16821714
if (tz_offset) {
1683-
date.setTime(date.getTime() + tz_offset);
1715+
date.setTime(date.getTime() - tz_offset);
16841716
}
16851717
return date;
16861718
};
@@ -1764,7 +1796,7 @@ Utils = (function() {
17641796
module.exports = Utils;
17651797

17661798

1767-
},{"./Pattern":7}],10:[function(require,module,exports){
1799+
},{"./Pattern":8}],11:[function(require,module,exports){
17681800
var Dumper, Parser, Utils, Yaml;
17691801

17701802
Parser = require('./Parser');
@@ -1870,4 +1902,4 @@ if (typeof window === "undefined" || window === null) {
18701902
module.exports = Yaml;
18711903

18721904

1873-
},{"./Dumper":1,"./Parser":6,"./Utils":9}]},{},[10]);
1905+
},{"./Dumper":1,"./Parser":7,"./Utils":10}]},{},[11]);

dist/yaml.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Dumper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Escaper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Exception/DumpException.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Exception/ParseException.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Exception/ParseMore.js

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)