2
0
Fork 0

Works better. Not perfectly, just better.

This commit is contained in:
Thomas Touhey 2018-06-22 02:43:31 +02:00
parent cfed4cc7de
commit 3cdd2b4bc1
No known key found for this signature in database
GPG Key ID: 2ECEB0517AD947FB
3 changed files with 20 additions and 11 deletions

View File

@ -55,7 +55,7 @@ __test_cases = {
'[show]lol': '<p><span style="font-family: monospace;">lol</span></p>',
'[quote][show][justify]hehe': \
'<div class="citation"><p><span style="font-family: monospace;">' \
'&lt;div class="align-justify"&gt;' \
'&lt;div class=&quot;align-justify&quot;&gt;' \
'&lt;p&gt;hehe&lt;/p&gt;&lt;/div&gt;' \
'</span></p></div>',

View File

@ -17,6 +17,7 @@ class TextoutShowTag(_TextoutBlockTag):
"""
aliases = ('[show]',)
notempty = True
superblock = True
inlined = True
generic = False
@ -26,9 +27,9 @@ class TextoutShowTag(_TextoutBlockTag):
return _htmlescape(content)
def begin_html(self):
return '<p><span style="font-family: monospace;">'
return '<span style="font-family: monospace;">'
def end_html(self):
return '</span></p>'
return '</span>'
# End of file.

View File

@ -267,7 +267,7 @@ class Translator:
next_block_is_super = dat.inlined
elif not superblocks_only and not blockfound:
blockfound = True
next_block_is_super = False
next_block_is_super = dat.inlined
else:
continue
@ -279,9 +279,18 @@ class Translator:
dat.last = True
continue
# Add the content to the preprocess buffer.
if not dat.raw:
text = process_func(text)
dat.last += text
# Start the tags if we're about to give this content to
# preprocessing.
if start_tags:
self.start_tags()
break
else:
# No `break` has been encountered, which means the content has
@ -388,8 +397,7 @@ class Translator:
dat = self.queue.pop(0)
tag = dat.tag
pcattrs = {'start_tags': False,
'superblocks_only': dat.type == dat.BLOCK,
pcattrs = {'superblocks_only': dat.type == dat.BLOCK,
'next_block_is_super': dat.inlined}
# If preprocessing has been enabled, we ought to process the content,
@ -438,11 +446,11 @@ class Translator:
# just put the content that we got earlier.
if hasattr(tag, 'begin'):
self.put_code(tag.begin(), False)
self.put_code(tag.begin(), **pcattrs)
dat.started = True
if hasattr(tag, 'content'):
self.put_code(tag.content())
self.put_code(tag.content(), **pcattrs)
elif dat.raw:
# XXX: I'm unsure about this. Shall raw tags return code
# or text? The text will only be escaped as raw mode is
@ -450,14 +458,14 @@ class Translator:
self.put_text(content)
else:
self.put_code(content)
self.put_code(content, **pcattrs)
elif hasattr(tag, 'content'):
# Tag replaces content without preprocessing, which means
# the content has been ignored and the tag only puts the
# things.
self.cign -= 1
self.put_code(tag.content())
self.put_code(tag.content(), **pcattrs)
elif hasattr(tag, 'default'):
# Tag defines a default content if there might be none,
# without text preprocessing. If there is no content, print it.
@ -485,7 +493,7 @@ class Translator:
if dat.type == dat.BLOCK:
self.close_inline_tags()
if hasattr(tag, 'end'):
self.put_code(tag.end(), False)
self.put_code(tag.end(), start_tags = False, **pcattrs)
# Disable raw mode if it was a raw tag (which means that it enabled it,
# as tags into raw tags cannot be processed).