首页 > 解决方案 > 锚点替换为 '#id1' 、 '#id2' 、 '#id3' ... Sphinx

问题描述

我在 rst 文件中使用数字命名,但在构建它之后,锚点被替换为 '#id1'、'#id2'、'#id3' ....

我只需要使用数字来命名锚点......但我不知道如何......

这是我的第一个文件。

实际代码

*************
Screen(HTS)
*************

Quote
=============

1101
------------------
.. raw:: html
    :file: _static/1101.html

1151
------------------
.. raw:: html
    :file: _static/1151.html

1152
------------------
.. raw:: html
    :file: _static/1152.html

1103
------------------
.. raw:: html
    :file: _static/1103.html

标签: anchorpython-sphinx

解决方案


首先,下划线和上划线必须与文本长度相同。

不幸的是,您想要以数字开头的锚点,但 Sphinx 不支持这一点。您可以改为使用以字符串开头的任意锚点。请参阅使用 .交叉引用任意位置:ref:的文档。这是一个例子。

***********
Screen(HTS)
***********

Quote
=====

.. _section-1101:

1101
----

推荐阅读