Revision: 4844
Author: wikipedian
Date: 2008-01-10 13:38:18 +0000 (Thu, 10 Jan 2008)
Log Message:
-----------
replaceExcept(): added regular expression for <source> tags (wiki markup is disabled
within these)
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-10 12:26:49 UTC (rev 4843)
+++ trunk/pywikipedia/wikipedia.py 2008-01-10 13:38:18 UTC (rev 4844)
@@ -2807,6 +2807,7 @@
'nowiki': re.compile(r'(?is)<nowiki>.*?</nowiki>'),
# preformatted text
'pre': re.compile(r'(?ism)<pre>.*?</pre>'),
+ 'source': re.compile(r'(?is)<source .*?</source>'),
# inline references
'ref': re.compile(r'(?ism)<ref[ >].*?</ref>'),
# lines that start with a space are shown in a monospace font and
@@ -2925,7 +2926,8 @@
'includeonly': r'<includeonly>.*?</includeonly>',
'nowiki': r'<nowiki>.*?</nowiki>',
'pre': r'<pre>.*?</pre>',
- }
+ 'source': r'<source .*?</source>',
+ }
if '*' in tags:
tags = regexes.keys()
toRemoveR = re.compile('|'.join([regexes[tag] for tag in tags]),
@@ -3020,7 +3022,7 @@
interwikiR = re.compile(r'\[\[(%s)\s?:[^\]]*\]\][\s]*'
% languageR, re.IGNORECASE)
text = replaceExcept(text, interwikiR, '',
- ['nowiki', 'comment', 'math', 'pre'], marker=marker)
+ ['nowiki', 'comment', 'math', 'pre', 'source'], marker=marker)
return text.strip()
def replaceLanguageLinks(oldtext, new, site = None):
@@ -3137,7 +3139,7 @@
# ASCII letters and hyphens.
catNamespace = '|'.join(site.category_namespaces())
categoryR = re.compile(r'\[\[\s*(%s)\s*:.*?\]\][\s]*' % catNamespace)
- text = replaceExcept(text, categoryR, '', ['nowiki', 'comment', 'math', 'pre'], marker = marker)
+ text = replaceExcept(text, categoryR, '', ['nowiki', 'comment', 'math', 'pre', 'source'], marker = marker)
return text.strip()
def replaceCategoryInPlace(oldtext, oldcat, newcat, site=None):
@@ -3163,12 +3165,12 @@
% (catNamespace, title))
if newcat is None:
text = replaceExcept(oldtext, categoryR, '',
- ['nowiki', 'comment', 'math', 'pre'])
+ ['nowiki', 'comment', 'math', 'pre', 'source'])
else:
text = replaceExcept(oldtext, categoryR,
'[[Category:%s\\2'
% newcat.titleWithoutNamespace(),
- ['nowiki', 'comment', 'math', 'pre'])
+ ['nowiki', 'comment', 'math', 'pre', 'source'])
return text
def replaceCategoryLinks(oldtext, new, site=None):