Prosemirror-Markdown + Tables?

Hello,

I’m just getting started with Prosemirror Markdown (it’s awesome!) using the prosemirror-example-setup package, and I was wondering if/how it’s possible to add tables via the menu bar that can be serialized into markdown table syntax? Can the prosemirror-tables package be used with prosemirror-markdown?

Thank you

1 Like

This is probably not all that easy and might involve some pull requests to the tables package to allow turning off of features like column and row spans that, at a glance, it looks like markdown tables don’t support. You’ll also need to write the markdown serializer and deserializer for the table nodes. But in principle it should be possible.

Thank you, @marjin !

Is there a guide/examples on writing your own markdown serializer and deserializer instead of using the defaultMarkdownSerializer / defaultMarkdownParser from the prosemirror-markdown package?

The readme for the module has docs on this. You can see how the built-in serializer and deserializer is defined in the src/to_markdown.js and src/from_markdown.js files.

1 Like

Great - I’ll take a look at those. Thanks again!

@sudo Did you have any progress? I am starting to make a table serializer.

1 Like

The default markdown-it table plugin produces a format which is hard to map with prosemirror-table. We created https://github.com/torifat/markdown-it-table to solve this problem.

2 Likes

@jiewuza , not yet, so that’s exciting news

@rifat , looks cool, thanks - will def give that a try

Does anyone have a working example or sample repo with prosemirror-markdown and table working?

1 Like

Is there any solution for this? anyone had a chance of implementing this?

I have removed a rude question here

prosemirror-tables is mostly unmaintained but should still work since the core library API is stable. I expect that reading library docs will get you further than asking a language model, in most cases.

I’m sorry for being rude, I’m just looking for an example of how to write a custom parser that can handle tables. Sofar everything I’ve tried ends up with either an ’ Token type table_open not supported by Markdown parser’ error or the parser just silently failing. I would appreciate any help you could give.

Oh, you also want to parse Markdown tables into a ProseMirror doc? Yeah, that’s going to require custom work—loading the appropriate markdown-it plugin, figuring out its token structure, and configuring a MarkdownParser to use it.

here is a demo

The outline editor got pulled into the main repo. Its now under shared.