Fixes for blank last cell in table #120
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original code uses a split on \n to divide the block into rows and a split on pipe to divide each row into cells.
Markdown however optionally allows leading and trailing pipes on each row so these have to be removed before the split otherwise spurious cells will be created. Similarly if there is a \n at the end of the block this also has to be removed to prevent a spurious row being generated.
Unfortunately the original code for removing the final \n also removes the final pipe. This does not matter if the final cell is not blank but if it is then another pipe will be removed when the row is processed leading to the final cell of the table not being generated. This fix changes the regex so that only the final \n is removed.