【问题标题】:Rinohtype link text is "Section 3.1" instead of the text specified in the link or link targetRinohtype 链接文本是“第 3.1 节”,而不是链接或链接目标中指定的文本
【发布时间】:2021-07-29 07:30:50
【问题描述】:

我指定一个明确的链接目标如下:

.. _REPLY_STATUS_CODE:

REPLY_STATUS_CODE (0x0001)
---------------------------

然后像这样创建对它的引用:

Related
    :ref:`REPLY_STATUS_CODE`

也试过这样:

A :ref:`REPLY_STATUS_CODE <REPLY_STATUS_CODE>` command...

在这两种情况下,链接上的文本都是“第 3.8 节”而不是“REPLY_STATUS_CODE”,使用 Sphinx 构建 HTML 会将链接文本呈现为“REPLY_STATUS_CODE”。有没有办法获得我想要的文本而不是 rinohtype 中的部分和数字?

【问题讨论】:

  • 我也在我的样式表中尝试了这个(它做了同样的事情):[reference] type=reference

标签: python-sphinx restructuredtext rinohtype


【解决方案1】:

您可以通过调整 linked reference 样式使 rinohtype 创建与 HTML 中的链接相同的链接:

[STYLESHEET]
name = My custom style sheet
base = sphinx

[linked reference]
type = custom

您仍然可以使用:numref: 角色按编号显式引用元素(这确实需要设置numfig = True,也会影响HTML 输出)。有关详细信息,请参阅问题 #244 How to restore target number references?

理想情况下,像您尝试的那样提供显式链接文本 (:ref:`REPLY_STATUS_CODE &lt;REPLY_STATUS_CODE&gt;` ) 会覆盖按数字链接部分的默认行为,但这需要更改 docutils/Sphinx,因为 rinohtype 无法看到有无引用之间的区别明确的链接文本。

最后,如果能够定义custom role 以便 rinohtype 可以区分不同类型的引用,那就太好了。例如:

.. role:: titleref(ref)
   :class: titleref

唉,这也不可能。因此,至少目前,您只能使用:ref::numref: 进行区分(这也会影响 HTML 输出)。

【讨论】:

猜你喜欢
  • 2015-10-20
  • 2016-05-15
  • 2017-12-15
  • 2012-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多