Revision: 6075 Author: btongminh Date: 2008-11-07 15:52:38 +0000 (Fri, 07 Nov 2008)
Log Message: ----------- Remove trailing spaces if the image is the first item on the line.
Modified Paths: -------------- trunk/pywikipedia/commonsdelinker/delinker.py
Modified: trunk/pywikipedia/commonsdelinker/delinker.py =================================================================== --- trunk/pywikipedia/commonsdelinker/delinker.py 2008-11-06 21:29:30 UTC (rev 6074) +++ trunk/pywikipedia/commonsdelinker/delinker.py 2008-11-07 15:52:38 UTC (rev 6075) @@ -247,6 +247,19 @@ # Found the end of the image break + # Check whether this image is the first one on the line + if image_start == 0: + prev = '' + else: + prev = new_text[image_start - 1] + if prev in ('', '\r', '\n') and replacement is None: + # Kill all spaces after end + while (end + 1) < len(new_text): + if new_text[end + 1] in (' ', '\t'): + end += 1 + else: + break + # Add the replacement to the todo list. Doing the # replacement right know would alter the indices. replacements.append((new_text[image_start:end],