mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 07:15:51 +01:00
server-ts: Port services/export/md
This commit is contained in:
19
src/services/export/md.ts
Normal file
19
src/services/export/md.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
import TurndownService = require('turndown');
|
||||
import turndownPluginGfm = require('joplin-turndown-plugin-gfm');
|
||||
|
||||
let instance: TurndownService | null = null;
|
||||
|
||||
function toMarkdown(content: string) {
|
||||
if (instance === null) {
|
||||
instance = new TurndownService({ codeBlockStyle: 'fenced' });
|
||||
instance.use(turndownPluginGfm.gfm);
|
||||
}
|
||||
|
||||
return instance.turndown(content);
|
||||
}
|
||||
|
||||
export = {
|
||||
toMarkdown
|
||||
};
|
||||
Reference in New Issue
Block a user