Incorrect _parse_to_element implementation
garyhurtz opened this issue · comments
Gary Hurtz commented
In one project I found an issue
<section><h1>text</h1></section>
parses to
<section>text</section>
the fix is below:
` def _parse_to_element(cls, soup):
"""
Parse soup into a (possibly nested) Element
:param soup:
:return: Element
"""
children = list(soup.children)
# if an element has one child and it is a string, it is held in soup.string
# else soup.string is None
if len(children) == 1 and not children[0].name:
return Element(soup.name, soup.string, soup.attrs)`