summaryrefslogtreecommitdiff
path: root/strikethrough.py
blob: d0342fc649ae58bb7b672eb515af5c0f2f13f113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Encapsulates text in <del> html tag, which usually displayed as strikethrough text.

Usage:
~~my text~~
"""
from marko import inline
from marko.helpers import MarkoExtension


class StrikeThrough(inline.InlineElement):
    pattern = '~~(.+)~~'
    parse_children = True


class StrikeThroughRenderer:
    def render_strike_through(self, element):
        return f"<del>{self.render_children(element)}</del>"


StrikeThrough = MarkoExtension(
    elements=[StrikeThrough],
    renderer_mixins=[StrikeThroughRenderer]
)