import { marked } from 'marked';
export const parseMarkdown = (text: string | undefined): string => {
if (!text) return '';
// Custom renderer
const renderer = new marked.Renderer();
// Override function to handle headings
renderer.heading = function ({ tokens, depth }) {
const text = this.parser.parseInline(tokens);
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return `${text}`;
};
// Override function to handle links
renderer.link = function ({ href, title, tokens }) {
const text = this.parser.parseInline(tokens);
if (href.startsWith('/')) {
href = `https://github.com/Lissy93/personal-security-checklist/blob/old-version/${href}`;
}
const titleAttr = title ? `title="${title}"` : '';
return `${text}`;
};
// Sanitize the input to remove