New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
search: support searching for (sub)titles #10717
Conversation
4684bcb
to
dfba5c3
Compare
Does this work for partial matches? A |
b66cda8
to
9d23ee2
Compare
Yes, I've just added partial match support. |
9d23ee2
to
180f91a
Compare
Please add tests and a CHANGES entry. A |
180f91a
to
a5f07bb
Compare
I've just added CHANGES, but for a working test, I would need an HTML inspection of rendered |
As an improvement, it should be possible to emit a link directly to the title in a page.
Can you please help me? |
I think you may need to look at the parent |
Note: In https://github.com/jbms/sphinx-immaterial I have implemented something similar entirely client side, but there are a few differences:
This is the source code of my implementation, for reference: In general handling this when building the index is probably better, though given that the HTML must be parsed anyway to handle the snippets I'm not sure. |
a5f07bb
to
b4541ff
Compare
Yes, I do prefer the server side implementation and I'm still curious about the title links as mentioned in my previous comment. One should be able to get a link to them. |
Something like A |
Yep, that almost works: diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py
index bbb28c0b9..7916d26f0 100644
--- a/sphinx/search/__init__.py
+++ b/sphinx/search/__init__.py
@@ -216,6 +216,8 @@ class WordCollector(nodes.NodeVisitor):
elif isinstance(node, nodes.title):
title = node.astext()
self.found_titles.append(title)
+ print('node:', node)
+ print('node.parent[names]:', node.parent['names'])
self.found_title_words.extend(self.lang.split(title))
elif isinstance(node, Element) and self.is_meta_keywords(node):
keywords = node['content'] emits something like:
So the last missing piece is probably an escaping that will emit e.g. |
Ahh, can you try A |
b4541ff
to
0f99495
Compare
Works for me, added that. |
b160baa
to
3f7d25c
Compare
Can you please @AA-Turner review the pull request now? |
Something seems to be wrong: https://sphinx--10717.org.readthedocs.build/en/10717/search.html?q=More+topics+to+be+covered https://www.sphinx-doc.org/en/master/search.html?q=More+topics+to+be+covered The PR only shows 5 results, and doesn't highlight the title, whereas the current master shows the title, albeit as the third result. A |
Yeah, it's a fancy feature of Please compare it with another pull request: |
Collect all titles from all pages and utilize a contains match (case insensitive) in Search page. Fixes: sphinx-doc#10689
Rebased. A |
3f7d25c
to
39a1301
Compare
If running an incremental build, A |
Thanks @marxin! A |
Thanks for merging that! |
Collect all titles from all pages and utilize a full match
(case insensitive) in Search page.
Fixes: #10689