Advertisement
Guest User

sx

a guest
Mar 31st, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def rend(txt):
  2.     out = bottle.html_escape(txt)
  3.     r1 = re.compile(r"(\b(http|https)://([-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]))")
  4.     out = r1.sub(r'<a href="\1">\1</a>',out)
  5.     out=out.split("\n")
  6.     rr=re.compile("^(&gt;){1,6}")
  7.     for i in range(0,len(out)):
  8.         if(re.match(rr,out[i])):
  9.             out[i]="<font color='green'>"+out[i]+"</font>"
  10.     out = ''.join(i+"\n" for i in out)
  11.    
  12.     r2 = re.compile(r"(\b(ii)://([-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]))")
  13.     out = r2.sub(r'<a href="\3"><span class="success radius label">\3</span></a>',out)
  14.     return out.replace('\n', '<br />')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement