Closed shirou closed 11 years ago
Could you add "?highlight=" to the result URL? This parameter makes highlighting words in the result page on Sphinx genareted html pages.
Here is a sample implementation.
diff --git a/templates/sphinx/_static/oktavia-jquery-ui.js b/templates/sphinx/_static/oktavia-jquery-ui.js index a65c92e..a97d6d7 100644 --- a/templates/sphinx/_static/oktavia-jquery-ui.js +++ b/templates/sphinx/_static/oktavia-jquery-ui.js @@ -199,12 +199,14 @@ self.clearResult(); } var results = this.engine.getResult$(); + var searchInput = $('.oktavia_search', this.node); + var queryWord = searchInput.val(); for (var i = 0; i < results.length; i++) { var result = results[i]; var url = this.getDocumentPath(result.url.slice(1)); var entry = $('<div/>', { "class": "entry" }); - var link = $('<a/>', { "href": url }).text(result.title); + var link = $('<a/>', { "href": url + "?highlight=" + queryWord }).text(result.title); link.bind('click', clearCallback); entry.append($('<div/>', { "class": "title" }).append(link)); entry.append($('<div/>', { "class": "url" }).text(url));
Thank you for your great code!
Could you add "?highlight=" to the result URL?
This parameter makes highlighting words in the result page on Sphinx genareted html pages.
Here is a sample implementation.
Thank you for your great code!