Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
[chore] Use marked v4
Browse files Browse the repository at this point in the history
Copied from icecream17#2

Actually updating to v4.0.10
The only relevant breaking change: https://github.com/markedjs/marked/releases/tag/v4.0.0 
is that the default export is removed: `({marked} = require('marked'))`

Parens are required to make it not a SyntaxError.

Only other change is that the docs: https://marked.js.org/using_advanced
recommend using sanitize on the output instead of in the options
  • Loading branch information
icecream17 committed Jan 15, 2022
1 parent b5629b6 commit 02e6dda
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,17 @@ let domPurify = null;

export function renderMarkdown(md) {
if (marked === null) {
marked = require('marked');
({marked} = require('marked'));

if (domPurify === null) {
const createDOMPurify = require('dompurify');
domPurify = createDOMPurify();
}

marked.setOptions({
silent: true,
sanitize: true,
sanitizer: html => domPurify.sanitize(html),
});
marked.setOptions({silent: true});
}

return marked(md);
return domPurify.sanitize(marked(md));
}

export const GHOST_USER = {
Expand Down

0 comments on commit 02e6dda

Please sign in to comment.