Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Jul 11, 2023
1 parent 1896226 commit aaaa499
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/markdown/parseMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 class="description">(.*?)<\/p>/s;
Expand Down Expand Up @@ -188,7 +204,7 @@ function getDescription(markdown) {
* @param {string} markdown
*/
function renderInline(markdown) {
return marked.parseInline(markdown, { headerIds: false, mangle: false });
return marked.parseInline(markdown, markedOptions);
}

// Help rank mui.com on component searches first.
Expand Down Expand Up @@ -350,20 +366,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: [
{
Expand Down Expand Up @@ -399,7 +401,7 @@ function createRender(context) {
],
});

return marked(markdown, markedOptions);
return marked(markdown, { ...markedOptions, renderer });
}

return render;
Expand Down

0 comments on commit aaaa499

Please sign in to comment.