commit a8496e161856360451a90f4f8fce721a43fbf2c4
parent 8fe35bff4c479f5c399eab8a081a2386b11ebe10
Author: breadcat <breadcat@users.noreply.github.com>
Date: Wed, 30 Jul 2025 16:04:06 +0100
Remove functions added to fix a bug that no longer exists
Diffstat:
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/themes/Brine/layouts/partials/search.html b/themes/Brine/layouts/partials/search.html
@@ -17,26 +17,10 @@
return text.replace(regex, "<mark>$1</mark>");
}
- // Clean text by normalizing whitespace and removing trailing invisible unicode chars
- function cleanText(text) {
- let cleaned = text.replace(/\s+/g, " "); // Normalize whitespace to single space
- cleaned = cleaned.trim();
- cleaned = cleaned.replace(/[\u200B\u00A0]+$/g, ""); // Remove zero-width and non-breaking spaces at end
- return cleaned;
- }
-
- // Remove replacement chars (? / U+FFFD) from text
- function removeReplacementChars(text) {
- return text.replace(/\uFFFD/g, "");
- }
-
- // Get snippet around first matched term, highlight terms, and clean text
+ // Get snippet around first matched term and highlight terms
function getSnippetWithHighlight(text, terms, contextWords = 40) {
if (!terms.length) return text;
- // Remove replacement chars first
- text = removeReplacementChars(text);
-
const div = document.createElement("div");
div.innerHTML = text;
const plainText = div.textContent || div.innerText || "";
@@ -53,7 +37,7 @@
if (matchIndex === -1) {
const snippet = words.slice(0, contextWords).join(" ");
- return cleanText(snippet) + "…";
+ return snippet + "…";
}
const start = Math.max(0, Math.floor(matchIndex - contextWords / 2));
@@ -61,7 +45,7 @@
const snippet = words.slice(start, end).join(" ");
const highlighted = highlightTerms(snippet, terms);
- return cleanText(highlighted) + "…";
+ return highlighted + "…";
}
// Load Lunr index and data
@@ -112,11 +96,8 @@
const item = store.find(page => page.permalink === result.ref);
if (!item) return; // safety check
- // Remove replacement chars from summary before snippet
- let cleanSummary = removeReplacementChars(item.summary);
-
const highlightedTitle = highlightTerms(item.title, terms);
- const highlightedSummary = getSnippetWithHighlight(cleanSummary, terms, 40);
+ const highlightedSummary = getSnippetWithHighlight(item.summary, terms, 40);
html += `
<li>