Skip to content

Commit

Permalink
add a test for a table which has a colgroup but no caption
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed Aug 7, 2024
1 parent 6e041ab commit a10ace1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tests/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,13 @@
# Table column with an emphasis should not be confused with a heading
('|_touch_ this!| _touch_ this! |',
'\t<table>\n\t\t<tr>\n\t\t\t<td><em>touch</em> this!</td>\n\t\t\t<td> <em>touch</em> this! </td>\n\t\t</tr>\n\t</table>'),

# Table with colgroup but no caption
(("|:\\5. 80 |\x20\n"
"|a|b|c|d|e|\x20\n"),
('\t<table>\n'
'\t<colgroup span="5" width="80">\n\t</colgroup>\n'
'\t\t<tr>\n\t\t\t<td>a</td>\n\t\t\t<td>b</td>\n\t\t\t<td>c</td>\n\t\t\t<td>d</td>\n\t\t\t<td>e</td>\n\t\t</tr>\n'
'\t</table>')),
)


Expand Down
4 changes: 2 additions & 2 deletions textile/objects/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, capts, cap, row, restricted):

def process(self, cap):
tag = generate_tag('caption', cap.strip(), self.attributes)
return '\t{0}\n'.format(tag)
return '\t{0}'.format(tag)


class Colgroup(object):
Expand Down Expand Up @@ -182,7 +182,7 @@ def process(self):
xml_declaration = "<?xml version='1.0' encoding='UTF-8'?>\n"
colgrp = colgrp.replace(xml_declaration, '')
colgrp = colgrp.replace('><', '>\n\t<')
return f"\t{colgrp}"
return f"\n\t{colgrp}"


class Row(object):
Expand Down

0 comments on commit a10ace1

Please sign in to comment.