如何移除或修改Sphinx/ReportLab/RST文档末尾注释分隔线?
RST/Sphinx/ReportLab注释分隔线处理方案
一、移除分隔线
- 若为手动添加的RST
transition(即一行连续的---/***等过渡字符):直接删除该行即可,无需保留<hr />标签。 - 若为Sphinx主题自动给注释区块(如
.. note::、.. warning::)添加的分隔线:- 在Sphinx项目的
_static目录创建自定义CSS文件(如custom.css) - 在CSS中覆盖对应注释区块的边框样式:
.admonition, .note, .warning { border-top: none; border-bottom: none; } - 在
conf.py中配置加载自定义CSS:html_css_files = ['custom.css']
- 在Sphinx项目的
- 若为ReportLab导出PDF时的分隔线:修改注释对应的样式模板,移除边框属性:
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet custom_note_style = ParagraphStyle( 'CustomNote', parent=getSampleStyleSheet()['Note'], borderWidth=0, borderColor=None )
二、修改分隔线颜色
- 针对RST
transition或Sphinx主题注释分隔线:在自定义CSS中调整边框颜色:/* 修改transition分隔线颜色 */ .docutils.transition { border-color: #66ccff; } /* 修改注释区块分隔线颜色 */ .note { border-top-color: #ff6600; border-bottom-color: #ff6600; } - 针对ReportLab PDF导出:在样式模板中设置边框颜色:
custom_note_style = ParagraphStyle( 'CustomNote', parent=getSampleStyleSheet()['Note'], borderColor='#ff6600' )
内容的提问来源于stack exchange,提问作者Viking Sharp Ax
相关产品推荐
相关产品推荐

