【问题标题】:How to use Sphinx section links within a code block如何在代码块中使用 Sphinx 部分链接
【发布时间】:2022-06-18 20:20:55
【问题描述】:

此扩展程序上可能有多个帖子不起作用。我不知道问题出在哪里,因为我是 RST 新手。

我正在尝试从代码块内部交叉引用到某个部分。我在conf.py 文件中启用了'sphinx.ext.autosectionlabel'。但我无法在生成的 HTML 中看到链接。

conf.py

extensions = [
    'sphinx.ext.doctest',
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.intersphinx',
    'sphinx.ext.autosectionlabel'
]

doc.rst

.. code-block:: RST

    FTP_ENABLED: "sgsf"
    FTP_USERNAME: asdasd
    FTP_PASSWORD: asdasd
    FTP_HOSTNAME: asdasd
    FTP_PORT: 21
    FTP_SLACK_WEBHOOK_URL: Use the URL by :ref:`Section 1`

Section 1
---------

Section text here

【问题讨论】:

  • 你不能那样做。 code-block 仅适用于代码,不适用于解释的 reStructuredText 角色。

标签: restructuredtext


【解决方案1】:

您可以使用.. parsed-literal:: 指令[1],但请注意您不能再指定语言。

[1]https://docutils.sourceforge.io/docs/ref/rst/directives.html#parsed-literal

【讨论】:

    猜你喜欢
    • 2021-08-01
    • 1970-01-01
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    • 2015-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多