index.js
function() {
    var captures = this.scanIndentation();

    if (captures) {
      var indents = captures[1].length;

      this.incrementLine(1);
      this.consume(indents + 1);

      if (' ' == this.input[0] || '\t' == this.input[0]) {
        this.error('INVALID_INDENTATION', 'Invalid indentation, you can use tabs or spaces but not both');
      }

      // blank line
      if ('\n' == this.input[0]) {
        this.interpolationAllowed = true;
        return this.tok('newline');
      }

      // outdent
      if (indents < this.indentStack[0]) {
        while (this.indentStack[0] > indents) {
          if (this.indentStack[1] < indents) {
            this.error('INCONSISTENT_INDENTATION', 'Inconsistent indentation. Expecting either ' + this.indentStack[1] + ' or ' + this.indentStack[0] + ' spaces/tabs.');
          }
          this.colno = this.indentStack[1] + 1;
          this.tokens.push(this.tok('outdent'));
          this.indentStack.shift();
        }
      // indent
      } else if (indents && indents != this.indentStack[0]) {
        this.tokens.push(this.tok('indent', indents));
        this.colno = 1 + indents;
        this.indentStack.unshift(indents);
      // newline
      } else {
        this.tokens.push(this.tok('newline'));
        this.colno = 1 + (this.indentStack[0] || 0);
      }

      this.interpolationAllowed = true;
      return true;
    }
  }
function() {
    var captures = this.scanIndentation();

    if (captures) {
      var indents = captures[1].length;

      this.incrementLine(1);
      this.consume(indents + 1);

      if (' ' == this.input[0] || '\t' == this.input[0]) {
        this.error('INVALID_INDENTATION', 'Invalid indentation, you can use tabs or spaces but not both');
      }

      // blank line
      if ('\n' == this.input[0]) {
        this.interpolationAllowed = true;
        return this.tok('newline');
      }

      // outdent
      if (indents < this.indentStack[0]) {
        while (this.indentStack[0] > indents) {
          if (this.indentStack[1] < indents) {
            this.error('INCONSISTENT_INDENTATION', 'Inconsistent indentation. Expecting either ' + this.indentStack[1] + ' or ' + this.indentStack[0] + ' spaces/tabs.');
          }
          this.colno = this.indentStack[1] + 1;
          this.tokens.push(this.tok('outdent'));
          this.indentStack.shift();
        }
      // indent
      } else if (indents && indents != this.indentStack[0]) {
        this.tokens.push(this.tok('indent', indents));
        this.colno = 1 + indents;
        this.indentStack.unshift(indents);
      // newline
      } else {
        this.tokens.push(this.tok('newline'));
        this.colno = 1 + (this.indentStack[0] || 0);
      }

      this.interpolationAllowed = true;
      return true;
    }
  }
function ( ) { var captures = this . scanIndentation ( ) ; if ( captures ) { var indents = captures [ 1 ] . length ; this . incrementLine ( 1 ) ; this . consume ( indents + 1 ) ; if ( ' ' == this . input [ 0 ] || '\t' == this . input [ 0 ] ) { this . error ( 'INVALID_INDENTATION' , 'Invalid indentation, you can use tabs or spaces but not both' ) ; } // blank line if ( '\n' == this . input [ 0 ] ) { this . interpolationAllowed = true ; return this . tok ( 'newline' ) ; } // outdent if ( indents < this . indentStack [ 0 ] ) { while ( this . indentStack [ 0 ] > indents ) { if ( this . indentStack [ 1 ] < indents ) { this . error ( 'INCONSISTENT_INDENTATION' , 'Inconsistent indentation. Expecting either ' + this . indentStack [ 1 ] + ' or ' + this . indentStack [ 0 ] + ' spaces/tabs.' ) ; } this . colno = this . indentStack [ 1 ] + 1 ; this . tokens . push ( this . tok ( 'outdent' ) ) ; this . indentStack . shift ( ) ; } // indent } else if ( indents && indents != this . indentStack [ 0 ] ) { this . tokens . push ( this . tok ( 'indent' , indents ) ) ; this . colno = 1 + indents ; this . indentStack . unshift ( indents ) ; // newline } else { this . tokens . push ( this . tok ( 'newline' ) ) ; this . colno = 1 + ( this . indentStack [ 0 ] || 0 ) ; } this . interpolationAllowed = true ; return true ; } }
Indent | Outdent | Newline.
Indent | Outdent | Newline .