#NEWLINE# def widont_html( value ) : #NEWLINE# #INDENT# '\n    Adds an HTML non-breaking space between the final two words at the end of\n    (and in sentences just outside of) block level tags to avoid "widowed"\n    words.\n\n    Examples:\n\n    >>> print(widont_html(\'<h2>Here is a simple  example  </h2> <p>Single</p>\'))\n    <h2>Here is a simple&nbsp;example  </h2> <p>Single</p>\n\n    >>> print(widont_html(\'<p>test me<br /> out</p><h2>Ok?</h2>Not in a p<p title="test me">and this</p>\'))\n    <p>test&nbsp;me<br /> out</p><h2>Ok?</h2>Not in a&nbsp;p<p title="test me">and&nbsp;this</p>\n\n    >>> print(widont_html(\'leading text  <p>test me out</p>  trailing text\'))\n    leading&nbsp;text  <p>test me&nbsp;out</p>  trailing&nbsp;text\n    ' #NEWLINE# def replace( matchobj ) : #NEWLINE# #INDENT# return force_text ( ( '%s&nbsp;%s%s' % matchobj . groups ( ) ) ) #NEWLINE# #UNINDENT# return re_widont_html . sub ( replace , force_text ( value ) )