reST:具有任意标题的内联链接?

发布于 2024-11-02 20:57:16 字数 400 浏览 0 评论 0原文

如果我定义了内部超链接目标,如何使用任意文本作为链接标题链接到它?

例如:

_`This is a very long internal link target`.

...

A `short reference`_ to the very long link target.

如何将“短参考”目标变成“非常长的内部目标”?

编辑:另一个例子:

Widgets
=======

...

Use a `widget`_.

如何将“widget”(单数)链接到“Widgets”(复数)标题?

(当然,我意识到这可以使用 `widget`_\s 来完成......但这并不能解决一般问题)

If I've defined an internal hyperlink target, how can I link to it using arbitrary text as the link title?

For example:

_`This is a very long internal link target`.

...

A `short reference`_ to the very long link target.

How could I make the “short reference” target the “very long internal target”?

Edit: Another example:

Widgets
=======

...

Use a `widget`_.

How can I make “widget” (singular) link to the “Widgets” (plural) heading?

(of course, I realize that this could be done using `widget`_\s… But that doesn't solve the general problem)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

記柔刀 2024-11-09 20:57:16

我还没有找到使用“标准”休息来做到这一点的方法。但使用 Sphinx 时,可以执行以下操作:

.. _`This is a very long internal link target`:

:ref:`Short reference <This is a very long internal link target>` to the very long link target.

I haven't found a way to do this using "standard" reST. But with Sphinx, the following works:

.. _`This is a very long internal link target`:

:ref:`Short reference <This is a very long internal link target>` to the very long link target.
孤千羽 2024-11-09 20:57:16

很好,mzjn 的答案也适用于课程:

:class:`MyClasses <mymodule.MyClass>` in plural is awesome.

万岁!

Nicely, mzjn's answer also works for classes:

:class:`MyClasses <mymodule.MyClass>` in plural is awesome.

Hurray!

柏林苍穹下 2024-11-09 20:57:16

pure-reStructuredText 方法是为同一个目标定义多个目标名称:(

.. _my widget:
.. _above:
My long title about widgets
===========================
…
See how to use  `my widget`_ in the section above_.

此方法的一个限制是您可能希望对两个使用相同的文本(例如“above”)不同的位置,在这种情况下上述方法失败。)

A pure-reStructuredText method is to define multiple target names for the same target:

.. _my widget:
.. _above:
My long title about widgets
===========================
…
See how to use  `my widget`_ in the section above_.

(A limitation of this approach is that you may want to use the same text (e.g. "above") for two different locations, and the approach above fails in this case.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文