self.raw = raw
self.is_em = self.is_b = 0
self.h_level = 0
+ self.h_count = 0
self.list_indents = []
self.in_pre = False
self.in_table = False
def _tit_repl(self, word):
if self.h_level:
- result = "</h%d>" % self.h_level
+ result = "</h%d></a>" % self.h_level
self.h_level = 0
else:
self.h_level = len(word) - 1
- result = "<h%d>" % self.h_level
+ self.h_count += 1
+ result = '<a href="#%d"><h%d id="%d">' % (self.h_count, self.h_level, self.h_count)
return result
def _rule_repl(self, word):
- s = self._undent()
- if len(word) <= 3:
- s = s + "\n<hr size='1' noshade=\"noshade\" />\n"
- else:
- s = s + "\n<hr size='%d' noshade=\"noshade\" />\n" % (len(word) - 2 )
- return s
+ return self._undent() + '\n<hr size="%d" noshade="noshade" />\n' % (len(word) - 2)
def _word_repl(self, word):
return Page(word).link_to()
def _email_repl(self, word):
return '<a href="mailto:%s">%s</a>' % (word, word)
+ def _html_repl(self, word):
+ return word; # Pass through
def _ent_repl(self, s):
return {'&': '&',
'<': '<',
'>': '>'}[s]
-
def _li_repl(self, match):
return '<li>'
-
def _pre_repl(self, word):
if word == '{{{' and not self.in_pre:
self.in_pre = True
+ r"(?P<emph>'{2,3})"
+ r"|(?P<tit>\={2,6})"
+ r"|(?P<rule>^-{3,})"
+ + r"|(?P<html><(/|)(div|span|iframe)[^<>]*>)"
+ r"|(?P<ent>[<>&])"
+ r"|(?P<hi>\b(FIXME|TODO|DONE)\b)"