1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-13 18:40:54 +01:00

Fixed highlighting not working for two or more words

This commit is contained in:
squidfunk 2017-04-08 16:04:09 +02:00
parent 5ef40b5e3d
commit 67bea5e152
6 changed files with 14 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@
<script src="{{ base_url }}/assets/javascripts/modernizr-56ade86843.js"></script> <script src="{{ base_url }}/assets/javascripts/modernizr-56ade86843.js"></script>
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-b168d32589.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-b1a1975878.css">
{% if config.extra.palette %} {% if config.extra.palette %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-f78e5cb881.palette.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-f78e5cb881.palette.css">
{% endif %} {% endif %}
@ -150,7 +150,7 @@
{% endblock %} {% endblock %}
</div> </div>
{% block scripts %} {% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application-ae2e7c9801.js"></script> <script src="{{ base_url }}/assets/javascripts/application-ff7132a167.js"></script>
<script>app.initialize({url:{base:"{{ base_url }}"}})</script> <script>app.initialize({url:{base:"{{ base_url }}"}})</script>
{% for path in extra_javascript %} {% for path in extra_javascript %}
<script src="{{ path }}"></script> <script src="{{ path }}"></script>

View File

@ -179,18 +179,24 @@ export default class Result {
if (doc.parent) { if (doc.parent) {
const ref = doc.parent.location const ref = doc.parent.location
items.set(ref, (items.get(ref) || []).concat(item)) items.set(ref, (items.get(ref) || []).concat(item))
} else {
const ref = doc.location
items.set(ref, (items.get(ref) || []))
} }
return items return items
}, new Map) }, new Map)
/* 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") `\\b(${escape(this.value_.trim()).replace(" ", "|")})`, "img")
const highlight = string => `<em>${string}</em>` const highlight = string => `<em>${string}</em>`
/* Render results */ /* Render results */
result.forEach((items, ref) => { result.forEach((items, ref) => {
const doc = this.docs_.get(ref) const doc = this.docs_.get(ref)
// console.log(ref, items)
// if (!items.length)// && !doc.text.length && !doc.title.match(match))
// return
/* Append search result */ /* Append search result */
this.list_.appendChild( this.list_.appendChild(

View File

@ -443,9 +443,9 @@ $md-toggle__search--checked:
} }
} }
// Add a little spacing on the last link // Add a little spacing on the teaser of the last link
&:last-child { &:last-child .md-search-result__teaser {
padding-bottom: 0.8rem; margin-bottom: 1.2rem;
} }
} }