Preformatted (verbatim) hyperlink in Sphinx-reST-RTD

对着背影说爱祢 提交于 2020-08-24 03:40:12

问题


I am building documentation with Sphinx-RTD.

I want to have a link somewhere, and be styled as a verbatim or preformatted text.

For example, say I have this verbatim:

ALTER TABLE

Is there a way to link it somewhere, say a :ref:... or even just a standard hyperlink?


回答1:


If I am not mistaken the "Replacement Text" directive can help.

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/

So maybe something like this:

Click |altertable|_ to read details about |altertable|.

----

Blah blah blah

----

.. _altertable:

Here are the details about |altertable|: blah blah blah.

.. |altertable| replace:: ``ALTER TABLE``


来源:https://stackoverflow.com/questions/59006744/preformatted-verbatim-hyperlink-in-sphinx-rest-rtd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!