diff --git a/src/utils.ts b/src/utils.ts index a8d837f..18942e9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -799,28 +799,10 @@ export const htmlToMarkdown = (text: string): string => { text = text.replace(new RegExp('(.*?)', 'gim'), '~$1~'); text = text.replace(new RegExp('(.*?)', 'gim'), '`$1`'); text = text.replace(new RegExp('
(.*?)
', 'gim'), '```$1```'); - text = text.replace(new RegExp('
(.*?)
', 'gim'), '> $1'); - - text = text.replace(new RegExp('<', 'gim'), '<'); - text = text.replace(new RegExp('>', 'gim'), '>'); - } - return text; -}; - -export const htmlToMarkdownLegacy = (text: string): string => { - if (text) { - const replacements = [ - { pattern: '([\\S\\s]+)', sub: '```$1\n$2```' }, - { pattern: '(.[^<]+)', sub: '$1' }, - { pattern: '<[/]?i>', sub: '_' }, - { pattern: '<[/]?b>', sub: '*' }, - { pattern: '<[/]?u>', sub: '~' }, - { pattern: '<[/]?code>', sub: '`' }, - { pattern: '<[/]?pre>', sub: '```' }, - ]; - replacements.map((rep) => { - text = text.replace(new RegExp(rep['pattern'], 'gim'), rep['sub']); + text = text.replace(new RegExp('
(.*?)
', 'gim'), (p1) => { + return '> ' + p1.replace(/\n/g, '\n> '); }); + text = text.replace(new RegExp('<', 'gim'), '<'); text = text.replace(new RegExp('>', 'gim'), '>'); }