##// END OF EJS Templates
Speed up parsing by moving constants to module scape
neko259 -
r302:f4eb05fc default
parent child Browse files
Show More
@@ -7,6 +7,12 b' import boards'
7 7 __author__ = 'neko259'
8 8
9 9
10 AUTOLINK_PATTERN = r'(https?://\S+)'
11 QUOTE_PATTERN = r'^(?<!>)(>[^>]+)$'
12 REFLINK_PATTERN = r'((>>)(\d+))'
13 SPOILER_PATTERN = r'%%(.+)%%'
14 COMMENT_PATTERN = r'^(//(.+))'
15
10 16 class AutolinkPattern(Pattern):
11 17 def handleMatch(self, m):
12 18 link_element = etree.Element('a')
@@ -56,12 +62,6 b' class CommentPattern(Pattern):'
56 62
57 63
58 64 class NeboardMarkdown(markdown.Extension):
59 AUTOLINK_PATTERN = r'(https?://\S+)'
60 QUOTE_PATTERN = r'^(?<!>)(>[^>]+)$'
61 REFLINK_PATTERN = r'((>>)(\d+))'
62 SPOILER_PATTERN = r'%%(.+)%%'
63 COMMENT_PATTERN = r'^(//(.+))'
64
65 65 def extendMarkdown(self, md, md_globals):
66 66 self._add_neboard_patterns(md)
67 67 self._delete_patterns(md)
@@ -73,11 +73,11 b' class NeboardMarkdown(markdown.Extension'
73 73 del md.inlinePatterns['image_reference']
74 74
75 75 def _add_neboard_patterns(self, md):
76 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
77 quote = QuotePattern(self.QUOTE_PATTERN, md)
78 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
79 spoiler = SpoilerPattern(self.SPOILER_PATTERN, md)
80 comment = CommentPattern(self.COMMENT_PATTERN, md)
76 autolink = AutolinkPattern(AUTOLINK_PATTERN, md)
77 quote = QuotePattern(QUOTE_PATTERN, md)
78 reflink = ReflinkPattern(REFLINK_PATTERN, md)
79 spoiler = SpoilerPattern(SPOILER_PATTERN, md)
80 comment = CommentPattern(COMMENT_PATTERN, md)
81 81
82 82 md.inlinePatterns[u'autolink_ext'] = autolink
83 83 md.inlinePatterns[u'spoiler'] = spoiler
General Comments 0
You need to be logged in to leave comments. Login now