我有一个reStructuredText表,像这样的行:
+------+-----------------------------+
| Mask | The bit mask: |
| | [bit 0] Description of bit0 |
| | [bit 1] And bit1 |
+------+-----------------------------+
Sphinx(例如HTML)生成的单元格是这样的:
<td><p>The bit mask:
[bit 0] Description of bit0
[bit 1] And bit1</p></td>
我想产生的是这种(或类似的)结果,其中至少在每条新行之前都强制换行:
<td><p>The bit mask:
<br>[bit 0] Description of bit0
<br>[bit 1] And bit1</p></td>
有没有一种方法可以配置Sphinx以尊重reStructuredText表单元格中的行?
(供参考,这是当前生成的整个表格:)
<table class="docutils align-default">
<colgroup>
<col style="width: 17%" />
<col style="width: 83%" />
</colgroup>
<tbody>
<tr class="row-odd">
<td>
<p>Mask</p>
</td>
<td>
<p>The bit mask:
[bit 0] Description of bit0
[bit 1] And bit1
</p>
</td>
</tr>
</tbody>
</table>
通常,有两种简单的方法可以确保reST中的换行或对齐。
1.使用段落,以下内容:
+------+-----------------------------+
| Mask | The bit mask: |
| | |
| | [bit 0] Description of bit0 |
| | |
| | [bit 1] And bit1 |
| | |
+------+-----------------------------+
会给:
<table class="docutils align-default">
<tbody>
<tr class="row-odd">
<td>
<p>Mask</p>
</td>
<td>
<p>The bit mask:</p>
<p>[bit 0] Description of bit0</p>
<p>[bit 1] And bit1</p>
</td>
</tr>
</tbody>
</table>
2.使用线块,以下内容:
+------+-------------------------------+
| Mask | | The bit mask: |
| | | [bit 0] Description of bit0 |
| | | [bit 1] And bit1 |
+------+-------------------------------+
会给:
</table>
<tbody>
<tr class="row-odd">
<td>
<p>Mask</p>
</td>
<td>
<div class="line-block">
<div class="line">The bit mask:</div>
<div class="line">[bit 0] Description of bit0</div>
<div class="line">[bit 1] And bit1</div>
</div>
</td>
</tr>
</tbody>
</table>
结果<div class="line"></div>
将像段落一样工作,并保持对齐。这是通过reST规范来保证的,因此,即使您的输出不是HTML,也应该有适当的机制来保证结果一致。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句