Support multiple lines in table cells #11
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.
Plain Markdown syntax doesn't support more than one line in a table cell, but Google Docs lets you have many paragraphs or lines in each cell. This update supports multiple lines by adding a custom handler for table cell nodes which outputs MDast
html
nodes representing<br>
tags to use in the table.It converts paragraphs to inline text separated by
<br>
tags rather than actual<p>
tags so as to keep the amount of inserted HTML fairly light. I think this is probably the right thing, but we’ll see if anyone has issues with it!This is probably not the nicest implementation, but it works reasonably well with a few test cases. @wooorm’s latest comment (#10 (comment)) suggests the right spot for this kind of logic is in the rehype → mdast conversion rather than in stringification, so that’s what I’ve done here. If
hast-util-to-mdast
gets more complicated and handles content in table cells differently in the future, this part may have to change, but I think that’s probably OK.Fixes #10.