mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-14 08:41:04 +10:00
Support math export in Markdown
This commit is contained in:
@ -21,6 +21,8 @@ export function turndown(html: string): string {
|
|||||||
toggleListTitle,
|
toggleListTitle,
|
||||||
toggleListBody,
|
toggleListBody,
|
||||||
listParagraph,
|
listParagraph,
|
||||||
|
mathInline,
|
||||||
|
mathBlock,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return turndownService.turndown(html).replaceAll('<br>', ' ');
|
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