changeset 4555:30ffb215bf6e

allow underscore in IDs, replace blanks by underscore (revert changeset a7dc3cc36362)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 06 Feb 2009 00:01:17 +0100
parents 1777b6d3674a
children 0c65fd71c7ad
files MoinMoin/_tests/test_wikiutil.py MoinMoin/wikiutil.py
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Thu Feb 05 19:27:35 2009 +0100
+++ b/MoinMoin/_tests/test_wikiutil.py	Fri Feb 06 00:01:17 2009 +0100
@@ -909,7 +909,8 @@
         tests = [
             # text                    expected output
             (u'\xf6\xf6ll\xdf\xdf',   'A.2BAPYA9g-ll.2BAN8A3w-'),
-            (u'level 2',              'level2'),
+            (u'level 2',              'level_2'),
+            (u'level_2',              'level_2'),
             (u'',                     'A'),
             (u'123',                  'A123'),
         ]
--- a/MoinMoin/wikiutil.py	Thu Feb 05 19:27:35 2009 +0100
+++ b/MoinMoin/wikiutil.py	Fri Feb 06 00:01:17 2009 +0100
@@ -2418,10 +2418,10 @@
 def anchor_name_from_text(text):
     '''
     Generate an anchor name from the given text
-    This function generates valid HTML IDs.
+    This function generates valid HTML IDs matching: [A-Za-z][A-Za-z0-9:_.-]*
     '''
     quoted = urllib.quote_plus(text.encode('utf-7'))
-    res = quoted.replace('%', '.').replace('+', '').replace('_', '')
+    res = quoted.replace('%', '.').replace('+', '_')
     if not res[:1].isalpha():
         return 'A%s' % res
     return res