diff --git a/package.json b/package.json index af18af1..a438374 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,8 @@ "electron-store": "^10.1.0", "highlight.js": "^11.11.1", "html2pdf.js": "^0.10.1", - "marked": "^16.2.1", + "marked": "^17.0.3", + "marked-highlight": "^2.2.3", "pdf-lib": "^1.17.1", "pdfjs-dist": "^3.11.174", "pdfkit": "^0.14.0", diff --git a/src/renderer.js b/src/renderer.js index a128a64..0ef4568 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -5,11 +5,12 @@ const { ipcRenderer } = require('electron'); const marked = require('marked'); +const { markedHighlight } = require('marked-highlight'); const DOMPurify = require('dompurify'); const hljs = require('highlight.js'); -// Configure marked -marked.setOptions({ +// Configure marked with highlight extension +marked.use(markedHighlight({ highlight: function(code, lang) { if (lang && hljs.getLanguage(lang)) { try { @@ -19,7 +20,10 @@ marked.setOptions({ } } return hljs.highlightAuto(code).value; - }, + } +})); + +marked.use({ breaks: true, gfm: true }); diff --git a/tests/setup.js b/tests/setup.js index 7c6bdaa..7090e7a 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -59,7 +59,7 @@ global.window.electronAPI = { // Mock marked library global.window.marked = { parse: jest.fn((text) => `

${text}

`), - setOptions: jest.fn() + use: jest.fn() }; // Mock DOMPurify