Bug fix: Don't let mispeller screw up <c> tags. Fixes #5

This commit is contained in:
Kiooeht 2011-09-07 21:56:47 -07:00
parent 2b9278d717
commit 109ec04422
2 changed files with 12 additions and 1 deletions

View file

@ -37,6 +37,7 @@ CHANGELOG
* Openning global userlist doesn't reset OP status of memo users - Kiooeht [evacipatedBox]
* Alt characters don't break on random replace - Kiooeht [evacipatedBox]
* Trollian 2.5 tray icon is now Trollian icon - Kiooeht [evacipatedBox]
* Don't screw up <c> tags with the mispeller - Kiooeht [evacipatedBox]
* Mac Bug fixes
* Create all datadir stuff - Lexi [lexicalNuance]

View file

@ -90,10 +90,20 @@ class pesterQuirk(object):
percentage = self.quirk["percentage"]/100.0
words = string.split(" ")
newl = []
ctag = re.compile("(</?c=?.*?>)", re.I)
for w in words:
p = random.random()
if p < percentage:
if not ctag.search(w) and p < percentage:
newl.append(mispeller(w))
elif p < percentage:
split = ctag.split(w)
tmp = []
for s in split:
if s and not ctag.search(s):
tmp.append(mispeller(s))
else:
tmp.append(s)
newl.append("".join(tmp))
else:
newl.append(w)
return " ".join(newl)