HTML Search: Fix removal of unwanted anchor content from search results (#12321)

This commit is contained in:
Will Lachance 2024-04-24 14:09:14 -04:00 committed by GitHub
parent 2008aa8c78
commit 208f4bcb66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View File

@ -25,6 +25,8 @@ Bugs fixed
* #12162: Fix a performance regression in the C domain that has
been present since version 3.0.0.
Patch by Donald Hunter.
* #12320: Fix removal of anchors from search summaries (regression in 7.3.0).
Patch by Will Lachance.
Testing
-------

View File

@ -178,7 +178,7 @@ const Search = {
htmlToText: (htmlString, anchor) => {
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
for (const removalQuery of [".headerlinks", "script", "style"]) {
for (const removalQuery of [".headerlink", "script", "style"]) {
htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
}
if (anchor) {

View File

@ -100,15 +100,15 @@ describe("htmlToText", function() {
</style>
<!-- main content -->
<section id="getting-started">
<h1>Getting Started</h1>
<h1>Getting Started <a class="headerlink" href="#getting-started" title="Link to this heading"></a></h1>
<p>Some text</p>
</section>
<section id="other-section">
<h1>Other Section</h1>
<h1>Other Section <a class="headerlink" href="#other-section" title="Link to this heading"></a></h1>
<p>Other text</p>
</section>
<section id="yet-another-section">
<h1>Yet Another Section</h1>
<h1>Yet Another Section <a class="headerlink" href="#yet-another-section" title="Link to this heading"></a></h1>
<p>More text</p>
</section>
</div>