如何 link 在 reStructuredText 中复制目标?
How to link duplicate targets in reStructuredText?
我的文档中有两个重复键 -> .. command:: targetName
,位于两个单独的页面上。我需要知道如何使用以下语法 link 到这两个单独的目标:
Page-1 Click this -> :command:`targetName` # this will always open the first targetName declared in the doc
目标:
Page-1 Click this -> :command:`targetName <page-1.html#targetName>` # not working :/
Page-2 Click this -> :command:`targetName <page-2.html#targetName>` # not working :/
Page-2 Click this -> `targetName <page-2.html#targetName>`_ # this will work but I don't want to use hyperlink instead of " :command: " cuz I want to keep my block style as is.
首先是一些术语。你所说的 targetName
在 reStructuredText 中被称为 title
。尖括号中的内容是target
。参见 Cross-referencing syntax。
reStructuredText 不支持嵌套内联标记,其中包括样式超链接。但是,replacement.
有一个解决方法
As reStructuredText doesn't support nested inline markup, the only way to create a reference with styled text is to use substitutions with the "replace" directive:
I recommend you try |Python|_.
.. |Python| replace:: Python, *the* best language around
.. _Python: http://www.python.org/
你的情况:
Page-1 Click this -> |myTarget|_
.. |myTarget| replace:: ``targetName``
.. _myTarget: page-1.html#targetName
要进一步自定义外观,请使用自定义样式。参见 一例。
我的文档中有两个重复键 -> .. command:: targetName
,位于两个单独的页面上。我需要知道如何使用以下语法 link 到这两个单独的目标:
Page-1 Click this -> :command:`targetName` # this will always open the first targetName declared in the doc
目标:
Page-1 Click this -> :command:`targetName <page-1.html#targetName>` # not working :/
Page-2 Click this -> :command:`targetName <page-2.html#targetName>` # not working :/
Page-2 Click this -> `targetName <page-2.html#targetName>`_ # this will work but I don't want to use hyperlink instead of " :command: " cuz I want to keep my block style as is.
首先是一些术语。你所说的 targetName
在 reStructuredText 中被称为 title
。尖括号中的内容是target
。参见 Cross-referencing syntax。
reStructuredText 不支持嵌套内联标记,其中包括样式超链接。但是,replacement.
有一个解决方法As reStructuredText doesn't support nested inline markup, the only way to create a reference with styled text is to use substitutions with the "replace" directive:
I recommend you try |Python|_. .. |Python| replace:: Python, *the* best language around .. _Python: http://www.python.org/
你的情况:
Page-1 Click this -> |myTarget|_
.. |myTarget| replace:: ``targetName``
.. _myTarget: page-1.html#targetName
要进一步自定义外观,请使用自定义样式。参见