如何在重组文本的两个链接中使用相同的文本?

时间:2011-03-28 20:20:35

标签: python restructuredtext

以下是我想做的事情:

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的版本,但它们都失败了。

有没有办法在重组文本中生成具有相同文本的多个链接?

3 个答案:

答案 0 :(得分:116)

警告

  

(警告/ 2)重复显式目标名称:foo

当您在“命名超链接引用”中为两个不同的链接使用相同的文本时,会出现

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

要绕过它,请使用带有双下划线的匿名 hyperlink references

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

这对Docutils 0.8.1没有警告。

答案 1 :(得分:15)

我想你会想要使用匿名超链接:

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

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

请记住,文档中提及的顺序非常重要。可以找到更多信息here

答案 2 :(得分:3)

好像你需要换行符和两个下划线。

这就是我的所作所为:

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

获得:

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>
相关问题