diff --git a/test/test_html.py b/test/test_html.py index 4417c6d..36a0a38 100755 --- a/test/test_html.py +++ b/test/test_html.py @@ -55,7 +55,7 @@ __test_cases = { '[show]lol': '

lol

', '[quote][show][justify]hehe': \ '

' \ - '<div class="align-justify">' \ + '<div class="align-justify">' \ '<p>hehe</p></div>' \ '

', diff --git a/textoutpc/builtin_tags/Show.py b/textoutpc/builtin_tags/Show.py index 5562ebf..66df4e8 100755 --- a/textoutpc/builtin_tags/Show.py +++ b/textoutpc/builtin_tags/Show.py @@ -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 '

' + return '' def end_html(self): - return '

' + return '' # End of file. diff --git a/textoutpc/translate.py b/textoutpc/translate.py index 3ecdbe2..7263704 100755 --- a/textoutpc/translate.py +++ b/textoutpc/translate.py @@ -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).