changeset 2761:3a6a25169f55

use rsplit for splitting off anchor
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 25 Aug 2007 17:42:25 +0200
parents d373e273cd7b
children 9b622bb9e7f7
files MoinMoin/formatter/__init__.py MoinMoin/formatter/text_html.py MoinMoin/parser/text_creole.py MoinMoin/parser/text_moin_wiki.py MoinMoin/parser/text_rst.py MoinMoin/script/migration/_conv160_wiki.py
diffstat 6 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/formatter/__init__.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/formatter/__init__.py	Sat Aug 25 17:42:25 2007 +0200
@@ -11,6 +11,7 @@
 
 from MoinMoin.util import pysupport
 from MoinMoin import wikiutil
+from MoinMoin.support.python_compatibility import rsplit
 
 modules = pysupport.getPackageModules(__file__)
 
@@ -102,7 +103,7 @@
         wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwiki, pagename)
         if wikitag == 'Self' or wikitag == self.request.cfg.interwikiname:
             if '#' in wikitail:
-                wikitail, kw['anchor'] = wikitail.split('#', 1)
+                wikitail, kw['anchor'] = rsplit(wikitail, '#', 1)
                 wikitail = wikiutil.url_unquote(wikitail)
             return self.pagelink(on, wikitail, **kw)
         return ''
--- a/MoinMoin/formatter/text_html.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/formatter/text_html.py	Sat Aug 25 17:42:25 2007 +0200
@@ -11,7 +11,7 @@
 from MoinMoin import wikiutil, i18n
 from MoinMoin.Page import Page
 from MoinMoin.action import AttachFile
-from MoinMoin.support.python_compatibility import set
+from MoinMoin.support.python_compatibility import set, rsplit
 
 # insert IDs into output wherever they occur
 # warning: breaks toggle line numbers javascript
@@ -485,7 +485,7 @@
         wikiurl = wikiutil.mapURL(self.request, wikiurl)
         if wikitag == 'Self': # for own wiki, do simple links
             if '#' in wikitail:
-                wikitail, kw['anchor'] = wikitail.split('#', 1)
+                wikitail, kw['anchor'] = rsplit(wikitail, '#', 1)
             wikitail = wikiutil.url_unquote(wikitail)
             try: # XXX this is the only place where we access self.page - do we need it? Crashes silently on actions!
                 pagename = wikiutil.AbsPageName(self.page.page_name, wikitail)
--- a/MoinMoin/parser/text_creole.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/parser/text_creole.py	Sat Aug 25 17:42:25 2007 +0200
@@ -23,6 +23,7 @@
 import re
 import StringIO
 from MoinMoin import config, macro, wikiutil
+from MoinMoin.support.python_compatibility import rsplit
 
 Dependencies = []
 
@@ -589,7 +590,7 @@
         if word.startswith(wikiutil.CHILD_PREFIX):
             word = self.formatter.page.page_name + '/' + word[wikiutil.CHILD_PREFIX_LEN:]
         # handle anchors
-        parts = word.split("#", 1)
+        parts = rsplit(word, "#", 1)
         anchor = ""
         if len(parts) == 2:
             word, anchor = parts
--- a/MoinMoin/parser/text_moin_wiki.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/parser/text_moin_wiki.py	Sat Aug 25 17:42:25 2007 +0200
@@ -27,6 +27,7 @@
 import re
 from MoinMoin import config, wikiutil, macro
 from MoinMoin.Page import Page
+from MoinMoin.support.python_compatibility import rsplit
 
 Dependencies = ['user'] # {{{#!wiki comment ... }}} has different output depending on the user's profile settings
 
@@ -554,7 +555,7 @@
             return self.formatter.text(orig_word)
         else:
             # handle anchors
-            parts = name.split("#", 1)
+            parts = rsplit(name, "#", 1)
             anchor = ""
             if len(parts) == 2:
                 name, anchor = parts
@@ -715,7 +716,7 @@
                     page_name = self.formatter.page.page_name + '/' + page_name[self.CHILD_PREFIX_LEN:] # XXX use func
                 # handle anchors
                 try:
-                    page_name, anchor = page_name.split("#", 1)
+                    page_name, anchor = rsplit(page_name, "#", 1)
                 except ValueError:
                     anchor = ""
                 if not page_name:
--- a/MoinMoin/parser/text_rst.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/parser/text_rst.py	Sat Aug 25 17:42:25 2007 +0200
@@ -20,6 +20,7 @@
 from MoinMoin.Page import Page
 from MoinMoin.action import AttachFile
 from MoinMoin import wikiutil
+from MoinMoin.support.python_compatibility import rsplit
 
 Dependencies = [] # this parser just depends on the raw text
 
@@ -379,7 +380,7 @@
                 pagename = refuri
                 anchor = ''
                 if '#' in refuri:
-                    pagename, anchor = refuri.split('#', 1)
+                    pagename, anchor = rsplit(refuri, '#', 1)
                 page = Page(self.request, wikiutil.AbsPageName(self.formatter.page.page_name, pagename))
                 node['refuri'] = page.url(self.request, anchor=anchor)
                 if not page.exists():
--- a/MoinMoin/script/migration/_conv160_wiki.py	Sat Aug 25 17:27:14 2007 +0200
+++ b/MoinMoin/script/migration/_conv160_wiki.py	Sat Aug 25 17:42:25 2007 +0200
@@ -33,6 +33,7 @@
 from MoinMoin import config, wikiutil, macro
 from MoinMoin.action import AttachFile
 from MoinMoin.Page import Page
+from MoinMoin.support.python_compatibility import rsplit
 
 from text_moin158_wiki import Parser
 
@@ -136,7 +137,7 @@
         return new_name
 
     def _replace_target(self, target):
-        target_and_anchor = target.split('#', 1)
+        target_and_anchor = rsplit(target, '#', 1)
         if len(target_and_anchor) > 1:
             target, anchor = target_and_anchor
             target = self._replace(('PAGE', target))