mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 09:22:38 +10:00
Support math export in Markdown
This commit is contained in:
@ -21,6 +21,8 @@ export function turndown(html: string): string {
|
||||
toggleListTitle,
|
||||
toggleListBody,
|
||||
listParagraph,
|
||||
mathInline,
|
||||
mathBlock,
|
||||
]);
|
||||
|
||||
return turndownService.turndown(html).replaceAll('<br>', ' ');
|
||||
@ -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}$$`;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user