summaryrefslogtreecommitdiff
path: root/strikethrough.py
blob: 9272898d52c274f3b1f964f403d3c65c97f7cb28 (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 StrikeThroughElement(inline.InlineElement):
    pattern = '~~(.+)~~'
    parse_children = True


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


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