diff options
Diffstat (limited to 'spoiler.py')
-rw-r--r-- | spoiler.py | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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( |