如何使用sphinx v4.5.0使用线号来修复事故格式?

发布于 2025-01-27 09:46:01 字数 1523 浏览 1 评论 0原文

最初,我在Sphinx v3.5.4中的代码很好。我使用了以下代码。

.. code-block:: python
    :caption: ex2.py: step 3
    :name: ex2.py
    :linenos:
    :lineno-start: 1
    :emphasize-lines: 2-5

    def Sum(iN):
        if (iN == 0):
            return(0)
        else:
            return(iN + Sum(iN - 1))

    iMax = 10
    for i in range(1, iMax):
        print(i, ':', Sum(i))

然后,狮身人面像将正常输出如下所示。

1 def Sum(iN):
2    if (iN == 0):
3        return(0)
4    else:
5        return(iN + Sum(iN - 1))
6 
7 iMax = 10
8 for i in range(1, iMax):
9     print(i, ':', Sum(i))

但是,从狮身人面像v4.5.0渲染后,我的示例代码如下所示。

1 def Sum(iN):
2 
    if (iN == 0):
3 
        return(0)
4 
    else:
5 
        return(iN + Sum(iN - 1))
6 
7 iMax = 10
8 for i in range(1, iMax):
9     print(i, ':', Sum(i))

基本上,我删除了:lineno:参数,事故线路破坏条件消失。无论如何,它可能带有线数功能。是否有人有解决这个问题的解决方案?

请注意,我在环境中使用了以下所需模块。

sphinx==4.5.0
graphviz==0.19.1
sphinxcontrib-plantuml==0.23
sphinxcontrib-blockdiag==2.0.0
sphinxcontrib-actdiag==2.0.0
sphinxcontrib-nwdiag==2.0.0
sphinxcontrib-seqdiag==2.0.0
sphinxbootstrap4theme>=0.6.0
sphinxcontrib.bibtex==2.4.2
sphinxcontrib.httpdomain==1.8.0
sphinx-autorun==1.1.1
sphinx-copybutton==0.5.0
hieroglyph==2.1.0

Originally, my codes in Sphinx v3.5.4 are quite well. I used the following codes.

.. code-block:: python
    :caption: ex2.py: step 3
    :name: ex2.py
    :linenos:
    :lineno-start: 1
    :emphasize-lines: 2-5

    def Sum(iN):
        if (iN == 0):
            return(0)
        else:
            return(iN + Sum(iN - 1))

    iMax = 10
    for i in range(1, iMax):
        print(i, ':', Sum(i))

Then, the Sphinx will output normally as shown as below.

1 def Sum(iN):
2    if (iN == 0):
3        return(0)
4    else:
5        return(iN + Sum(iN - 1))
6 
7 iMax = 10
8 for i in range(1, iMax):
9     print(i, ':', Sum(i))

However, after rendered from the Sphinx v4.5.0, my example code is shown as below.

1 def Sum(iN):
2 
    if (iN == 0):
3 
        return(0)
4 
    else:
5 
        return(iN + Sum(iN - 1))
6 
7 iMax = 10
8 for i in range(1, iMax):
9     print(i, ':', Sum(i))

Basically, I remove the :lineno: parameter, the accident line-break condition is disappear. Anyway, it might be come with line-number feature. Is there anyone has any solution to solve this problem?

Note that I used the following required modules in my environment.

sphinx==4.5.0
graphviz==0.19.1
sphinxcontrib-plantuml==0.23
sphinxcontrib-blockdiag==2.0.0
sphinxcontrib-actdiag==2.0.0
sphinxcontrib-nwdiag==2.0.0
sphinxcontrib-seqdiag==2.0.0
sphinxbootstrap4theme>=0.6.0
sphinxcontrib.bibtex==2.4.2
sphinxcontrib.httpdomain==1.8.0
sphinx-autorun==1.1.1
sphinx-copybutton==0.5.0
hieroglyph==2.1.0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黎夕旧梦 2025-02-03 09:46:01

我看到了同样的问题。 this github问题说该错误是由<代码的v2.3.1引起的。 > Pygments 软件包,并在Pygments的v2.11.2中修复。

I was seeing the same issue. This github issue says the bug was caused by v2.3.1 of the pygments package and is fixed in v2.11.2 of pygments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文