def compact_text(text, elidelength=None):
 lines = []
 for line in text.splitlines():
  lines.append(line.strip())
 out = ''.join(lines)
 if (elidelength is not None):
  out = elide(out, elidelength)
 return out

def compact_text ( text , elidelength = None ) : lines = [ ] for line in text . splitlines ( ) : lines . append ( line . strip ( ) ) out = '' . join ( lines ) if ( elidelength is not None ) : out = elide ( out , elidelength ) return out
remove leading whitespace and newlines from a text and maybe elide it .