Skip to content

Commit 325b1b0

Browse files
committed
Adjustments to keyword highlighting process πŸ§šπŸ»β€β™€οΈ
1 parent c83921b commit 325b1b0

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

β€Žjs/searcher.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ const searchMain = () => {
4343
};
4444

4545
const init = config => {
46-
const mark_exclude = [];
47-
4846
resultsOptions = config.results_options;
4947
searchOptions = config.search_options;
5048

@@ -101,6 +99,12 @@ const searchMain = () => {
10199
ELEMENT_RESULTS.appendChild(resultElem);
102100
}
103101

102+
const marker = new markjs(document.getElementById('searchresults-outer'));
103+
marker.mark(decodeURIComponent(term).split(' '), {
104+
accuracy: 'complementary',
105+
exclude: ['a'],
106+
});
107+
104108
// Display results
105109
document.getElementById('searchresults-header').innerText =
106110
(results.length > count ? 'Over ' : '') + `${count} search results for: ${term}`;
@@ -130,17 +134,16 @@ const searchMain = () => {
130134
return;
131135
}
132136

133-
const markStr = decodeURIComponent(params[PARAM_HIGHLIGHT]);
137+
const term = decodeURIComponent(params[PARAM_HIGHLIGHT]);
134138

135-
if (markStr === undefined) {
139+
if (term === undefined) {
136140
return;
137141
}
138-
ELEMENT_BAR.value = markStr;
142+
ELEMENT_BAR.value = term;
139143

140144
const marker = new markjs(document.querySelector('.content main'));
141-
142-
marker.mark(decodeURIComponent(markStr).split(' '), {
143-
exclude: mark_exclude,
145+
marker.mark(decodeURIComponent(term).split(' '), {
146+
accuracy: 'complementary',
144147
});
145148

146149
for (const x of document.querySelectorAll('mark')) {

β€Žjs/serviceworker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CACHE_VERSION = 'v0.10.1a';
1+
const CACHE_VERSION = 'v0.10.2';
22
const CACHE_LIST = [
33
'/commentary/book.js',
44
'/commentary/elasticlunr.min.js',

β€Žscss/theme/chrome.scss

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
text-decoration: underline;
3434
}
3535
}
36+
37+
mark {
38+
cursor: pointer;
39+
}
40+
3641
img,
3742
video {
3843
display: flex;

β€Žscss/theme/general.scss

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ pre {
140140
mark {
141141
color: var(--fg);
142142
background: linear-gradient(rgba(0, 0, 0, 0) 70%, var(--search-mark-bg));
143-
cursor: pointer;
144143
}
145144

146145
blockquote {

0 commit comments

Comments
Β (0)