souvikinator / notion-to-md

Convert notion pages, block and list of blocks to markdown (supports nesting and custom parsing)
https://www.npmjs.com/package/notion-to-md
MIT License
1.08k stars 89 forks source link

'undefined' in the last line of table markdown string #86

Closed feilvan closed 1 year ago

feilvan commented 1 year ago

Hello, I got this extra line when I'm trying to convert a table to md string

'\n' +
'| Table | Name |\n' +
'| ----- | ---- |\n' +
'| 1     | Aa   |\n' +
'| 2     | Bb   |\n' +
'\n' +
'undefined'

The block in Notion looks like this

image

Here's the md block (if needed)

{
  type: 'table',
  blockId: 'a50e6d08-ffee-428b-b0bd-fc464bb67e88',
  parent: '| Table | Name |\n| ----- | ---- |\n| 1     | Aa   |\n| 2     | Bb   |',
  children: [
    {
      type: 'table_row',
      blockId: 'bcce0040-dfb3-4328-af92-fae1eedcf393',
      parent: '',
      children: []
    },
    {
      type: 'table_row',
      blockId: '4e2cfa23-b872-4a88-8bd7-383e63c7879b',
      parent: '',
      children: []
    },
    {
      type: 'table_row',
      blockId: 'af86e7dd-77a4-4fa1-8123-dce55f1d164f',
      parent: '',
      children: []
    }
  ]
}
souvikinator commented 1 year ago

Seems like a bug. I'll fix it ASAP.

souvikinator commented 1 year ago

This is fixed now. Should be live in the coming update. Thank you for the contribution and using the library.

feilvan commented 1 year ago

awesome! thanks for your hard work. this library is perfect for my need.

souvikinator commented 1 year ago

Glad to hear that! Thank you :)) The fix is now live in v3.0.1 Closing the issue, feel free to reopen if the issue still persists.

ge9 commented 1 year ago

This happened again in 3.1.0. I think we may need some code for case "table_row" near https://github.com/souvikinator/notion-to-md/blob/ffc51450e17f8ebe9f66fdba5babcbc125e925d1/src/notion-to-md.ts#L391.

souvikinator commented 1 year ago

I'm on it. I'll fix it and release a patch.