diff --git a/app/filter.py b/app/filter.py index 64455ef..5299b92 100644 --- a/app/filter.py +++ b/app/filter.py @@ -95,9 +95,26 @@ class Filter: if not self.main_divs: return - question_divs = [_ for _ in self.main_divs.find_all('div', recursive=False) if len(_.find_all('h2')) > 0] + question_divs = [_ for _ in self.main_divs.find_all( + 'div', recursive=False + ) if len(_.find_all('h2')) > 0] + + if len(question_divs) == 0: + return + + # Wrap section in details element to allow collapse/expand + details = BeautifulSoup(features='lxml').new_tag('details') + summary = BeautifulSoup(features='lxml').new_tag('summary') + summary.string = question_divs[0].find('h2').text + question_divs[0].find('h2').decompose() + details.append(summary) + question_divs[0].wrap(details) + for question_div in question_divs: - questions = [_ for _ in question_div.find_all('div', recursive=True) if _.text.endswith('?')] + questions = [_ for _ in question_div.find_all( + 'div', recursive=True + ) if _.text.endswith('?')] + for question in questions: question['style'] = 'padding: 10px; font-style: italic;' diff --git a/app/static/css/search-dark.css b/app/static/css/search-dark.css index 2ac5b47..cef079e 100644 --- a/app/static/css/search-dark.css +++ b/app/static/css/search-dark.css @@ -32,4 +32,9 @@ .autocomplete-active { background-color: #685e79 !important; color: #ffffff; -} \ No newline at end of file +} + +details summary { + padding: 10px; + font-weight: bold; +} diff --git a/app/static/css/search.css b/app/static/css/search.css index a79522b..155cfcf 100644 --- a/app/static/css/search.css +++ b/app/static/css/search.css @@ -31,4 +31,9 @@ .autocomplete-active { background-color: #685e79 !important; color: #ffffff; -} \ No newline at end of file +} + +details summary { + padding: 10px; + font-weight: bold; +}