Sphinx search result showing "===" and "---"

391 views
Skip to first unread message

Chris

unread,
Apr 15, 2011, 8:21:39 PM4/15/11
to sphinx-dev
I noticed that on the search result page, the snippets include the
markup used to identify various headings in the .rst files. shouldn't
these be hidden to the end user?

For example:
http://sphinx.pocoo.org/search.html?q=doctest+snippet

shows:

sphinx.ext.doctest – Test snippets in the documentation
.. highlight:: rest :mod:`sphinx.ext.doctest` -- Test snippets in the
documentation
=============================================================== ..
module:: sphinx.ext.doctest :synopsis: Test snippets in the
documentation. .. index...

and

Changes in Sphinx
:tocdepth: 2 .. _changes: Changes in Sphinx ***************** ..
include:: ../CHANGES...

Jeff McKenna

unread,
Apr 20, 2011, 12:40:13 PM4/20/11
to sphin...@googlegroups.com
I was about to ask the same question as Chris: how to not show the raw
restructured text in Sphinx's search results. If an html snippet can't
be shown instead, can I customize the search results to only show the
page heading name? (I found one site that does not show the
restructured text, but shows the page's heading name instead:
http://docs.geoserver.org/stable/en/user/search.html?check_keywords=yes&area=default&q=install&x=0&y=0)

Any thoughts on this issue (showing html instead of rst in search
results, or, not showing the rst snippet at all, just the heading)?

-jeff

On 11-04-15 9:21 PM, Chris wrote:
> I noticed that on the search result page, the snippets include the
> markup used to identify various headings in the .rst files. shouldn't
> these be hidden to the end user?
>
> For example:
> http://sphinx.pocoo.org/search.html?q=doctest+snippet
>
> shows:
>

> sphinx.ext.doctest � Test snippets in the documentation

Jeff McKenna

unread,
Apr 20, 2011, 4:14:48 PM4/20/11
to sphin...@googlegroups.com
I've done some research into this, so I'll reply to my own email:

To modify the search output, you can modify the _static/searchtools.js
file in your output directory. If you look at around line#483 of that
file in a text editor, you can see that it looks in the _source
directory and crawls the ".txt" files for the search term. You can
change that javascript so it crawls the .html files instead, but the
same problem will occur: raw html tags will be included in the result
summary.

You can remove the summary and just show the page name by commenting
line#486:

//listItem.append($.makeSearchSummary(data, searchterms, hlterms));

I hope this info helps someone else down the line.

Thanks!

-jeff

Kevin Horn

unread,
Apr 20, 2011, 9:02:21 PM4/20/11
to sphin...@googlegroups.com
I haven't tried this, but it seems like you could probably run the "text builder" and change the JS code to search the output of that.  Which would at least minimize the amount of extra "stuff" in your search output.

Kevin Horn

sphinx.ext.doctest – Test snippets in the documentation

.. highlight:: rest :mod:`sphinx.ext.doctest` -- Test snippets in the
documentation
=============================================================== ..
module:: sphinx.ext.doctest :synopsis: Test snippets in the
documentation. .. index...

and

Changes in Sphinx
:tocdepth: 2 .. _changes: Changes in Sphinx ***************** ..
include:: ../CHANGES...



--
You received this message because you are subscribed to the Google Groups "sphinx-dev" group.
To post to this group, send email to sphin...@googlegroups.com.
To unsubscribe from this group, send email to sphinx-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.


Jeff McKenna

unread,
Apr 21, 2011, 9:33:41 AM4/21/11
to sphin...@googlegroups.com
Hi Kevin,

Interesting idea. I did try this but the textbuilder still creates
files with the section header text ("==========") included.

Thanks.

-jeff

Kayce Basques

unread,
Nov 13, 2014, 11:46:53 AM11/13/14
to sphinx...@googlegroups.com, sphin...@googlegroups.com, chrish...@gmail.com
Reply all
Reply to author
Forward
0 new messages