def test_parse_html2(self):
parser = QqParser(allowed_tags={'chapter', 'section',
'subsection', 'subsubsection',
'eq', 'eqref', 'ref',
'equation', 'label', 'idx'})
doc = r"""\chapter \label h1:label
Hello
This is a \ref{h1:label}.
"""
tree = parser.parse(doc)
html = QqHTMLFormatter(tree)
s = html.do_format()
soup = BeautifulSoup(s, 'html.parser')
self.assertEqual(soup.h1['id'], 'label_h1_label')
self.assertEqual(soup.span['class'], ['section__number'])
self.assertEqual(soup.span.string, "1")
self.assertEqual(soup("a")[1].attrs,{'class': ['a-ref'], 'title': '', 'href': '#label_h1_label'})
self.assertEqual(soup("a")[1].string, "1")
评论列表
文章目录