diff MoinMoin/script/migration/_conv160_wiki.py @ 2612:e3e5e2373c60

1.6 converter: cleanup link conversion, cleanup/add tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 08 Aug 2007 03:53:46 +0200
parents 7ed38f2af242
children d2d4e74978bd 6cb75379c073
line wrap: on
line diff
--- a/MoinMoin/script/migration/_conv160_wiki.py	Tue Aug 07 17:35:08 2007 +0200
+++ b/MoinMoin/script/migration/_conv160_wiki.py	Wed Aug 08 03:53:46 2007 +0200
@@ -232,17 +232,14 @@
         # Local extended link? [:page name:link text]
         if word[0] == ':':
             words = word[1:].split(':', 1)
-            words[0] = self._replace_target(words[0])
-            if len(words) == 1:
-                link = words[0]
-                link = wikiutil.quoteName(link)
-                return '[%s]' % link # use freelink
-            else:
-                link, text = words
-                link = wikiutil.quoteName(link)
-                if text:
-                    text = ' ' + text
-                return '[%s%s]' % (link, text) # use freelink with text
+            link, text = (words + ['', ''])[:2]
+            if link.strip() == text.strip():
+                text = ''
+            link = self._replace_target(link)
+            link = wikiutil.quoteName(link)
+            if text:
+                text = ' ' + text
+            return '[%s%s]' % (link, text) # use freelink with text
 
         scheme_and_rest = word.split(":", 1)
         if len(scheme_and_rest) == 2: # scheme given