2016-11-26 1 views
-1

Comment faire pour que deux liens aient le même texte mais des cibles différentes dans reStructuredText? Le script suivant ne fonctionne pas, mais peut vous aider à obtenir le point:Lier le même texte à différentes cibles dans reStructuredText

This Python_ is not the same as that Python_. 

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

Ce travail peut se faire en Markdown:

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

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

Résultat:

Ce Python n'est pas la même chose que que Python.

Répondre

1

Une meilleure solution:

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

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

trouvé une solution avec les directives et subsitutions. Je ne sais pas si c'est le meilleur.

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/