Skip to content

Commit

Permalink
use custom trimmer to preserve @ and !
Browse files Browse the repository at this point in the history
fixes #494
  • Loading branch information
visr committed Sep 25, 2017
1 parent ebcc55e commit 4bff0eb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/html/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ requirejs.config({
var currentScript = document.currentScript;

require(["jquery", "lunr"], function($, lunr) {
// custom trimmer that doesn't strip @ and !, which are used in julia macro and function names
lunr.trimmer = function (token) {
return token.update(function (s) {
return s.replace(/^[^a-zA-Z0-9@!]+/, '').replace(/[^a-zA-Z0-9@!]+$/, '')
})
}

lunr.Pipeline.registerFunction(lunr.trimmer, 'juliatrimmer')

var index = lunr(function () {
this.ref('location')
this.field('title')
Expand Down

0 comments on commit 4bff0eb

Please sign in to comment.