如何处理 reStructuredText 中重复的目标名称?

发布于 2024-10-14 21:04:50 字数 689 浏览 2 评论 0原文

示例:

foo is a tool used to do foo.

Download_

.. _Download: http://example.com/foo

blah blah blah (omit a lot of paragraphs)

bar is another tool to do bar.

Download_

.. _Download: http://example.com/bar

由于 Download 指向不同的 url,docutilus 会给出以下错误报告:

Duplicate target name, cannot be used as a
unique reference: "Download".

While in markdown, I can specify different id for this two Download:

[Download][download-foo]
[download-foo]: http://example.com/foo
[Download][download-bar]
[download-bar]: http://example.com/bar

How can I do like things in重构文本?

Example:

foo is a tool used to do foo.

Download_

.. _Download: http://example.com/foo

blah blah blah (omit a lot of paragraphs)

bar is another tool to do bar.

Download_

.. _Download: http://example.com/bar

Since Download points to different urls, docutilus gives this error report:

Duplicate target name, cannot be used as a
unique reference: "Download".

While in markdown, I can specify different id for this two Download:

[Download][download-foo]
[download-foo]: http://example.com/foo
[Download][download-bar]
[download-bar]: http://example.com/bar

How can I do similar things in reStructuredText?

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

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

发布评论

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

评论(2

倦话 2024-10-21 21:04:50

选项一

正如@mzjn指出的那样,使目标名称更清晰:

`Download foo`_

.. _Download foo: http://example.com/foo

`Download bar`_

.. _Download bar: http://example.com/bar

选项二

来自 docutils -用户邮件列表

使用匿名超链接:

Download__


__ http://example.com/foo


Download__

__ http://example.com/bar

Option one

As @mzjn pointed out, make target name more clear:

`Download foo`_

.. _Download foo: http://example.com/foo

`Download bar`_

.. _Download bar: http://example.com/bar

Option two

From docutils-user maillist:

Use Anonymous hyperlink:

Download__


__ http://example.com/foo


Download__

__ http://example.com/bar
ら栖息 2024-10-21 21:04:50

据我所知文档,参考ReST 文档中的名称共享公共命名空间,因此它们必须是唯一的。我想不出比这更好的事情了:

foo is a tool used to do foo.

`Download foo`_

.. _Download foo: http://example.com/foo

blah blah blah (omit a lot of paragraphs)

bar is another tool to do bar.

`Download bar`_

.. _Download bar: http://example.com/bar

As far as I can tell from the documentation, reference names in ReST documents share a common namespace, so they must be unique. I can't think of anything better than this:

foo is a tool used to do foo.

`Download foo`_

.. _Download foo: http://example.com/foo

blah blah blah (omit a lot of paragraphs)

bar is another tool to do bar.

`Download bar`_

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