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=.First Header '
+ ' | \n\t\t\tSecond Header | '
+ '\n\t\t
\n\t
')
+ 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.