http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11340
Revision: 11340 Author: xqt Date: 2013-04-05 16:22:05 +0000 (Fri, 05 Apr 2013) Log Message: ----------- hide the flat template marker
Modified Paths: -------------- trunk/pywikipedia/pywikibot/textlib.py
Modified: trunk/pywikipedia/pywikibot/textlib.py =================================================================== --- trunk/pywikipedia/pywikibot/textlib.py 2013-04-04 17:30:35 UTC (rev 11339) +++ trunk/pywikipedia/pywikibot/textlib.py 2013-04-05 16:22:05 UTC (rev 11340) @@ -130,6 +130,8 @@ Rvalue = re.compile('{{{.+?}}}') Rmarker1 = re.compile('%(mark)s(\d+)%(mark)s' % {'mark': marker1}) Rmarker2 = re.compile('%(mark)s(\d+)%(mark)s' % {'mark': marker2}) + # hide the flat template marker + dontTouchRegexes.append(Rmarker1) values = {} count = 0 for m in Rvalue.finditer(text): @@ -145,6 +147,7 @@ item = m.group() text = text.replace(item, '%s%d%s' % (marker1, count, marker1))
+ # Make sure stored templates don't contain markers for m2 in Rmarker1.finditer(item): item = item.replace(m2.group(), inside[int(m2.group(1))]) for m2 in Rmarker2.finditer(item):