From 9ceea408679913000039013f3a1ddfb695880e6a Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Fri, 6 Sep 2024 20:29:02 +0200 Subject: added quote renderer --- quote.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 quote.py (limited to 'quote.py') 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
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'

"

{self.render_children(element)}

"

' + + +Quote = MarkoExtension( + elements=[QuoteElement], + renderer_mixins=[QuoteRenderer] +) -- cgit v1.2.3-70-g09d2