Skip to content

Commit

Permalink
fix: synced blocks custom transformer produces double output #62
Browse files Browse the repository at this point in the history
  • Loading branch information
souvikinator committed May 16, 2023
1 parent a7502a9 commit 9d74e27
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/notion-to-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class NotionToMarkdown {
if (!blocks) return mdBlocks;

for (let i = 0; i < blocks.length; i++) {
let block = blocks[i];
let block: ListBlockChildrenResponseResult = blocks[i];

if ("has_children" in block && block.has_children) {
// Get children of this block.
Expand All @@ -206,12 +206,19 @@ export class NotionToMarkdown {
});

// Recursively call blocksToMarkdown to get children of this block.
let l = mdBlocks.length;
await this.blocksToMarkdown(
child_blocks,
totalPage,
mdBlocks[l - 1].children
);
// check for custom transformer before parsing child
if (
!(block.type in this.customTransformers) &&
!this.customTransformers[block.type]
) {
let l = mdBlocks.length;
await this.blocksToMarkdown(
child_blocks,
totalPage,
mdBlocks[l - 1].children
);
}

continue;
}

Expand Down

0 comments on commit 9d74e27

Please sign in to comment.