summaryrefslogtreecommitdiff
path: root/quote.py
blob: 06897d2339d0758a4c79f34db13b5b8dde08fbba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""
Encapsulates text in a <div> 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\"""
"""
from marko import inline
from marko.helpers import MarkoExtension


class QuoteElement(inline.InlineElement):
    pattern = '"""(.+)"""'
    parse_children = True


class QuoteRenderer:
    def render_quote_element(self, element):
        return f'<div class="quote"><p>"</p><p>{self.render_children(element)}</p><p>"</p></div>'


Quote = MarkoExtension(
    elements=[QuoteElement],
    renderer_mixins=[QuoteRenderer]
)