diff --git a/packages/renderer/htmlUtils.ts b/packages/renderer/htmlUtils.ts index 592b9643da..7b5906d73f 100644 --- a/packages/renderer/htmlUtils.ts +++ b/packages/renderer/htmlUtils.ts @@ -30,9 +30,13 @@ const selfClosingElements = [ 'wbr', ]; +interface SanitizeHtmlOptions { + addNoMdConvClass: boolean; +} + class HtmlUtils { - public attributesHtml(attr: any) { + public attributesHtml(attr: Record) { const output = []; for (const n in attr) { @@ -76,8 +80,15 @@ class HtmlUtils { public processAnchorTags(html: string, callback: Function) { if (!html) return ''; + interface Action { + type: 'replaceElement' | 'replaceSource' | 'setAttributes'; + href: string; + html: string; + attrs: Record; + } + return html.replace(anchorRegex, (_v, before, href, after) => { - const action = callback({ href: href }); + const action: Action = callback({ href: href }); if (!action) return ``; @@ -149,7 +160,7 @@ class HtmlUtils { return url.startsWith('https://') || url.startsWith('http://') || url.startsWith('mailto://'); } - public sanitizeHtml(html: string, options: any = null) { + public sanitizeHtml(html: string, options: SanitizeHtmlOptions = null) { options = Object.assign({}, { // If true, adds a "jop-noMdConv" class to all the tags. // It can be used afterwards to restore HTML tags in Markdown.