diff options
author | Botond Hende <nettingman@gmail.com> | 2024-09-22 20:07:01 +0200 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-09-22 20:07:01 +0200 |
commit | 172401092bc5bb1ec309031f9b61e72e47e52961 (patch) | |
tree | a77802abade24c3078730be13a281b15d42e8c3f /spoiler.py | |
parent | 0f2a22208906cb2f7aeaf01bccaeb9c58fb83ae3 (diff) |
updated spoiler and doc
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( |