mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed search when query contains colon after non-field
This commit is contained in:
parent
148c9fdba4
commit
a6436bd483
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -212,7 +212,7 @@
|
||||
"base": base_url,
|
||||
"features": features,
|
||||
"translations": {},
|
||||
"search": "assets/javascripts/workers/search.e5c33ebb.min.js" | url
|
||||
"search": "assets/javascripts/workers/search.db81ec45.min.js" | url
|
||||
} -%}
|
||||
{%- if config.extra.version -%}
|
||||
{%- set _ = app.update({ "version": config.extra.version }) -%}
|
||||
|
@ -70,7 +70,20 @@ export function transformSearchQuery(
|
||||
|
||||
/* Extract and tokenize term from lexeme */
|
||||
for (const { type, str: term, start, end } of lexer.lexemes)
|
||||
if (type === "TERM")
|
||||
switch (type) {
|
||||
|
||||
/* Hack: remove colon - see https://bit.ly/3wD3T3I */
|
||||
case "FIELD":
|
||||
if (!["title", "text", "tags"].includes(term))
|
||||
part = [
|
||||
part.slice(0, end),
|
||||
" ",
|
||||
part.slice(end + 1)
|
||||
].join("")
|
||||
break
|
||||
|
||||
/* Tokenize term */
|
||||
case "TERM":
|
||||
split(term, lunr.tokenizer.separator, (...range) => {
|
||||
terms.push([
|
||||
part.slice(0, start),
|
||||
@ -78,6 +91,7 @@ export function transformSearchQuery(
|
||||
part.slice(end)
|
||||
].join(""))
|
||||
})
|
||||
}
|
||||
|
||||
/* Return terms */
|
||||
return terms
|
||||
|
Loading…
Reference in New Issue
Block a user