Improve formatting of collapsible infobox (#612)

main
Nitish Yadav 2022-01-19 02:17:35 +05:30 committed by GitHub
parent 257e3f33ef
commit fc50359752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -178,10 +178,17 @@ class Filter:
# Find and decompose the first element with an inner HTML text val.
# This typically extracts the title of the section (i.e. "Related
# Searches", "People also ask", etc)
# If there are more than one child tags with text
# parenthesize the rest except the first
label = 'Collapsed Results'
subtitle = None
for elem in result_children:
if elem.text:
label = elem.text
content = list(elem.strings)
label = content[0]
if len(content) > 1:
subtitle = '<span> (' + \
''.join(content[1:]) + ')</span>'
elem.decompose()
break
@ -196,6 +203,11 @@ class Filter:
details = BeautifulSoup(features='html.parser').new_tag('details')
summary = BeautifulSoup(features='html.parser').new_tag('summary')
summary.string = label
if subtitle:
soup = BeautifulSoup(subtitle, 'html.parser')
summary.append(soup)
details.append(summary)
if parent and not minimal_mode:

View File

@ -26,6 +26,10 @@ details summary {
font-weight: bold;
}
details summary span {
font-weight: normal;
}
#lingva-iframe {
width: 100%;
height: 650px;