// src/utils/markdown-toc.ts
function slugify(text) {
  return text.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
function extractTableOfContents(markdown) {
  if (!markdown) return [];
  const toc = [];
  const lines = markdown.split("\n");
  for (const line of lines) {
    const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
    if (headingMatch) {
      const level = headingMatch[1].length;
      const title = headingMatch[2].trim();
      if (level >= 2 && level <= 3) {
        const id = slugify(title);
        toc.push({
          id,
          title,
          level
        });
      }
    }
  }
  return toc;
}
export {
  extractTableOfContents
};
//# sourceMappingURL=markdown-toc.js.map