Skip to content

Instantly share code, notes, and snippets.

@netjunki
Last active January 8, 2018 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netjunki/da7fffb65b7f51a4c5c27e5c6b9ff137 to your computer and use it in GitHub Desktop.
Save netjunki/da7fffb65b7f51a4c5c27e5c6b9ff137 to your computer and use it in GitHub Desktop.
Multiline IWikiSyntaxProvider
This is a page with ##just hidden## spoiler. <- This works correctly and on the page displays without the surrounding ##
== '''__Header2__''' ==
Trying to replicate an issue found on another page.
The below content doesn't work correctly and the ## are shown.
##
=== '''''Header3 Header''''' ===
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vulputate, est ultricies euismod malesuada, diam nulla dignissim eros, id fringilla tortor libero ut nisl. Aliquam porttitor turpis lorem, nec pharetra ex vehicula nec. Cras feugiat luctus lacinia. Vestibulum cursus bibendum diam, at tincidunt libero egestas venenatis. Praesent quis luctus nunc. Donec auctor enim purus, ut commodo risus varius sed. Nunc id erat suscipit, mollis est nec, posuere lectus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis quis odio quis orci vestibulum mattis non ac arcu.
##
# -*- coding: utf-8 -*-
""" Copyright (c) 2018 Ben Lau <benjamin.a.lau@gmail.com>"""
from genshi.builder import tag
from trac.core import *
from trac.wiki.api import IWikiSyntaxProvider
class SpoilerMarkupPlugin(Component):
""" Trac Plug-in to provide Wiki Syntax for marking spoiler for exclusion in includes."""
implements ( IWikiSyntaxProvider )
RE_SPOILER = r"##(?P<spoiler>.*?)##(?ms)"
def _spoiler(self, formatter, match, fullmatch):
content = fullmatch.group('spoiler')
return content
def get_wiki_syntax(self):
yield ( self.RE_SPOILER , self._spoiler )
def get_link_resolvers(self):
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment