diff --git a/apps/server/src/integrations/export/turndown-utils.ts b/apps/server/src/integrations/export/turndown-utils.ts index 3f72050..a7cf514 100644 --- a/apps/server/src/integrations/export/turndown-utils.ts +++ b/apps/server/src/integrations/export/turndown-utils.ts @@ -21,6 +21,8 @@ export function turndown(html: string): string { toggleListTitle, toggleListBody, listParagraph, + mathInline, + mathBlock, ]); return turndownService.turndown(html).replaceAll('
', ' '); @@ -98,3 +100,31 @@ function toggleListBody(turndownService: TurndownService) { }, }); } + +function mathInline(turndownService: TurndownService) { + turndownService.addRule('mathInline', { + filter: function (node: HTMLInputElement) { + return ( + node.nodeName === 'SPAN' && + node.getAttribute('data-type') === 'mathInline' + ); + }, + replacement: function (content: any, node: HTMLInputElement) { + return `$${content}$`; + }, + }); +} + +function mathBlock(turndownService: TurndownService) { + turndownService.addRule('mathBlock', { + filter: function (node: HTMLInputElement) { + return ( + node.nodeName === 'DIV' && + node.getAttribute('data-type') === 'mathBlock' + ); + }, + replacement: function (content: any, node: HTMLInputElement) { + return `$$${content}$$`; + }, + }); +}