Skip to content

Commit

Permalink
search: Match plaintext case-insensitively [fix #27]
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-w committed Aug 20, 2024
1 parent b7c06ae commit c262a19
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions _includes/search-dictionary.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@
}
}

function showAllExamplesOfEntriesWithPlaintextMatching(query) {
const showAll = query === ''
function showAllExamplesOfEntriesWithPlaintextMatching(/** @type{string} */query) {
const lowercaseTrimmedQuery = query.trim().toLowerCase()
const showAll = lowercaseTrimmedQuery === ''
const anchors = document.querySelectorAll('a[data-plaintext]')
let entryCount = 0
for (const anchor of anchors) {
const plaintext = anchor.dataset.plaintext.replaceAll('\\"', '"')
const isMatch = showAll || plaintext.includes(query)
const plaintext = anchor.dataset.plaintext.replaceAll('\\"', '"').toLowerCase()
const isMatch = showAll || plaintext.includes(lowercaseTrimmedQuery)

const entry = anchor.closest('li')
if (isMatch) {
Expand Down

0 comments on commit c262a19

Please sign in to comment.