Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderer.heading = (text: string, level: number) => {
const escapedText = text.toLowerCase()
.replace(/[^\w():]+/g, '-')
.replace(/-code-/g, '-')
.replace(/-strong-/g, '')
.replace(/-$/, '')
.replace(/^-/, '')
.replace(/\([a-zA-Z: ]*\)$/, '');
const currentUrl = router.routerState.snapshot.url.split('#')[0].substr(1);
return level >= 4
? `
<a href="${currentUrl}#${escapedText}" class="header" id="${escapedText}">
${octicons.link.toSVG()}
${text}
</a>
`
: `
${text}
`;
};