summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-09-22 20:07:01 +0200
committerBotond Hende <nettingman@gmail.com>2024-09-22 20:07:01 +0200
commit172401092bc5bb1ec309031f9b61e72e47e52961 (patch)
treea77802abade24c3078730be13a281b15d42e8c3f
parent0f2a22208906cb2f7aeaf01bccaeb9c58fb83ae3 (diff)
updated spoiler and doc
-rw-r--r--spoiler.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/spoiler.py b/spoiler.py
index ee15dfd..ff762ef 100644
--- a/spoiler.py
+++ b/spoiler.py
@@ -1,12 +1,11 @@
"""
-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.
+Creates a <span> that contains a checkbox with a label that has a content and another that is a number of rectangle
+characters (▉) equal to the content. A clickable spoiler/hidden text can be made with these when correctly styled.
-Usage (without the backslashes):
-\"""my quote\"""
-or
-\"""my quote "" source \"""
+Usage:
+||unique_id||content||
"""
+from html import unescape
from marko import inline
from marko.helpers import MarkoExtension
@@ -26,7 +25,7 @@ class SpoilerElement(inline.InlineElement):
class SpoilerRenderer:
def render_spoiler_element(self, element: SpoilerElement):
content = self.render_children(element)
- return f'<span><input type="checkbox" class="spoiler" id="{element.id}"><label class="spoiler-on" for="{element.id}"><span>{"▉" * len(content)}</span></label><label class="spoiler-off" for="{element.id}"><span>{content}</span></label></span>'
+ return f'<span><input type="checkbox" class="spoiler" id="{element.id}"><label class="spoiler-on" for="{element.id}"><span>{"▉" * len(unescape(content))}</span></label><label class="spoiler-off" for="{element.id}"><span>{content}</span></label></span>'
Spoiler = MarkoExtension(