Skip to content

Commit 64c0d9e

Browse files
authored
Merge pull request #119 from Mikescops/bugfix/callout-displayed-twice
Fix: Callout displayed twice
2 parents 01233db + 9db8729 commit 64c0d9e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/notion-to-md.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ export class NotionToMarkdown {
157157
}
158158

159159
mdOutput[pageIdentifier] += "\n";
160-
} else {
160+
} else if (mdBlocks.type === "callout") {
161+
// do nothing the callout block is already processed
162+
}
163+
else {
161164
let mdstr = this.toMarkdownString(
162165
mdBlocks.children,
163166
pageIdentifier,

src/utils/md.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ export const callout = (text: string, icon?: CalloutIcon) => {
6969
}
7070

7171
// the replace is done to handle multiple lines
72-
return `> ${emoji ? emoji + " " : ""}${text.replace(/\n/g, " \n> ")}`;
72+
const formattedText = text.replace(/\n/g, " \n> ");
73+
const formattedEmoji = emoji ? emoji + " " : "";
74+
const headingMatch = text.match(/^(#{1,6})\s+(.*)/);
75+
if (headingMatch) {
76+
const headingLevel = headingMatch[1].length;
77+
const headingContent = headingMatch[2];
78+
return `> ${"#".repeat(headingLevel)} ${formattedEmoji}${headingContent}`;
79+
}
80+
return `> ${formattedEmoji}${formattedText}`;
7381
};
7482

7583
export const bullet = (text: string, count?: number) => {

0 commit comments

Comments
 (0)