我有一个reST格式的表,其中一些单元格包含长的文本块(即多个段落或项目符号列表),并且定期更新,例如:
+-------+-----------------------+
|Cat | Chunk that is updated |
| | periodically. |
| | |
| | Line #2, #3, etc |
+-------+-----------------------+
|Dog | Substitution means |
| | table boilplat static |
| | |
| | Line #2, #3, etc |
+-------+-----------------------+为了避免每次更新都维护表样板,我首先尝试了替换,但这只适用于内联指令(如图像)和单行文本.不是多段:
.. |cellb1| replace:: Chunk that is updated periodically via copy-and-paste
.. |cellb3| replace:: Substitution means table boilerplate can remain static
+-------+-----------------------+
|Cat | |cellb1| |
+-------+-----------------------+
|Dog | |cellb3| |
+-------+-----------------------+第二种方法是。。包括:指令。这对于多个段落来说很好,但代价是复杂性(内容现在在多个外部文本文件中被错位)。
+-------+-----------------------+
|Cat | .. include:: xr1.txt |
+-------+-----------------------+
|Dog | .. include:: xr3.txt |
+-------+-----------------------+表表没有帮助,csv-表也没有帮助(因为内容包括逗号和引号)。
.. csv-table:: Test csv-table with multi-paragraph
:header: "a", "b", "c"
Cat,"Chunk that is updated periodically via copy-and-paste.
Line #2, #3, etc", "Kitten"
Dog,"Substitution means table boilerplate can remain static.
Line #2, #3, etc", "Puppy"注意:csv-table__会出现一个附带问题,缩进和列数会影响狮身人面像解析器,因此内容被格式化为块引用或定义列表。编辑:见下面的答案-由于:header:行的缩进不一致
有更好的办法吗?
发布于 2019-02-19 05:43:18
下面的示例适用于我。请注意,空格是非常棘手的。在缩进任何内容时,我总是使用4个空格,包括:header:等选项,因为这样可以更容易地检测问题,并确保狮身人面像正确地解释空格。在您的示例中,您所需要做的就是在:header:之前再添加一个空间,总共4个空格,以使所有内容对齐。我还添加了一个枚举列表的示例。
.. csv-table:: Test csv-table with multi-paragraph
:header: "a", "b", "c"
Cat,"Chunk that is updated periodically via copy-and-paste.
Line #2, #3, etc", "Kitten"
Dog,"Substitution means table boilerplate can remain static.
Line #2, #3, etc", "Puppy"
Walrus,"#. List Item 1
#. List Item 2
#. List Item 3", "Pup"https://stackoverflow.com/questions/54740265
复制相似问题