Search: compact summaries for long code blocks and lists #4278
Description
Contribution guidelines
- I've read the contribution guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the problem doesn't occur with the
mkdocs
orreadthedocs
themes - ... the problem persists when all overrides are removed, i.e.
custom_dir
,extra_javascript
andextra_css
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
The search results preview displays the whole <ol>
or <ul>
, regardless of where in the list the result appears. This makes for a lot of scrolling in the results. I first commented about this on #3053 in April, because I mistakenly thought I was getting the entire page in the result. Now that I've narrowed it down, I'm back with a new issue as requested.
Expected behaviour
Similar to results that appear in a plain paragraph, I would expect the search preview to display the <li>
in which the search term appears. If the <li>
includes multiple paragraphs, maybe even just the relevant <p>
.
Actual behaviour
I have an ordered list, several of whose list items contain nested, unordered lists. See attached lorem ipsum file long_search_result.md
When served or built, if I search for TN2206
, I get the entire <ol>
in the preview, with its nested unordered lists, even though TN2206
only appears once in the <ol>
, as the last word of the last <li>
in the last <ul>
in the last <ol>
.
When served or built, if I search for cras
, I get the entire <ol>
in the preview, with its nested unordered lists, even though cras
only appears once in the <ol>
, in the first <li>
of the top <ol>
.
Steps to reproduce
- Serve or build an MkDocs project containing long_search_result.md.
- Search the served/built docs for
TN2206
. - Search the served/built docs for
cras
.
Package versions
- Python:
Python 3.10.0
- MkDocs:
mkdocs, version 1.3.0 from /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mkdocs (Python 3.10)
- Material:
Version: 8.4.0+insiders.4.21.1
Configuration
site_name: Long Search Results
site_url: "https://example.com/docs"
plugins:
- search:
separator: '[\s\-/\\]+'
- offline
nav:
- Example: long_search_result.md
theme:
name: material
markdown_extensions:
- smarty
- admonition
System information
- Operating system:
macOS Monterey Version 12.4
- Browser:
Google Chrome Version 104.0.5112.101 (Official Build) (x86_64)