修复了导入bug
This commit is contained in:
+1
-41
@@ -1,48 +1,9 @@
|
||||
import TurndownService from "turndown";
|
||||
import JSZip from "jszip";
|
||||
import { saveAs } from "file-saver";
|
||||
import { Page } from "./store";
|
||||
import { useSettingsStore } from "./settings-store";
|
||||
import { sanitizeFilename } from "./page-utils";
|
||||
|
||||
import { gfm } from "turndown-plugin-gfm";
|
||||
|
||||
// Initialize Turndown service
|
||||
const turndownService = new TurndownService({
|
||||
headingStyle: "atx",
|
||||
codeBlockStyle: "fenced",
|
||||
bulletListMarker: "-",
|
||||
});
|
||||
|
||||
// Use GFM plugin for tables
|
||||
turndownService.use(gfm);
|
||||
|
||||
// Configure Turndown to handle some common elements better if needed
|
||||
turndownService.addRule('strikethrough', {
|
||||
filter: ['del', 's'],
|
||||
replacement: function (content: string) {
|
||||
return '~~' + content + '~~';
|
||||
}
|
||||
});
|
||||
|
||||
// Task List Support (Simple)
|
||||
turndownService.addRule('taskListItems', {
|
||||
filter: function (node: HTMLElement) {
|
||||
return node.nodeName === 'LI' && node.className.includes('task-list-item');
|
||||
},
|
||||
replacement: function (content: string, node: HTMLElement) {
|
||||
const isChecked = node.getAttribute('data-checked') === 'true';
|
||||
return (isChecked ? '- [x] ' : '- [ ] ') + content.replace(/^- /, '') + '\n';
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts HTML content to Markdown
|
||||
*/
|
||||
export function htmlToMarkdown(html: string): string {
|
||||
if (!html) return "";
|
||||
return turndownService.turndown(html);
|
||||
}
|
||||
import { htmlToMarkdown } from "./markdown-codec";
|
||||
|
||||
// Helper to escape YAML strings
|
||||
function escapeYamlString(str: string): string {
|
||||
@@ -179,4 +140,3 @@ function addPagesToZipRecursive(currentFolder: JSZip, parentId: string | null, a
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user