diff options
author | Botond Hende <nettingman@gmail.com> | 2024-09-06 20:29:02 +0200 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-09-06 20:29:02 +0200 |
commit | 9ceea408679913000039013f3a1ddfb695880e6a (patch) | |
tree | 998c1ffdb81d4e8061ee91ceb07392c4b489aa21 /quote.py | |
parent | ed0aa1323a7acae363c670cc1dd6611c09e0c3fb (diff) |
added quote renderer
Diffstat (limited to 'quote.py')
-rw-r--r-- | quote.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/quote.py b/quote.py new file mode 100644 index 0000000..06897d2 --- /dev/null +++ b/quote.py @@ -0,0 +1,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] +) |