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/tests/test_github_issues.py b/tests/test_github_issues.py index 6c9e7464..0aeba4d8 100644 --- a/tests/test_github_issues.py +++ b/tests/test_github_issues.py @@ -173,3 +173,29 @@ 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 + +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 + +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/core.py b/textile/core.py index 392ceed1..efb1c4dc 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) @@ -917,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() 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. 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'