app/assets/javascripts/examples.js
/**
  * Strips any leading indentation from the text content of a node.
  *
  * @param {String} textContent
  * @returns {String}
  */
Strips any leading indentation from the text content of a node.
@param {String} textContent
@returns {String}
Strips any leading indentation from the text content of a node . @param { String } textContent @returns { String }
function stripIndentation (textContent) {
   var textIndentation = detectIndentation(textContent);
   if (textIndentation === 0) {
     return textContent;
   }
   var firstLine = textContent.substring(0, textContent.indexOf('\n'));
   var lines = textContent.split('\n').slice(1);
   lines = lines.map(function (line) {
     if (line === '') {
       return line;
     }
     return line.substring(textIndentation);
   });
   return firstLine + '\n' + lines.join('\n');
 }
function stripIndentation ( textContent ) { var textIndentation = detectIndentation ( textContent ) ; if ( textIndentation === 0 ) { return textContent ; } var firstLine = textContent . substring ( 0 , textContent . indexOf ( '\n' ) ) ; var lines = textContent . split ( '\n' ) . slice ( 1 ) ; lines = lines . map ( function ( line ) { if ( line === '' ) { return line ; } return line . substring ( textIndentation ) ; } ) ; return firstLine + '\n' + lines . join ( '\n' ) ; }
Strips any leading indentation from the text content of a node.
Strips any leading indentation from the text content of a node .