summaryrefslogtreecommitdiff
path: root/quote.py
diff options
context:
space:
mode:
Diffstat (limited to 'quote.py')
-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]
+)