fixing th condition and adding one more unit test

This commit is contained in:
Hasko, Vladimir 2023-04-19 06:27:15 +00:00
parent efab231e2b
commit ecc478cd31
2 changed files with 15 additions and 1 deletions

View File

@ -224,7 +224,7 @@ class OTCDocConvertor:
# Drop strong in table headers "/"
for th in soup.body.find_all("th"):
if th and th.p.strong:
if th.p and th.p.strong:
th.p.strong.unwrap()
if args and args.improve_table_headers:

View File

@ -233,3 +233,17 @@ class TestConvertor(TestCase):
str(res.find('th')),
expected.strip(),
)
def test_streamline_html_escape_17(self):
test_data= """
<th align="left" class="cellrowborder" id="mcps1.3.2.3.2.5.1.2" valign="top" width="20%">Mandatory</th>
""" # noqa
expected = """
<th align="left" class="cellrowborder" id="mcps1.3.2.3.2.5.1.2" valign="top" width="20%">Mandatory</th>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
str(res.find('th')),
expected.strip(),
)