Update dependency marked to v12 (#82245)

* Update dependency marked to v12

* make sure marked return value is synchronous

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
renovate[bot] 2024-02-14 15:01:33 +00:00 committed by GitHub
parent d956282913
commit 8a7828da48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 16 deletions

View File

@ -329,7 +329,7 @@
"lru-cache": "10.2.0",
"lru-memoize": "^1.1.0",
"lucene": "^2.1.1",
"marked": "5.1.1",
"marked": "12.0.0",
"marked-mangle": "1.1.7",
"memoize-one": "6.0.0",
"ml-regression-polynomial": "^3.0.0",

View File

@ -46,7 +46,7 @@
"fast_array_intersect": "1.1.0",
"history": "4.10.1",
"lodash": "4.17.21",
"marked": "5.1.1",
"marked": "12.0.0",
"marked-mangle": "1.1.7",
"moment": "2.30.1",
"moment-timezone": "0.5.45",

View File

@ -1,4 +1,4 @@
import { marked } from 'marked';
import { marked, MarkedOptions } from 'marked';
import { mangle } from 'marked-mangle';
import { sanitizeTextPanelContent } from './sanitize';
@ -10,13 +10,9 @@ export interface RenderMarkdownOptions {
breaks?: boolean;
}
const markdownOptions = {
headerIds: false,
const markdownOptions: MarkedOptions = {
pedantic: false,
gfm: true,
smartLists: true,
smartypants: false,
xhtml: false,
breaks: false,
};
@ -36,6 +32,12 @@ export function renderMarkdown(str?: string, options?: RenderMarkdownOptions): s
}
const html = marked(str || '', opts);
// `marked()` returns a promise if using any extensions that require async processing.
// we don't use any async extensions, but there is no way for typescript to know this, so we need to check the type.
if (typeof html !== 'string') {
throw new Error('Failed to process markdown synchronously.');
}
if (options?.noSanitize) {
return html;
}
@ -51,6 +53,13 @@ export function renderTextPanelMarkdown(str?: string, options?: RenderMarkdownOp
}
const html = marked(str || '');
// `marked()` returns a promise if using any extensions that require async processing.
// we don't use any async extensions, but there is no way for typescript to know this, so we need to check the type.
if (typeof html !== 'string') {
throw new Error('Failed to process markdown synchronously.');
}
if (options?.noSanitize) {
return html;
}

View File

@ -46,7 +46,7 @@
"eventemitter3": "5.0.1",
"lodash": "4.17.21",
"lru-cache": "10.2.0",
"marked": "5.1.1",
"marked": "12.0.0",
"marked-mangle": "1.1.7",
"moment": "2.30.1",
"moment-timezone": "0.5.45",

View File

@ -3540,7 +3540,7 @@ __metadata:
fast_array_intersect: "npm:1.1.0"
history: "npm:4.10.1"
lodash: "npm:4.17.21"
marked: "npm:5.1.1"
marked: "npm:12.0.0"
marked-mangle: "npm:1.1.7"
moment: "npm:2.30.1"
moment-timezone: "npm:0.5.45"
@ -3957,7 +3957,7 @@ __metadata:
jest-matcher-utils: "npm:29.7.0"
lodash: "npm:4.17.21"
lru-cache: "npm:10.2.0"
marked: "npm:5.1.1"
marked: "npm:12.0.0"
marked-mangle: "npm:1.1.7"
moment: "npm:2.30.1"
moment-timezone: "npm:0.5.45"
@ -18371,7 +18371,7 @@ __metadata:
lru-cache: "npm:10.2.0"
lru-memoize: "npm:^1.1.0"
lucene: "npm:^2.1.1"
marked: "npm:5.1.1"
marked: "npm:12.0.0"
marked-mangle: "npm:1.1.7"
memoize-one: "npm:6.0.0"
mini-css-extract-plugin: "npm:2.8.0"
@ -22104,12 +22104,12 @@ __metadata:
languageName: node
linkType: hard
"marked@npm:5.1.1":
version: 5.1.1
resolution: "marked@npm:5.1.1"
"marked@npm:12.0.0":
version: 12.0.0
resolution: "marked@npm:12.0.0"
bin:
marked: bin/marked.js
checksum: 10/88bf0b1db52a84222956bc32e7e7cc7b3ecc6a978ec37acafd4e45aeb6c1c5a62640ab570fc1fccbaf385d39b4783a41a2e1d71f2766cf905e32164dc74eeec5
checksum: 10/ac2e5a3ebf33f8636e65c1eb7f73267cbe101fea1ad08abab60d51e5b4fda30faa59050e2837dc03fb6dbf58f630485c8d01ae5b9d90d36bf4562d7f40c1d33e
languageName: node
linkType: hard