src/compiler.js
function normalizeBlocks(input) {

    var numberOfLinesToIndent = 0;
    var thisLineContainsStuff = false;
    var thisLinesIndentation = '';
    var out = '';

    for (var i = 0; i < input.length; i++) {

        var chr = input[i];

        if (chr == '\r') {
            continue;
        }

        if (chr === '\n') {
            if (!thisLineContainsStuff) {
                numberOfLinesToIndent++;
            } else {
                out += '\n';
            }

            thisLineContainsStuff = false;
            thisLinesIndentation = '';
            continue;
        }

        if (!thisLineContainsStuff && (chr === ' ' || chr === '\t')) {
            thisLinesIndentation += chr;
            continue;
        }

        if (chr !== ' ' || chr !== '\t') {

            if (!thisLineContainsStuff) {
                for (var j = 0; j < numberOfLinesToIndent; j++) {
                    out += thisLinesIndentation + '\n';
                }

                out += thisLinesIndentation + chr;
            } else {
                out += chr;
            }

            numberOfLinesToIndent = 0;
            thisLineContainsStuff = true;

        }

    }

    return out;

}
function normalizeBlocks(input) {

    var numberOfLinesToIndent = 0;
    var thisLineContainsStuff = false;
    var thisLinesIndentation = '';
    var out = '';

    for (var i = 0; i < input.length; i++) {

        var chr = input[i];

        if (chr == '\r') {
            continue;
        }

        if (chr === '\n') {
            if (!thisLineContainsStuff) {
                numberOfLinesToIndent++;
            } else {
                out += '\n';
            }

            thisLineContainsStuff = false;
            thisLinesIndentation = '';
            continue;
        }

        if (!thisLineContainsStuff && (chr === ' ' || chr === '\t')) {
            thisLinesIndentation += chr;
            continue;
        }

        if (chr !== ' ' || chr !== '\t') {

            if (!thisLineContainsStuff) {
                for (var j = 0; j < numberOfLinesToIndent; j++) {
                    out += thisLinesIndentation + '\n';
                }

                out += thisLinesIndentation + chr;
            } else {
                out += chr;
            }

            numberOfLinesToIndent = 0;
            thisLineContainsStuff = true;

        }

    }

    return out;

}
function normalizeBlocks ( input ) { var numberOfLinesToIndent = 0 ; var thisLineContainsStuff = false ; var thisLinesIndentation = '' ; var out = '' ; for ( var i = 0 ; i < input . length ; i ++ ) { var chr = input [ i ] ; if ( chr == '\r' ) { continue ; } if ( chr === '\n' ) { if ( ! thisLineContainsStuff ) { numberOfLinesToIndent ++ ; } else { out += '\n' ; } thisLineContainsStuff = false ; thisLinesIndentation = '' ; continue ; } if ( ! thisLineContainsStuff && ( chr === ' ' || chr === '\t' ) ) { thisLinesIndentation += chr ; continue ; } if ( chr !== ' ' || chr !== '\t' ) { if ( ! thisLineContainsStuff ) { for ( var j = 0 ; j < numberOfLinesToIndent ; j ++ ) { out += thisLinesIndentation + '\n' ; } out += thisLinesIndentation + chr ; } else { out += chr ; } numberOfLinesToIndent = 0 ; thisLineContainsStuff = true ; } } return out ; }
Whenever we hit an indented block, make sure all preceding empty lines are made to have this indentation level
Whenever we hit an indented block make sure all preceding empty lines are made to have this indentation level