""" Encapsulates text in a
html tag with the class "quote" and between two paragraphs which contain a quote ("). These all can be styled in css. Usage (without the backslashes): \"""my quote\""" or \"""my quote "" source \""" """ from marko import inline from marko.helpers import MarkoExtension class SpoilerElement(inline.InlineElement): pattern = '\\|\\|(.*)\\|\\|(.*)\\|\\|' parse_children = True parse_group = 2 priority = 7 def __init__(self, match): self.id = match.group(1) self.children = match.group(2) class SpoilerRenderer: def render_spoiler_element(self, element: SpoilerElement): content = self.render_children(element) return f'' Spoiler = MarkoExtension( elements=[SpoilerElement], renderer_mixins=[SpoilerRenderer] )