Cleanup patch from Loic Berthe
authorMikael Berthe <mikael@lilotux.net>
Sun, 20 May 2007 09:46:49 +0200
changeset 39 2123977057c5
parent 38 a81dc352e96e
child 40 0d917adf0daf
Cleanup patch from Loic Berthe
plugins/rss_plugin.py
--- a/plugins/rss_plugin.py	Sat May 19 15:22:09 2007 +0200
+++ b/plugins/rss_plugin.py	Sun May 20 09:46:49 2007 +0200
@@ -17,25 +17,24 @@
 ################################################################################
 
 import re
-def rss_remove_html(text):
-	exp = re.compile('<[^>]*>')
-	text = exp.sub('', text)
-	notags = text.replace('&lt;', '<').replace('&gt;', '>')
-	noescape = notags.replace('&amp;', '&').replace('&lt;', '<').replace('&gt;', '>').replace('&quot;', '"')
-	noescape = noescape.replace('&lt;p&gt;', '')
-	noescape = noescape.replace('&lt;/p&gt;', '')
-	noescape = noescape.replace('&lt;p /&gt;', '').replace('&lt;p/&gt;', '')
-	return noescape
 
-""" OLD CODE: REMOVE LATER IF NEW FUNCTION (added 2005-10-12) WORKS
+html_table = [
+	('&lt;p&gt;'  , '' ),
+	('&lt;/p&gt;' , '' ),
+	('&lt;p /&gt;', '' ),
+	('&lt;p/&gt;' , '' ),
+	('&gt;'       , '>'),
+	('&gt;'       , '>'),
+	('&lt;'       , '<'),
+	('&quot;'     , '"'),
+	('&amp;'      , '&'),
+]
+
 def rss_remove_html(text):
-	notags = text.replace('&lt;', '<').replace('&gt;', '>')
-	noescape = notags.replace('&amp;', '&').replace('&lt;', '<').replace('&gt;', '>').replace('&quot;', '"')
-	noescape = noescape.replace('&lt;p&gt;', '')
-	noescape = noescape.replace('&lt;/p&gt;', '')
-	noescape = noescape.replace('&lt;p /&gt;', '').replace('&lt;p/&gt;', '')
-	return noescape
-"""
+	text = re.sub(r'<[^>]*>', '', text)
+	for bad, new in html_table :
+		text = text.replace(bad, new)
+	return text
 
 def rss_update_file():
 	global RSS_CACHE