@@ -151,23 +151,13 @@ theme:
151151 - search.suggest
152152` ` `
153153
154- Searching for ^^search su^^ yields ^^search suggestions^^ as a suggestion :
154+ Searching for [:octicons-search-24 : ^^search su^^][9] yields ^^search suggestions^^ as a suggestion:
155155
156- <figure markdown="1">
157-
158- [![Search suggestions][9]][9]
159-
160- <figcaption markdown="1">
161-
162- A demo is worth a thousand words — check it out at
163- [squidfunk.github.io/mkdocs-material-insiders][10]
164-
165- </figcaption>
166- </figure>
156+ [![Search suggestions][10]][10]
167157
168158 [8] : ../insiders/index.md
169- [9] : ../assets/screenshots/ search-suggestions.png
170- [10] : https://squidfunk.github.io/mkdocs-material-insiders/reference/code-blocks/?q=code+high
159+ [9] : ?q= search+su
160+ [10] : ../assets/screenshots/search-suggestions.png
171161
172162# ## Search highlighting
173163
@@ -186,22 +176,15 @@ theme:
186176 - search.highlight
187177` ` `
188178
189- Searching for ^^code highlighting^^ yields :
190-
191- <figure markdown="1">
192-
193- [![Search highlighting][11]][11]
194-
195- <figcaption markdown="1">
179+ Searching for [:octicons-search-24 : ^^code highlighting^^][11] yields:
196180
197- A demo is worth a thousand words — check it out at
198- [squidfunk.github.io/mkdocs-material-insiders][12]
181+ [![Search highlighting][12]][12]
199182
200183 </figcaption>
201184</figure>
202185
203- [11] : ../assets/screenshots/search-highlighting.png
204- [12] : https://squidfunk.github.io/mkdocs-material-insiders/reference/code-blocks/?h=code+blocks
186+ [11] : ../reference/code-blocks.md?h=code+blocks
187+ [12] : ../assets/screenshots/search-highlighting.png
205188
206189# ## Search sharing
207190
@@ -223,37 +206,26 @@ theme:
223206When a user clicks the share button, the URL is automatically copied to the
224207clipboard.
225208
226- <figure markdown="1">
227-
228209[![Search sharing][13]][13]
229210
230- <figcaption markdown="1">
231-
232- A demo is worth a thousand words — check it out at
233- [squidfunk.github.io/mkdocs-material-insiders][14]
234-
235- </figcaption>
236- </figure>
237-
238211 [13] : ../assets/screenshots/search-share.png
239- [14] : https://squidfunk.github.io/mkdocs-material-insiders/setup/setting-up-site-search/?q=share+search
240212
241213# ## Offline search
242214
243- [:octicons-file-code-24 : Source][15 ] ·
244- [:octicons-cpu-24 : Plugin][16 ] · :octicons-beaker-24: Experimental
215+ [:octicons-file-code-24 : Source][14 ] ·
216+ [:octicons-cpu-24 : Plugin][15 ] · :octicons-beaker-24: Experimental
245217
246218If you distribute your documentation as `*.html` files, the built-in search
247219will not work out-of-the-box due to the restrictions modern browsers impose for
248- security reasons. This can be mitigated with the [localsearch][16 ] plugin in
249- combination with @squidfunk's [iframe-worker][17 ] polyfill.
220+ security reasons. This can be mitigated with the [localsearch][15 ] plugin in
221+ combination with @squidfunk's [iframe-worker][16 ] polyfill.
250222
251- For setup instructions, refer to the [official documentation][18 ].
223+ For setup instructions, refer to the [official documentation][17 ].
252224
253- [15 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html
254- [16 ] : https://github.com/wilhelmer/mkdocs-localsearch/
255- [17 ] : https://github.com/squidfunk/iframe-worker
256- [18 ] : https://github.com/wilhelmer/mkdocs-localsearch#installation-material-v5
225+ [14 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html
226+ [15 ] : https://github.com/wilhelmer/mkdocs-localsearch/
227+ [16 ] : https://github.com/squidfunk/iframe-worker
228+ [17 ] : https://github.com/wilhelmer/mkdocs-localsearch#installation-material-v5
257229
258230!!! tip
259231
@@ -271,7 +243,7 @@ For setup instructions, refer to the [official documentation][18].
271243
272244In order to give specific pages a higher relevance in search, [lunr][4] supports
273245page-specific boosts, which can be defined for each page by leveraging the
274- [Metadata][19 ] extension :
246+ [Metadata][18 ] extension :
275247
276248` ` ` bash
277249---
@@ -283,7 +255,7 @@ search:
283255...
284256` ` `
285257
286- [19 ] : ../../reference/meta-tags/#metadata
258+ [18 ] : ../../reference/meta-tags/#metadata
287259
288260# # Customization
289261
@@ -297,52 +269,45 @@ your needs.
297269
298270# ## Query transformation
299271
300- [:octicons-file-code-24 : Source][20 ] ·
272+ [:octicons-file-code-24 : Source][19 ] ·
301273:octicons-mortar-board-24 : Difficulty: _easy_
302274
303275When a user enters a query into the search box, the query is pre-processed
304276before it is submitted to the search index. Material for MkDocs will apply the
305- following transformations, which can be customized by [extending the theme][21 ] :
277+ following transformations, which can be customized by [extending the theme][20 ] :
306278
307279` ` ` ts
308- /**
309- * Default transformation function
310- *
311- * 1. Search for terms in quotation marks and prepend a ` +` modifier to denote
312- * that the resulting document must contain all terms, converting the query
313- * to an `AND` query (as opposed to the default `OR` behavior). While users
314- * may expect terms enclosed in quotation marks to map to span queries, i.e.
315- * for which order is important, `lunr` doesn't support them, so the best
316- * we can do is to convert the terms to an `AND` query.
317- *
318- * 2. Replace control characters which are not located at the beginning of the
319- * query or preceded by white space, or are not followed by a non-whitespace
320- * character or are at the end of the query string. Furthermore, filter
321- * unmatched quotation marks.
322- *
323- * 3. Trim excess whitespace from left and right.
324- *
325- * @param query - Query value
326- *
327- * @returns Transformed query value
328- */
329280export function defaultTransform(query: string): string {
330281 return query
331- .split(/"([^"]+)"/g) /* => 1 */
282+ .split(/"([^"]+)"/g) /* (1) */
332283 .map((terms, index) => index & 1
333284 ? terms.replace(/^\b |^(?![^\x00 -\x7F ]|$)|\s +/g, " +")
334285 : terms
335286 )
336287 .join("")
337- .replace(/"|(?:^|\s+)[*+\-:^~]+(?=\s+|$)/g, "") /* => 2 */
338- .trim() /* => 3 */
288+ .replace(/"|(?:^|\s +)[*+\- :^~]+(?=\s +|$)/g, "") /* (2) */
289+ .trim() /* (3) */
339290}
340291` ` `
341292
293+ 1. Search for terms in quotation marks and prepend a `+` modifier to denote
294+ that the resulting document must contain all terms, converting the query
295+ to an `AND` query (as opposed to the default `OR` behavior). While users
296+ may expect terms enclosed in quotation marks to map to span queries, i.e.
297+ for which order is important, `lunr` doesn't support them, so the best
298+ we can do is to convert the terms to an `AND` query.
299+
300+ 2. Replace control characters which are not located at the beginning of the
301+ query or preceded by white space, or are not followed by a non-whitespace
302+ character or are at the end of the query string. Furthermore, filter
303+ unmatched quotation marks.
304+
305+ 3. Trim excess whitespace from left and right.
306+
342307If you want to switch to the default behavior of the `mkdocs` and `readthedocs`
343308themes, both of which don't transform the query prior to submission, or
344309customize the `transform` function, you can do this by [overriding the
345- ` config ` block] [ 22 ] :
310+ `config` block][21 ] :
346311
347312` ` ` html
348313{% block config %}
@@ -360,19 +325,19 @@ customize the `transform` function, you can do this by [overriding the
360325The `transform` function will receive the query string as entered by the user
361326and must return the processed query string to be submitted to the search index.
362327
363- [ 20 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/transform/index.ts
364- [ 21 ] : ../customization.md#extending-the-theme
365- [ 22 ] : ../customization.md#overriding-blocks-recommended
328+ [19 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/transform/index.ts
329+ [20 ] : ../customization.md#extending-the-theme
330+ [21 ] : ../customization.md#overriding-blocks-recommended
366331
367332# ## Custom search
368333
369- [ :octicons-file-code-24: Source] [ 23 ] ·
334+ [:octicons-file-code-24 : Source][22 ] ·
370335:octicons-mortar-board-24 : Difficulty: _challenging_
371336
372- Material for MkDocs implements search as part of a [ web worker] [ 24 ] . If you
337+ Material for MkDocs implements search as part of a [web worker][23 ]. If you
373338want to switch the web worker with your own implementation, e.g. to submit
374339search to an external service, you can add a custom JavaScript file to the
375- ` docs ` directory and [ override the ` config ` block] [ 21 ] :
340+ `docs` directory and [override the `config` block][20 ] :
376341
377342` ` ` html
378343{% block config %}
@@ -390,8 +355,8 @@ format using _discriminated unions_, i.e. through the `type` property of the
390355message. See the following interface definitions to learn about the message
391356formats :
392357
393- - [ :octicons-file-code-24: ` SearchMessage ` ] [ 25 ]
394- - [ :octicons-file-code-24: ` SearchIndex ` and ` SearchResult ` ] [ 26 ]
358+ - [:octicons-file-code-24 : ` SearchMessage` ][24 ]
359+ - [:octicons-file-code-24 : ` SearchIndex` and `SearchResult`][25 ]
395360
396361The sequence and direction of messages is rather intuitive :
397362
@@ -400,7 +365,7 @@ The sequence and direction of messages is rather intuitive:
400365- :octicons-arrow-right-24 : ` SearchQueryMessage`
401366- :octicons-arrow-left-24 : ` SearchResultMessage`
402367
403- [ 23 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker
404- [ 24 ] : https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
405- [ 25 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker/message/index.ts
406- [ 26 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/_/index.ts
368+ [22 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker
369+ [23 ] : https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
370+ [24 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker/message/index.ts
371+ [25 ] : https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/_/index.ts
0 commit comments