diff --git a/boards/mdx_neboard.py b/boards/mdx_neboard.py --- a/boards/mdx_neboard.py +++ b/boards/mdx_neboard.py @@ -34,23 +34,43 @@ class ReflinkPattern(Pattern): return ref_element +class SpoilerPattern(Pattern): + def handleMatch(self, m): + quote_element = etree.Element('span') + quote_element.set('class', 'spoiler') + quote_element.text = m.group(2) + + return quote_element + + +class CommentPattern(Pattern): + def handleMatch(self, m): + quote_element = etree.Element('span') + quote_element.set('class', 'comment') + quote_element.text = '//' + m.group(3) + + return quote_element + + class NeboardMarkdown(markdown.Extension): AUTOLINK_PATTERN = r'(http://\S+)' QUOTE_PATTERN = r'(>){1}(.+)' REFLINK_PATTERN = r'((>){2}(\d+))' + SPOILER_PATTERN = r'%%(.+)%%' + COMMENT_PATTERN = r'(//(.+))' def extendMarkdown(self, md, md_globals): autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md) quote = QuotePattern(self.QUOTE_PATTERN, md) reflink = ReflinkPattern(self.REFLINK_PATTERN, md) + spoiler = SpoilerPattern(self.SPOILER_PATTERN, md) + comment = CommentPattern(self.COMMENT_PATTERN, md) md.inlinePatterns[u'autolink_ext'] = autolink md.inlinePatterns.add(u'reflink', reflink, '