From cdfa9490bea32b33bde09dac83ff3b219fafd4d8 Mon Sep 17 00:00:00 2001 From: Kirill Mavreshko Date: Wed, 31 Aug 2022 12:56:49 +0500 Subject: [PATCH] Fix wrong output when "bc.." is the last block #81 --- tests/fixtures/README.txt | 2 +- tests/test_values.py | 8 ++++++++ textile/core.py | 9 ++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/fixtures/README.txt b/tests/fixtures/README.txt index 61dc0f0..949db70 100644 --- a/tests/fixtures/README.txt +++ b/tests/fixtures/README.txt @@ -60,4 +60,4 @@ When textile is not installed locally: -
PYTHONPATH=. pytest
\ No newline at end of file +
PYTHONPATH=. pytest
\ No newline at end of file diff --git a/tests/test_values.py b/tests/test_values.py index 063ed3e..9792881 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -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", + "
The beginning
\n\n
This code\n\nis the last\n\nblock in the document
"), + ("bc.. This code\n\nis not\n\nsurrounded by anything\n", + "
This code\n\nis not\n\nsurrounded by anything
"), + ("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\np.. post-code paragraph", + "
Paragraph 1\n\nParagraph 2\n\nParagraph 3
\n\n

post-code paragraph

"), + ("bc.. Paragraph 1\n\nParagraph 2\n\nParagraph 3\n\npre.. post-code non-p block", + "
Paragraph 1\n\nParagraph 2\n\nParagraph 3
\n\n
post-code non-p block
"), ('I spoke.\nAnd none replied.', '\t

I spoke.
\nAnd none replied.

'), ('I __know__.\nI **really** __know__.', '\t

I know.
\nI really know.

'), ("I'm %{color:red}unaware%\nof most soft drinks.", '\t

I’m unaware
\nof most soft drinks.

'), diff --git a/textile/core.py b/textile/core.py index 7b66af0..bf0871d 100644 --- a/textile/core.py +++ b/textile/core.py @@ -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):