mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
feat: upgrade marked to v17 with marked-highlight extension
- Update marked from ^16.2.1 to ^17.0.3 - Add marked-highlight ^2.2.3 for syntax highlighting support - Replace deprecated marked.setOptions() with marked.use() in renderer.js - Extract highlight config into markedHighlight() extension (required in v17) - Update test mock to reflect new API (use instead of setOptions)
This commit is contained in:
+2
-1
@@ -60,7 +60,8 @@
|
|||||||
"electron-store": "^10.1.0",
|
"electron-store": "^10.1.0",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"html2pdf.js": "^0.10.1",
|
"html2pdf.js": "^0.10.1",
|
||||||
"marked": "^16.2.1",
|
"marked": "^17.0.3",
|
||||||
|
"marked-highlight": "^2.2.3",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"pdfjs-dist": "^3.11.174",
|
"pdfjs-dist": "^3.11.174",
|
||||||
"pdfkit": "^0.14.0",
|
"pdfkit": "^0.14.0",
|
||||||
|
|||||||
+7
-3
@@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
const { ipcRenderer } = require('electron');
|
const { ipcRenderer } = require('electron');
|
||||||
const marked = require('marked');
|
const marked = require('marked');
|
||||||
|
const { markedHighlight } = require('marked-highlight');
|
||||||
const DOMPurify = require('dompurify');
|
const DOMPurify = require('dompurify');
|
||||||
const hljs = require('highlight.js');
|
const hljs = require('highlight.js');
|
||||||
|
|
||||||
// Configure marked
|
// Configure marked with highlight extension
|
||||||
marked.setOptions({
|
marked.use(markedHighlight({
|
||||||
highlight: function(code, lang) {
|
highlight: function(code, lang) {
|
||||||
if (lang && hljs.getLanguage(lang)) {
|
if (lang && hljs.getLanguage(lang)) {
|
||||||
try {
|
try {
|
||||||
@@ -19,7 +20,10 @@ marked.setOptions({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hljs.highlightAuto(code).value;
|
return hljs.highlightAuto(code).value;
|
||||||
},
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
marked.use({
|
||||||
breaks: true,
|
breaks: true,
|
||||||
gfm: true
|
gfm: true
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ global.window.electronAPI = {
|
|||||||
// Mock marked library
|
// Mock marked library
|
||||||
global.window.marked = {
|
global.window.marked = {
|
||||||
parse: jest.fn((text) => `<p>${text}</p>`),
|
parse: jest.fn((text) => `<p>${text}</p>`),
|
||||||
setOptions: jest.fn()
|
use: jest.fn()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Mock DOMPurify
|
// Mock DOMPurify
|
||||||
|
|||||||
Reference in New Issue
Block a user