@@ -154,8 +154,17 @@ def test_term_in_heading_and_section(app: SphinxTestApp) -> None:
154154 # if search term is in the title of one doc and in the text of another
155155 # both documents should be a hit in the search index as a title,
156156 # respectively text hit
157- assert '"textinhead":2' in searchindex
158- assert '"textinhead":0' in searchindex
157+ assert '"textinhead":3' in searchindex
158+ assert '"textinhead":1' in searchindex
159+
160+
161+ @pytest .mark .sphinx ('html' , testroot = 'search' )
162+ def test_escaped_title (app : SphinxTestApp ) -> None :
163+ app .build (force_all = True )
164+ searchindex = load_searchindex (app .outdir / 'searchindex.js' )
165+ print (searchindex )
166+ assert 'escapedtitle' in searchindex ['docnames' ]
167+ assert 'escaped title with < and > in it' in searchindex ['titles' ]
159168
160169
161170@pytest .mark .sphinx ('html' , testroot = 'search' )
@@ -388,15 +397,15 @@ def test_search_index_gen_zh(app: SphinxTestApp) -> None:
388397def test_nosearch (app : SphinxTestApp ) -> None :
389398 app .build ()
390399 index = load_searchindex (app .outdir / 'searchindex.js' )
391- assert index ['docnames' ] == ['index' , 'nosearch' , 'tocitem' ]
400+ assert index ['docnames' ] == ['escapedtitle' , ' index' , 'nosearch' , 'tocitem' ]
392401 # latex is in 'nosearch.rst', and nowhere else
393402 assert 'latex' not in index ['terms' ]
394403 # cat is in 'index.rst' but is marked with the 'no-search' class
395404 assert 'cat' not in index ['terms' ]
396405 # bat is indexed from 'index.rst' and 'tocitem.rst' (document IDs 0, 2), and
397406 # not from 'nosearch.rst' (document ID 1)
398407 assert 'bat' in index ['terms' ]
399- assert index ['terms' ]['bat' ] == [0 , 2 ]
408+ assert index ['terms' ]['bat' ] == [1 , 3 ]
400409
401410
402411@pytest .mark .sphinx (
@@ -408,7 +417,7 @@ def test_nosearch(app: SphinxTestApp) -> None:
408417def test_parallel (app : SphinxTestApp ) -> None :
409418 app .build ()
410419 index = load_searchindex (app .outdir / 'searchindex.js' )
411- assert index ['docnames' ] == ['index' , 'nosearch' , 'tocitem' ]
420+ assert index ['docnames' ] == ['escapedtitle' , ' index' , 'nosearch' , 'tocitem' ]
412421
413422
414423@pytest .mark .sphinx ('html' , testroot = 'search' )
0 commit comments