diff --git a/packages/notifications/lib/notification-element.js b/packages/notifications/lib/notification-element.js index 660ee6e7e..4d3ef9be4 100644 --- a/packages/notifications/lib/notification-element.js +++ b/packages/notifications/lib/notification-element.js @@ -8,18 +8,14 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ let NotificationElement; -const createDOMPurify = require('dompurify'); const fs = require('fs-plus'); const path = require('path'); -const marked = require('marked'); const {shell} = require('electron'); const NotificationIssue = require('./notification-issue'); const TemplateHelper = require('./template-helper'); const UserUtilities = require('./user-utilities'); -let DOMPurify = null; - const NotificationTemplate = `\
@@ -110,12 +106,7 @@ module.exports = const notificationContainer = this.element.querySelector('.message'); - if (DOMPurify === null) { - DOMPurify = createDOMPurify(); - } - notificationContainer.innerHTML = DOMPurify.sanitize( - marked.parse(this.model.getMessage()) - ); + notificationContainer.innerHTML = atom.ui.markdown.render(this.model.getMessage()); if (detail = this.model.getDetail()) { let stack; @@ -137,7 +128,7 @@ module.exports = metaContainer = this.element.querySelector('.meta'); metaContainer.appendChild(TemplateHelper.render(this.metaTemplate)); const description = this.element.querySelector('.description'); - description.innerHTML = marked.parse(metaContent); + description.innerHTML = atom.ui.markdown.render(metaContent); } if (options.buttons && (options.buttons.length > 0)) { diff --git a/packages/notifications/package.json b/packages/notifications/package.json index 0b85bdb40..84e938761 100644 --- a/packages/notifications/package.json +++ b/packages/notifications/package.json @@ -9,9 +9,7 @@ "atom": ">0.50.0" }, "dependencies": { - "dompurify": "3.0.3", "fs-plus": "^3.0.0", - "marked": "5.0.3", "moment": "^2.19.3", "semver": "^7.0.0", "stacktrace-parser": "^0.1.3", diff --git a/spec/ui-spec.js b/spec/ui-spec.js new file mode 100644 index 000000000..a2b250162 --- /dev/null +++ b/spec/ui-spec.js @@ -0,0 +1,36 @@ +const UI = require("../src/ui.js"); + +describe("Just testing for now", async () => { + console.log("here0"); + const content = +` +# Hello World + +My friends + +\`\`\`javascript +const hello = "world"; +\`\`\` + +`; + + console.log("here4"); + try { + const html = UI.markdown.renderMarkdown(content); + console.log("here3"); + console.log(html); + + const htmlDom = UI.markdown.convertToDOM(html); + + console.log("here1"); + await UI.markdown.applySyntaxHighlighting(htmlDom); + console.log("here2"); + + console.log(htmlDom.innerHTML); + + } catch(er) { + console.log("we errored"); + console.error(er); + } + +}); diff --git a/src/ui.js b/src/ui.js index 13ae726cc..62484674d 100644 --- a/src/ui.js +++ b/src/ui.js @@ -305,7 +305,7 @@ function convertAtomEditorToStandardElement(editorElement, preElement) { // Markdown Exported Object const markdown = { - renderMarkdown: renderMarkdown, + render: renderMarkdown, applySyntaxHighlighting: applySyntaxHighlighting, convertToDOM: convertToDOM };