""" 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 QuoteElement(inline.InlineElement): pattern = '"""([^"]*)(?:""([^"]*))?"""' parse_children = True def __init__(self, match): self.quote = match.group(1) self.source = match.group(2) if match.group(2) is not None and not match.group(2).isspace() else None class QuoteRenderer: def render_quote_element(self, element: QuoteElement): source = f'

-- {element.source}

' if element.source is not None else '' return f'

"

{element.quote}

"

{source}
' Quote = MarkoExtension( elements=[QuoteElement], renderer_mixins=[QuoteRenderer] )