app/styleguide/js/libs/highlighter/shCore.js
/**
 * Wraps each line of the string into <code/> tag with given style applied to it.
 * 
 * @param {String} str   Input string.
 * @param {String} css   Style name to apply to the string.
 * @return {String}      Returns input string with each line surrounded by <span/> tag.
 */
Wraps each line of the string into  tag with given style applied to it.

@param {String} str   Input string.
@param {String} css   Style name to apply to the string.
@return {String}      Returns input string with each line surrounded by  tag.
Wraps each line of the string into tag with given style applied to it . @param { String } str Input string . @param { String } css Style name to apply to the string . @return { String } Returns input string with each line surrounded by tag .
function wrapLinesWithCode(str, css)
{
  if (str == null || str.length == 0 || str == '\n') 
    return str;
  str = str.replace(/</g, '&lt;');
  str = str.replace(/ {2,}/g, function(m)
  {
    var spaces = '';
    for (var i = 0; i < m.length - 1; i++)
      spaces += sh.config.space;
    return spaces + ' ';
  });
  if (css != null) 
    str = eachLine(str, function(line)
    {
      if (line.length == 0) 
        return '';
      var spaces = '';
      line = line.replace(/^(&nbsp;| )+/, function(s)
      {
        spaces = s;
        return '';
      });
      if (line.length == 0) 
        return spaces;
      return spaces + '<code class="' + css + '">' + line + '</code>';
    });
  return str;
}
function wrapLinesWithCode ( str , css ) { if ( str == null || str . length == 0 || str == '\n' ) return str ; str = str . replace ( / < / g , '&lt;' ) ; str = str . replace ( /  {2,} / g , function ( m ) { var spaces = '' ; for ( var i = 0 ; i < m . length - 1 ; i ++ ) spaces += sh . config . space ; return spaces + ' ' ; } ) ; if ( css != null ) str = eachLine ( str , function ( line ) { if ( line . length == 0 ) return '' ; var spaces = '' ; line = line . replace ( / ^(&nbsp;| )+ / , function ( s ) { spaces = s ; return '' ; } ) ; if ( line . length == 0 ) return spaces ; return spaces + '<code class="' + css + '">' + line + '</code>' ; } ) ; return str ; }
Wraps each line of the string into <code/> tag with given style applied to it.
Wraps each line of the string into <code / > tag with given style applied to it .
// Replace two or more sequential spaces with &nbsp; leaving last space untouched. // Split each line and apply <span class="...">...</span> to them so that // leading spaces aren't included.