diff --git a/src/sphinx.js b/src/sphinx.js index c333a66..e8a0be8 100644 --- a/src/sphinx.js +++ b/src/sphinx.js @@ -151,8 +151,12 @@ export function searchIndex(index, query) { // Titles in the index arrive as the HTML of the page's

, markup and all // (docs.python.org wraps module names in spans), so they are flattened -// to text before they are placed on the results page. -const plainTitle = (t) => String(t).replace(/<[^>]*>/g, ''); +// to text before they are placed on the results page. The '>' is optional so +// a tag the title never closes is dropped too, not left standing as ' String(t).replace(/<[^>]*>?/g, '').trim(); const escapeHTML = (s) => String(s) .replaceAll('&', '&').replaceAll('<', '<') diff --git a/tests/sphinx.test.js b/tests/sphinx.test.js index 4037540..7964784 100644 --- a/tests/sphinx.test.js +++ b/tests/sphinx.test.js @@ -43,6 +43,15 @@ test('titles are flattened to text before they reach the results page', () => { assert.equal(found.docs[0].title, 'json - JSON encoder and decoder'); }); +test('a tag the title never closes is stripped, not left standing', () => { + // 'json encoder