@@ -58,6 +58,15 @@ const _removeChildren = (element) => {
5858const _escapeRegExp = ( string ) =>
5959 string . replace ( / [ . * + \- ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ; // $& means the whole matched string
6060
61+ const _escapeHTML = ( text ) => {
62+ return text
63+ . replaceAll ( "&" , "&" )
64+ . replaceAll ( "<" , "<" )
65+ . replaceAll ( ">" , ">" )
66+ . replaceAll ( '"' , """ )
67+ . replaceAll ( "'" , "'" ) ;
68+ }
69+
6170const _displayItem = ( item , searchTerms , highlightTerms ) => {
6271 const docBuilder = DOCUMENTATION_OPTIONS . BUILDER ;
6372 const docFileSuffix = DOCUMENTATION_OPTIONS . FILE_SUFFIX ;
@@ -324,14 +333,6 @@ const Search = {
324333 const titles = Search . _index . titles ;
325334 const allTitles = Search . _index . alltitles ;
326335 const indexEntries = Search . _index . indexentries ;
327- const htmlEscape = ( text ) => {
328- return String ( text )
329- . replaceAll ( "&" , "&" )
330- . replaceAll ( "<" , "<" )
331- . replaceAll ( ">" , ">" )
332- . replaceAll ( '"' , """ )
333- . replaceAll ( "'" , "'" ) ;
334- }
335336
336337 // Collect multiple result groups to be sorted separately and then ordered.
337338 // Each is an array of [docname, title, anchor, descr, score, filename, kind].
@@ -348,7 +349,7 @@ const Search = {
348349 const boost = titles [ file ] === title ? 1 : 0 ; // add a boost for document titles
349350 normalResults . push ( [
350351 docNames [ file ] ,
351- htmlEscape (
352+ _escapeHTML (
352353 titles [ file ] !== title ? `${ titles [ file ] } > ${ title } ` : title
353354 ) ,
354355 id !== null ? "#" + id : "" ,
@@ -368,7 +369,7 @@ const Search = {
368369 const score = Math . round ( 100 * queryLower . length / entry . length ) ;
369370 const result = [
370371 docNames [ file ] ,
371- htmlEscape ( titles [ file ] ) ,
372+ _escapeHTML ( titles [ file ] ) ,
372373 id ? "#" + id : "" ,
373374 null ,
374375 score ,
0 commit comments