Skip to content

Commit

Permalink
Fix wrong output when "bc.." is the last block textile#81
Browse files Browse the repository at this point in the history
  • Loading branch information
kpot committed Aug 31, 2022
1 parent 6cdcd52 commit cdfa949
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/fixtures/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@

When textile is not installed locally:</code></pre>

<pre>PYTHONPATH=. pytest</pre>
<pre><code>PYTHONPATH=. pytest</code></pre>
8 changes: 8 additions & 0 deletions tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@

# A few extra cases for HTML4
html_known_values = (
("pre.. The beginning\n\nbc.. This code\n\nis the last\n\nblock in the document\n",
"<pre>The beginning</pre>\n\n<pre><code>This code\n\nis the last\n\nblock in the document</code></pre>"),
("bc.. This code\n\nis not\n\nsurrounded by anything\n",
"<pre><code>This code\n\nis not\n\nsurrounded by anything</code></pre>"),
("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\np.. post-code paragraph",
"<pre><code>Paragraph 1\n\nParagraph 2\n\nParagraph 3</code></pre>\n\n<p>post-code paragraph</p>"),
("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\npre.. post-code non-p block",
"<pre><code>Paragraph 1\n\nParagraph 2\n\nParagraph 3</code></pre>\n\n<pre>post-code non-p block</pre>"),
('I spoke.\nAnd none replied.', '\t<p>I spoke.<br />\nAnd none replied.</p>'),
('I __know__.\nI **really** __know__.', '\t<p>I <i>know</i>.<br />\nI <b>really</b> <i>know</i>.</p>'),
("I'm %{color:red}unaware%\nof most soft drinks.", '\t<p>I&#8217;m <span style="color:red;">unaware</span><br />\nof most soft drinks.</p>'),
Expand Down
9 changes: 4 additions & 5 deletions textile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,10 @@ def block(self, text):
# at this point, we've gone through all the lines. if there's still an
# extension in effect, we close it here
if ext and out and not block.tag == 'p':
block.content = out.pop()
block.process()
final = generate_tag(block.outer_tag, block.content,
block.outer_atts)
out.append(final)
content = out.pop()
content = generate_tag(block.inner_tag, content, block.inner_atts)
content = generate_tag(block.outer_tag, content, block.outer_atts)
out.append(content)
return ''.join(out)

def footnoteRef(self, text):
Expand Down

0 comments on commit cdfa949

Please sign in to comment.