self.in_pre = self.in_table = False
self.in_header = True
self.list_indents = []
- self.tr_cnt = self.h_cnt = 0
+ self.tr_cnt = 0
self.styles = {
#wiki html enabled?
"//": ["em", False],
self.h_level = 0
else:
self.h_level = len(word) - 1
- self.h_cnt += 1
- #abridged = re.sub('[^a-z_]', '', word.lower().replace(' ', '_'))
- result = '<h%d id="%d"><a class="heading" href="#%d">¶</a> ' % (self.h_level, self.h_cnt, self.h_cnt)
+ abridged = re.sub('[^A-Za-z0-9_]', '', self.line).lower()
+ result = '<h%d id="%s"><a class="heading" href="#%s">¶</a> ' % (self.h_level, abridged, abridged)
return result
def _br_repl(self, word):
indent_re = re.compile(r"^\s*")
tr_re = re.compile(r"^\s*\|\|")
eol_re = re.compile(r"\r?\n")
- for line in eol_re.split(self.raw.expandtabs()):
+ for self.line in eol_re.split(self.raw.expandtabs()):
# Skip ACLs
if self.in_header:
- if line.startswith('#'):
+ if self.line.startswith('#'):
continue
self.in_header = False
if self.in_pre:
- print re.sub(pre_re, self.replace, line)
+ print re.sub(pre_re, self.replace, self.line)
else:
- if self.in_table and not tr_re.match(line):
+ if self.in_table and not tr_re.match(self.line):
self.in_table = False
print '</tbody></table><p>'
- if blank_re.match(line):
+ if blank_re.match(self.line):
print '</p><p>'
else:
- indent = indent_re.match(line)
+ indent = indent_re.match(self.line)
print self._indent_to(len(indent.group(0)))
- print re.sub(scan_re, self.replace, line)
+ print re.sub(scan_re, self.replace, self.line)
if self.in_pre: print '</pre>'
if self.in_table: print '</tbody></table><p>'