diff --git a/src/tools/epub-to-markdown/epub-to-markdown.service.ts b/src/tools/epub-to-markdown/epub-to-markdown.service.ts index 5b7197ac..921b289a 100644 --- a/src/tools/epub-to-markdown/epub-to-markdown.service.ts +++ b/src/tools/epub-to-markdown/epub-to-markdown.service.ts @@ -4,14 +4,6 @@ import type { SpineItem } from 'epubjs/types/section'; import TurndownService from 'turndown'; import { gfm as addGFM } from '@guyplusplus/turndown-plugin-gfm'; -function escapeMarkdown(text: string) { - return text - .replace(/\\/g, '\\\\') // escape backslash first - .replace(/([*_#>|`])/g, '\\$1') // escape common markdown symbols - .replace(/([\[\]\(\)])/g, '\\$1') // escape brackets and parentheses - .replace(/\|/g, '\\|'); // escape table pipes -} - interface SpineItems { items: SpineItem[]; get(href: string | undefined): Section; @@ -20,14 +12,6 @@ export async function extractTextAndMetaFromEPUB(file: File, format: 'text' | 'm let turndownService: TurndownService; if (format === 'markdown') { turndownService = new TurndownService(); - turndownService.addRule('escapeText', { - filter(node) { - return node.nodeType === 3; // text nodes - }, - replacement(content) { - return escapeMarkdown(content); - }, - }); addGFM(turndownService); turndownService.addRule('normalizedHeading', { filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], diff --git a/src/tools/html-to-data/html-to-data.vue b/src/tools/html-to-data/html-to-data.vue index d3f590c6..935c73fd 100644 --- a/src/tools/html-to-data/html-to-data.vue +++ b/src/tools/html-to-data/html-to-data.vue @@ -34,23 +34,6 @@ const formats = [ const turndownService = new TurndownService(); -function escapeMarkdown(text: string) { - return text - .replace(/\\/g, '\\\\') // escape backslash first - .replace(/([*_#>|`])/g, '\\$1') // escape common markdown symbols - .replace(/([\[\]\(\)])/g, '\\$1') // escape brackets and parentheses - .replace(/\|/g, '\\|'); // escape table pipes -} - -turndownService.addRule('escapeText', { - filter(node) { - return node.nodeType === 3; // text nodes - }, - replacement(content) { - return escapeMarkdown(content); - }, -}); - addGFM(turndownService); async function convertContent() { diff --git a/src/tools/html-to-markdown/html-to-markdown.vue b/src/tools/html-to-markdown/html-to-markdown.vue index 78bc3e0a..25255299 100644 --- a/src/tools/html-to-markdown/html-to-markdown.vue +++ b/src/tools/html-to-markdown/html-to-markdown.vue @@ -20,23 +20,6 @@ const emphasisStyle = useQueryParamOrStorage({ const turndownService = new TurndownService(); -function escapeMarkdown(text: string) { - return text - .replace(/\\/g, '\\\\') // escape backslash first - .replace(/([*_#>|`])/g, '\\$1') // escape common markdown symbols - .replace(/([\[\]\(\)])/g, '\\$1') // escape brackets and parentheses - .replace(/\|/g, '\\|'); // escape table pipes -} - -turndownService.addRule('escapeText', { - filter(node) { - return node.nodeType === 3; // text nodes - }, - replacement(content) { - return escapeMarkdown(content); - }, -}); - addGFM(turndownService); turndownService.addRule('normalizedHeading', {