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

Panic when table has an empty heading cell #61

Open
rahji opened this issue Jul 25, 2024 · 2 comments
Open

Panic when table has an empty heading cell #61

rahji opened this issue Jul 25, 2024 · 2 comments

Comments

@rahji
Copy link

rahji commented Jul 25, 2024

A table like this:

|       | head2 | head3 |
| ----- | ----- | ----- |
| 1     | 2     | 3     |

causes a panic. As far as I know, it's legal markdown to have an empty heading cell, but not sure. I've never had a problem rendering it in any other way or converting it to PDF with pandoc, vscode extensions, etc.

@jessp01
Copy link
Collaborator

jessp01 commented Jul 25, 2024

Hi @rahji ,

Please see gomarkdown/markdown#207

I can suggest a workaround that will produce the desired result:

| \     | head2 | head3 |
| ----- | ----- | ----- |
| 1     | 2     | 3     |  

1.pdf

But the problem runs deeper since, with the current code, the width of a column is determined by the length of the string used as the header. This is a problem regardless of the empty header, for example, consider:

| head1 | head2                            | head3 |
|-----------|--------------------------------|-----------|
| 1111    | 222222277777772     | 3           | 

222222277777772 will be cut off; but it's an even bigger problem when the header is an empty string.

I didn't write the original implementation but I'll take a look into changing it so that the width of the column is determined based on the longest string value in any of the respective cells (rather than that of the header).

@rahji
Copy link
Author

rahji commented Jul 25, 2024

Thanks for the workaround. I think I was most concerned that it results in a panic with no real info about the cause. I kind of guessed my way into finding that this was the cause. 😬

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

No branches or pull requests

2 participants