THUNDERGROOVE

Untitled

Jun 30th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. def breakLinks(body, kwargs, onlyGT=False):
  2. Thread = kwargs['Thread']
  3. board = kwargs['board']
  4. reply = kwargs['reply']
  5. body = strip_tags(body)
  6. lines = body.split("\n")
  7. reg = re.compile(r"(>>\d+)")
  8. for p, i in enumerate(lines):
  9. #line linking
  10. if onlyGT == False:
  11. l = reg.split(i)
  12. # Strip bullshit that'll fuck everything up
  13. l = [str(x).strip() for x in l]
  14. l = filter(None, l)
  15. l = [x.strip(' ') for x in l]
  16.  
  17. p
  18. newLine = []
  19. if ">>" in i:
  20. for j,k in enumerate(l):
  21. if k.startswith(">>"):
  22. try:
  23. ID = k.split(">>")[len(k.split(">>")) - 1]
  24. except:
  25. ID = ""
  26.  
  27. temp = ">>" + ID
  28. newLine.append("".join(temp))
  29. newLine.append(" ")
  30. else:
  31. newLine.append(k)
  32. newLine.append(" ")
  33. lines[p] = "".join(newLine)
  34. else:
  35. pass
  36.  
  37. if str(i).startswith(">") and not str(i).startswith(">>"):
  38. lines[p] = "".join(["<span class='quote'>", i, "</span>"])
  39. body = "".join(lines)
  40. return body
Advertisement
Add Comment
Please, Sign In to add comment