@mui/internal-markdown 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/parseMarkdown.js +15 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-markdown",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI markdown parser. This is an internal package not meant for general use.",
6
6
  "main": "./index.js",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@babel/runtime": "^7.24.7",
20
20
  "lodash": "^4.17.21",
21
- "marked": "^5.1.2",
21
+ "marked": "^13.0.1",
22
22
  "prismjs": "^1.29.0"
23
23
  },
24
24
  "devDependencies": {
package/parseMarkdown.js CHANGED
@@ -309,12 +309,13 @@ function createRender(context) {
309
309
  */
310
310
  function render(markdown) {
311
311
  const renderer = new marked.Renderer();
312
- renderer.heading = (headingHtml, level) => {
312
+ renderer.heading = function heading({ tokens, depth: level }) {
313
313
  // Main title, no need for an anchor.
314
314
  // It adds noises to the URL.
315
315
  //
316
316
  // Small title, no need for an anchor.
317
317
  // It reduces the risk of duplicated id and it's fewer elements in the DOM.
318
+ const headingHtml = this.parser.parseInline(tokens);
318
319
  if (level === 1 || level >= 4) {
319
320
  return `<h${level}>${headingHtml}</h${level}>`;
320
321
  }
@@ -372,11 +373,12 @@ function createRender(context) {
372
373
  `</h${level}>`,
373
374
  ].join('');
374
375
  };
375
- renderer.link = (href, linkTitle, linkText) => {
376
+ renderer.link = function link({ href, title, tokens }) {
377
+ const linkText = this.parser.parseInline(tokens);
376
378
  let more = '';
377
379
 
378
- if (linkTitle) {
379
- more += ` title="${linkTitle}"`;
380
+ if (title) {
381
+ more += ` title="${title}"`;
380
382
  }
381
383
 
382
384
  if (noSEOadvantage.some((domain) => href.indexOf(domain) !== -1)) {
@@ -404,17 +406,17 @@ function createRender(context) {
404
406
 
405
407
  return `<a href="${finalHref}"${more}>${linkText}</a>`;
406
408
  };
407
- renderer.code = (code, infostring, escaped) => {
409
+ renderer.code = ({ lang, text, escaped }) => {
408
410
  // https://github.com/markedjs/marked/blob/30e90e5175700890e6feb1836c57b9404c854466/src/Renderer.js#L15
409
- const lang = (infostring || '').match(/\S*/)[0];
410
- const title = (infostring || '').match(/title="([^"]*)"/)?.[1];
411
- const out = prism(code, lang);
412
- if (out != null && out !== code) {
411
+ const langString = (lang || '').match(/\S*/)[0];
412
+ const title = (lang || '').match(/title="([^"]*)"/)?.[1];
413
+ const out = prism(text, langString);
414
+ if (out != null && out !== text) {
413
415
  escaped = true;
414
- code = out;
416
+ text = out;
415
417
  }
416
418
 
417
- code = `${code.replace(/\n$/, '')}\n`;
419
+ const code = `${text.replace(/\n$/, '')}\n`;
418
420
 
419
421
  if (!lang) {
420
422
  return `<pre><code>${escaped ? code : escape(code, true)}</code></pre>\n`;
@@ -462,9 +464,11 @@ function createRender(context) {
462
464
  ${
463
465
  ['info', 'success', 'warning', 'error'].includes(token.severity)
464
466
  ? [
467
+ '<div class="MuiCallout-icon-container">',
465
468
  '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="ContentCopyRoundedIcon">',
466
469
  `<use class="MuiCode-copied-icon" xlink:href="#${token.severity}-icon" />`,
467
470
  '</svg>',
471
+ '</div>',
468
472
  ].join('\n')
469
473
  : ''
470
474
  }