I use Sphinx with the Read the Docs theme. For small inline code snippets, such as the mention of a single variable among a piece of text, I use double backticks to format the code as what's called "inline literals" in the documentation.
Unlike proper code blocks, no language specific syntax highlighting is performed on the inline code snippets (that's fine). As seen in the linked documentation above (see the below screen shot), all such "inline literals" are colored red.

I'm only concerned with the HTML output of Sphinx.
I found a solution, though it involves changing the Sphinx RTD theme source code.
The HTML coloring used by the RTD theme is specified in sphinx_rtd_theme/static/css/theme.css, with the sphinx_rtd_theme directory located in the site-packages directory of the Python installation. The red color used is #e74c3c and the specific place which sets this color for inline literals is
literal{color:#e74c3c}
Changing this color does exactly what I want. Making changes directly to theme_css feels wrong though. The specific change takes place on line 4, which is over 100000 characters wide! Clearly this file is generated from other files. I guess the proper solution involves performing the change do one of these (to me unknown) files.
With a custom .css file, the colors of the inline literals can be set using
code.literal {
color: #404040 !important;
background-color: #fbfbfb !important;
}
The name of a .css file containing the above should be added to html_css_files in the Sphinx conf.py, i.e.
# conf.py
html_css_files = ['custom.css']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With