From 02e6dda706838c422c096868f58c04b63dfd016c Mon Sep 17 00:00:00 2001 From: Steven nguyen Date: Sat, 15 Jan 2022 12:41:31 -0600 Subject: [PATCH] [chore] Use marked v4 Copied from https://github.com/icecream17/github/pull/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 --- lib/helpers.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 30e694bc98..bf531a2b38 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -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 = {