ProseMirror / prosemirror-markdown

ProseMirror Markdown integration
https://prosemirror.net
MIT License
344 stars 81 forks source link

How to handle tables? #84

Closed segevfiner closed 2 years ago

segevfiner commented 2 years ago

markdown-it doesn't output a paragraph_{open,close} token around a table cell's contents which causes it to be dropped with just:

  table: { block: "table" },
  tr: { block: "tableRow" },
  th: { block: "tableHeader" },
  td: { block: "tableCell" },
  thead: { ignore: true },
  tbody: { ignore: true },

As there is only an inline inside the th and td but the schema I have specifies block+ for them, which means it should have a paragraph... Or is that invalid in Markdown and I should reconfigure the schema?

marijnh commented 2 years ago

Do you mean dropped when parsing with a markdown parser? Or something else?

segevfiner commented 2 years ago

Dropped by prosemirror due to having a schema with block+ for table headers, cells. I customized it so it is now inline+ so that it works, but I was wondering whether it's legal to have block stuff inside tables and if/how I should support it.

marijnh commented 2 years ago

Yes, that's legal, but I still don't understand which process is dropping these.

segevfiner commented 2 years ago

The prosemirror schema validation as far as I can tell. Because I'm trying to integrate prosemirror-markdown with an external prosemirror schema.

marijnh commented 2 years ago

How are you transforming stuff into a ProseMirror document where this happens?

segevfiner commented 2 years ago

Using MarkdownParser from this package, with a slightly modified config from the default, but otherwise very similar.

marijnh commented 2 years ago

I see. It looks like MarkdownParser doesn't really support this, but I'm also wondering how you can have multiple blocks in your markdown tables if the Markdown parser doesn't parse its content as such (omitting block tokens there suggests no block are being parsed)?

segevfiner commented 2 years ago

That's what I'm not sure about, if you can have blocks inside a Markdown table or not... Because the schema I tried to adapt MarkdownParser specifies them as containing blocks while the schema here as inlines.

marijnh commented 2 years ago

Are these GFM-style tables? I don't believe those support block markup in the cells.

segevfiner commented 2 years ago

Yeah GFM tables like in the default preset of markdown-it. If those don't support these, then my question is answered, and I just need to adjust the schema to accommodate as I did.