Common code to a utils file
[mussorgsky] / src / utils.py
1 def escape_html (text, max_length=40):
2     if (len (text) > max_length):
3         cutpoint = text.find (' ', max_length-10)
4         if (cutpoint == -1 or cutpoint > max_length):
5             cutpoint = max_length
6         text = text [0:cutpoint] + "..."
7     return text.replace ("&","&amp;").replace ("<", "&lt;").replace (">", "&gt;").replace ("\"", "&quot;")
8