lib/util.js
function format(string) {
  string = _.toString(string);

  // Replace all code snippets with a token.
  var snippets = [];
  string = string.replace(reCode, function(match) {
    snippets.push(match);
    return token;
  });

  return string
    // Add line breaks.
    .replace(/:\n(?=[\t ]*\S)/g, ':<br>\n')
    .replace(/\n( *)[-*](?=[\t ]+\S)/g, '\n<br>\n$1*')
    .replace(/^[\t ]*\n/gm, '<br>\n<br>\n')
    // Normalize whitespace.
    .replace(/\n +/g, ' ')
    // Italicize parentheses.
    .replace(/(^|\s)(\(.+\))/g, '$1*$2*')
    // Mark numbers as inline code.
    .replace(/[\t ](-?\d+(?:.\d+)?)(?!\.[^\n])/g, ' `$1`')
    // Replace all tokens with code snippets.
    .replace(reToken, function(match) {
      return snippets.shift();
    })
    .trim();
}
function format(string) {
  string = _.toString(string);

  // Replace all code snippets with a token.
  var snippets = [];
  string = string.replace(reCode, function(match) {
    snippets.push(match);
    return token;
  });

  return string
    // Add line breaks.
    .replace(/:\n(?=[\t ]*\S)/g, ':<br>\n')
    .replace(/\n( *)[-*](?=[\t ]+\S)/g, '\n<br>\n$1*')
    .replace(/^[\t ]*\n/gm, '<br>\n<br>\n')
    // Normalize whitespace.
    .replace(/\n +/g, ' ')
    // Italicize parentheses.
    .replace(/(^|\s)(\(.+\))/g, '$1*$2*')
    // Mark numbers as inline code.
    .replace(/[\t ](-?\d+(?:.\d+)?)(?!\.[^\n])/g, ' `$1`')
    // Replace all tokens with code snippets.
    .replace(reToken, function(match) {
      return snippets.shift();
    })
    .trim();
}
function format ( string ) { string = _ . toString ( string ) ; // Replace all code snippets with a token. var snippets = [ ] ; string = string . replace ( reCode , function ( match ) { snippets . push ( match ) ; return token ; } ) ; return string // Add line breaks. . replace ( / :\n(?=[\t ]*\S) / g , ':<br>\n' ) . replace ( / \n( *)[-*](?=[\t ]+\S) / g , '\n<br>\n$1*' ) . replace ( / ^[\t ]*\n / gm , '<br>\n<br>\n' ) // Normalize whitespace. . replace ( / \n + / g , ' ' ) // Italicize parentheses. . replace ( / (^|\s)(\(.+\)) / g , '$1*$2*' ) // Mark numbers as inline code. . replace ( / [\t ](-?\d+(?:.\d+)?)(?!\.[^\n]) / g , ' `$1`' ) // Replace all tokens with code snippets. . replace ( reToken , function ( match ) { return snippets . shift ( ) ; } ) . trim ( ) ; }
Performs common string formatting operations.

@memberOf util
@param {string} string The string to format.
@returns {string} Returns the formatted string.
Performs common string formatting operations .