mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2025-01-31 11:53:53 +01: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,
|
"base": base_url,
|
||||||
"features": features,
|
"features": features,
|
||||||
"translations": {},
|
"translations": {},
|
||||||
"search": "assets/javascripts/workers/search.e5c33ebb.min.js" | url
|
"search": "assets/javascripts/workers/search.db81ec45.min.js" | url
|
||||||
} -%}
|
} -%}
|
||||||
{%- if config.extra.version -%}
|
{%- if config.extra.version -%}
|
||||||
{%- set _ = app.update({ "version": config.extra.version }) -%}
|
{%- set _ = app.update({ "version": config.extra.version }) -%}
|
||||||
|
@ -70,14 +70,28 @@ export function transformSearchQuery(
|
|||||||
|
|
||||||
/* Extract and tokenize term from lexeme */
|
/* Extract and tokenize term from lexeme */
|
||||||
for (const { type, str: term, start, end } of lexer.lexemes)
|
for (const { type, str: term, start, end } of lexer.lexemes)
|
||||||
if (type === "TERM")
|
switch (type) {
|
||||||
split(term, lunr.tokenizer.separator, (...range) => {
|
|
||||||
terms.push([
|
/* Hack: remove colon - see https://bit.ly/3wD3T3I */
|
||||||
part.slice(0, start),
|
case "FIELD":
|
||||||
term.slice(...range),
|
if (!["title", "text", "tags"].includes(term))
|
||||||
part.slice(end)
|
part = [
|
||||||
].join(""))
|
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),
|
||||||
|
term.slice(...range),
|
||||||
|
part.slice(end)
|
||||||
|
].join(""))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/* Return terms */
|
/* Return terms */
|
||||||
return terms
|
return terms
|
||||||
|
Loading…
x
Reference in New Issue
Block a user