Revision: 7962
Author: xqt
Date: 2010-02-25 14:00:14 +0000 (Thu, 25 Feb 2010)
Log Message:
-----------
handle <source /> alias from trunk
Modified Paths:
--------------
branches/rewrite/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py 2010-02-25 13:42:02 UTC (rev 7961)
+++ branches/rewrite/pywikibot/textlib.py 2010-02-25 14:00:14 UTC (rev 7962)
@@ -201,14 +201,19 @@
'parts' parameter, which defaults to all.
"""
regexes = {
- 'comments' : r'<!--.*?-->',
- 'includeonly':
r'<includeonly>.*?</includeonly>',
- 'nowiki': r'<nowiki>.*?</nowiki>',
- 'pre': r'<pre>.*?</pre>',
- 'source': r'<source .*?</source>',
+ 'comments' : r'<!--.*?-->',
+ 'includeonly':
r'<includeonly>.*?</includeonly>',
+ 'nowiki': r'<nowiki>.*?</nowiki>',
+ 'pre': r'<pre>.*?</pre>',
+ 'source': r'<source .*?</source>',
+ 'syntaxhighlight': r'<syntaxhighlight
.*?</syntaxhighlight>',
}
if '*' in tags:
tags = regexes.keys()
+ # add alias
+ tags = set(tags)
+ if 'source' in tags:
+ tags.add('syntaxhighlight')
toRemoveR = re.compile('|'.join([regexes[tag] for tag in tags]),
re.IGNORECASE | re.DOTALL)
return toRemoveR.sub('', text)
@@ -259,9 +264,9 @@
marker = text[firstinseparator:firstinmarker] + marker
return marker
-
+#-------------------------------------------------
# Functions dealing with interwiki language links
-
+#-------------------------------------------------
# Note - MediaWiki supports two kinds of interwiki links; interlanguage and
# interproject. These functions only deal with links to a
# corresponding page in another language on the same project (e.g.,
@@ -475,8 +480,9 @@
sites = insite.interwiki_putfirst_doubled(sites) + sites
return sites
-
+#---------------------------------------
# Functions dealing with category links
+#---------------------------------------
def getCategoryLinks(text, site):
"""Return a list of category links found in text.
@@ -660,6 +666,9 @@
#catLinks.sort()
return sep.join(catLinks) + '\r\n'
+#---------------------------------------
+# Functions dealing with external links
+#---------------------------------------
def compileLinkR(withoutBracketed=False, onlyBracketed=False):
"""Return a regex that matches external links."""
@@ -690,6 +699,9 @@
linkR = re.compile(regex)
return linkR
+#----------------------------------
+# Functions dealing with templates
+#----------------------------------
def extract_templates_and_params(text, get_redirect=False):
"""Return list of template calls found in text.
@@ -800,7 +812,9 @@
result.append((name, params))
return result
+#----------------
# I18N functions
+#----------------
# Languages to use for comment text after the actual language but before
# en:. For example, if for language 'xx', you want the preference of
Show replies by date