Compare commits

...

2 Commits

2 changed files with 29 additions and 1 deletions

View File

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

View File

@ -219,3 +219,31 @@ class TestConvertor(TestCase):
str(res.find('p')), str(res.find('p')),
expected.strip(), expected.strip(),
) )
def test_streamline_html_escape_16(self):
test_data= """
<th align="left" class="cellrowborder" id="mcps1.3.2.3.2.5.1.2" valign="top" width="20%"><p><strong>Mandatory</strong></p></th>
""" # noqa
expected = """
<th align="left" class="cellrowborder" id="mcps1.3.2.3.2.5.1.2" valign="top" width="20%"><p>Mandatory</p></th>
""" # noqa
soup = bs4.BeautifulSoup(test_data, 'lxml')
res = self.convertor.streamline_html(soup, "dummy")
self.assertEqual(
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(),
)