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