From 479d61820b686c02d43f8a85a58cb8ee25309e6d Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Fri, 21 Jul 2017 16:28:17 -0400 Subject: [PATCH 1/4] tweak block processing to fix #50 --- tests/test_github_issues.py | 10 ++++++++++ textile/core.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 6c9e7464..832de243 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -173,3 +173,13 @@ def test_github_issue_49(): result = textile.textile(s) expect = '\t

link

' assert result == expect + +def test_github_issue_50(): + """Incorrect wrap code with Java generics in pre""" + test = ('pre.. public class Tynopet {}\n\nfinal ' + 'List> multipleList = new ArrayList<>();') + result = textile.textile(test) + expect = ('
public class Tynopet<T extends Framework> {}\n\n'
+              'final List<List<String>> multipleList = new '
+              'ArrayList<>();
') + assert result == expect diff --git a/textile/core.py b/textile/core.py index 392ceed1..f044959e 100644 --- a/textile/core.py +++ b/textile/core.py @@ -534,7 +534,10 @@ 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: - final = generate_tag(block.outer_tag, out.pop(), block.outer_atts) + block.content = out.pop() + block.process() + final = generate_tag(block.outer_tag, block.content, + block.outer_atts) out.append(final) return ''.join(out) From 6b3a105ffa891dfef04ba1de519baf15e8c7df55 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Tue, 25 Jul 2017 08:53:23 -0400 Subject: [PATCH 2/4] quick and easy fix for #51 --- tests/test_github_issues.py | 7 +++++++ textile/core.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index 832de243..e50ad385 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -183,3 +183,10 @@ def test_github_issue_50(): 'final List<List<String>> multipleList = new ' 'ArrayList<>();') assert result == expect + +def test_github_issue_51(): + """Link build with $ sign without "http" prefix broken.""" + test = '"$":www.google.com.br' + result = textile.textile(test) + expect = '\t

www.google.com.br

' + assert result == expect diff --git a/textile/core.py b/textile/core.py index f044959e..efb1c4dc 100644 --- a/textile/core.py +++ b/textile/core.py @@ -920,7 +920,7 @@ def _casesdefault(c, pop, popped, url_chars, counts, pre): text = url if "://" in text: text = text.split("://")[1] - else: + elif ":" in text: text = text.split(":")[1] text = text.strip() From 6ad9e3841fcffed79cfa736875bdd589cc0c5346 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Wed, 9 Aug 2017 21:52:42 -0400 Subject: [PATCH 3/4] handle poor table formatting better. fixes #52 --- tests/test_github_issues.py | 9 +++++++++ textile/objects/table.py | 16 +++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py index e50ad385..0aeba4d8 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -190,3 +190,12 @@ def test_github_issue_51(): result = textile.textile(test) expect = '\t

www.google.com.br

' assert result == expect + +def test_github_issue_52(): + """Table build without space after aligment raise a AttributeError.""" + test = '|=.First Header |=. Second Header |' + result = textile.textile(test) + expect = ('\t\n\t\t\n\t\t\t\n\t\t\t' + '\n\t\t\n\t
=.First Header ' + 'Second Header
') + assert result == expect diff --git a/textile/objects/table.py b/textile/objects/table.py index f6940985..4796afce 100644 --- a/textile/objects/table.py +++ b/textile/objects/table.py @@ -38,15 +38,17 @@ def process(self): # as a normal center-aligned cell. if i == 0 and row[:2] == '|=': captionpattern = (r"^\|\=(?P{s}{a}{c})\. " - r"(?P[^\n]*)(?P.*)".format(**{'s': - table_span_re_s, 'a': align_re_s, 'c': cls_re_s})) + r"(?P[^\n]*)(?P.*)".format(**{ + 's': table_span_re_s, 'a': align_re_s, + 'c': cls_re_s})) caption_re = re.compile(captionpattern, re.S) cmtch = caption_re.match(row) - caption = Caption(**cmtch.groupdict()) - self.caption = '\n{0}'.format(caption.caption) - row = cmtch.group('row').lstrip() - if row == '': - continue + if cmtch: + caption = Caption(**cmtch.groupdict()) + self.caption = '\n{0}'.format(caption.caption) + row = cmtch.group('row').lstrip() + if row == '': + continue # Colgroup -- A colgroup row will not necessarily end with a |. # Hence it may include the next row of actual table data. From eda1971121fdfcf7c138804925ade1bcc68141c3 Mon Sep 17 00:00:00 2001 From: Dennis Burke Date: Mon, 14 Aug 2017 09:23:47 -0400 Subject: [PATCH 4/4] version bumpin' and CHANGELOGgin' --- CHANGELOG.textile | 6 ++++++ textile/version.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.textile b/CHANGELOG.textile index 27384d74..5047e1af 100644 --- a/CHANGELOG.textile +++ b/CHANGELOG.textile @@ -1,5 +1,11 @@ h1. Textile Changelog +h2. Version 2.3.16 +* Bugfixes: +** Fix processing of extended code blocks ("#50":https://github.com/textile/python-textile/issues/50) +** Don't break when links fail to include "http:" ("#51":https://github.com/textile/python-textile/issues/51) +** Better handling of poorly-formatted tables ("#52":https://github.com/textile/python-textile/issues/52) + h2. Version 2.3.15 * Bugfix: Don't break on unicode characters in the fragment of a url. diff --git a/textile/version.py b/textile/version.py index 5e4173d6..beb7a8e4 100644 --- a/textile/version.py +++ b/textile/version.py @@ -1 +1 @@ -VERSION = '2.3.15' +VERSION = '2.3.16'