blob: 63f35430c66ef23b278fc454f214d9a628d97c23 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
#******************************************************************************
from .. import BlockTag as _BlockTag
__all__ = ["SpoilerTag"]
class SpoilerTag(_BlockTag):
""" Hide content at first glance, force people to click to read content.
These elements can contain 'secret' elements such as solutions, source
code, or various other things.
Example uses:
[spoiler]This is hidden![/spoiler]
[spoiler=Y a quelque chose de caché !|Ah, bah en fait non :)]:E
And it's multiline, [big]and formatted[/big], as usual :D[/spoiler]
"""
aliases = ('[spoiler]',)
superblock = True
notempty = True
procvalue = True
def prepare(self, name, value):
self._closed = "Cliquez pour découvrir"
self._open = "Cliquez pour recouvrir"
if value:
titles = value.split('|')
if titles[0]:
self._closed = titles[0]
if len(titles) >= 2 and (len(titles) > 2 or titles[1]):
self._open = '|'.join(titles[1:])
def begin_html(self):
return '<div class="spoiler">' \
'<div class="title on" onclick="toggleSpoiler(this.parentNode, ' \
'\'open\');"><p>{}</p></div>' \
'<div class="title off" onclick="toggleSpoiler(this.parentNode, ' \
'\'close\');"><p>{}</p></div>' \
'<div class="off">'.format(self._closed, self._open)
def end_html(self):
return '</div></div>'
# End of file.
|