How to allow line breaks within a Markdown table


We plan to replace our current markdown based editor with a prosemirror implementation. I’ve extended the markdown example with some markdown-it plugins and everything worked fine so far.

One problem I’am currently struggling with is allowing breaks and other markup within tables cells, since new lines are not allowed within markdown tables. Most Markdown editors allow <br> tags within tables in order to add new lines. Now I need a way for switching form new lines to <br> tags while serializing the content of a table cell to markdown and also allow <br> tags in the MarkdownParser. I think the parsing should not be a problem but rather the serialization.

Here is my current serialization logic for a table cell, which currently only extracts the textContent, otherwise the table will be destroyed by new lines.

Perhaps anyone of you solved this issue before or has an idea how to solve it.

Also, thanks for this amazing project!

1 Like

Since there is unfortunately no standard Markdown table syntax, and the various implementations differ a lot (and are, in my experience, all pretty bad and poorly specified) I’m not sure what kind of Markdown table you mean.

If your syntax doesn’t allow newlines in tables, then you might want to just normalize them to spaces in your serializer. I don’t think you need to strip other markup for that.

I’am using GFM tables, which are supported by markdown-it by default. You are right it probably would be sufficient to just replace new lines with spaces within tables, at least in a first version.

Thanks for the suggestion.