0 fails!
This commit is contained in:
parent
f162d1b94c
commit
4b47e63fff
|
@ -6,9 +6,9 @@ For more information, read the documentation accessible on
|
|||
|
||||
.. warning::
|
||||
|
||||
If you are accessing this repository from <https://git.planet-casio.com>_,
|
||||
If you are accessing this repository from `Planète Casio's forge`_,
|
||||
keep in mind that it is only a mirror and that the real repository
|
||||
is located at <https://forge.touhey.fr/pc/textout.git>_ for now.
|
||||
is located `in my forge <Thomas' forge_>`_ for now.
|
||||
|
||||
What is left to do
|
||||
------------------
|
||||
|
@ -29,4 +29,6 @@ What is left to do
|
|||
- Look for security flaws (we really don't want stored XSS flaws!).
|
||||
- Manage keywords with tags such as ``[tag key=value other="something else"]``.
|
||||
|
||||
.. _Planète Casio's forge:: https://gitea.planet-casio.com/
|
||||
.. _Thomas' forge_:: https://forge.touhey.fr/pc/textout.git
|
||||
.. _the official website:: https://textout.touhey.fr/docs/
|
||||
|
|
|
@ -113,18 +113,18 @@ __test_cases = {
|
|||
'<div class="citation"><p>a</p></div>',
|
||||
'[quote=Test 1 :)]lel[/quote]': \
|
||||
'<div class="citation"><p><b>Test 1 ' \
|
||||
'<img src="/images/smileys/smile.gif"> a écrit :</b></p><br />' \
|
||||
'<img src="/images/smileys/smile.gif"> a écrit :</b></p><p>' \
|
||||
'lel</p></div>',
|
||||
|
||||
# Spoilers.
|
||||
'[spoiler]': '',
|
||||
'[spoiler=Hello|world> :D]Close this, quick![/spoiler]': \
|
||||
'<div class="spoiler"><div class="title on" ' \
|
||||
'onclick="toggleSpoiler(this.parentNode, ' "'open'" ');">Hello' \
|
||||
'</div><div class="title off" ' \
|
||||
'onclick="toggleSpoiler(this.parentNode, ' "'close'" ');">world' \
|
||||
'> <img src="/images/smileys/grin.gif"></div><div class="off">' \
|
||||
'Close this, quick!</div></div>',
|
||||
'onclick="toggleSpoiler(this.parentNode, ' "'open'" ');"><p>Hello' \
|
||||
'</p></div><div class="title off" ' \
|
||||
'onclick="toggleSpoiler(this.parentNode, ' "'close'" ');"><p>world' \
|
||||
'> <img src="/images/smileys/grin.gif"></p></div>' \
|
||||
'<div class="off"><p>Close this, quick!</p></div></div>',
|
||||
|
||||
# Code.
|
||||
'[code]': '',
|
||||
|
|
|
@ -21,6 +21,7 @@ class TextoutCodeTag(_TextoutBlockTag):
|
|||
aliases = ('[code]',)
|
||||
generic = False
|
||||
raw = True
|
||||
notempty = True
|
||||
|
||||
def begin_html(self):
|
||||
return '<div class="code">'
|
||||
|
|
|
@ -33,11 +33,13 @@ class TextoutLinkTag(_TextoutInlineTag):
|
|||
|
||||
# If there is no value, wait until we have a content to
|
||||
# decide if we are valid or not.
|
||||
|
||||
if value == None:
|
||||
self.preprocess = self._preprocess_if_no_value
|
||||
return
|
||||
|
||||
# Otherwise, get the URL and validate.
|
||||
|
||||
self._url = value
|
||||
self._validate()
|
||||
self.default = self._default_if_value
|
||||
|
@ -74,10 +76,12 @@ class TextoutProfileTag(TextoutLinkTag):
|
|||
|
||||
def prepare(self, name, value):
|
||||
# Override the TextoutLinkTag's prepare method.
|
||||
|
||||
pass
|
||||
|
||||
def preprocess(self, content):
|
||||
# FIXME: check the username content!
|
||||
|
||||
username = content
|
||||
self._url = 'https://www.planet-casio.com/Fr/compte/voir_profil.php' \
|
||||
'?membre={}'.format(username)
|
||||
|
|
|
@ -23,6 +23,7 @@ class TextoutQuoteTag(_TextoutBlockTag):
|
|||
|
||||
aliases = ('[quote]',)
|
||||
superblock = True
|
||||
notempty = True
|
||||
|
||||
def prepare(self, name, value):
|
||||
self._value = value
|
||||
|
|
|
@ -23,6 +23,7 @@ class TextoutSpoilerTag(_TextoutBlockTag):
|
|||
|
||||
aliases = ('[spoiler]',)
|
||||
superblock = True
|
||||
notempty = True
|
||||
|
||||
def prepare(self, name, value):
|
||||
self._closed = "Cliquez pour découvrir"
|
||||
|
@ -38,9 +39,9 @@ class TextoutSpoilerTag(_TextoutBlockTag):
|
|||
def begin_html(self):
|
||||
return '<div class="spoiler">' \
|
||||
'<div class="title on" onclick="toggleSpoiler(this.parentNode, ' \
|
||||
'\'open\');">{}</div>' \
|
||||
'\'open\');"><p>{}</p></div>' \
|
||||
'<div class="title off" onclick="toggleSpoiler(this.parentNode, ' \
|
||||
'\'close\');">{}</div>' \
|
||||
'\'close\');"><p>{}</p></div>' \
|
||||
'<div class="off">'.format(_htmlsmileys(_htmlescape(self._closed)),
|
||||
_htmlsmileys(_htmlescape(self._open)))
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class TextoutVideoTag(_TextoutBlockTag):
|
|||
|
||||
if not self._type:
|
||||
url = _htmlescape(self._url)
|
||||
return '<a href="{}">{}</a>'.format(url, url)
|
||||
return '<p><a href="{}">{}</a></p>'.format(url, url)
|
||||
|
||||
code = '<div class="video-wrapper {}{}">'.format(self._sizeclass,
|
||||
" video-center" if self._center else "")
|
||||
|
|
|
@ -474,6 +474,11 @@ class Translator:
|
|||
# an exception if the tag in its current configuration should
|
||||
# not have an empty content.
|
||||
|
||||
if not dat.started:
|
||||
if hasattr(dat.tag, 'begin'):
|
||||
self.put_code(dat.tag.begin(), **pcattrs)
|
||||
dat.started = True
|
||||
|
||||
if not dat.last:
|
||||
try:
|
||||
self.put_text(tag.default())
|
||||
|
@ -488,7 +493,7 @@ class Translator:
|
|||
|
||||
# Don't forget to end the tag!
|
||||
|
||||
if dat.notempty and not dat.started:
|
||||
if not dat.started:
|
||||
pass
|
||||
else:
|
||||
if dat.type == dat.BLOCK:
|
||||
|
@ -528,8 +533,6 @@ class Translator:
|
|||
|
||||
if type(dat.last) != bool:
|
||||
break
|
||||
if dat.notempty and not dat.last:
|
||||
break
|
||||
|
||||
# Then put the tag in the appropriate queue.
|
||||
|
||||
|
@ -546,7 +549,8 @@ class Translator:
|
|||
else:
|
||||
inlines.insert(0, dat)
|
||||
|
||||
# If there is no new block to start
|
||||
# If there is no new block to start, there's no need to end the
|
||||
# current block.
|
||||
|
||||
if not block_to_start:
|
||||
block_to_end = None
|
||||
|
@ -566,10 +570,15 @@ class Translator:
|
|||
|
||||
# Then, put the tag beginnings.
|
||||
|
||||
for dat in superblocks + ([block_to_start] if block_to_start else []) \
|
||||
+ inlines:
|
||||
to_begin = superblocks \
|
||||
+ ([block_to_start] if block_to_start else []) \
|
||||
+ inlines
|
||||
|
||||
for dat in to_begin:
|
||||
if dat.started:
|
||||
continue
|
||||
if dat.notempty and not dat.last:
|
||||
break
|
||||
|
||||
if hasattr(dat.tag, 'begin'):
|
||||
self.put_code(dat.tag.begin(), start_tags = False,
|
||||
|
|
Loading…
Reference in New Issue