Skip to content

Commit

Permalink
Fix search term highlighting and deploy <mark> tags (#169)
Browse files Browse the repository at this point in the history
* fix search term highlighting

* revert additional sub logic

* use mixin for mark tag styling
  • Loading branch information
mitchdawson1982 authored Mar 14, 2024
1 parent a36b346 commit ad717f3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
18 changes: 9 additions & 9 deletions home/service/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ def _generate_label_clear_ref(self) -> dict[str, dict[str, str]] | None:
if classifications:
classifications_clear_href = {}
for classification in classifications:
classifications_clear_href[
classification
] = self.form.encode_without_filter(
filter_name="classifications", filter_value=classification
classifications_clear_href[classification] = (
self.form.encode_without_filter(
filter_name="classifications", filter_value=classification
)
)
label_clear_href["classifications"] = classifications_clear_href

if where_to_access:
where_to_access_clear_href = {}
for access in where_to_access:
where_to_access_clear_href[
access
] = self.form.encode_without_filter(
filter_name="where_to_access", filter_value=access
where_to_access_clear_href[access] = (
self.form.encode_without_filter(
filter_name="where_to_access", filter_value=access
)
)
label_clear_href["availability"] = where_to_access_clear_href
else:
Expand Down Expand Up @@ -177,7 +177,7 @@ def _highlight_results(self):
for result in highlighted_results.page_results:
result.description = re.sub(
pattern,
r"**\1**",
r"<mark>\1</mark>",
result.description,
flags=re.IGNORECASE,
)
Expand Down
8 changes: 7 additions & 1 deletion scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ $govuk-global-styles: true;
display: none;
}

mark {
background-color: inherit;
color: inherit;
@include govuk-typography-weight-bold($important: false);
}

@import './glossary';
@import './details';
@import './details';
6 changes: 6 additions & 0 deletions static/assets/css/base.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/assets/css/base.css.map

Large diffs are not rendered by default.

0 comments on commit ad717f3

Please sign in to comment.