Notes/src/services/import/markdown.ts

18 lines
461 B
TypeScript

"use strict";
import marked = require('marked');
import htmlSanitizer from "../html_sanitizer.js";
import importUtils from "./utils.js";
function renderToHtml(content: string, title: string) {
const html = marked.parse(content, {
async: false
}) as string;
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
return htmlSanitizer.sanitize(h1Handled);
}
export = {
renderToHtml
};