Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle tables? #84

Closed
segevfiner opened this issue Sep 21, 2022 · 10 comments
Closed

How to handle tables? #84

segevfiner opened this issue Sep 21, 2022 · 10 comments

Comments

@segevfiner
Copy link
Contributor

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
Copy link
Member

marijnh commented Sep 21, 2022

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

@segevfiner
Copy link
Contributor Author

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
Copy link
Member

marijnh commented Sep 22, 2022

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

@segevfiner
Copy link
Contributor Author

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

@marijnh
Copy link
Member

marijnh commented Sep 22, 2022

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

@segevfiner
Copy link
Contributor Author

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

@marijnh
Copy link
Member

marijnh commented Sep 22, 2022

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
Copy link
Contributor Author

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
Copy link
Member

marijnh commented Sep 22, 2022

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

@segevfiner
Copy link
Contributor Author

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.

@marijnh marijnh closed this as completed Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants