Notes/src/services/import/markdown.ts

18 lines
457 B
TypeScript
Raw Normal View History

"use strict";
2024-07-19 00:02:39 +03:00
import { parse } from "marked";
import htmlSanitizer from "../html_sanitizer.js";
import importUtils from "./utils.js";
function renderToHtml(content: string, title: string) {
2024-07-19 00:02:39 +03:00
const html = parse(content, {
async: false
2024-04-13 17:30:48 +03:00
}) as string;
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
return htmlSanitizer.sanitize(h1Handled);
}
export default {
renderToHtml
};