我正在使用 Sphinx 来记录工作项目。我想在整个文档的多个页面上使用指向下载的相同链接。
例如:
home.rst:
Hi
==
I want you to download_ my project.
.. _download: blah.com/download
other_page.rst
Hello Again
===========
You can also download_ it here.
.. _download: blah.com/download
有没有某种方法可以让每个页面都指向一个变量,以便当链接需要更新时仅需要更新变量?
最好的选择是使用代换 https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#substitutions, rst_epilog https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog, and raw-html
如本文所述回答 mailto 链接 https://stackoverflow.com/a/44593780/2214933.
In your conf.py
:
rst_epilog = """
.. role:: raw-html(raw)
:format: html
.. |download| replace:: :raw-html:`<a href="https://blah.com/download/">download</a>`
"""
In your *.rst
:
Please |download| my file.
The extlink扩大 http://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html很接近,但假设您希望使用 URL 作为该站点其他链接的基础。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)