Skip to content

Commit

Permalink
Deploying to gh-pages from @ 08894d4 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
phtournier committed Sep 6, 2023
1 parent eb55147 commit ad2aca6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
55 changes: 31 additions & 24 deletions _static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ const searchLunr = (text) => {
q.term(term, { usePipeline: true, boost: 10000 })

// look for terms that match the beginning of this queryTerm and apply a medium boost
q.term(term, {
if (text.length > 2) q.term(term, {
wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING,
usePipeline: false,
boost: 100 }
);

// look for terms that match with an edit distance of 2 and apply a small boost
q.term(term, { usePipeline: false, editDistance: 2, boost: 1 })
if (text.length > 4) q.term(term, { usePipeline: false, editDistance: 2, boost: 1 })
})
})
results = results.slice(0,20)
Expand All @@ -56,14 +56,14 @@ const searchLunr = (text) => {
q.term(term, { usePipeline: true, boost: 10000 })

// look for terms that match the beginning of this queryTerm and apply a medium boost
q.term(term, {
if (text.length > 2) q.term(term, {
wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING,
usePipeline: false,
boost: 100 }
);

// look for terms that match with an edit distance of 2 and apply a small boost
q.term(term, { usePipeline: false, editDistance: 2, boost: 1 })
if (text.length > 4) q.term(term, { usePipeline: false, editDistance: 2, boost: 1 })
})
})
})
Expand Down Expand Up @@ -132,28 +132,35 @@ function parseLunrResults(results, results_i, text) {
const item_i = PREVIEW_PAGEDATA[ref][ref_i]
const title_i = item_i.title
const link_i = item_i.link
const preview_i = item_i.preview

const lowerCasePreview = preview_i.toLowerCase()
const lowerCaseText = text.toLowerCase()
const textIndex = lowerCasePreview.indexOf(lowerCaseText)

const splittedPreview = preview_i.slice(
Math.max(0, textIndex - 124),
Math.min(textIndex + 124, preview_i.length)
)

const lowerCasePreview2 = splittedPreview.toLowerCase()
const textIndex2 = lowerCasePreview2.indexOf(lowerCaseText)
const finalPreview =
splittedPreview.slice(0, textIndex2) +
'<b>' +
splittedPreview.slice(textIndex2, textIndex2 + text.length) +
'</b>' +
splittedPreview.slice(textIndex2 + text.length)
var preview_i = item_i.preview
var newpreview = ""

Object.keys(result_i.matchData.metadata).forEach(function (term, index) {
const lowerCaseText = term.toLowerCase()

if (index == 0) {
const lowerCasePreview = preview_i.toLowerCase()
const textIndex = lowerCasePreview.indexOf(lowerCaseText)
preview_i = preview_i.slice(
Math.max(0, textIndex - 124),
Math.min(textIndex + 124, preview_i.length)
)
}

const lowerCasePreview2 = preview_i.toLowerCase()
const textIndex2 = lowerCasePreview2.indexOf(lowerCaseText)
if (textIndex2 != -1) {
newpreview = newpreview +
preview_i.slice(0, textIndex2) +
'<b>' +
preview_i.slice(textIndex2, textIndex2 + term.length) +
'</b>'
preview_i = preview_i.slice(textIndex2 + term.length)
}
})

titles.push(title_i)
previews.push(finalPreview)
previews.push(newpreview+preview_i)
links.push(rootPath + link_i)
})

Expand Down
Binary file modified pdf/FreeFEM-documentation.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion pdf/FreeFEM-documentation.pdf.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
835617335b343c847731ff6704f5c764 FreeFEM-documentation.pdf
b63f0a560e3b9df42f8e64e0f16e3cf9 FreeFEM-documentation.pdf

0 comments on commit ad2aca6

Please sign in to comment.