Find valid parent element when collapsing result content

Previously if a result element marked for collapsing didn't have a valid
"parent" element, the collapsing was skipped altogether. This loops
through child elements until a valid parent is found (or if one isn't
found, the element will not be collapsed).
main
Ben Busby 2021-07-04 15:20:19 -04:00
parent 958faed1b6
commit 38c38a772f
No known key found for this signature in database
GPG Key ID: 339B7B7EB5333D14
1 changed files with 6 additions and 2 deletions

View File

@ -173,8 +173,12 @@ class Filter:
break
# Create the new details element to wrap around the result's
# immediate parent
parent = result_children[0].parent
# first parent
parent = None
idx = 0
while not parent and idx < len(result_children):
parent = result_children[idx].parent
idx += 1
details = BeautifulSoup(features='html.parser').new_tag('details')
summary = BeautifulSoup(features='html.parser').new_tag('summary')
summary.string = label