【问题标题】:How to place bulleted lists within simple tables in restructured text?如何在重组文本的简单表格中放置项目符号列表?
【发布时间】:2013-09-02 13:17:32
【问题描述】:

我试图在我的 reST 简单表中放置一个项目符号列表,但项目符号列表的每一行都有自己的行:

======================  =======================  =======================
|foo.png|               |bar.png|                |baz.png|
======================  =======================  =======================
* foo1 - Lorem ipsum    * bar                    * baz 
  dolor sit amet, 
  consectetur 
* foo2 - adipisicing 
  elit
======================  =======================  =======================

.. |foo.png| image:: assets/img/foo.png
.. |bar.png| image:: assets/img/bar.png
.. |baz.png| image:: assets/img/baz.png

结果是* foo1 - Lorem ipsumdolor sit amet,consectetur* foo2 - adipisicingelit 中的每一行都被放置到单独的表行中。

期望的结果是第一列中的项目符号列表包含在一个表格行项目中。有没有一种简单的方法可以得到我想要的结果?

如果做不到这一点,有没有办法将我的设计的 HTML 表格嵌入到 reST 文档中?

我尝试过的另一件事是替换:

======================  =======================  =======================
|foo.png|               |bar.png|                |baz.png|
======================  =======================  =======================
|foo_list|              |bar_list|               |baz_list|
======================  =======================  =======================

.. |foo.png| image:: assets/img/foo.png
.. |bar.png| image:: assets/img/bar.png
.. |baz.png| image:: assets/img/baz.png

.. |foo_list| replace::
   * foo1 - Lorem ipsum dolor sit amet, consectetur
   * foo2 - adipisicing elit
.. |bar_list| replace::
   * bar
.. |baz_list| replace::
   * baz

这根本不起作用,在|foo.png| 图像下方的第一个左上角单元格中显示文本|foo_list|

【问题讨论】:

    标签: python html-table python-sphinx restructuredtext


    【解决方案1】:

    试试list-table 指令:

    .. list-table:: Example table
       :header-rows: 1
    
       * - First header
         - Second header
         - Third header
       * - Some text
         - Some text
         - A list:
             * foo
             * bar
             * baz
       * - Second row
         - More cells
         - etc.
       * - ...
         - ...
         - ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-31
      • 2011-05-06
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多