mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
server-ts: Port services/import/markdown
This commit is contained in:
parent
cc1a545e13
commit
59d618f06b
@ -1,5 +1,5 @@
|
||||
const becca = require('../../becca/becca');
|
||||
const markdownService = require('../../services/import/markdown.js');
|
||||
const markdownService = require('../../services/import/markdown');
|
||||
|
||||
function getIconUsage() {
|
||||
const iconClassToCountMap = {};
|
||||
|
@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const marked = require("marked");
|
||||
const htmlSanitizer = require('../html_sanitizer');
|
||||
const importUtils = require('./utils');
|
||||
|
||||
function renderToHtml(content, title) {
|
||||
const html = marked.parse(content, {
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
|
||||
return htmlSanitizer.sanitize(h1Handled);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
renderToHtml
|
||||
};
|
17
src/services/import/markdown.ts
Normal file
17
src/services/import/markdown.ts
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
import marked = require("marked");
|
||||
import htmlSanitizer = require('../html_sanitizer');
|
||||
import importUtils = require('./utils');
|
||||
|
||||
function renderToHtml(content: string, title: string) {
|
||||
const html = marked.parse(content, {
|
||||
async: false
|
||||
}); // FIXME: mangle and headerIds does not seem to exist in marked
|
||||
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
|
||||
return htmlSanitizer.sanitize(h1Handled);
|
||||
}
|
||||
|
||||
export = {
|
||||
renderToHtml
|
||||
};
|
@ -3,7 +3,7 @@
|
||||
const noteService = require('../../services/notes');
|
||||
const imageService = require('../../services/image');
|
||||
const protectedSessionService = require('../protected_session');
|
||||
const markdownService = require('./markdown.js');
|
||||
const markdownService = require('./markdown');
|
||||
const mimeService = require('./mime');
|
||||
const utils = require('../../services/utils');
|
||||
const importUtils = require('./utils');
|
||||
|
@ -14,7 +14,7 @@ const yauzl = require("yauzl");
|
||||
const htmlSanitizer = require('../html_sanitizer');
|
||||
const becca = require('../../becca/becca');
|
||||
const BAttachment = require('../../becca/entities/battachment');
|
||||
const markdownService = require('./markdown.js');
|
||||
const markdownService = require('./markdown');
|
||||
|
||||
/**
|
||||
* @param {TaskContext} taskContext
|
||||
|
Loading…
x
Reference in New Issue
Block a user