Skip to content
Browse files

Fixed; retain original indentation spaces in text blocks

  • Loading branch information...
1 parent a3b4a54 commit 87f8dba3cce775d9757ba887a032ee4a0e5793ae @tj tj committed
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/parser.js
View
10 lib/parser.js
@@ -295,11 +295,12 @@ Parser.prototype = {
* indent (text | newline)* outdent
*/
- parseTextBlock: function(indent){
- indent = indent || '';
+ parseTextBlock: function(){
var text = new nodes.Text;
text.line = this.line();
- this.expect('indent');
+ var spaces = this.expect('indent').val;
+ if (null == this._spaces) this._spaces = spaces;
+ var indent = Array(spaces - this._spaces + 1).join(' ');
while ('outdent' != this.peek().type) {
switch (this.peek().type) {
case 'newline':
@@ -308,7 +309,7 @@ Parser.prototype = {
break;
case 'indent':
text.push('\\n');
- this.parseTextBlock(indent + ' ').nodes.forEach(function(node){
+ this.parseTextBlock().nodes.forEach(function(node){
text.push(node);
});
text.push('\\n');
@@ -317,6 +318,7 @@ Parser.prototype = {
text.push(indent + this.advance().val);
}
}
+ this._spaces = null;
this.expect('outdent');
return text;
},

0 comments on commit 87f8dba

Please sign in to comment.
Something went wrong with that request. Please try again.