diff MoinMoin/wikiutil.py @ 2730:a907a61c33b3

* The 1.5.8 to 1.6.0 converter now uses the 1.5.8 wiki parser, for better (bug) compatibility. * Wiki parser fixes. * Reverted split_wiki/resolve_wiki to 1.5.8 code. The 1.6/1.7 code supported pagename quoting and this is not used any more. Also we need the (broken) 1.5.8 code to have the converter behave as 1.5.8 would do. Added deprecation notes for this old code. * Added new split_interwiki/resolve_interwiki code as replacement. * HTML formatter's attachment_link method got a new kw arg 'text_format' so we can call it with non-text link descriptions (e.g. images), too. * misc. fixes/cleanups
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 19 Aug 2007 19:28:35 +0200
parents 59b3d8b8971f
children 7bfe80df6772
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Mon Aug 13 04:06:53 2007 +0200
+++ b/MoinMoin/wikiutil.py	Sun Aug 19 19:28:35 2007 +0200
@@ -578,56 +578,25 @@
     return _interwiki_list
 
 def split_wiki(wikiurl):
-    """ Split a wiki url, e.g:
-
-    'MoinMoin:FrontPage' -> "MoinMoin", "FrontPage", ""
-    'FrontPage' -> "Self", "FrontPage", ""
-    'MoinMoin:"Page with blanks" link title' -> "MoinMoin", "Page with blanks", "link title"
-
-    can also be used for:
-
-    'attachment:"filename with blanks.txt" other title' -> "attachment", "filename with blanks.txt", "other title"
+    """
+    Split a wiki url.
 
     *** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
     Use split_interwiki(), see below.
 
     @param wikiurl: the url to split
     @rtype: tuple
-    @return: (wikiname, pagename, linktext)
+    @return: (tag, tail)
     """
+    # !!! use a regex here!
     try:
-        wikiname, rest = wikiurl.split(":", 1) # e.g. MoinMoin:FrontPage
+        wikitag, tail = wikiurl.split(":", 1)
     except ValueError:
         try:
-            wikiname, rest = wikiurl.split("/", 1) # for what is this used?
+            wikitag, tail = wikiurl.split("/", 1)
         except ValueError:
-            wikiname, rest = 'Self', wikiurl
-    if rest:
-        if rest[0] == '"': # quoted pagename
-            idx = 1
-            max = len(rest)
-            while idx < max:
-                if idx + 1 < max:
-                    next = rest[idx + 1]
-                else:
-                    next = None
-                if next == rest[idx] == '"':
-                    idx += 2
-                    continue
-                if next != '"' and rest[idx] == '"':
-                    break
-                idx += 1
-            pagename_linktext = rest[1:idx].replace('""', '"'), rest[idx+1:]
-        else: # not quoted, split on whitespace
-            pagename_linktext = rest.split(None, 1)
-    else:
-        pagename_linktext = "", ""
-    if len(pagename_linktext) == 1:
-        pagename, linktext = pagename_linktext[0], ""
-    else:
-        pagename, linktext = pagename_linktext
-    linktext = linktext.strip()
-    return wikiname, pagename, linktext
+            wikitag, tail = 'Self', wikiurl
+    return wikitag, tail
 
 def split_interwiki(wikiurl):
     """ Split a interwiki name, into wikiname and pagename, e.g:
@@ -652,7 +621,8 @@
     return wikiname, pagename
 
 def resolve_wiki(request, wikiurl):
-    """ Resolve an interwiki link.
+    """
+    Resolve an interwiki link.
 
     *** DEPRECATED FUNCTION FOR OLD 1.5 SYNTAX - ONLY STILL HERE FOR THE 1.5 -> 1.6 MIGRATION ***
     Use resolve_interwiki(), see below.
@@ -663,7 +633,10 @@
     @return: (wikitag, wikiurl, wikitail, err)
     """
     _interwiki_list = load_wikimap(request)
-    wikiname, pagename, linktext = split_wiki(wikiurl)
+    # split wiki url
+    wikiname, pagename = split_wiki(wikiurl)
+
+    # return resolved url
     if wikiname in _interwiki_list:
         return (wikiname, _interwiki_list[wikiname], pagename, False)
     else: