mirror of
https://github.com/zadam/trilium.git
synced 2025-11-08 22:35:50 +01:00
feat(markdown): preserve figures
This commit is contained in:
@@ -45,6 +45,7 @@ function toMarkdown(content: string) {
|
||||
instance.addRule("img", buildImageFilter());
|
||||
instance.addRule("admonition", buildAdmonitionFilter());
|
||||
instance.addRule("inlineLink", buildInlineLinkFilter());
|
||||
instance.addRule("figure", buildFigureFilter());
|
||||
instance.use(gfm);
|
||||
instance.keep([ "kbd" ]);
|
||||
}
|
||||
@@ -195,6 +196,17 @@ function buildInlineLinkFilter(): Rule {
|
||||
}
|
||||
}
|
||||
|
||||
function buildFigureFilter(): Rule {
|
||||
return {
|
||||
filter(node, options) {
|
||||
return node.nodeName === 'FIGURE'
|
||||
},
|
||||
replacement(content, node) {
|
||||
return (node as HTMLElement).outerHTML;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Taken from upstream since it's not exposed.
|
||||
// https://github.com/mixmark-io/turndown/blob/master/src/commonmark-rules.js
|
||||
function cleanAttribute(attribute: string | null | undefined) {
|
||||
|
||||
Reference in New Issue
Block a user