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?
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.
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.
The default markdown-ittable 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.
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.