fix: plugin imports

This commit is contained in:
amhsirak
2025-11-20 04:10:12 +05:30
parent b14d84d83a
commit 839f9fa5ce

View File

@@ -1,27 +1,22 @@
import TurndownService from "turndown";
import { gfm } from "joplin-turndown-plugin-gfm";
export async function parseMarkdown(
html: string | null | undefined,
): Promise<string> {
if (!html) return "";
const TurndownService = require("turndown");
const { gfm } = require("joplin-turndown-plugin-gfm");
const t = new TurndownService();
// Custom rule for inline links
t.addRule("inlineLink", {
filter: (node: any, opts: any) =>
opts.linkStyle === "inlined" &&
node.nodeName === "A" &&
node.getAttribute("href"),
replacement: (content: string, node: any) => {
const href = node.getAttribute("href")?.trim() || "";
const href = node.getAttribute("href").trim();
const title = node.title ? ` "${node.title}"` : "";
return `[${content.trim()}](${href}${title})\n`;
},
});
// GitHub-flavored markdown features
t.use(gfm);
try {
@@ -52,7 +47,6 @@ function fixBrokenLinks(md: string): string {
result += ch;
}
}
return result;
}
@@ -60,3 +54,4 @@ function stripSkipLinks(md: string): string {
return md.replace(/\[Skip to Content\]\(#[^\)]*\)/gi, "");
}