BlockNote
BlockNote copied to clipboard
Parsing markdown table is wrong
Describe the bug Parsing the markdown table adds an extra row. Thus, if you store the date in markdown, it will add an empty row every time you save.
To Reproduce
I use https://www.blocknotejs.org/examples/interoperability/converting-blocks-to-md or https://www.blocknotejs.org/examples/interoperability/converting-blocks-from-md
Misc
- Node version: 18.20
- Package manager: RubyGems
- Browser: Chrome
- [ ] I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Is there a md spec that specifies that the empty header should not be parsed? To me it seems correct that it gets parsed to an empty row tbh
Even im facing same issue every time i parse to md an additional row is getting added at the beginning of the table. am i missing something ?
const markdown: string | undefined = await editor.blocksToMarkdownLossy(editor.document);
I'm not sure there's a good way around this tbh - Markdown tables are fundamentally different from BlockNote/HTML tables as they require defining a header. Since these are all data cells there is no 1:1 mapping of the BlockNote representation vs the Markdown one, there is always going to be some misinterpretation.
This is definitely a bug, IMO, since we can't really use the table element when using Markdown for storage. Every time you save, the table grows by one empty row. I may write a regex to remove it but that's a bit of a risky hack.
The problem occurs during the conversion from blocks to Markdown (blocksToMarkdownLossy) - not the other direction.
Ideally Blocknote would adhere to the Markdown standard of requiring a table header. But if this parsing issue was fixed, that would be fine, too.
Thank you for the superb OSS!