From 2b90b80467b2cd64034da1f2a39ce2fb5b494c6e Mon Sep 17 00:00:00 2001 From: ivanspengen Date: Wed, 11 Apr 2018 19:13:47 +0200 Subject: [PATCH 1/2] Fix for multiline paragraph (p..)

..

tags added correctly and double escaping Fix for paragraph multiline, only last paragraph is rendered correctly Removed shelve from p tags Check to see if test are passed Fix for multiline paragraph (p..)

..

tags added correctly and double escaping revert utils.py --- tests/test_github_issues.py | 44 +++++++++++++++++++++++++++++++++++-- textile/core.py | 41 ++++++++++++++++++++++++++++------ 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 6b5b3d75..bced0dcb 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -290,9 +290,49 @@ def test_github_issue_57(): Back to 10-4 CAPS -

Some multiline Paragragh +

Some multiline Paragragh

-Here is some output!!! “Some” CAPS

''' +

Here is some output!!! “Some” CAPS

''' + t = textile.Textile() + result = t.parse(input) + assert result == expect + +def test_issue_58(): + input = '''p.. First one 'is' + +ESCAPED "bad" + +p.. Second one 'is' + + + +ESCAPED "bad" + +p.. Third one 'is' + +ESCAPED "bad" + +p.. Last one 'is' + +ESCAPED "good" test''' + + expect = '''

First one ‘is’

+ +

ESCAPED “bad”

+ +

Second one ‘is’

+ + + +

ESCAPED “bad”

+ +

Third one ‘is’

+ +

ESCAPED “bad”

+ +

Last one ‘is’

+ +

ESCAPED “good” test

''' t = textile.Textile() result = t.parse(input) assert result == expect diff --git a/textile/core.py b/textile/core.py index a5dae835..76016f08 100644 --- a/textile/core.py +++ b/textile/core.py @@ -433,6 +433,12 @@ def block(self, text): # the case, we'd want to drop the whitespace which comes after it. eat_whitespace = False + # check to see if previous block has already been escaped + escaped = False + + # check if multiline paragraph (p..) tags

..

are added to line + multiline_para = False + tag = 'p' atts = cite = ext = '' @@ -458,11 +464,17 @@ def block(self, text): if ext and out: # it's out[-2] because the last element in out is the # whitespace that preceded this line - content = encode_html(out[-2], quotes=True) - content = generate_tag(block.inner_tag, content, - block.inner_atts) - content = generate_tag(block.outer_tag, content, - block.outer_atts) + if not escaped: + content = encode_html(out[-2], quotes=True) + escaped = True + else: + content = out[-2] + + if not multiline_para: + content = generate_tag(block.inner_tag, content, + block.inner_atts) + content = generate_tag(block.outer_tag, content, + block.outer_atts) out[-2] = content tag, atts, ext, cite, content = match.groups() block = Block(self, **match.groupdict()) @@ -479,11 +491,18 @@ def block(self, text): # pre tags and raw text won't be indented. if block.outer_tag != 'pre' and not has_raw_text(line): line = "\t{0}".format(line) + + # set having paragraph tags to false + if block.tag == 'p' and ext: + multiline_para = False # no tag specified else: # if we're inside an extended block, add the text from the # previous line to the front if ext and out: + if block.tag == 'p': + line = generate_tag(block.tag, line, block.outer_atts) + multiline_para = True line = '{0}{1}'.format(out.pop(), line) # the logic in the if statement below is a bit confusing in # php-textile. I'm still not sure I understand what the php @@ -508,7 +527,15 @@ def block(self, text): else: line = self.graf(line) - line = self.doPBr(line) + if block.tag == 'p': + escaped = True + + if block.tag == 'p' and ext and not multiline_para: + line = generate_tag(block.tag, line, block.outer_atts) + multiline_para = True + else: + line = self.doPBr(line) + line = line.replace('
', '
') # if we're in an extended block, and we haven't specified a new @@ -533,7 +560,7 @@ def block(self, text): # at this point, we've gone through all the lines, and if there's still # an extension in effect, we close it here. - if ext and out: + if ext and out and not block.tag == 'p': block.content = out.pop() block.process() final = generate_tag(block.outer_tag, block.content, From b5478e81dd3b294d2e8e6e9cd115a69141b6d426 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Thu, 12 Apr 2018 12:22:55 -0400 Subject: [PATCH 2/2] update changelog and bump version number. --- CHANGELOG.textile | 3 +++ textile/version.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index cc256bfe..76c6436b 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -1,5 +1,8 @@ h1. Textile Changelog +h2. Version 3.0.2 +* BUGFIX: Fix for multiple multi-line paragraphs. ("#62":https://github.com/textile/python-textile/pull/62) + h2. Version 3.0.1 * BUGFIX: Fix improper handling of extended code blocks. ("#61":https://github.com/textile/python-textile/pull/61) diff --git a/textile/version.py b/textile/version.py index a29b27e7..5eb8b3af 100644 --- a/textile/version.py +++ b/textile/version.py @@ -1 +1 @@ -VERSION = '3.0.1' +VERSION = '3.0.2'