code: def widont(value, autoescape=None):
      
      esc = autoescape and conditional_escape or (lambda x: x)
  
      def replace(matchobj):
          return '&nbsp;%s' % matchobj.group(1)
  
      value = END_PUNCTUATION_WIDONT_REGEXP.sub(replace, esc(smart_text(value)))
      value = WIDONT_REGEXP.sub(replace, value)
      value = DOUBLE_SPACE_PUNCTUATION_WIDONT_REGEXP.sub(replace, value)
  
      return mark_safe(value)
docs: Add an HTML non-breaking space between the final
      two words of the string to avoid "widowed" words.