How to use marked and sanitize html instead of sending raw html to front end

167 views Asked by At

I'm using marked, dompurify, and JSDOM to convert markedown text to HTML and then sanitize but It sends send raw HTML instead of HTML

imports

const { marked } = require("marked");
const createDomPurify = require("dompurify");
const { JSDOM } = require("jsdom");
const dompurify = createDomPurify(new JSDOM().window);
const sanitizedArticle = dompurify.sanitize(marked(news.article));

input

# Lorem ipsum dolor,

output

<h1 id="lorem-ipsum-dolor">Lorem ipsum dolor,</h1>
0

There are 0 answers