当然,在网络上下划线表示超链接,但是如果我需要下划线而不是超链接怎么办?
我在这里问了类似的问题。尝试这样:
.. role:: underline
:class: underline
在文档中,可以按如下方式应用:
:underline:`This text is underlined`
在您的 css
文件中,您可以有:
.underline {
text-decoration: underline;
}
这应该适用于 HTML 输出。然而,下划线故意不属于 ReST 规范的一部分。请参阅此链接。
.. role:: underline
:class: underline
在文档中,您可以用以下内容指示带下划线的文本:
:underline:`This text is underlined`
要为下划线类指定 css,如果您使用的是 sphinx_rtd_theme,请在文件夹 _themes/sphinx_rtd_theme/sphinx_rtd_theme/ 内的布局.html 文件中添加一些 css,否则您的默认主题目录:
<style>
.underline {
text-decoration: underline;
}
</style>
这将相应地设置您的 html 样式。
下划线是 StructureText 的一部分,但不是 Sphinx 的 reStructuredText 规范的一部分,根据 David Ascher 在 2000 年 1 月 21 日的 Doc-SIG 邮件列表帖子“Docstring 语法:一个非常修订的提案”中的引用:
用 _ 标记带下划线的文本不是最理想的。下划线 不应该从印刷的角度使用(下划线是 设计用于手稿中与排字人员沟通 文本应该是斜体——没有一本排版良好的书使用过 下划线),并与双下划线Python变量冲突 名称(
init等),会被截断并且 当不需要这种效果时,会加下划线。请注意,虽然完成 我认为标记会防止截断('init') 文档字符串标记很像我认为的类型注释——它们应该 是可选的,最重要的是没有害处。在这种情况下,下划线 标记确实有害。
.. role:: ins
The "ins" role is by default rendered as underlined :ins:`in HTML5,
where the <ins> tag is used`.