aboutsummaryrefslogtreecommitdiffstats
path: root/pysite
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-05-06 18:34:15 +0100
committerGravatar Gareth Coles <[email protected]>2018-05-06 18:34:15 +0100
commit8746427e3bc999fea8b55c5bd4297ddd908ba762 (patch)
treedc04398d8aea4a561c64e8f9e82b03d26c53ce16 /pysite
parent[Wiki] Misc improvements, plus a beta search feature (diff)
[Wiki] Case-insensitive searching
Diffstat (limited to 'pysite')
-rw-r--r--pysite/views/wiki/search.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/pysite/views/wiki/search.py b/pysite/views/wiki/search.py
index 1c920e15..369da943 100644
--- a/pysite/views/wiki/search.py
+++ b/pysite/views/wiki/search.py
@@ -31,7 +31,7 @@ class SearchView(RouteView, DBMixin):
pages = self.db.filter(
self.table_name,
- lambda doc: doc["text"].match(query)
+ lambda doc: doc["text"].match(f"(?i){query}")
)
if len(pages) == 1:
@@ -41,7 +41,7 @@ class SearchView(RouteView, DBMixin):
for obj in pages:
text = obj["text"]
- matches = re.finditer(query, text)
+ matches = re.finditer(query, text, flags=re.IGNORECASE)
snippets = []
for match in matches:
@@ -56,7 +56,7 @@ class SearchView(RouteView, DBMixin):
end = len(text)
match_text = text[start:end]
- match_text = re.sub(query, r"<strong>\1</strong>", html.escape(match_text))
+ match_text = re.sub(query, r"<strong>\1</strong>", html.escape(match_text), flags=re.IGNORECASE)
snippets.append(match_text.replace("\n", "<br />"))