summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Parser.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Parser.js b/lib/Parser.js
index 3a8ae74..d62dd7f 100644
--- a/lib/Parser.js
+++ b/lib/Parser.js
@@ -528,7 +528,7 @@ Parser = (function() {
};
Parser.prototype.cleanup = function(value) {
- var count, trimmedValue, _ref, _ref1, _ref2;
+ var count, i, indent, line, lines, smallestIndent, trimmedValue, _i, _j, _len, _len1, _ref, _ref1, _ref2;
if (value.indexOf("\r") !== -1) {
value = value.split("\r\n").join("\n").split("\r").join("\n");
}
@@ -546,6 +546,22 @@ Parser = (function() {
value = trimmedValue;
value = this.PATTERN_DOCUMENT_MARKER_END.replace(value, '');
}
+ lines = value.split("\n");
+ smallestIndent = -1;
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
+ line = lines[_i];
+ indent = line.length - Utils.ltrim(line).length;
+ if (smallestIndent === -1 || indent < smallestIndent) {
+ smallestIndent = indent;
+ }
+ }
+ if (smallestIndent > 0) {
+ for (i = _j = 0, _len1 = lines.length; _j < _len1; i = ++_j) {
+ line = lines[i];
+ lines[i] = line.slice(smallestIndent);
+ }
+ value = lines.join("\n");
+ }
return value;
};