code: def tmpl_shorten(text, max_size=32):
          
          max_size = int(max_size)
          if len(text) <= max_size:
              return text
          text = textwrap.wrap(text, max_size)[0]
          import re
          text = re.sub(r'\W+$', '', text)
          return text.strip()
docs: Shorten the given text to ``max_size``
  
          * synopsis: ``%shorten{text}`` or ``%shorten{text,max_size}``
          * example: ``%shorten{$title,32}``
          * description: Shorten “text” on word boundarys.