'_munge_whitespace(text : string) -> string
Munge whitespace in text: expand tabs and convert all other
whitespace characters to spaces.  Eg. " foo     bar
baz"
becomes " foo    bar  baz".'

def _munge_whitespace(self, text):

    if self.expand_tabs:
        text = text.expandtabs()
    if self.replace_whitespace:
        if isinstance(text, str):
            text = text.translate(self.whitespace_trans)
        elif isinstance(text, _unicode):
            text = text.translate(self.unicode_whitespace_trans)
    return text
