# Regular expression defining a WikiWord
# (but this definition is also assumed in other places)
-word_re = re.compile(r"^\b((([A-Z][a-z]+){2,}/)*([A-Z][a-z]+){2,})\b$")
+word_re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
# FIXME: we accept stuff like foo/../bar and we shouldn't
file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$")
img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg)$", re.IGNORECASE)
pathname = url + '/' + pathname
return pathname
-# Formatting stuff --------------------------------------------------
+def permalink(s):
+ return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip())
+# Formatting stuff --------------------------------------------------
def emit_header(mime_type="text/html"):
print "Content-type: " + mime_type + "; charset=utf-8\n"
self.h_level = 0
else:
self.h_level = len(word) - 1
- abridged = re.sub('[^A-Za-z0-9_]', '', self.line).lower()
- result = '\n</p><h%d id="%s"><a class="heading" href="#%s">¶</a> ' % (self.h_level, abridged, abridged)
+ link = permalink(self.line)
+ result = '\n</p><h%d id="%s"><a class="heading" href="#%s">¶</a> ' % (self.h_level, link, link)
return result
def _br_repl(self, word):