gpt4 book ai didi

python-sphinx - 在Sphinx中的引用内保留内联代码

转载 作者:行者123 更新时间:2023-12-03 08:06:32 25 4
gpt4 key购买 nike

在Sphinx中,如果我有以下标题声明:

.. _somestuff:

``this is code``, this is not!
==============================

它呈现如下:

this is code,这不是!

这很好,但是,如果我使用引用,例如:
Have a look at :ref:`somestuff`

它会丢失代码格式,并呈现为:

看看 this is code, this is not!

代替:

看看 this is code , this is not!

是否可以保留引用中的代码格式?我将如何处理呢?

最佳答案

如果您在official web site中查看有关内联标记的:ref:文档:

:ref:

To support cross-referencing to arbitrary locations in any document, the standard reST labels are used. For this to work label names must be unique throughout the entire documentation ...



我认为(就像@Kevin Horn一样)现在不可能,因为它仅用于创建与项目中其他部分的链接(无rst格式)。然后,如果您编写这样的内容:
.. _somestuff:

``this is code``, this is not!
==============================

.. _another_somestuff:

this is another code!
========================

如果我链接这些部分:
Have a look at :ref:`somestuff`
Have a look at :ref:`another_somestuff`
Have a look at :ref:`this link <somestuff>`

结果是:

看看 ,这是代码,这不是!

看看 ,这是另一个代码!

看看 这个链接

他们的风格都是一样的。

注意:斜体/粗体字表示链接

关于python-sphinx - 在Sphinx中的引用内保留内联代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8091979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com