Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RST writer generate invalid output for empty table rows #3516

Closed
pyhedgehog opened this issue Mar 20, 2017 · 1 comment
Closed

RST writer generate invalid output for empty table rows #3516

pyhedgehog opened this issue Mar 20, 2017 · 1 comment

Comments

@pyhedgehog
Copy link

Scenario

Let's start with some correct RST:

+---+---+
| 1 | 2 |
+---+---+
|   |   |
+---+---+

Then we can do:

# pandoc -r rst -w html -o pandoc_bug.html pandoc_bug.rst
# pandoc -r html -w rst -o pandoc_bug-o.rst pandoc_bug.html

html output is correct:

<table style="width:11%;">
<colgroup>
<col style="width: 5%" />
<col style="width: 5%" />
</colgroup>
<tbody>
<tr class="odd">
<td>1</td>
<td>2</td>
</tr>
<tr class="even">
<td></td>
<td></td>
</tr>
</tbody>
</table>

But back to RST creates invalid file:

+--------------------------------------+--------------------------------------+
| 1                                    | 2                                    |
+--------------------------------------+--------------------------------------+
+--------------------------------------+--------------------------------------+

Same will happens if we use some other intermediate format supporting tables:

# pandoc -r rst -w odt -o pandoc_bug.odt pandoc_bug.rst
# pandoc -r odt -w rst -o pandoc_bug-o.rst pandoc_bug.odt

Environment

OS: Windows 10 x64
PanDoc: 1.19.2.1

C:\>clist -lo pandoc
Chocolatey v0.10.3
pandoc 1.19.2.1
1 packages installed.
C:\>pandoc -v
pandoc.EXE 2.0
Compiled with pandoc-types 1.17.0.4, texmath 0.9, skylighting 0.1.1.4
Default user data directory: C:\Users\username\AppData\Roaming\pandoc
Copyright (C) 2006-2016 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
@jgm
Copy link
Owner

jgm commented Mar 21, 2017

The markdown writer/reader gets this right:

% pandoc -f markdown -t markdown
+---+---+
| 1 | 2 |
+---+---+
|   |   |
+---+---+
^D
+---+---+
| 1 | 2 |
+---+---+
|   |   |
+---+---+

but I can confirm that (even in the dev version) the rst reader does not. Simple test case:

% pandoc -t rst -f rst
+---+---+
| 1 | 2 |
+---+---+
|   |   |
+---+---+
^D
+------+------+
| 1    | 2    |
+------+------+
+------+------+

Note that there are two problems: the missing "sides" of the bottom table row and the widening of the cells.

Note that the markdown and rst readers both parse this as

[Table [] [AlignDefault,AlignDefault] [5.555555555555555e-2,5.555555555555555e-2]
 [[]
 ,[]]
 [[[Plain [Str "1"]]
  ,[Plain [Str "2"]]]
 ,[[]
  ,[]]]]

so the problems concern the RST writer.

@jgm jgm added this to the pandoc 2.0 milestone Mar 21, 2017
@jgm jgm closed this as completed in daf8d1d Mar 21, 2017
jgm added a commit that referenced this issue Mar 21, 2017
Uses the new gridTable in Writers.Shared, which is here
improved to better handle 0-width cells.

Closes #3516.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants