~widelands-dev/widelands-website/django_staticfiles

« back to all changes in this revision

Viewing changes to pybb/markups/mypostmarkup.py

  • Committer: Holger Rapp
  • Date: 2009-02-25 16:55:36 UTC
  • Revision ID: sirver@kallisto.local-20090225165536-3abfhjx8qsgtzyru
- Added my hacked version of pybb. Remerging new versions is very difficult at this point :(

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pybb.markups import postmarkup
 
2
import re
 
3
 
 
4
RE_FIRST_LF = re.compile('^\s*\r?\n')
 
5
markup = postmarkup.create(exclude=['link', 'url', 'code'], use_pygments=False)
 
6
 
 
7
class LinkTagNoAnnotate(postmarkup.LinkTag):
 
8
    def annotate_link(self, domain):        
 
9
        return ''
 
10
 
 
11
 
 
12
class CodeTagNoBreak(postmarkup.CodeTag):
 
13
    def render_open(self, parser, node_index):
 
14
 
 
15
        contents = self._escape(self.get_contents(parser))
 
16
        contents = RE_FIRST_LF.sub('', contents)
 
17
        self.skip_contents(parser)
 
18
        return '<pre><code>%s</code></pre>' % contents
 
19
 
 
20
    def _escape(self, s):
 
21
        return postmarkup.PostMarkup.standard_replace_no_break(s.rstrip('\n'))
 
22
                
 
23
 
 
24
markup.tag_factory.add_tag(LinkTagNoAnnotate, 'url')
 
25
markup.tag_factory.add_tag(CodeTagNoBreak, 'code')