Sha256: 1dc5eaf3ea3de66927daec426f6e9a96a451466425d226035d5e59fbe7cb1e4c
Contents?: true
Size: 895 Bytes
Versions: 19
Compression:
Stored size: 895 Bytes
Contents
function cleanWhiteSpace(codeBlocks){ if (!codeBlocks) return; for (var i = codeBlocks.length - 1; i >= 0; i--) { var codeBlock = codeBlocks[i], lines, offset; var text = codeBlock.textContent || codeBlock.innerText; lines = text.split( '\n' ); if ( lines.length > 1 && lines[ lines.length - 1 ].trim() === '' ){ lines.pop(); } var canClean = lines[1] != undefined; if (canClean) { // how much white-space do we need to remove form each line? offset = lines[ 1 ].match( /^\s*/ )[ 0 ].length; // remove the excess white-space from the beginning of each line lines = lines.map( function ( line ) { return line.slice( offset ); }); lines.shift(); codeBlock.textContent = lines.join( '\n' ); } hljs.highlightBlock(codeBlock); }; }
Version data entries
19 entries across 19 versions & 1 rubygems