How to remove the emphasis for the internal hyperlink in sphinx documentation

552 views Asked by At

Cross-referencing in sphinx is done using ref , like:

.. _my-reference-label:

Section to cross-reference
--------------------------

This is the text of the section.

It refers to the section itself, see :ref:`my-reference-label`.

When compiled to HTML, above would introduce a hyperlink after "see", but would also embed it within the <em> tag, making internal references look different from external hyperlinks.

Is there any way to instruct sphinx not to emphasize internal references, that is, not to embed them within the <em> tag?

2

There are 2 answers

0
Steve Barnes On

You could write your own theme and template to do this.

1
Steven Almeroth On

You can add a line to your CSS file:

a.internal {font-style: normal}

In order for Sphinx to use a custom CSS file you need to edit conf.py:

html_style = 'my_style.css'

Then put the file in the _static directory, or whichever directory you have declared with html_static_path.

Then my_style.css might look like:

@import url("default.css");  /* This should be the file used by your theme */

/* Internal links */
a.internal {font-style: normal}

This will not get rid of the surrounding <em> tag but should work to style your docs correctly.