[Pywikipedia-l] SVN: [4852] trunk/pywikipedia/cosmetic_changes.py

wikipedian at svn.wikimedia.org wikipedian at svn.wikimedia.org
Fri Jan 11 01:10:50 UTC 2008


Revision: 4852
Author:   wikipedian
Date:     2008-01-11 01:10:49 +0000 (Fri, 11 Jan 2008)

Log Message:
-----------
Newer MediaWiki versions automatically place a non-breaking space in
front of a percent sign, so it is no longer required to place it
manually. => remove   in this case.

Modified Paths:
--------------
    trunk/pywikipedia/cosmetic_changes.py

Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py	2008-01-10 23:21:57 UTC (rev 4851)
+++ trunk/pywikipedia/cosmetic_changes.py	2008-01-11 01:10:49 UTC (rev 4852)
@@ -98,6 +98,7 @@
         text = self.resolveHtmlEntities(text)
         text = self.validXhtml(text)
         text = self.removeUselessSpaces(text)
+        text = self.removeNonBreakingSpaceBeforePercent(text)
         try:
             text = isbn.hyphenateIsbnNumbers(text)
         except isbn.InvalidIsbnException, error:
@@ -285,6 +286,15 @@
 
         return text
 
+    def removeNonBreakingSpaceBeforePercent(self, text):
+        '''
+        Newer MediaWiki versions automatically place a non-breaking space in
+        front of a percent sign, so it is no longer required to place it
+        manually.
+        '''
+        percentR = re.compile(r'(\d) %')
+        text = percentR.sub(r'\1 %', text)
+        return text
 
     def cleanUpSectionHeaders(self, text):
         """





More information about the Pywikipedia-l mailing list