【问题标题】:How to remove the emphasis for the internal hyperlink in sphinx documentation如何在 sphinx 文档中消除对内部超链接的强调
【发布时间】:2013-12-14 00:08:55
【问题描述】:

sphinx 中的交叉引用是使用 ref 完成的,例如:

.. _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`.

当编译为 HTML 时,上面会在“see”之后引入一个超链接,但也会将其嵌入到 <em> 标记中,使内部引用看起来与外部超链接不同。

有没有什么办法可以指示sphinx不要强调内部引用,也就是不要将它们嵌入到<em>标签中?

【问题讨论】:

    标签: css python-sphinx restructuredtext cross-reference


    【解决方案1】:

    您可以在 CSS 文件中添加一行:

    a.internal {font-style: normal}
    

    为了让 Sphinx 使用自定义 CSS 文件,您需要编辑 conf.py:

    html_style = 'my_style.css'
    

    然后将文件放在_static 目录中,或者您使用html_static_path 声明的任何目录中。

    那么my_style.css 可能看起来像:

    @import url("default.css");  /* This should be the file used by your theme */
    
    /* Internal links */
    a.internal {font-style: normal}
    

    这不会消除周围的 <em> 标记,但应该可以正确设置您的文档样式。

    【讨论】:

    • 最后一行代码必须为a.internal em {...。 “em”不见了。像现在这样,它不起作用。
    【解决方案2】:

    您可以编写自己的 theme 和 template 来执行此操作。

    【讨论】:

      猜你喜欢
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 2010-11-08
      • 1970-01-01
      • 2015-04-25
      相关资源
      最近更新 更多