sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

highlightSearchWords() is not called after fragments are loaded via AJAX

Open mitya57 opened this issue 3 years ago • 0 comments

Describe the bug

When I build Sphinx' own documentation locally, and search for example, search results look like this: Screenshot 1

Only if I go to browser console and call SphinxHighlight.highlightSearchWords(), it starts looking like this: Screenshot 2

highlightSearchWords() is called on DOMContentLoaded event, but page fragments are loaded separately after that event.

How to Reproduce

$ git clone https://github.com/sphinx-doc/sphinx.git
$ cd sphinx
$ python3 ./sphinx/cmd/build.py -T doc build/html/
$ cd build/html
$ python3 -m http.server
$ # open http://127.0.0.1:8000/search.html?q=example

Expected behavior

Search terms are highlighted after all page fragments are loaded.

Your project

Sphinx itself

Screenshots

No response

OS

Linux

Python version

3.10.7

Sphinx version

5.2.0.post1 and master

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

mitya57 avatar Sep 25 '22 17:09 mitya57