Skip to content

Commit

Permalink
[docs-infra] Remove code tags in ToC (mui#37834)
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Tassinari <[email protected]>
  • Loading branch information
cherniavskii and oliviertassinari committed Jul 10, 2023
1 parent 1508512 commit 17f5651
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/markdown/parseMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ function createRender(context) {
}

// Remove links to avoid nested links in the TOCs
const headingText = headingHtml.replace(/<a\b[^>]*>/i, '').replace(/<\/a>/i, '');
let headingText = headingHtml.replace(/<a\b[^>]*>/i, '').replace(/<\/a>/i, '');
// Remove `code` tags
headingText = headingText.replace(/<code\b[^>]*>/i, '').replace(/<\/code>/i, '');

// Standardizes the hash from the default location (en) to different locations
// Need english.md file parsed first
Expand Down
6 changes: 6 additions & 0 deletions packages/markdown/parseMarkdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ authors:
### Unofficial 👍
### Warning ⚠️
### Header with Pro plan [<span class="plan-pro"></span>](/x/introduction/licensing/#pro-plan)
### Header with \`code\`
`;

const {
Expand All @@ -198,6 +199,11 @@ authors:
level: 3,
text: 'Header with Pro plan <span class="plan-pro"></span>',
},
{
hash: 'header-with-code',
level: 3,
text: 'Header with code',
},
],
hash: 'community-help-free',
level: 2,
Expand Down

0 comments on commit 17f5651

Please sign in to comment.