summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-09-06 20:29:02 +0200
committerBotond Hende <nettingman@gmail.com>2024-09-06 20:29:02 +0200
commit9ceea408679913000039013f3a1ddfb695880e6a (patch)
tree998c1ffdb81d4e8061ee91ceb07392c4b489aa21
parented0aa1323a7acae363c670cc1dd6611c09e0c3fb (diff)
added quote renderer
-rw-r--r--quote.py25
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]
+)