mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Port services/export/md
This commit is contained in:
parent
0903cf2646
commit
ec4bd6659a
13
package-lock.json
generated
13
package-lock.json
generated
@ -97,6 +97,7 @@
|
|||||||
"@types/mime-types": "^2.1.4",
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/node": "^20.11.19",
|
"@types/node": "^20.11.19",
|
||||||
"@types/sanitize-html": "^2.11.0",
|
"@types/sanitize-html": "^2.11.0",
|
||||||
|
"@types/turndown": "^5.0.4",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.10",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.8",
|
"electron": "25.9.8",
|
||||||
@ -1757,6 +1758,12 @@
|
|||||||
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/turndown": {
|
||||||
|
"version": "5.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/turndown/-/turndown-5.0.4.tgz",
|
||||||
|
"integrity": "sha512-28GI33lCCkU4SGH1GvjDhFgOVr+Tym4PXGBIU1buJUa6xQolniPArtUT+kv42RR2N9MsMLInkr904Aq+ESHBJg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/unist": {
|
"node_modules/@types/unist": {
|
||||||
"version": "2.0.10",
|
"version": "2.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
|
||||||
@ -16466,6 +16473,12 @@
|
|||||||
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
"integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/turndown": {
|
||||||
|
"version": "5.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/turndown/-/turndown-5.0.4.tgz",
|
||||||
|
"integrity": "sha512-28GI33lCCkU4SGH1GvjDhFgOVr+Tym4PXGBIU1buJUa6xQolniPArtUT+kv42RR2N9MsMLInkr904Aq+ESHBJg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/unist": {
|
"@types/unist": {
|
||||||
"version": "2.0.10",
|
"version": "2.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.10.tgz",
|
||||||
|
@ -120,6 +120,7 @@
|
|||||||
"@types/mime-types": "^2.1.4",
|
"@types/mime-types": "^2.1.4",
|
||||||
"@types/node": "^20.11.19",
|
"@types/node": "^20.11.19",
|
||||||
"@types/sanitize-html": "^2.11.0",
|
"@types/sanitize-html": "^2.11.0",
|
||||||
|
"@types/turndown": "^5.0.4",
|
||||||
"@types/ws": "^8.5.10",
|
"@types/ws": "^8.5.10",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.8",
|
"electron": "25.9.8",
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TurndownService = require('turndown');
|
import TurndownService = require('turndown');
|
||||||
const turndownPluginGfm = require('joplin-turndown-plugin-gfm');
|
import turndownPluginGfm = require('joplin-turndown-plugin-gfm');
|
||||||
|
|
||||||
let instance = null;
|
let instance: TurndownService | null = null;
|
||||||
|
|
||||||
function toMarkdown(content) {
|
function toMarkdown(content: string) {
|
||||||
if (instance === null) {
|
if (instance === null) {
|
||||||
instance = new TurndownService({ codeBlockStyle: 'fenced' });
|
instance = new TurndownService({ codeBlockStyle: 'fenced' });
|
||||||
instance.use(turndownPluginGfm.gfm);
|
instance.use(turndownPluginGfm.gfm);
|
||||||
@ -14,6 +14,6 @@ function toMarkdown(content) {
|
|||||||
return instance.turndown(content);
|
return instance.turndown(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export = {
|
||||||
toMarkdown
|
toMarkdown
|
||||||
};
|
};
|
@ -3,7 +3,7 @@
|
|||||||
const mimeTypes = require('mime-types');
|
const mimeTypes = require('mime-types');
|
||||||
const html = require('html');
|
const html = require('html');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
const mdService = require('./md.js');
|
const mdService = require('./md');
|
||||||
const becca = require('../../becca/becca');
|
const becca = require('../../becca/becca');
|
||||||
|
|
||||||
function exportSingleNote(taskContext, branch, format, res) {
|
function exportSingleNote(taskContext, branch, format, res) {
|
||||||
|
@ -4,7 +4,7 @@ const html = require('html');
|
|||||||
const dateUtils = require('../date_utils');
|
const dateUtils = require('../date_utils');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const mimeTypes = require('mime-types');
|
const mimeTypes = require('mime-types');
|
||||||
const mdService = require('./md.js');
|
const mdService = require('./md');
|
||||||
const packageInfo = require('../../../package.json');
|
const packageInfo = require('../../../package.json');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
const protectedSessionService = require('../protected_session');
|
const protectedSessionService = require('../protected_session');
|
||||||
|
8
src/types.d.ts
vendored
8
src/types.d.ts
vendored
@ -16,4 +16,12 @@ declare module 'html2plaintext' {
|
|||||||
declare module 'normalize-strings' {
|
declare module 'normalize-strings' {
|
||||||
function normalizeString(string: string): string;
|
function normalizeString(string: string): string;
|
||||||
export = normalizeString;
|
export = normalizeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'joplin-turndown-plugin-gfm' {
|
||||||
|
import TurndownService = require("turndown");
|
||||||
|
namespace gfm {
|
||||||
|
function gfm(service: TurndownService): void;
|
||||||
|
}
|
||||||
|
export = gfm;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user