def __init__(self, raw):
self.raw = raw
self.h_level = 0
- self.in_pre = self.in_table = self.in_tt = self.in_em = self.in_b = False
+ self.in_pre = self.in_table = False
self.in_header = True
self.list_indents = []
self.tr_cnt = self.h_cnt = 0
+ self.styles = {
+ #wiki html enabled?
+ "//": ["em", False],
+ "''": ["em", False],
+ "**": ["b", False],
+ "'''": ["b", False],
+ "##": ["tt", False],
+ "``": ["tt", False],
+ "__": ["u", False],
+ "^^": ["sup", False],
+ ",,": ["sub", False]
+ }
def _b_repl(self, word):
- self.in_b = not self.in_b
- return ['</strong>', '<strong>'][self.in_b]
-
- def _em_repl(self, word):
- self.in_em = not self.in_em
- return ['</em>', '<em>'][self.in_em]
-
- def _tt_repl(self, word):
- self.in_tt = not self.in_tt
- return ['</tt>', '<tt>'][self.in_tt]
+ style = self.styles[word]
+ style[1] = not style[1]
+ return ['</','<'][style[1]] + style[0] + '>'
def _tit_repl(self, word):
if self.h_level:
scan_re = re.compile(
r"(?:"
# Formatting
- + r"(?P<b>\*\*|''')"
- + r"|(?P<em>//|'')"
- + r"|(?P<tt>##|``)"
+ + r"(?P<b>\*\*|'''|//|''|##|``|__|\^\^|,,)"
+ r"|(?P<tit>\={2,6})"
+ r"|(?P<br>\\\\)"
+ r"|(?P<rule>^-{3,})"