【问题标题】:Syntax highlighting on readthedocs.io of sphinx code-blocksphinx 代码块的 readthedocs.io 上的语法高亮显示
【发布时间】:2021-04-01 10:09:51
【问题描述】:

我在我的项目中使用 RTD + Sphinx (redgrease = https://github.com/lyngon/redgrease),似乎代码块的语法突出显示在 readthedocs.io 页面上不起作用。

它只在一个框中显示黑色文本。

例如见清单项目 3: https://redgrease.readthedocs.io/en/latest/intro.html#intro-redgrease

当我在本地构建(使用 sphinx-build)以及在 VS Code 中使用 reStructuredText 插件构建时,语法突出显示效果很好。

工作(本地)

不工作(readthedocs.io)

代码块都是缩进的(因为它们出现在列表中),类似于:

#. :ref:`Server-side Redis commands <red_commands>`.

    Allowing for ... blah blah ...
    It is ... yada yada ...

    .. code-block:: python
        :emphasize-lines: 8, 11, 13

        import redgrease
        import redgrease.utils

        # ... moar codes ..

可能会发生什么? 我需要一些扩展或添加一些配置选项吗? 我在 'conf.py' 和 '.readthedocs.yml' 中没有太多的诡计。 (见回购)

【问题讨论】:

  • RTD 支持能够非常迅速地发现问题。谢谢桑托斯!我已经回复了下面的解决方案。

标签: python syntax-highlighting python-sphinx read-the-docs


【解决方案1】:

原因非常简单。

我错误地将真正旧版本的“sphinx-rtd-theme”固定在我的“requirements.txt”文件中。

我固定的是 0.1.5 版本,而不是最新的 0.5.1
我的本地环境只是有一个更新的版本。

哇! ?

【讨论】:

    猜你喜欢
    • 2011-02-03
    • 2020-11-08
    • 2011-09-08
    • 1970-01-01
    • 2014-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多