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

blocksToMarkdown() drops sublist items in a column #96

Closed andrew-polk closed 1 year ago

andrew-polk commented 1 year ago

Steps:

The column_list block will look like

{
  "object": "block",
  "id": "5fcf1c58-3ddf-495c-a2c4-22376bcab1fd",
...
  "has_children": true,
  "archived": false,
  "type": "column_list",
  "column_list": {}
}

but the result of blocksToMarkdown() is

{ type: 'column_list', parent: '1. Column One\n\n', children: [] }

and subsequently, toMarkdownString() gives

1. Column One

The sublist item is missing completely.



Further detail showing that the blocks are correct coming from the Notion API: column:

{
      "object": "block",
      "id": "e6d2d7b7-b1ed-464a-86d2-bb5f6be78a03",
      "parent": {
        "type": "block_id",
        "block_id": "5fcf1c58-3ddf-495c-a2c4-22376bcab1fd"
      },
...
      "has_children": true,
      "archived": false,
      "type": "column",
      "column": {}
    }

numbered_list_item:

{
      "object": "block",
      "id": "ef7a9a98-0a6a-4df0-a790-aec9ab29d55a",
      "parent": {
        "type": "block_id",
        "block_id": "e6d2d7b7-b1ed-464a-86d2-bb5f6be78a03"
      },
...
      "has_children": true,
      "archived": false,
      "type": "numbered_list_item",
      "numbered_list_item": {
        "rich_text": [
          {
            "type": "text",
            "text": { "content": "Column One", "link": null },
            "annotations": {
              "bold": false,
              "italic": false,
              "strikethrough": false,
              "underline": false,
              "code": false,
              "color": "default"
            },
            "plain_text": "Column One",
            "href": null
          }
        ],
        "color": "default"
      }
    }

bulleted_list_item:

{
      "object": "block",
      "id": "c0fe4b1b-4803-43b1-8454-8ecff8babe9d",
      "parent": {
        "type": "block_id",
        "block_id": "ef7a9a98-0a6a-4df0-a790-aec9ab29d55a"
      },
...
      "has_children": false,
      "archived": false,
      "type": "bulleted_list_item",
      "bulleted_list_item": {
        "rich_text": [
          {
            "type": "text",
            "text": { "content": "missing bullet", "link": null },
            "annotations": {
              "bold": false,
              "italic": false,
              "strikethrough": false,
              "underline": false,
              "code": false,
              "color": "default"
            },
            "plain_text": "missing bullet",
            "href": null
          }
        ],
        "color": "default"
      }
    }
andrew-polk commented 1 year ago

This may be fixed in 3.1.1. (I was on 2.5.5.) Investigating.

andrew-polk commented 1 year ago

Yes, this does seem to work in 3.1.1 so long as you don't have custom transformers (see #98).