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

Ordered list parsed as unordered list #108

Open
ddsuhaimi opened this issue May 19, 2024 · 0 comments
Open

Ordered list parsed as unordered list #108

ddsuhaimi opened this issue May 19, 2024 · 0 comments

Comments

@ddsuhaimi
Copy link

ddsuhaimi commented May 19, 2024

notion-md-version: 3.1.1

A notion block with type numbered_list_item got parse as unordered list. You can check out minimal working example here:

const { Client } = require('@notionhq/client');
const { NotionToMarkdown } = require('notion-to-md');

const blocks = [
  {
    object: 'block',
    id: 'xxxxxxxxx',
    parent: { type: 'page_id', page_id: 'pxxxxxxxxxx' },
    created_time: '2023-12-13T16:55:00.000Z',
    last_edited_time: '2023-12-15T07:32:00.000Z',
    created_by: { object: 'user', id: 'userxxxxxxx' },
    last_edited_by: {
      object: 'user',
      id: 'userxxxxxxx',
    },
    has_children: false,
    archived: false,
    in_trash: false,
    type: 'numbered_list_item',
    numbered_list_item: {
      rich_text: [
        {
          type: 'text',
          text: { content: 'Numbered Item 1', link: null },
          annotations: {
            bold: false,
            italic: false,
            strikethrough: false,
            underline: false,
            code: false,
            color: 'default',
          },
          plain_text: 'Numbered Item 1',
          href: null,
        },
      ],
      color: 'default',
    },
  },
  {
    object: 'block',
    id: 'xxxxxxxxx',
    parent: { type: 'page_id', page_id: 'pxxxxxxxxxx' },
    created_time: '2023-12-13T16:55:00.000Z',
    last_edited_time: '2023-12-15T07:32:00.000Z',
    created_by: { object: 'user', id: 'userxxxxxxx' },
    last_edited_by: {
      object: 'user',
      id: 'userxxxxxxx',
    },
    has_children: false,
    archived: false,
    in_trash: false,
    type: 'numbered_list_item',
    numbered_list_item: {
      rich_text: [
        {
          type: 'text',
          text: { content: 'Numbered Item 2', link: null },
          annotations: {
            bold: false,
            italic: false,
            strikethrough: false,
            underline: false,
            code: false,
            color: 'default',
          },
          plain_text: 'Numbered Item 2',
          href: null,
        },
      ],
      color: 'default',
    },
  },
];

const notion = new Client({
  auth: '',
});

const n2m = new NotionToMarkdown({ notionClient: notion });

async function run() {
  const mdblocks = await n2m.blocksToMarkdown(blocks);
  const mdstring = n2m.toMarkdownString(mdblocks);
  console.log(mdstring.parent);
}

run();

Result:

- Numbered Item 1
- Numbered Item 2

Expected:

1. Numbered Item 1
2. Numbered Item 2

EDIT: apparently it works if we get the blocks from n2m.pageToMarkdown("target_page_id") instead of using blocks response from notion API. So might not be an issue :)

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

1 participant