def __init__(self, raw):
self.raw = raw
self.h_level = 0
- self.in_pre = self.in_table = self.in_var = self.in_em = self.in_b = False
+ self.in_pre = self.in_table = self.in_tt = self.in_em = self.in_b = False
self.in_header = True
self.list_indents = []
self.tr_cnt = self.h_cnt = 0
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]
+
def _tit_repl(self, word):
if self.h_level:
result = '</h%d>' % self.h_level
cl = 'notice'
return '<strong class="highlight ' + cl + '">' + word + '</strong>'
- def _var_repl(self, word):
- if word == '{{' and not self.in_var:
- self.in_var = True
- return '<code>'
- elif self.in_var:
- self.in_var = False
- return '</code>'
- return ''
-
def _tr_repl(self, word):
out = ''
if not self.in_table:
# Formatting
+ r"(?P<b>\*\*|''')"
+ r"|(?P<em>//|'')"
+ + r"|(?P<tt>##|``)"
+ r"|(?P<tit>\={2,6})"
+ r"|(?P<br>\\\\)"
+ r"|(?P<rule>^-{3,})"
# Lists, divs, spans
+ r"|(?P<li>^\s+[\*#] +)"
+ r"|(?P<pre>\{\{\{|\s*\}\}\})"
- + r"|(?P<var>\{\{|\}\})"
# Tables
+ r"|(?P<tr>^\s*\|\|(=|)\s*)"