BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Parsing markdown table is wrong

Open littlefrontender opened this issue 1 year ago • 3 comments

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 Снимок экрана 2024-05-13 в 17 11 32 Снимок экрана 2024-05-13 в 17 12 43

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 💖

littlefrontender avatar May 13 '24 13:05 littlefrontender

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

YousefED avatar May 28 '24 12:05 YousefED

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);

ursnj avatar Aug 29 '24 01:08 ursnj

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.

matthewlipski avatar Aug 30 '24 16:08 matthewlipski

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!

jonathanmosney avatar Oct 19 '24 04:10 jonathanmosney