server-ts: Port services/import/markdown

This commit is contained in:
Elian Doran
2024-02-25 08:12:07 +02:00
parent cc1a545e13
commit 59d618f06b
5 changed files with 20 additions and 21 deletions

View 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
};