Issue
If I have a rst like this:
+--------------------------------+
| Table H1 |
+-------------+------------------+
| Table H2a | Table H2b |
+=============+==================+
| a1 | b1 |
+-------------+------------------+
| a2 | b2 |
+-------------+------------------+
| a3 | b3 |
+-------------+------------------+
And convert it to html like this:
python -u %PYTHONPATH3%\\Scripts\\rst2html5.py input.rst output.html
The generated html table looks like this:
<body>
<div class="document"><blockquote><table>
<colgroup>
<col style="width: 42%" />
<col style="width: 58%" />
</colgroup>
<thead>
<tr><th class="head" colspan="2"><p>Table H1</p></th>
</tr>
<tr><th class="head"><p>Table H2a</p></th>
<th class="head"><p>Table H2b</p></th>
</tr>
</thead>
<tbody>
<tr><td><p>a1</p></td>
<td><p>b1</p></td>
</tr>
<tr><td><p>a2</p></td>
<td><p>b2</p></td>
</tr>
<tr><td><p>a3</p></td>
<td><p>b3</p></td>
</tr>
</tbody>
</table></blockquote></div>
</body>
The cell contents, as you can see, are placed inside paragraph tags (inside <p></p>), thus being formatted as a paragraph and not like my table is configured in a css file (eg. if I add a first-line indent to text paragraphs in the css, the cell contents also receive that indentation)
Is there a way to generate html tables without paragraphs inside the cells (using docutils rst2html)?
Notes:
- I'm actually converting a really long rst file, so making it work properly instead of hacking/replacing the html should be preferred.
- The same thing happens with my list items, the are created inside
<p>tags (eg.<li><p>Something</p></li>).
Solution
You could use custom CSS to override the visual spacing from the <p> tags. Something like this.
td > p, li > p {
margin: 0;
}
I think it is strange, however, that your output generates <p> tags in tables, as that is not what docutils does, assuming that is what rst2html5 is based upon. I would suggest you contact the author of that library.
Edit: Here's my HTML output using Sphinx and your reST sample:
<table border="1" class="docutils">
<colgroup>
<col width="42%">
<col width="58%">
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head" colspan="2">Table H1</th>
</tr>
<tr class="row-even"><th class="head">Table H2a</th>
<th class="head">Table H2b</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-odd"><td>a1</td>
<td>b1</td>
</tr>
<tr class="row-even"><td>a2</td>
<td>b2</td>
</tr>
<tr class="row-odd"><td>a3</td>
<td>b3</td>
</tr>
</tbody>
</table>
Answered By - Steve Piercy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.