lib/extract.js
function cleanseText( options, cb ) {
  return function( error, text ) {
    if ( !error ) {
      // clean up text
      text = util.replaceBadCharacters( text );

      if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) {
        if ( options.preserveOnlyMultipleLineBreaks ) {
          text = text.replace( STRIP_ONLY_SINGLE_LINEBREAKS, '$1 ' ).trim();
        }
        text = text.replace( WHITELIST_PRESERVE_LINEBREAKS, ' ' );
      } else {
        text = text.replace( WHITELIST_STRIP_LINEBREAKS, ' ' );
      }

      // multiple spaces, tabs, vertical tabs, non-breaking space]
      text = text.replace( / (?! )/g, '' )
        .replace( /[ \t\v\u00A0]{2,}/g, ' ' );

      text = entities.decode( text );
    }
    cb( error, text );
  };
}
function cleanseText( options, cb ) {
  return function( error, text ) {
    if ( !error ) {
      // clean up text
      text = util.replaceBadCharacters( text );

      if ( options.preserveLineBreaks || options.preserveOnlyMultipleLineBreaks ) {
        if ( options.preserveOnlyMultipleLineBreaks ) {
          text = text.replace( STRIP_ONLY_SINGLE_LINEBREAKS, '$1 ' ).trim();
        }
        text = text.replace( WHITELIST_PRESERVE_LINEBREAKS, ' ' );
      } else {
        text = text.replace( WHITELIST_STRIP_LINEBREAKS, ' ' );
      }

      // multiple spaces, tabs, vertical tabs, non-breaking space]
      text = text.replace( / (?! )/g, '' )
        .replace( /[ \t\v\u00A0]{2,}/g, ' ' );

      text = entities.decode( text );
    }
    cb( error, text );
  };
}
function cleanseText ( options , cb ) { return function ( error , text ) { if ( ! error ) { // clean up text text = util . replaceBadCharacters ( text ) ; if ( options . preserveLineBreaks || options . preserveOnlyMultipleLineBreaks ) { if ( options . preserveOnlyMultipleLineBreaks ) { text = text . replace ( STRIP_ONLY_SINGLE_LINEBREAKS , '$1 ' ) . trim ( ) ; } text = text . replace ( WHITELIST_PRESERVE_LINEBREAKS , ' ' ) ; } else { text = text . replace ( WHITELIST_STRIP_LINEBREAKS , ' ' ) ; } // multiple spaces, tabs, vertical tabs, non-breaking space] text = text . replace ( /  (?! ) / g , '' ) . replace ( / [ \t\v\u00A0]{2,} / g , ' ' ) ; text = entities . decode ( text ) ; } cb ( error , text ) ; } ; }
global, all file type, content cleansing
global all file type content cleansing