changeset 4125:8662bba9e431

GUI editor converter: fix roundtripping of free interwiki links
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 Sep 2008 21:03:09 +0200
parents a6f8071cfbe1
children fa60d012b867
files MoinMoin/converter/text_html_text_moin_wiki.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sun Sep 21 19:21:07 2008 +0200
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sun Sep 21 21:03:09 2008 +0200
@@ -13,6 +13,9 @@
 from MoinMoin import config, wikiutil
 from MoinMoin.error import ConvertError
 
+from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
+interwiki_re = re.compile(WikiParser.interwiki_rule, re.VERBOSE|re.UNICODE)
+
 # Portions (C) International Organization for Standardization 1986
 # Permission to copy in any form is granted for use with
 # conforming SGML systems and applications as defined in
@@ -1229,10 +1232,11 @@
                 pagename = wikiutil.url_unquote(href)
                 interwikiname = "%s:%s" % (title, pagename)
             if interwikiname and pagename == desc:
-                if ' ' in interwikiname:
+                if interwiki_re.match(interwikiname+' '): # the blank is needed by interwiki_re to match
+                    # this is valid as a free interwiki link
+                    self.text.append("%s" % interwikiname)
+                else:
                     self.text.append("[[%s]]" % interwikiname)
-                else:
-                    self.text.append("%s" % interwikiname)
                 return
             elif title == 'Self':
                 self.text.append('[[%s|%s]]' % (href, desc))