@@ -155,8 +155,17 @@ def test_term_in_heading_and_section(app: SphinxTestApp) -> None:
155
155
# if search term is in the title of one doc and in the text of another
156
156
# both documents should be a hit in the search index as a title,
157
157
# respectively text hit
158
- assert '"textinhead":2' in searchindex
159
- assert '"textinhead":0' in searchindex
158
+ assert '"textinhead":3' in searchindex
159
+ assert '"textinhead":1' in searchindex
160
+
161
+
162
+ @pytest .mark .sphinx ('html' , testroot = 'search' )
163
+ def test_escaped_title (app : SphinxTestApp ) -> None :
164
+ app .build (force_all = True )
165
+ searchindex = load_searchindex (app .outdir / 'searchindex.js' )
166
+ print (searchindex )
167
+ assert 'escapedtitle' in searchindex ['docnames' ]
168
+ assert 'escaped title with < and > in it' in searchindex ['titles' ]
160
169
161
170
162
171
@pytest .mark .sphinx ('html' , testroot = 'search' )
@@ -398,15 +407,15 @@ def test_search_index_gen_zh(app: SphinxTestApp) -> None:
398
407
def test_nosearch (app : SphinxTestApp ) -> None :
399
408
app .build ()
400
409
index = load_searchindex (app .outdir / 'searchindex.js' )
401
- assert index ['docnames' ] == ['index' , 'nosearch' , 'tocitem' ]
410
+ assert index ['docnames' ] == ['escapedtitle' , ' index' , 'nosearch' , 'tocitem' ]
402
411
# latex is in 'nosearch.rst', and nowhere else
403
412
assert 'latex' not in index ['terms' ]
404
413
# cat is in 'index.rst' but is marked with the 'no-search' class
405
414
assert 'cat' not in index ['terms' ]
406
415
# bat is indexed from 'index.rst' and 'tocitem.rst' (document IDs 0, 2), and
407
416
# not from 'nosearch.rst' (document ID 1)
408
417
assert 'bat' in index ['terms' ]
409
- assert index ['terms' ]['bat' ] == [0 , 2 ]
418
+ assert index ['terms' ]['bat' ] == [1 , 3 ]
410
419
411
420
412
421
@pytest .mark .sphinx (
@@ -418,7 +427,7 @@ def test_nosearch(app: SphinxTestApp) -> None:
418
427
def test_parallel (app : SphinxTestApp ) -> None :
419
428
app .build ()
420
429
index = load_searchindex (app .outdir / 'searchindex.js' )
421
- assert index ['docnames' ] == ['index' , 'nosearch' , 'tocitem' ]
430
+ assert index ['docnames' ] == ['escapedtitle' , ' index' , 'nosearch' , 'tocitem' ]
422
431
423
432
424
433
@pytest .mark .sphinx ('html' , testroot = 'search' )
0 commit comments