def preserve_whitespace(v, quote=True):
 if quote:
  v = html_quote(v)
 v = v.replace('\n', '<br>\n')
 v = re.sub('()(  +)', _repl_nbsp, v)
 v = re.sub('(\\n)( +)', _repl_nbsp, v)
 v = re.sub('^()( +)', _repl_nbsp, v)
 return ('<code>%s</code>' % v)

def preserve_whitespace ( v , quote = True ) : if quote : v = html_quote ( v ) v = v . replace ( '\n' , '<br>\n' ) v = re . sub ( '()(  +)' , _repl_nbsp , v ) v = re . sub ( '(\\n)( +)' , _repl_nbsp , v ) v = re . sub ( '^()( +)' , _repl_nbsp , v ) return ( '<code>%s</code>' % v )
quote a value for html .