mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
HTML Search: Fix removal of unwanted anchor content from search results (#12321)
This commit is contained in:
parent
2008aa8c78
commit
208f4bcb66
@ -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
|
||||
-------
|
||||
|
@ -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) {
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user