Skip to content

Callout is being displayed twice after pageToMarkdown and toMarkdownString #118

Open
@Mikescops

Description

@Mikescops

My Notion page contains a Callout block, and when doing:

const mdblocks = await n2m.pageToMarkdown(id);
const mdString = n2m.toMarkdownString(mdblocks);

The blockquote is rendered twice because pageToMarkdown takes the child block and already make them as markdown in the parent when building MD blocks. This operation is done another time when toMarkdownString parses the blocks again.

Example of mdblocks:

 {
    "type": "callout",
    "blockId": "143eac7c-3bb3-801c-9f7e-e533b0665635",
    "parent": "> 📝 ### **A Simplified Analogy**  \n>   \n> Think of confidential computing as an ultra-secure vault:  \n>   \n> 1. **The Vault (Trusted Execution Environment or TEE):** This is a locked room where only specific operations can take place, shielded from everything outside. Even if a hacker (or a curious system admin) tried to gain entry to the vault, they’d see only encrypted gibberish.  \n>   \n> 2. **The Key (Encryption):** Only you—and those you trust—can unlock what’s inside. Even the company hosting the vault doesn’t have a spare key.",
    "children": [
      {
        "type": "heading_3",
        "blockId": "143eac7c-3bb3-8031-9fc2-ceb8475d347b",
        "parent": "### **A Simplified Analogy**",
        "children": []
      },
      {
        "type": "paragraph",
        "blockId": "143eac7c-3bb3-80cd-9f39-e031f41b5786",
        "parent": "Think of confidential computing as an ultra-secure vault:",
        "children": []
      },
      {
        "type": "numbered_list_item",
        "blockId": "143eac7c-3bb3-8050-901b-d988226c5beb",
        "parent": "1. **The Vault (Trusted Execution Environment or TEE):** This is a locked room where only specific operations can take place, shielded from everything outside. Even if a hacker (or a curious system admin) tried to gain entry to the vault, they’d see only encrypted gibberish.",
        "children": []
      },
      {
        "type": "numbered_list_item",
        "blockId": "143eac7c-3bb3-8007-9f42-e41c95fe37e9",
        "parent": "2. **The Key (Encryption):** Only you—and those you trust—can unlock what’s inside. Even the company hosting the vault doesn’t have a spare key.",
        "children": []
      }
    ]
  },

This can be easily solved by adding conditions in notion-to-md.ts file, I'll open a PR and let you look if it's the best solution.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv4-candidateThis issue / PR can be better handled in v4

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions