将相同的文本链接到reStructuredText中的不同目标

时间:2016-11-26 08:31:30

标签: markdown restructuredtext

如何让两个链接在reStructuredText中具有相同的文本但不同的目标?以下脚本不起作用,但可以帮助您明白这一点:

This Python_ is not the same as that Python_.

.. _Python2: https://docs.python.org/2/
.. _Python3: https://docs.python.org/3/

这项工作可以在Markdown中完成:

This [Python][Python2] is not the same as that [Python][Python3].

[Python2]: https://docs.python.org/2/
[Python3]: https://docs.python.org/3/

结果:

PythonPython不同。

1 个答案:

答案 0 :(得分:2)

更好的解决方案:

This `Python <Python2_>`_ is not the same as that `Python <Python3_>`_.

.. _Python2: https://docs.python.org/2/
.. _Python3: https://docs.python.org/3/

找到一个包含指令和替换的解决方案。不确定这是否是最好的。

This |Python2|_ is not the same as that |Python3|_.

.. |Python2| replace:: Python
.. |Python3| replace:: Python
.. _Python2: https://docs.python.org/2/
.. _Python3: https://docs.python.org/3/