Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable highlighting in html output

I generate Sphinx documentation with make html. Everything is ok with that. But when I use search feature, I get a link with search term appended, like this:

http://url/search.html?q=searched&check_keywords=yes&area=default
http://url/module.html?highlight=searched

The thing is the highlight ("searched" above) is always there. The only way to disable it is to edit URL in the browser manually.

Is there any other way to get link to the document without highlight part?

Platform: windows
Sphinx version: 1.1.3

Regards, Robert

like image 626
Robert Gomułka Avatar asked Mar 27 '17 10:03

Robert Gomułka


People also ask

How do I turn off highlighting in HTML?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How do I stop my text from highlighting?

Remove highlighting from part or all of a document Select the text that you want to remove highlighting from, or press Ctrl+A to select all of the text in the document. Go to Home and select the arrow next to Text Highlight Color. Select No Color.

How do you change highlights in HTML?

To change the look and feel of highlighted text on an HTML page you will use the ::selection operator. You can apply this operator as wide or as narrow as you see fit.


1 Answers

The highlighted text is rendered by a <span class="highlighted">searched</span> element. The default CSS rule (in basic.css) is this:

dt:target, span.highlighted {
    background-color: #fbe54e;
}

You can override this rule in a custom CSS file (let's call it custom.css) with this content:

/* Assume that the 'alabaster' theme is used */
@import url("alabaster.css");
 
/* No search term highlighting */
span.highlighted {
    background-color: transparent;
}

Put custom.css in the _static folder of your Sphinx project and add or modify the following lines in conf.py:

html_static_path = ["_static"]
html_style = "custom.css"

The above disables highlighting on the "search results" page and on each linked page.

Tested with Sphinx 1.6.5 (1.1.3 is quite old).

like image 106
mzjn Avatar answered Nov 17 '22 20:11

mzjn