col width attribute changes the rendered width of the table
bug
<!--
Thank you for reporting an issue!
Before you continue, please make sure that you have
- reproduced your issue with the latest release of pandoc
(https://github.com/jgm/pandoc/releases), or online (https://pandoc.org/try).
- searched the issue tracker (https://github.com/jgm/pandoc/issues)
for similar issues (including closed issues).
- searched the discussion forum
(https://github.com/jgm/pandoc/discussions) for solutions.
If you are experiencing a regression (an unwanted change of
behavior from an earlier version of pandoc), please indicate
this and give relevant version numbers. Be sure to check the
release notes (https://pandoc.org/releases) for relevant
changes, as you might find a solution there.
Note that this bug tracker is for reporting bugs, not asking
questions. For questions, use the discussion forum:
https://github.com/jgm/pandoc/discussions.
-->
**Explain the problem.**
Save the following to `pandoc-repro.html`:
```html
<table>
<colgroup>
<col width="1%"/>
<col />
</colgroup>
<tbody>
<tr>
<td>
<p>A</p><p>B</p>
</td>
<td>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
</td>
</tr>
</tbody>
</table>
```
Now render as plain text:
```console
> pandoc pandoc-repro.html --to=plain
+---+---------------+
| A | Lorem ipsum |
| | dolor sit |
| B | amet, |
| | consectetur |
| | adipiscing |
| | elit, sed do |
| | eiusmod |
| | tempor |
| | incididunt ut |
| | labore et |
| | dolore magna |
| | aliqua. Ut |
| | enim ad minim |
| | veniam, quis |
| | nostrud |
| | exercitation |
| | ullamco |
| | laboris nisi |
| | ut aliquip ex |
| | ea commodo |
| | consequat. |
| | Duis aute |
| | irure dolor |
| | in |
| | reprehenderit |
| | in voluptate |
| | velit esse |
| | cillum dolore |
| | eu fugiat |
| | nulla |
| | pariatur. |
| | Excepteur |
| | sint occaecat |
| | cupidatat non |
| | proident, |
| | sunt in culpa |
| | qui officia |
| | deserunt |
| | mollit anim |
| | id est |
| | laborum. |
+---+---------------+
```
Even though the width is only applied to the first column, both columns are squished.
For comparison, if you remove `width="1%"`, the table renders normally:
```console
> pandoc pandoc-repro.html --to=plain
+---+------------------------------------------------------------------+
| A | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do |
| | eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut |
| B | enim ad minim veniam, quis nostrud exercitation ullamco laboris |
| | nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor |
| | in reprehenderit in voluptate velit esse cillum dolore eu fugiat |
| | nulla pariatur. Excepteur sint occaecat cupidatat non proident, |
| | sunt in culpa qui officia deserunt mollit anim id est laborum. |
+---+------------------------------------------------------------------+
```
**Pandoc version?**
pandoc 3.9.0.2, on x86-64 Linux (binary from the GitHub release).
2 条评论