comparison MoinMoin/wikiutil.py @ 2576:f4c371b00fec

refactor the ID generation/writing code
author Johannes Berg <johannes AT sipsolutions DOT net>
date Fri, 27 Jul 2007 11:37:37 +0200
parents a7dc3cc36362
children 2e6227a50d27
comparison
equal deleted inserted replaced
2575:d1ec881c6f86 2576:f4c371b00fec
2098 2098
2099 lines = diff_text.diff(lines1, lines2, **kw) 2099 lines = diff_text.diff(lines1, lines2, **kw)
2100 return lines 2100 return lines
2101 2101
2102 def anchor_name_from_text(text): 2102 def anchor_name_from_text(text):
2103 '''
2104 Generate an anchor name from the given text
2105 This function generates valid HTML IDs.
2106 '''
2103 quoted = urllib.quote_plus(text.encode('utf-7')) 2107 quoted = urllib.quote_plus(text.encode('utf-7'))
2104 res = quoted.replace('%', '.').replace('+', '').replace('_', '') 2108 res = quoted.replace('%', '.').replace('+', '').replace('_', '')
2105 if not res[:1].isalpha(): 2109 if not res[:1].isalpha():
2106 return 'A%s' % res 2110 return 'A%s' % res
2107 return res 2111 return res