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

Crashes if first column header is empty but wider than 3 space #2

Open
iliatimofeev opened this issue Jul 12, 2018 · 5 comments
Open
Assignees

Comments

@iliatimofeev
Copy link

import CommonMarkExtensions.tables
CommonMarkExtensions.tables.commonmark("""
|          | Header 2 |
| -------- | -------- |
| Cells    | **can**  |
| `have`   | inlines. |
    """)
~/anaconda/anaconda/envs/alt_dev/lib/python3.6/site-packages/CommonMarkExtensions/tables.py in finalize(parser, block)
    137 
    138                 # Fill in empty rows if fewer than the header.
--> 139                 if len(table_parts) > 1 and len(table_parts[0][0]) > len(table_parts[-1][-1]):
    140                     table_parts[-1][-1].extend( ["" for _ in range(len(table_parts[0][0]) - len(table_parts[-1][-1])) ] )
    141 

IndexError: list index out of range
@gregelin gregelin changed the title Crushes if first column header is empty but wider than 3 space Crashes if first column header is empty but wider than 3 space Jul 13, 2018
@gregelin
Copy link

@iliatimofeev Do you want to try and correct and submit a pull request?

@iliatimofeev
Copy link
Author

In fact it is much more tricky than it seems. I'm not sure that CommParser is designed to be extended.

@gregelin
Copy link

@iliatimofeev We will take a look, too.

@JoshData
Copy link
Contributor

Yeah the underlying CommonMark library that this package is based on wasn't designed to be extended to add new CommonMark language elements like this.

Interestingly, it's not about the header being empty -- it's just about the first four spaces after the pipe. This also crashes with the same exception:

|    x     | Header 2 |
| -------- | -------- |
| Cells    | **can**  |
| `have`   | inlines. |

The input to Table.finalize is already wrong in this case, so the problem is either in Table.continue_ or this might just not be fixable.

We'll continue looking at it.

@hughdavenport
Copy link
Contributor

This is fixed in #7

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

4 participants