如何有相同的文本在两个链接与重新构造的文本?

下面是我想做的:

1. `link <http://www.google.com>`__
2. `link <http://www.yahoo.com>`__

获得:

<ol>
<li><a href="http://www.google.com">link</a></li>
<li><a href="http://www.yahoo.com">link</a></li>
</ol>

上下文是一个出版物列表,我希望它们的末尾都有一个标记为“ DOI”的链接。

然而,这似乎失败了:

<string>:3: (WARNING/2) Duplicate explicit target name: "doi".

确切的错误似乎取决于我使用的 docutils 的版本,但它们都失败了。

是否有一种方法可以在重新构造的文本中生成具有相同文本的多个链接?

9036 次浏览

I think you'll want to use anonymous hyperlinks:

1. `link`__
2. `link`__


__ http://www.google.com
__ http://www.yahoo.com

Keep in mind that the order they're referred to in the document is important. More information can be found here.

Seems like you need a newline and two underscores.

This is what I do:

What is that Process object good for? `(html)
<process.html>`__
`(html)
<other.process.rst>`__

to obtain:

What is that Process object good for?
<a class="reference external" href="process.html">(html)</a>
<a class="reference external" href="process.rst">(html)</a>

The warning

(WARNING/2) Duplicate explicit target name:foo

occurs when you use the same text for two different links in "Named hyperlink references":

`Foo <http://example.org>`_
`Foo <http://example.com>`_

To circumvent it, use anonymous hyperlink references with double underscores:

`Foo <http://example.org>`__
`Foo <http://example.com>`__

This works without a warning on docutils 0.8.1.