Fixed search highlighting for non-latin languages

This commit is contained in:
squidfunk 2017-06-01 00:54:06 +02:00
parent 974f07ccb4
commit d17b0fbb90
4 changed files with 4 additions and 4 deletions

View File

@ -149,7 +149,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application-71e40776cb.js"></script> <script src="{{ base_url }}/assets/javascripts/application-1906b41020.js"></script>
{% set languages = lang.t('search.languages').split(",") %} {% set languages = lang.t('search.languages').split(",") %}
{% if languages | length and languages[0] != "" %} {% if languages | length and languages[0] != "" %}
{% set path = base_url + "/assets/javascripts/lunr" %} {% set path = base_url + "/assets/javascripts/lunr" %}

View File

@ -5,7 +5,7 @@
"footer.next": "Next", "footer.next": "Next",
"meta.comments": "Comments", "meta.comments": "Comments",
"meta.source": "Source", "meta.source": "Source",
"search.languages": "", "search.languages": "ru",
"search.placeholder": "Search", "search.placeholder": "Search",
"search.result.placeholder": "Type to start searching", "search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents", "search.result.none": "No matching documents",

View File

@ -209,7 +209,7 @@ export default class Result {
/* Assemble highlight regex from query string */ /* Assemble highlight regex from query string */
const match = new RegExp( const match = new RegExp(
`\\b(${escape(this.value_.trim()).replace(" ", "|")})`, "img") `(?:^|\\s)(${escape(this.value_.trim()).replace(" ", "|")})`, "img")
const highlight = string => `<em>${string}</em>` const highlight = string => `<em>${string}</em>`
/* Render results */ /* Render results */