@@ -58,6 +58,15 @@ const _removeChildren = (element) => {
58
58
const _escapeRegExp = ( string ) =>
59
59
string . replace ( / [ . * + \- ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ; // $& means the whole matched string
60
60
61
+ const _escapeHTML = ( text ) => {
62
+ return text
63
+ . replaceAll ( "&" , "&" )
64
+ . replaceAll ( "<" , "<" )
65
+ . replaceAll ( ">" , ">" )
66
+ . replaceAll ( '"' , """ )
67
+ . replaceAll ( "'" , "'" ) ;
68
+ }
69
+
61
70
const _displayItem = ( item , searchTerms , highlightTerms ) => {
62
71
const docBuilder = DOCUMENTATION_OPTIONS . BUILDER ;
63
72
const docFileSuffix = DOCUMENTATION_OPTIONS . FILE_SUFFIX ;
@@ -324,14 +333,6 @@ const Search = {
324
333
const titles = Search . _index . titles ;
325
334
const allTitles = Search . _index . alltitles ;
326
335
const indexEntries = Search . _index . indexentries ;
327
- const htmlEscape = ( text ) => {
328
- return String ( text )
329
- . replaceAll ( "&" , "&" )
330
- . replaceAll ( "<" , "<" )
331
- . replaceAll ( ">" , ">" )
332
- . replaceAll ( '"' , """ )
333
- . replaceAll ( "'" , "'" ) ;
334
- }
335
336
336
337
// Collect multiple result groups to be sorted separately and then ordered.
337
338
// Each is an array of [docname, title, anchor, descr, score, filename, kind].
@@ -348,7 +349,7 @@ const Search = {
348
349
const boost = titles [ file ] === title ? 1 : 0 ; // add a boost for document titles
349
350
normalResults . push ( [
350
351
docNames [ file ] ,
351
- htmlEscape (
352
+ _escapeHTML (
352
353
titles [ file ] !== title ? `${ titles [ file ] } > ${ title } ` : title
353
354
) ,
354
355
id !== null ? "#" + id : "" ,
@@ -368,7 +369,7 @@ const Search = {
368
369
const score = Math . round ( 100 * queryLower . length / entry . length ) ;
369
370
const result = [
370
371
docNames [ file ] ,
371
- htmlEscape ( titles [ file ] ) ,
372
+ _escapeHTML ( titles [ file ] ) ,
372
373
id ? "#" + id : "" ,
373
374
null ,
374
375
score ,
0 commit comments