preserve <figure> and <figcaption>

This commit is contained in:
Will Boyd
2024-02-21 14:24:40 -05:00
parent bcc0c5ce3e
commit 06ee39c545
+9 -1
View File
@@ -9,7 +9,6 @@ function initTurndownService() {
});
turndownService.use(turndownPluginGfm.tables);
turndownService.keep(['iframe']);
// preserve embedded tweets
turndownService.addRule('tweet', {
@@ -56,6 +55,15 @@ function initTurndownService() {
}
});
// preserve <figure> and <figcaption>
turndownService.addRule('fig', {
filter: ['figure', 'figcaption'],
replacement: (content, node) => {
const tagName = node.nodeName.toLowerCase();
return '<' + tagName + '>' + content + '</' + tagName + '>';
}
});
return turndownService;
}