From 54c49923627a7802deddbe328c8dc786e36645d4 Mon Sep 17 00:00:00 2001 From: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Date: Wed, 12 Jul 2023 09:09:21 +0200 Subject: [PATCH] [core] Remove warnings in docs:api (#37858) --- docs/scripts/reportBrokenLinks.js | 2 +- packages/markdown/parseMarkdown.js | 34 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index 5d184009a79c49..f91933a2996bc8 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -15,7 +15,7 @@ const getPageLinks = (markdown) => { hrefs.push(href); } }; - marked(markdown, { renderer }); + marked(markdown, { mangle: false, headerIds: false, renderer }); return hrefs; }; diff --git a/packages/markdown/parseMarkdown.js b/packages/markdown/parseMarkdown.js index 983296916e2500..3fae9387178057 100644 --- a/packages/markdown/parseMarkdown.js +++ b/packages/markdown/parseMarkdown.js @@ -3,6 +3,22 @@ const kebabCase = require('lodash/kebabCase'); const textToHash = require('./textToHash'); const prism = require('./prism'); +/** + * Option used by `marked` the library parsing markdown. + */ +const markedOptions = { + gfm: true, + tables: true, + breaks: false, + pedantic: false, + sanitize: false, + smartLists: true, + smartypants: false, + headerPrefix: false, + headerIds: false, + mangle: false, +}; + const headerRegExp = /---[\r\n]([\s\S]*)[\r\n]---/; const titleRegExp = /# (.*)[\r\n]/; const descriptionRegExp = /

(.*?)<\/p>/s; @@ -188,7 +204,7 @@ function getDescription(markdown) { * @param {string} markdown */ function renderInline(markdown) { - return marked.parseInline(markdown); + return marked.parseInline(markdown, markedOptions); } // Help rank mui.com on component searches first. @@ -352,20 +368,6 @@ function createRender(context) { ].join('')}\n`; }; - const markedOptions = { - gfm: true, - tables: true, - breaks: false, - pedantic: false, - sanitize: false, - smartLists: true, - smartypants: false, - headerPrefix: false, - headerIds: false, - mangle: false, - renderer, - }; - marked.use({ extensions: [ { @@ -401,7 +403,7 @@ function createRender(context) { ], }); - return marked(markdown, markedOptions); + return marked(markdown, { ...markedOptions, renderer }); } return render;