index.js
function preprocessCode (code) {

  // Remove starting comments
  while (code.indexOf('//') === 0) {
    code = code.slice(code.indexOf('\n'));
  }

  // Starts with an object literal
  if (code.indexOf('{') === 0) {
    code = 'var json = ' + code;

  // Starts with an object property
  } else if (code.indexOf(':') !== -1 &&
             code.indexOf(':') < code.indexOf(' ')) {
    code = 'var json = {' + code + '}';
  }

  // Starts with an anonymous function
  if (code.indexOf('function') === 0) {
    code = 'var func = ' + code;
  }

  // Contains ...
  return code.replace('...', '');
}
function preprocessCode (code) {

  // Remove starting comments
  while (code.indexOf('//') === 0) {
    code = code.slice(code.indexOf('\n'));
  }

  // Starts with an object literal
  if (code.indexOf('{') === 0) {
    code = 'var json = ' + code;

  // Starts with an object property
  } else if (code.indexOf(':') !== -1 &&
             code.indexOf(':') < code.indexOf(' ')) {
    code = 'var json = {' + code + '}';
  }

  // Starts with an anonymous function
  if (code.indexOf('function') === 0) {
    code = 'var func = ' + code;
  }

  // Contains ...
  return code.replace('...', '');
}
function preprocessCode ( code ) { // Remove starting comments while ( code . indexOf ( '//' ) === 0 ) { code = code . slice ( code . indexOf ( '\n' ) ) ; } // Starts with an object literal if ( code . indexOf ( '{' ) === 0 ) { code = 'var json = ' + code ; // Starts with an object property } else if ( code . indexOf ( ':' ) !== - 1 && code . indexOf ( ':' ) < code . indexOf ( ' ' ) ) { code = 'var json = {' + code + '}' ; } // Starts with an anonymous function if ( code . indexOf ( 'function' ) === 0 ) { code = 'var func = ' + code ; } // Contains ... return code . replace ( '...' , '' ) ; }
Preprocesses the code block and re-formats it to allow for partial code
@param  {String} code A block of code from the markdown file
@return {String} Processed code transformed from partial code
Preprocesses the code block and re - formats it to allow for partial code