如何使用sphinx v4.5.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到了同样的问题。 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 ofpygments
.