MetaScript.js
function indent(str, indent) {
            if (typeof indent === 'number') {
                var indent_str = '';
                while (indent_str.length < indent) indent_str += ' ';
                indent = indent_str;
            }
            var lines = str.split(/\n/);
            for (var i=0; i<lines.length; i++) {
                if (lines[i].trim() !== '')
                    lines[i] = indent + lines[i];
            }
            return lines.join("\n");            
        }
function indent(str, indent) {
            if (typeof indent === 'number') {
                var indent_str = '';
                while (indent_str.length < indent) indent_str += ' ';
                indent = indent_str;
            }
            var lines = str.split(/\n/);
            for (var i=0; i<lines.length; i++) {
                if (lines[i].trim() !== '')
                    lines[i] = indent + lines[i];
            }
            return lines.join("\n");            
        }
function indent ( str , indent ) { if ( typeof indent === 'number' ) { var indent_str = '' ; while ( indent_str . length < indent ) indent_str += ' ' ; indent = indent_str ; } var lines = str . split ( / \n / ) ; for ( var i = 0 ; i < lines . length ; i ++ ) { if ( lines [ i ] . trim ( ) !== '' ) lines [ i ] = indent + lines [ i ] ; } return lines . join ( "\n" ) ; }
Indents a block of text.
@function indent
@param {string} str Text to indent
@param {string|number} indent Whitespace text to use for indentation or the number of whitespaces to use
@returns {string} Indented text
Indents a block of text .