from pybb markup import postmarkup markup postmarkup create exclude co

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from pybb.markup import postmarkup
markup = postmarkup.create(exclude=['code'], use_pygments=True)
class CodeTagNoBreak(postmarkup.CodeTag):
def render_open(self, parser, node_index):
contents = self._escape(self.get_contents(parser))
self.skip_contents(parser)
return '<div class="code"><pre>%s</pre></div>' % contents
def _escape(self, s):
return postmarkup.PostMarkup.standard_replace_no_break(s.rstrip('\n'))
markup.tag_factory.add_tag(CodeTagNoBreak, 'code')