简体   繁体   English

如何删除表 header 中的空行和 sphinx_rtd_theme 中的多行单元格?

[英]How can I remove empty line in table header and multi-line cell in sphinx_rtd_theme?

I am trying to make an HTML document in sphinx_rtd_theme.我正在尝试在 sphinx_rtd_theme 中制作 HTML 文档。 I want to make a table containing a multi-line cell, so I added a code like我想制作一个包含多行单元格的表格,所以我添加了一个类似的代码

+----------+----------+----------+
| header 1 | header 2 | header 3 |
+==========+==========+==========+
| a        | | b1     | c        |
|          | | b2     |          |
+----------+----------+----------+

As a result, I get an HTML file that looks like the following image:结果,我得到了一个 HTML 文件,如下图所示:

在此处输入图像描述

There are blank lines in the header row and the second row. header 行和第二行有空行。 They make the table ugly so I want to remove those empty lines.它们使表格变得难看,所以我想删除那些空行。 Is there anything I can do this?有什么我能做到的吗? Thank you for reading my question.感谢您阅读我的问题。

I solved the problem by adding我通过添加解决了这个问题

html_static_path = ['_static']
def setup(app):
    app.add_stylesheet('custom.css')

in the "conf.py", and在“conf.py”中,和

/* Table appearance */
.wy-table-responsive table td, .wy-table-responsive table th {
    /* !important prevents the common CSS stylesheets from
       overriding this as on RTD they are loaded after this stylesheet */
    white-space: normal !important;
}

.wy-table-responsive {
    overflow: visible !important;
}

in the "_static/custom.css", where I think the above code is copied from https://samnicholls.net/2016/06/15/how-to-sphinx-readthedocs/ .在“_static/custom.css”中,我认为上面的代码是从https://samnicholls.net/2016/06/15/how-to-sphinx-readthedocs/复制的。

In a way, there was already an answer to my question, but it took some time to realize that due to the lack of my knowledge on html, sphinx, and so on.在某种程度上,我的问题已经有了答案,但由于我对 html、sphinx 等缺乏了解,我花了一些时间才意识到这一点。

Anyway, thanks to Steve Piercy for help in the comment.无论如何,感谢史蒂夫皮尔西在评论中的帮助。

Penny for your thoughts, have you considered using list-table directive?一分钱你的想法,你有没有考虑使用列表表指令? It's my favorite and much simpler than grid tables where I have to literally paint the table myself这是我最喜欢的,而且比我必须自己绘制表格的网格表简单得多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM