在Python3-Sphinx中显示带有网格的数据

发布于 2025-01-27 00:57:44 字数 1990 浏览 1 评论 0原文

我构建了Python3-Sphinx来存储并显示一些材料。

vim  show_table.rst
show table
=================

| #   | Expression      | Result      | Comments                                   |
| --- | --------------- | ----------- | -------------------------------------------|
| 1   | `"$a"`          | `apple`     | variables are expanded inside `""`         |
| 2   | `'$a'`          | `$a`        | variables are not expanded inside `''`     |

这是由Markdown定义的标准网格表,而不是CrunductureText。
WQ并进行:

make html

打开show_table.html在浏览器中:

这不是我想要的格式,而是标准的HTML表格式。副本并粘贴到我的新show_table.rst

vim show_table.rst
    show table
=================
.. raw:: html

    <table border=”1” class=”docutils”> <thead> <tr> <th>#</th> <th>Expression</th> <th>Result</th> <th>Comments</th> </tr> </thead>
    <tbody> <tr> <td>1</td> <td><code>”$a”</code></td> <td><code>apple</code></td> <td>variables are expanded inside <code>””</code>
    </td> </tr> <tr> <td>2</td> <td><code>’$a’</code></td> <td><code>$a</code></td> <td>variables are not expanded inside <code>’’</code>
    </td> </tr> </tbody> </table>

make html < /code>,打开show_table.html在浏览器中再次获得。

将类似网格的表转换为sphinx中的标准网格表是一项琐碎的工作(我不喜欢的另一种方式)。也许可以在rst文件中添加一些东西可以实现我的目标。

I build python3-sphinx to store and show some material.

vim  show_table.rst
show table
=================

| #   | Expression      | Result      | Comments                                   |
| --- | --------------- | ----------- | -------------------------------------------|
| 1   | `"$a"`          | `apple`     | variables are expanded inside `""`         |
| 2   | `'$a'`          | `$a`        | variables are not expanded inside `''`     |

It is a standard grid table defined by markdown,instead of restructureText.
wq and make it :

make html

Open the show_table.html in browser:
enter image description here

It is not the format i want ,but it is in a standard html table format.Copy it and paste into my new show_table.rst,

vim show_table.rst
    show table
=================
.. raw:: html

    <table border=”1” class=”docutils”> <thead> <tr> <th>#</th> <th>Expression</th> <th>Result</th> <th>Comments</th> </tr> </thead>
    <tbody> <tr> <td>1</td> <td><code>”$a”</code></td> <td><code>apple</code></td> <td>variables are expanded inside <code>””</code>
    </td> </tr> <tr> <td>2</td> <td><code>’$a’</code></td> <td><code>$a</code></td> <td>variables are not expanded inside <code>’’</code>
    </td> </tr> </tbody> </table>

make html ,open show_table.html in browser again,i get it.
enter image description here

It is a trivial job to convert the grid-like table into standard grid table in sphinx(Another way i don't like).Maybe to add something in rst file can achieve my target.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文