From 109ec04422f5350558e2fbd47ee5b6d3ebde0961 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Wed, 7 Sep 2011 21:56:47 -0700 Subject: [PATCH] Bug fix: Don't let mispeller screw up tags. Fixes #5 --- CHANGELOG.mkdn | 1 + dataobjs.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 73494e0..8004d30 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -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 tags with the mispeller - Kiooeht [evacipatedBox] * Mac Bug fixes * Create all datadir stuff - Lexi [lexicalNuance] diff --git a/dataobjs.py b/dataobjs.py index 8dbd22d..411d268 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -90,10 +90,20 @@ class pesterQuirk(object): percentage = self.quirk["percentage"]/100.0 words = string.split(" ") newl = [] + ctag = re.compile("()", 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)