Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No highlighting on search result page #11955

Closed
madjxatw opened this issue Feb 6, 2024 · 9 comments
Closed

No highlighting on search result page #11955

madjxatw opened this issue Feb 6, 2024 · 9 comments

Comments

@madjxatw
Copy link

madjxatw commented Feb 6, 2024

Describe the bug

When a search is done, none of the matched words is highlighted on the search result page. Additionally, only the h1 heading of the target page where the matched word is found is displayed in the preview, although the matched word more precisely belongs to a section started by a sub heading (e.g. a h2 heading).

Look at the following screenshots:

  1. The result of searching uniform, the matched word is found, summary is shown, but uniform does not get highlighted in the summary.
    sphinx-search-uniform-result-preview

  2. Clicking Linking to open the target page, you can see that uniform is actually located in a paragraph under the h2 heading Library naming. But in the search result page as shown above, the h2 heading is not shown so that the browser is not able to automatically scroll to the line containing matched word in the target page.
    sphinx-search-uniform-target-page

I've also tested several other themes like alabaster, sphinx-book-theme, etc, these issues persist.

How to Reproduce

What in the docs

Only two files, i.e. index.md and linking.md.

The content of my conf.py

project = "Sphinx Test"
copyright = "2024, xxx"
author = "Sphinx Tester"
release = "0.1.0"
extensions = [
    "myst_parser",
    "sphinx_design",
]
templates_path = ["_templates"]
exclude_patterns = [
    "__pypackages__",
    "pyproject.toml",
    "pdm.lock",
    "_build",
    "Thumbs.db",
    ".DS_Store",
]
highlight_language = "none"
html_show_sourcelink = False
html_copy_source = False
html_title = project
html_theme = "sphinx_rtd_theme"

myst_enable_extensions = [
    "attrs_inline",
    "deflist",
    "fieldlist",
    "colon_fence",
    "replacements",
    "smartquotes",
    "substitution",
]
myst_url_schemes = ["http", "https", "mailto"]
myst_heading_anchors = 3

Operations

  • build the docs
  • under docs root directory, run python3 -m http.server -b 127.0.0.1 -d _buildf/html
  • open http://127.0.0.1:8000 in a web browser (chromium-based)
  • type uniform in the search box

Environment Information

  • Python 3.8
  • sphinx 7.1.2
  • myst-parser 2.0.0
  • sphinx-rtd-theme 2.0.0

Sphinx extensions

[myst_parser, sphinx_design]

Additional context

No response

@picnixz
Copy link
Member

picnixz commented Feb 6, 2024

  • Can you upgrade to the latest Sphinx version?
  • Can you check without additional extensions and alabaster theme? If the issue is with myst_parser or sphinx_design the issue should be raised on their repo.

@picnixz picnixz added the awaiting:response Waiting for a response from the author of this issue label Feb 6, 2024
@madjxatw
Copy link
Author

madjxatw commented Feb 6, 2024

Info updated

  • Sphinx 7.2.6 (latest stable release)
  • Alabaster 0.7.16

No plugin used, all doc files written in RST.

  1. The result of searching uniform, the matched word highlighted, but the h2 heading Library naming not shown.

    The search result page:
    sphinx726-search-uniform

    The target page:
    screenshot_20240206-134412UTC

  2. The result of searching Library, only the h2 heading containing Library shown, no other matched items listed. The first Linking > Library Naming entry and the second Linking entry seem duplicate. Really confused with the search logic behind.

    sphinx726-search-library

@madjxatw
Copy link
Author

madjxatw commented Feb 6, 2024

A further test

I added a line containing uniform before the first paragraph in linking.rst, there should be two matches but the search results for uniform only show the first match.

screenshot_20240206-140816UTC

@picnixz
Copy link
Member

picnixz commented Feb 6, 2024

Thank you for your report. It appears that there are some issues and PRs related to your problem by @wlach.

@wlach Could you confirm that you are also working towards fixing this issue? If so, we may close this issue (but keep it somewhere in one your issues as a related issue).

@picnixz picnixz removed the awaiting:response Waiting for a response from the author of this issue label Feb 6, 2024
@wlach
Copy link
Contributor

wlach commented Feb 6, 2024

Thank you for your report. It appears that there are some issues and PRs related to your problem by @wlach.

@wlach Could you confirm that you are also working towards fixing this issue? If so, we may close this issue (but keep it somewhere in one your issues as a related issue).

I think the highlighting is a seperate issue of some kind: I can also reproduce it with the readthedocs theme and a fairly recent version of Sphinx, as the author suggests. However highlighting seems to work locally with Sphinx when I built it itself (as @madjxatw noticed). I'd investigate more but I'm out of time for a few weeks. 😞

I think the issues reported later with the search summaries being off is a duplicate of #11943

@picnixz
Copy link
Member

picnixz commented Feb 6, 2024

I see. For now, I'll keep this one open since I'm not sure whether they are all related or not. It doesn't hurt to have duplicates for this kind of issues because it's hard to identify the real problem.

@madjxatw I don't work on the search engine generally, and I plan to first fix the Windows test this w-e, so I'm not sure anyone will be able to help with this before some time. When I've got time, I may try to fix this one or whatever search-related issues it remains.

@wlach
Copy link
Contributor

wlach commented Feb 6, 2024

Update: Highlighting was fixed by #10930, 7.2.0+ should have it.

Pretty sure we can close this ticket.

@madjxatw
Copy link
Author

madjxatw commented Feb 7, 2024

Update: Highlighting was fixed by #10930, 7.2.0+ should have it.

Pretty sure we can close this ticket.

So the issue of "not all matched items displayed on the result page" has nothing to do with the highlighting feature itself, right?

I have Python 3.8 on the machine in my office and for some reason me and our team must stick to 3.8, but Sphinx 7.2.0+ requires Python 3.9+. Will the highlighting fix be ported to old versions of Sphinx? If not, it would be a bit troublesome to integrate the docs into the project what depends on Python 3.8.

@picnixz
Copy link
Member

picnixz commented Feb 7, 2024

Will the highlighting fix be ported to old versions of Sphinx?

Unfortunately, we don't do backports and since we dropped Python 3.8 support, some code might not work, especially the code related to typing. Alternatively, you could use Python 3.9 to generate the docs but I'm not sure that it will "correctly" work since we are doing dynamic analysis and not static analysis.

So the issue of "not all matched items displayed on the result page" has nothing to do with the highlighting feature itself, right?

Probably. I am not an expert in that area. But the matched item issue might be related to #11959 or #11955. As such, I'll be closing this issue (since it was about highlighting) but feel free to comment on either of the other two for the "multiple matched issue" (or open a fresh one if you think it's not related to).

@picnixz picnixz closed this as completed Feb 7, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants