[{"data":1,"prerenderedAt":62},["Reactive",2],{"blog-post-markdown-heading-hierarchy-navigation-complete-guide":3},{"slug":4,"title":5,"description":6,"excerpt":7,"date":8,"category":9,"author":10,"keywords":11,"readingMinutes":12,"html":13,"headings":14,"tools":37,"related":38},"markdown-heading-hierarchy-navigation-complete-guide","Markdown Heading Hierarchy and Navigation: Complete Guide for Documentation Structure and Content Organization","Master advanced Markdown heading management techniques for creating structured documentation hierarchies, automated navigation systems, and consistent content organization. Learn heading best practices, anchor link generation, and navigation automation.","Advanced Markdown heading hierarchy and navigation systems enable sophisticated documentation architectures that provide clear content structure, intuitive navigation experiences, and scalable…","2025-10-18","Tutorial","Matthew Rathbone","markdown headings, markdown navigation, heading hierarchy, markdown table of contents, heading structure, markdown document organization, heading anchor links, markdown navigation systems",28,"\u003Cp>Advanced Markdown heading hierarchy and navigation systems enable sophisticated documentation architectures that provide clear content structure, intuitive navigation experiences, and scalable information organization. By mastering heading management strategies, automated navigation generation, and consistent hierarchical patterns, technical writers can build comprehensive documentation ecosystems that guide readers effectively through complex information while maintaining accessibility and supporting both human readers and automated processing systems.\u003C/p>\n\u003Ch2 id=\"why-master-heading-hierarchy-and-navigation\">Why Master Heading Hierarchy and Navigation?\u003C/h2>\n\u003Cp>Professional heading management provides essential benefits for structured content:\u003C/p>\n\u003Cul>\n\u003Cli>\u003Cstrong>Information Architecture\u003C/strong>: Create logical content hierarchies that guide reader understanding and navigation\u003C/li>\n\u003Cli>\u003Cstrong>Accessibility Compliance\u003C/strong>: Ensure proper semantic structure for screen readers and assistive technologies  \u003C/li>\n\u003Cli>\u003Cstrong>SEO Optimization\u003C/strong>: Improve search engine understanding and ranking through proper heading structure\u003C/li>\n\u003Cli>\u003Cstrong>Navigation Generation\u003C/strong>: Enable automated table of contents and navigation menu creation\u003C/li>\n\u003Cli>\u003Cstrong>Content Maintenance\u003C/strong>: Facilitate content updates and reorganization through consistent structural patterns\u003C/li>\n\u003C/ul>\n\u003Ch2 id=\"foundation-heading-principles\">Foundation Heading Principles\u003C/h2>\n\u003Ch3 id=\"semantic-heading-structure\">Semantic Heading Structure\u003C/h3>\n\u003Cp>Understanding the fundamentals of semantic heading organization:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Document Title (H1) - Only one per document\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Primary Sections (H2) - Main topic divisions\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### Subsections (H3) - Supporting topics within sections\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### Sub-subsections (H4) - Detailed breakdowns\u003C/span>\n\n\u003Cspan class=\"hljs-section\">##### Minor subsections (H5) - Specific details\u003C/span>\n\n\u003Cspan class=\"hljs-section\">###### Micro-sections (H6) - Finest granularity\u003C/span>\n\u003C/code>\u003C/pre>\u003Ch3 id=\"hierarchical-best-practices\">Hierarchical Best Practices\u003C/h3>\n\u003Cp>Implementing consistent heading patterns for maintainable documentation:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">\u003Cspan class=\"hljs-section\"># Complete Guide to API Authentication\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Overview\u003C/span>\n\nBrief introduction to authentication concepts and this guide&#x27;s scope.\n\n\u003Cspan class=\"hljs-section\">## Authentication Methods\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### API Key Authentication\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### Generating API Keys\u003C/span>\n\nStep-by-step process for creating API keys.\n\n\u003Cspan class=\"hljs-section\">#### Using API Keys in Requests\u003C/span>\n\nCode examples and implementation details.\n\n\u003Cspan class=\"hljs-section\">#### API Key Security Best Practices\u003C/span>\n\nSecurity considerations and recommendations.\n\n\u003Cspan class=\"hljs-section\">### OAuth 2.0 Authentication  \u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### OAuth 2.0 Flow Overview\u003C/span>\n\nUnderstanding the OAuth process.\n\n\u003Cspan class=\"hljs-section\">#### Implementation Steps\u003C/span>\n\n\u003Cspan class=\"hljs-section\">##### Client Registration\u003C/span>\n\u003Cspan class=\"hljs-section\">##### Authorization Request  \u003C/span>\n\u003Cspan class=\"hljs-section\">##### Token Exchange\u003C/span>\n\u003Cspan class=\"hljs-section\">##### Using Access Tokens\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### OAuth 2.0 Troubleshooting\u003C/span>\n\nCommon issues and solutions.\n\n\u003Cspan class=\"hljs-section\">### JWT Token Authentication\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### JWT Structure and Components\u003C/span>\n\nUnderstanding JWT token format.\n\n\u003Cspan class=\"hljs-section\">#### Implementing JWT Authentication\u003C/span>\n\nCode examples for JWT handling.\n\n\u003Cspan class=\"hljs-section\">## Advanced Authentication Topics\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### Multi-factor Authentication\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### TOTP Implementation\u003C/span>\n\u003Cspan class=\"hljs-section\">#### SMS Verification\u003C/span>\n\u003Cspan class=\"hljs-section\">#### Hardware Keys\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### Authentication Security\u003C/span>\n\n\u003Cspan class=\"hljs-section\">#### Token Refresh Strategies\u003C/span>\n\u003Cspan class=\"hljs-section\">#### Security Headers\u003C/span>\n\u003Cspan class=\"hljs-section\">#### Rate Limiting\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Integration Examples\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### JavaScript Integration\u003C/span>\n\u003Cspan class=\"hljs-section\">### Python Integration  \u003C/span>\n\u003Cspan class=\"hljs-section\">### cURL Examples\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Troubleshooting\u003C/span>\n\n\u003Cspan class=\"hljs-section\">### Common Authentication Errors\u003C/span>\n\u003Cspan class=\"hljs-section\">### Debugging Authentication Issues\u003C/span>\n\u003Cspan class=\"hljs-section\">### Support Resources\u003C/span>\n\n\u003Cspan class=\"hljs-section\">## Conclusion\u003C/span>\n\nSummary and next steps.\n\u003C/code>\u003C/pre>\u003Ch3 id=\"automated-heading-management-system\">Automated Heading Management System\u003C/h3>\n\u003Cp>Creating comprehensive heading analysis and management tools:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// heading-manager.js - Advanced heading hierarchy management\u003C/span>\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> fs = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;fs&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">promises\u003C/span>;\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> path = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>);\n\u003Cspan class=\"hljs-keyword\">const\u003C/span> matter = \u003Cspan class=\"hljs-built_in\">require\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;gray-matter&#x27;\u003C/span>);\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">AdvancedHeadingManager\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span> = options.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">anchorIndex\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Heading pattern matchers\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">headings\u003C/span>: \u003Cspan class=\"hljs-regexp\">/^(#{1,6})\\s+(.+)$/gm\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">anchorLinks\u003C/span>: \u003Cspan class=\"hljs-regexp\">/\\[([^\\]]+)\\]\\(#([^)]+)\\)/g\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">htmlHeadings\u003C/span>: \u003Cspan class=\"hljs-regexp\">/&lt;h([1-6])[^&gt;]*(?:\\sid\\s*=\\s*[&quot;&#x27;]([^&quot;&#x27;]+)[&quot;&#x27;])?[^&gt;]*&gt;([^&lt;]+)&lt;\\/h[1-6]&gt;/gi\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">totalHeadings\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">avgDepth\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxDepth\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">headingDistribution\u003C/span>: {},\n            \u003Cspan class=\"hljs-attr\">anchorLinks\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">duplicateAnchors\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">validationRules\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">maxDepth\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxDepth\u003C/span> || \u003Cspan class=\"hljs-number\">6\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">requireH1\u003C/span>: options.\u003Cspan class=\"hljs-property\">requireH1\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">noSkippedLevels\u003C/span>: options.\u003Cspan class=\"hljs-property\">noSkippedLevels\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">uniqueAnchors\u003C/span>: options.\u003Cspan class=\"hljs-property\">uniqueAnchors\u003C/span> !== \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxHeadingLength\u003C/span>: options.\u003Cspan class=\"hljs-property\">maxHeadingLength\u003C/span> || \u003Cspan class=\"hljs-number\">100\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">scanHeadings\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Scanning content for heading analysis...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> markdownFiles = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">contentDirectory\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> filePath \u003Cspan class=\"hljs-keyword\">of\u003C/span> markdownFiles) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeFileHeadings\u003C/span>(filePath);\n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error analyzing \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">calculateStatistics\u003C/span>();\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildNavigationStructures\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Heading analysis completed&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateHeadingReport\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">findMarkdownFiles\u003C/span>(\u003Cspan class=\"hljs-params\">directory\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> files = [];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span> = \u003Cspan class=\"hljs-keyword\">async\u003C/span> (\u003Cspan class=\"hljs-params\">dir\u003C/span>) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> entries = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readdir\u003C/span>(dir, { \u003Cspan class=\"hljs-attr\">withFileTypes\u003C/span>: \u003Cspan class=\"hljs-literal\">true\u003C/span> });\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> entry \u003Cspan class=\"hljs-keyword\">of\u003C/span> entries) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> fullPath = path.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(dir, entry.\u003Cspan class=\"hljs-property\">name\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isDirectory\u003C/span>() &amp;&amp; !entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">startsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>)) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(fullPath);\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (entry.\u003Cspan class=\"hljs-title function_\">isFile\u003C/span>() &amp;&amp; entry.\u003Cspan class=\"hljs-property\">name\u003C/span>.\u003Cspan class=\"hljs-title function_\">endsWith\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)) {\n                    files.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(fullPath);\n                }\n            }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-title function_\">scan\u003C/span>(directory);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> files;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">analyzeFileHeadings\u003C/span>(\u003Cspan class=\"hljs-params\">filePath\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> { \u003Cspan class=\"hljs-attr\">data\u003C/span>: frontmatter, \u003Cspan class=\"hljs-attr\">content\u003C/span>: body } = \u003Cspan class=\"hljs-title function_\">matter\u003C/span>(content);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileData = {\n            \u003Cspan class=\"hljs-attr\">path\u003C/span>: filePath,\n            frontmatter,\n            \u003Cspan class=\"hljs-attr\">content\u003C/span>: body,\n            \u003Cspan class=\"hljs-attr\">headings\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">anchorMap\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>(),\n            \u003Cspan class=\"hljs-attr\">navigationTree\u003C/span>: \u003Cspan class=\"hljs-literal\">null\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">issues\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Extract markdown headings\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> match;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-property\">lastIndex\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(body)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> level = match[\u003Cspan class=\"hljs-number\">1\u003C/span>].\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> text = match[\u003Cspan class=\"hljs-number\">2\u003C/span>].\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> anchor = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateAnchorId\u003C/span>(text);\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> heading = {\n                level,\n                text,\n                anchor,\n                \u003Cspan class=\"hljs-attr\">position\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">line\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getLineNumber\u003C/span>(body, match.\u003Cspan class=\"hljs-property\">index\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">raw\u003C/span>: match[\u003Cspan class=\"hljs-number\">0\u003C/span>]\n            };\n            \n            fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(heading);\n            \n            \u003Cspan class=\"hljs-comment\">// Track anchor usage\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fileData.\u003Cspan class=\"hljs-property\">anchorMap\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(anchor)) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;duplicate-anchor&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Duplicate anchor &#x27;\u003Cspan class=\"hljs-subst\">${anchor}\u003C/span>&#x27; for heading &#x27;\u003Cspan class=\"hljs-subst\">${text}\u003C/span>&#x27;`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">line\u003C/span>: heading.\u003Cspan class=\"hljs-property\">line\u003C/span>\n                });\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">duplicateAnchors\u003C/span>++;\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                fileData.\u003Cspan class=\"hljs-property\">anchorMap\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(anchor, heading);\n            }\n            \n            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span>++;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Extract HTML headings if present\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">htmlHeadings\u003C/span>.\u003Cspan class=\"hljs-property\">lastIndex\u003C/span> = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> ((match = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">patterns\u003C/span>.\u003Cspan class=\"hljs-property\">htmlHeadings\u003C/span>.\u003Cspan class=\"hljs-title function_\">exec\u003C/span>(body)) !== \u003Cspan class=\"hljs-literal\">null\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> level = \u003Cspan class=\"hljs-built_in\">parseInt\u003C/span>(match[\u003Cspan class=\"hljs-number\">1\u003C/span>]);\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> explicitId = match[\u003Cspan class=\"hljs-number\">2\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> text = match[\u003Cspan class=\"hljs-number\">3\u003C/span>].\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> anchor = explicitId || \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateAnchorId\u003C/span>(text);\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> heading = {\n                level,\n                text,\n                anchor,\n                \u003Cspan class=\"hljs-attr\">position\u003C/span>: match.\u003Cspan class=\"hljs-property\">index\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">line\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">getLineNumber\u003C/span>(body, match.\u003Cspan class=\"hljs-property\">index\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">raw\u003C/span>: match[\u003Cspan class=\"hljs-number\">0\u003C/span>],\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>\n            };\n            \n            fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(heading);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Sort headings by position\u003C/span>\n        fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a.\u003Cspan class=\"hljs-property\">position\u003C/span> - b.\u003Cspan class=\"hljs-property\">position\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Validate heading structure\u003C/span>\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">validateHeadingStructure\u003C/span>(fileData);\n        \n        \u003Cspan class=\"hljs-comment\">// Build navigation tree for this file\u003C/span>\n        fileData.\u003Cspan class=\"hljs-property\">navigationTree\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildNavigationTree\u003C/span>(fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>);\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(filePath, fileData);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> fileData;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">getLineNumber\u003C/span>(\u003Cspan class=\"hljs-params\">content, position\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> content.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, position).\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateAnchorId\u003C/span>(\u003Cspan class=\"hljs-params\">headingText\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> headingText\n            .\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>()\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[^a-z0-9\\s\\-_]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\s+/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;-&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/-+/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;-&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^-|-$/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">validateHeadingStructure\u003C/span>(\u003Cspan class=\"hljs-params\">fileData\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headings = fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> previousLevel = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; headings.\u003Cspan class=\"hljs-property\">length\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> heading = headings[i];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> { level, text, line } = heading;\n            \n            \u003Cspan class=\"hljs-comment\">// Check H1 requirement\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">validationRules\u003C/span>.\u003Cspan class=\"hljs-property\">requireH1\u003C/span> &amp;&amp; i === \u003Cspan class=\"hljs-number\">0\u003C/span> &amp;&amp; level !== \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;missing-h1&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Document should start with H1 heading&#x27;\u003C/span>,\n                    line\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check multiple H1s\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (level === \u003Cspan class=\"hljs-number\">1\u003C/span> &amp;&amp; i &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;multiple-h1&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Multiple H1 headings found - should have only one&#x27;\u003C/span>,\n                    line\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check skipped levels\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">validationRules\u003C/span>.\u003Cspan class=\"hljs-property\">noSkippedLevels\u003C/span> &amp;&amp; level &gt; previousLevel + \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;skipped-level&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Heading level \u003Cspan class=\"hljs-subst\">${level}\u003C/span> follows level \u003Cspan class=\"hljs-subst\">${previousLevel}\u003C/span> - levels should not be skipped`\u003C/span>,\n                    line\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check heading length\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">validationRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxHeadingLength\u003C/span> &amp;&amp; text.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">validationRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxHeadingLength\u003C/span>) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;heading-too-long&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Heading text exceeds \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.validationRules.maxHeadingLength}\u003C/span> characters`\u003C/span>,\n                    line\n                });\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check for empty headings\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (text.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>().\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;empty-heading&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Empty heading found&#x27;\u003C/span>,\n                    line\n                });\n            }\n            \n            previousLevel = level;\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">buildNavigationTree\u003C/span>(\u003Cspan class=\"hljs-params\">headings\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> root = { \u003Cspan class=\"hljs-attr\">children\u003C/span>: [], \u003Cspan class=\"hljs-attr\">level\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span> };\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> stack = [root];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> node = {\n                ...heading,\n                \u003Cspan class=\"hljs-attr\">children\u003C/span>: []\n            };\n            \n            \u003Cspan class=\"hljs-comment\">// Find appropriate parent\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">while\u003C/span> (stack.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">1\u003C/span> &amp;&amp; stack[stack.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>].\u003Cspan class=\"hljs-property\">level\u003C/span> &gt;= heading.\u003Cspan class=\"hljs-property\">level\u003C/span>) {\n                stack.\u003Cspan class=\"hljs-title function_\">pop\u003C/span>();\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Add to parent\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> parent = stack[stack.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>];\n            parent.\u003Cspan class=\"hljs-property\">children\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(node);\n            \n            \u003Cspan class=\"hljs-comment\">// Add to stack for potential children\u003C/span>\n            stack.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(node);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> root.\u003Cspan class=\"hljs-property\">children\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">calculateStatistics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalDepth = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> maxDepth = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> levelCounts = {};\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [, fileData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                totalDepth += heading.\u003Cspan class=\"hljs-property\">level\u003C/span>;\n                maxDepth = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(maxDepth, heading.\u003Cspan class=\"hljs-property\">level\u003C/span>);\n                levelCounts[heading.\u003Cspan class=\"hljs-property\">level\u003C/span>] = (levelCounts[heading.\u003Cspan class=\"hljs-property\">level\u003C/span>] || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">avgDepth\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? totalDepth / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">maxDepth\u003C/span> = maxDepth;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">headingDistribution\u003C/span> = levelCounts;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">buildNavigationStructures\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Building site-wide navigation structures...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Build site-wide navigation\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, fileData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fileData.\u003Cspan class=\"hljs-property\">navigationTree\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(filePath, {\n                    \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">extractDocumentTitle\u003C/span>(fileData),\n                    \u003Cspan class=\"hljs-attr\">path\u003C/span>: filePath,\n                    \u003Cspan class=\"hljs-attr\">tree\u003C/span>: fileData.\u003Cspan class=\"hljs-property\">navigationTree\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">headingCount\u003C/span>: fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>\n                });\n            }\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">extractDocumentTitle\u003C/span>(\u003Cspan class=\"hljs-params\">fileData\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Try frontmatter first\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fileData.\u003Cspan class=\"hljs-property\">frontmatter\u003C/span>.\u003Cspan class=\"hljs-property\">title\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> fileData.\u003Cspan class=\"hljs-property\">frontmatter\u003C/span>.\u003Cspan class=\"hljs-property\">title\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Try first H1\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> h1 = fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">find\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> h1.\u003Cspan class=\"hljs-property\">text\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Fall back to filename\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(fileData.\u003Cspan class=\"hljs-property\">path\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[-_]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\b\\w/g\u003C/span>, \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">l\u003C/span> =&gt;\u003C/span> l.\u003Cspan class=\"hljs-title function_\">toUpperCase\u003C/span>());\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateTableOfContents\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileData = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(filePath);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!fileData) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> {\n            minLevel = \u003Cspan class=\"hljs-number\">1\u003C/span>,\n            maxLevel = \u003Cspan class=\"hljs-number\">6\u003C/span>,\n            includeH1 = \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            format = \u003Cspan class=\"hljs-string\">&#x27;markdown&#x27;\u003C/span>,\n            numbering = \u003Cspan class=\"hljs-literal\">false\u003C/span>\n        } = options;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> filteredHeadings = fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> &gt;= minLevel &amp;&amp; h.\u003Cspan class=\"hljs-property\">level\u003C/span> &lt;= maxLevel &amp;&amp; (includeH1 || h.\u003Cspan class=\"hljs-property\">level\u003C/span> &gt; \u003Cspan class=\"hljs-number\">1\u003C/span>);\n        });\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (format === \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateHTMLTableOfContents\u003C/span>(filteredHeadings, numbering);\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateMarkdownTableOfContents\u003C/span>(filteredHeadings, numbering);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateMarkdownTableOfContents\u003C/span>(\u003Cspan class=\"hljs-params\">headings, numbering = \u003Cspan class=\"hljs-literal\">false\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> toc = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> numbers = [\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>]; \u003Cspan class=\"hljs-comment\">// Track numbering for each level\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> indent = \u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>.\u003Cspan class=\"hljs-title function_\">repeat\u003C/span>(heading.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (numbering) {\n                \u003Cspan class=\"hljs-comment\">// Reset deeper level numbers\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = heading.\u003Cspan class=\"hljs-property\">level\u003C/span>; i &lt; numbers.\u003Cspan class=\"hljs-property\">length\u003C/span>; i++) {\n                    numbers[i] = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n                }\n                \n                \u003Cspan class=\"hljs-comment\">// Increment current level\u003C/span>\n                numbers[heading.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>]++;\n                \n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> numberPrefix = numbers.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, heading.\u003Cspan class=\"hljs-property\">level\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">n\u003C/span> =&gt;\u003C/span> n &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>) + \u003Cspan class=\"hljs-string\">&#x27;. &#x27;\u003C/span>;\n                \n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${indent}\u003C/span>- \u003Cspan class=\"hljs-subst\">${numberPrefix}\u003C/span>[\u003Cspan class=\"hljs-subst\">${heading.text}\u003C/span>](#\u003Cspan class=\"hljs-subst\">${heading.anchor}\u003C/span>)`\u003C/span>);\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${indent}\u003C/span>- [\u003Cspan class=\"hljs-subst\">${heading.text}\u003C/span>](#\u003Cspan class=\"hljs-subst\">${heading.anchor}\u003C/span>)`\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> toc.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateHTMLTableOfContents\u003C/span>(\u003Cspan class=\"hljs-params\">headings, numbering = \u003Cspan class=\"hljs-literal\">false\u003C/span>\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (headings.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> toc = [\u003Cspan class=\"hljs-string\">&#x27;&lt;nav class=&quot;table-of-contents&quot;&gt;&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&lt;ol&gt;&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> currentLevel = headings[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">level\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> numbers = [\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> i = \u003Cspan class=\"hljs-number\">0\u003C/span>; i &lt; headings.\u003Cspan class=\"hljs-property\">length\u003C/span>; i++) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> heading = headings[i];\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> nextLevel = i &lt; headings.\u003Cspan class=\"hljs-property\">length\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span> ? headings[i + \u003Cspan class=\"hljs-number\">1\u003C/span>].\u003Cspan class=\"hljs-property\">level\u003C/span> : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            \n            \u003Cspan class=\"hljs-comment\">// Handle level changes\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">while\u003C/span> (currentLevel &lt; heading.\u003Cspan class=\"hljs-property\">level\u003C/span>) {\n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;li&gt;&lt;ol&gt;&#x27;\u003C/span>);\n                currentLevel++;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">while\u003C/span> (currentLevel &gt; heading.\u003Cspan class=\"hljs-property\">level\u003C/span>) {\n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/ol&gt;&lt;/li&gt;&#x27;\u003C/span>);\n                currentLevel--;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Generate numbering if requested\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> numberPrefix = \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (numbering) {\n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">let\u003C/span> j = heading.\u003Cspan class=\"hljs-property\">level\u003C/span>; j &lt; numbers.\u003Cspan class=\"hljs-property\">length\u003C/span>; j++) {\n                    numbers[j] = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n                }\n                numbers[heading.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>]++;\n                numberPrefix = numbers.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, heading.\u003Cspan class=\"hljs-property\">level\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">n\u003C/span> =&gt;\u003C/span> n &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>)\n                    .\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.&#x27;\u003C/span>) + \u003Cspan class=\"hljs-string\">&#x27;. &#x27;\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Add the heading\u003C/span>\n            toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`&lt;li&gt;&lt;a href=&quot;#\u003Cspan class=\"hljs-subst\">${heading.anchor}\u003C/span>&quot;&gt;\u003Cspan class=\"hljs-subst\">${numberPrefix}\u003C/span>\u003Cspan class=\"hljs-subst\">${heading.text}\u003C/span>&lt;/a&gt;`\u003C/span>);\n            \n            \u003Cspan class=\"hljs-comment\">// Check if we need to close this li\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!nextLevel || nextLevel &lt;= heading.\u003Cspan class=\"hljs-property\">level\u003C/span>) {\n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/li&gt;&#x27;\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Close remaining open elements\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">while\u003C/span> (currentLevel &gt; headings[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">level\u003C/span>) {\n            toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/ol&gt;&lt;/li&gt;&#x27;\u003C/span>);\n            currentLevel--;\n        }\n        \n        toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/ol&gt;&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&lt;/nav&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> toc.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateNavigationMenu\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> {\n            format = \u003Cspan class=\"hljs-string\">&#x27;markdown&#x27;\u003C/span>,\n            maxDepth = \u003Cspan class=\"hljs-number\">2\u003C/span>,\n            includeFileNames = \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            sortAlphabetically = \u003Cspan class=\"hljs-literal\">false\u003C/span>\n        } = options;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> menuItems = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, navData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (navData.\u003Cspan class=\"hljs-property\">tree\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">continue\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileName = includeFileNames ? \n                \u003Cspan class=\"hljs-string\">` (\u003Cspan class=\"hljs-subst\">${path.basename(filePath, \u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>)}\u003C/span>)`\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>;\n                \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> item = {\n                \u003Cspan class=\"hljs-attr\">title\u003C/span>: navData.\u003Cspan class=\"hljs-property\">title\u003C/span> + fileName,\n                \u003Cspan class=\"hljs-attr\">path\u003C/span>: filePath,\n                \u003Cspan class=\"hljs-attr\">headings\u003C/span>: navData.\u003Cspan class=\"hljs-property\">tree\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> &lt;= maxDepth)\n            };\n            \n            menuItems.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(item);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (sortAlphabetically) {\n            menuItems.\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> a.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">localeCompare\u003C/span>(b.\u003Cspan class=\"hljs-property\">title\u003C/span>));\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (format === \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateHTMLNavigationMenu\u003C/span>(menuItems);\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateMarkdownNavigationMenu\u003C/span>(menuItems);\n        }\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateMarkdownNavigationMenu\u003C/span>(\u003Cspan class=\"hljs-params\">menuItems\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> menu = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> menuItems) {\n            menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`## [\u003Cspan class=\"hljs-subst\">${item.title}\u003C/span>](\u003Cspan class=\"hljs-subst\">${item.path}\u003C/span>)`\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> item.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> indent = \u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>.\u003Cspan class=\"hljs-title function_\">repeat\u003C/span>(heading.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${indent}\u003C/span>- [\u003Cspan class=\"hljs-subst\">${heading.text}\u003C/span>](\u003Cspan class=\"hljs-subst\">${item.path}\u003C/span>#\u003Cspan class=\"hljs-subst\">${heading.anchor}\u003C/span>)`\u003C/span>);\n            }\n            \n            menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> menu.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateHTMLNavigationMenu\u003C/span>(\u003Cspan class=\"hljs-params\">menuItems\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> menu = [\u003Cspan class=\"hljs-string\">&#x27;&lt;nav class=&quot;site-navigation&quot;&gt;&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&lt;ul class=&quot;nav-list&quot;&gt;&#x27;\u003C/span>];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> menuItems) {\n            menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`&lt;li class=&quot;nav-item&quot;&gt;`\u003C/span>);\n            menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`  &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${item.path}\u003C/span>&quot; class=&quot;nav-title&quot;&gt;\u003Cspan class=\"hljs-subst\">${item.title}\u003C/span>&lt;/a&gt;`\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (item.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;ul class=&quot;nav-sublist&quot;&gt;&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> item.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                    menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`    &lt;li class=&quot;nav-subitem level-\u003Cspan class=\"hljs-subst\">${heading.level}\u003C/span>&quot;&gt;`\u003C/span>);\n                    menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`      &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${item.path}\u003C/span>#\u003Cspan class=\"hljs-subst\">${heading.anchor}\u003C/span>&quot;&gt;\u003Cspan class=\"hljs-subst\">${heading.text}\u003C/span>&lt;/a&gt;`\u003C/span>);\n                    menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;/li&gt;&#x27;\u003C/span>);\n                }\n                \n                menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;/ul&gt;&#x27;\u003C/span>);\n            }\n            \n            menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/li&gt;&#x27;\u003C/span>);\n        }\n        \n        menu.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/ul&gt;&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&lt;/nav&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> menu.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">validateAllHeadings\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Validating heading structures...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> validationResults = {\n            \u003Cspan class=\"hljs-attr\">totalFiles\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">totalIssues\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">issuesByType\u003C/span>: {},\n            \u003Cspan class=\"hljs-attr\">fileIssues\u003C/span>: {},\n            \u003Cspan class=\"hljs-attr\">recommendations\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, fileData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                validationResults.\u003Cspan class=\"hljs-property\">fileIssues\u003C/span>[filePath] = fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>;\n                validationResults.\u003Cspan class=\"hljs-property\">totalIssues\u003C/span> += fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> issue \u003Cspan class=\"hljs-keyword\">of\u003C/span> fileData.\u003Cspan class=\"hljs-property\">issues\u003C/span>) {\n                    validationResults.\u003Cspan class=\"hljs-property\">issuesByType\u003C/span>[issue.\u003Cspan class=\"hljs-property\">type\u003C/span>] = \n                        (validationResults.\u003Cspan class=\"hljs-property\">issuesByType\u003C/span>[issue.\u003Cspan class=\"hljs-property\">type\u003C/span>] || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Generate recommendations\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (validationResults.\u003Cspan class=\"hljs-property\">issuesByType\u003C/span>[\u003Cspan class=\"hljs-string\">&#x27;missing-h1&#x27;\u003C/span>] &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            validationResults.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Add H1 headings to documents for better structure and SEO&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (validationResults.\u003Cspan class=\"hljs-property\">issuesByType\u003C/span>[\u003Cspan class=\"hljs-string\">&#x27;skipped-level&#x27;\u003C/span>] &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            validationResults.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;hierarchy&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>, \n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Fix skipped heading levels to maintain proper document hierarchy&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (validationResults.\u003Cspan class=\"hljs-property\">issuesByType\u003C/span>[\u003Cspan class=\"hljs-string\">&#x27;duplicate-anchor&#x27;\u003C/span>] &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            validationResults.\u003Cspan class=\"hljs-property\">recommendations\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;anchors&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Resolve duplicate anchor IDs to ensure proper link functionality&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> validationResults;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateHeadingAnalytics\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> analytics = {\n            \u003Cspan class=\"hljs-attr\">overview\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalFiles\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">totalHeadings\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageHeadingsPerFile\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageDepth\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">avgDepth\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">maxDepth\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">maxDepth\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">distribution\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">headingDistribution\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">topLevelAnalysis\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">filesWithH1\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">filesWithoutH1\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageH1Length\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">longestH1\u003C/span>: { \u003Cspan class=\"hljs-attr\">text\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">length\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-attr\">file\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span> }\n            },\n            \u003Cspan class=\"hljs-attr\">depthAnalysis\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">shallow\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,  \u003Cspan class=\"hljs-comment\">// 1-2 levels\u003C/span>\n                \u003Cspan class=\"hljs-attr\">medium\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,   \u003Cspan class=\"hljs-comment\">// 3-4 levels  \u003C/span>\n                \u003Cspan class=\"hljs-attr\">deep\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>      \u003Cspan class=\"hljs-comment\">// 5-6 levels\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">anchorAnalysis\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">uniqueAnchors\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">anchorIndex\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">duplicateAnchors\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">duplicateAnchors\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageAnchorLength\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n            }\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalH1Length = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> h1Count = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> totalAnchorLength = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, fileData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> maxLevel = \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">max\u003C/span>(...fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span>));\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (maxLevel &lt;= \u003Cspan class=\"hljs-number\">2\u003C/span>) analytics.\u003Cspan class=\"hljs-property\">depthAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">shallow\u003C/span>++;\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (maxLevel &lt;= \u003Cspan class=\"hljs-number\">4\u003C/span>) analytics.\u003Cspan class=\"hljs-property\">depthAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">medium\u003C/span>++;\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span> analytics.\u003Cspan class=\"hljs-property\">depthAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">deep\u003C/span>++;\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> h1s = fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1s.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                analytics.\u003Cspan class=\"hljs-property\">topLevelAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">filesWithH1\u003C/span>++;\n                \n                \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> h1 \u003Cspan class=\"hljs-keyword\">of\u003C/span> h1s) {\n                    totalH1Length += h1.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                    h1Count++;\n                    \n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; analytics.\u003Cspan class=\"hljs-property\">topLevelAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">longestH1\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>) {\n                        analytics.\u003Cspan class=\"hljs-property\">topLevelAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">longestH1\u003C/span> = {\n                            \u003Cspan class=\"hljs-attr\">text\u003C/span>: h1.\u003Cspan class=\"hljs-property\">text\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">length\u003C/span>: h1.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n                            \u003Cspan class=\"hljs-attr\">file\u003C/span>: filePath\n                        };\n                    }\n                }\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                analytics.\u003Cspan class=\"hljs-property\">topLevelAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">filesWithoutH1\u003C/span>++;\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Analyze anchor lengths\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n                totalAnchorLength += heading.\u003Cspan class=\"hljs-property\">anchor\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            }\n        }\n        \n        analytics.\u003Cspan class=\"hljs-property\">topLevelAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">averageH1Length\u003C/span> = h1Count &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ? \n            \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(totalH1Length / h1Count) : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n            \n        analytics.\u003Cspan class=\"hljs-property\">anchorAnalysis\u003C/span>.\u003Cspan class=\"hljs-property\">averageAnchorLength\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span> ?\n            \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(totalAnchorLength / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span>) : \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> analytics;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">updateHeadingAnchors\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> {\n            format = \u003Cspan class=\"hljs-string\">&#x27;github&#x27;\u003C/span>,\n            addIds = \u003Cspan class=\"hljs-literal\">false\u003C/span>,\n            updateExisting = \u003Cspan class=\"hljs-literal\">false\u003C/span>\n        } = options;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileData = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(filePath);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!fileData) {\n            \u003Cspan class=\"hljs-keyword\">throw\u003C/span> \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Error\u003C/span>(\u003Cspan class=\"hljs-string\">`File not found: \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> updatedContent = fileData.\u003Cspan class=\"hljs-property\">content\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> updates = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Process headings in reverse order to maintain positions\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headings = [...fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>].\u003Cspan class=\"hljs-title function_\">reverse\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-property\">type\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;html&#x27;\u003C/span>) \u003Cspan class=\"hljs-keyword\">continue\u003C/span>; \u003Cspan class=\"hljs-comment\">// Skip HTML headings\u003C/span>\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> newAnchor = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateAnchorId\u003C/span>(heading.\u003Cspan class=\"hljs-property\">text\u003C/span>, format);\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (addIds || (updateExisting &amp;&amp; heading.\u003Cspan class=\"hljs-property\">anchor\u003C/span> !== newAnchor)) {\n                \u003Cspan class=\"hljs-comment\">// Add or update heading ID\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> headingWithId = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${heading.raw}\u003C/span> {#\u003Cspan class=\"hljs-subst\">${newAnchor}\u003C/span>}`\u003C/span>;\n                \n                updatedContent = updatedContent.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, heading.\u003Cspan class=\"hljs-property\">position\u003C/span>) +\n                    headingWithId +\n                    updatedContent.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(heading.\u003Cspan class=\"hljs-property\">position\u003C/span> + heading.\u003Cspan class=\"hljs-property\">raw\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>);\n                \n                updates.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">heading\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">oldAnchor\u003C/span>: heading.\u003Cspan class=\"hljs-property\">anchor\u003C/span>,\n                    newAnchor,\n                    \u003Cspan class=\"hljs-attr\">position\u003C/span>: heading.\u003Cspan class=\"hljs-property\">position\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (updates.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(filePath, updatedContent, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Updated \u003Cspan class=\"hljs-subst\">${updates.length}\u003C/span> heading anchors in \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">updatesApplied\u003C/span>: updates.\u003Cspan class=\"hljs-property\">length\u003C/span>,\n            updates\n        };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateHeadingReport\u003C/span>(\u003Cspan class=\"hljs-params\">\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-attr\">summary\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">filesAnalyzed\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">totalHeadings\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">averageHeadingsPerFile\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">round\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">totalHeadings\u003C/span> / \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>),\n                \u003Cspan class=\"hljs-attr\">headingDistribution\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">stats\u003C/span>.\u003Cspan class=\"hljs-property\">headingDistribution\u003C/span>\n            },\n            \u003Cspan class=\"hljs-attr\">validation\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalIssues\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>())\n                    .\u003Cspan class=\"hljs-title function_\">reduce\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">sum, data\u003C/span>) =&gt;\u003C/span> sum + data.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>)\n            },\n            \u003Cspan class=\"hljs-attr\">navigation\u003C/span>: {\n                \u003Cspan class=\"hljs-attr\">totalDocuments\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span>.\u003Cspan class=\"hljs-property\">size\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">navigableDocuments\u003C/span>: \u003Cspan class=\"hljs-title class_\">Array\u003C/span>.\u003Cspan class=\"hljs-title function_\">from\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span>.\u003Cspan class=\"hljs-title function_\">values\u003C/span>())\n                    .\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">nav\u003C/span> =&gt;\u003C/span> nav.\u003Cspan class=\"hljs-property\">tree\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>\n            }\n        };\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">AdvancedHeadingManager\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch3 id=\"navigation-generation-automation\">Navigation Generation Automation\u003C/h3>\n\u003Cp>Automated navigation system creation and maintenance:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// navigation-generator.js - Automated navigation generation\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">NavigationGenerator\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">headingManager\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span> = headingManager;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">navigationConfigs\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">templateCache\u003C/span> = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateSiteNavigation\u003C/span>(\u003Cspan class=\"hljs-params\">config = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> {\n            outputPath = \u003Cspan class=\"hljs-string\">&#x27;navigation.md&#x27;\u003C/span>,\n            template = \u003Cspan class=\"hljs-string\">&#x27;default&#x27;\u003C/span>,\n            groupBy = \u003Cspan class=\"hljs-string\">&#x27;directory&#x27;\u003C/span>,\n            sortBy = \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>,\n            includeToC = \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            maxDepth = \u003Cspan class=\"hljs-number\">3\u003C/span>\n        } = config;\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Generating site-wide navigation...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Group documents\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> groupedDocs = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">groupDocuments\u003C/span>(groupBy);\n        \n        \u003Cspan class=\"hljs-comment\">// Sort within groups\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedGroups = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">sortDocumentGroups\u003C/span>(groupedDocs, sortBy);\n        \n        \u003Cspan class=\"hljs-comment\">// Generate navigation structure\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> navigation = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildNavigationStructure\u003C/span>(\n            sortedGroups, \n            { includeToC, maxDepth }\n        );\n        \n        \u003Cspan class=\"hljs-comment\">// Apply template\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> output = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">applyNavigationTemplate\u003C/span>(navigation, template);\n        \n        \u003Cspan class=\"hljs-comment\">// Write to file\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(outputPath, output, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Site navigation generated: \u003Cspan class=\"hljs-subst\">${outputPath}\u003C/span>`\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { outputPath, \u003Cspan class=\"hljs-attr\">structure\u003C/span>: navigation };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">groupDocuments\u003C/span>(\u003Cspan class=\"hljs-params\">groupBy\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> groups = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, navData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span>.\u003Cspan class=\"hljs-property\">navigationStructure\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">let\u003C/span> groupKey;\n            \n            \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (groupBy) {\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;directory&#x27;\u003C/span>:\n                    groupKey = path.\u003Cspan class=\"hljs-title function_\">dirname\u003C/span>(filePath);\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;category&#x27;\u003C/span>:\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileData = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(filePath);\n                    groupKey = fileData?.\u003Cspan class=\"hljs-property\">frontmatter\u003C/span>?.\u003Cspan class=\"hljs-property\">category\u003C/span> || \u003Cspan class=\"hljs-string\">&#x27;uncategorized&#x27;\u003C/span>;\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;title-prefix&#x27;\u003C/span>:\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> titleWords = navData.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n                    groupKey = titleWords.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">1\u003C/span> ? titleWords[\u003Cspan class=\"hljs-number\">0\u003C/span>] : \u003Cspan class=\"hljs-string\">&#x27;other&#x27;\u003C/span>;\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>;\n                \u003Cspan class=\"hljs-attr\">default\u003C/span>:\n                    groupKey = \u003Cspan class=\"hljs-string\">&#x27;all&#x27;\u003C/span>;\n            }\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!groups.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(groupKey)) {\n                groups.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(groupKey, []);\n            }\n            \n            groups.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(groupKey).\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                filePath,\n                ...navData\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> groups;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">sortDocumentGroups\u003C/span>(\u003Cspan class=\"hljs-params\">groups, sortBy\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> sorted = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [groupKey, docs] \u003Cspan class=\"hljs-keyword\">of\u003C/span> groups) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> sortedDocs = [...docs].\u003Cspan class=\"hljs-title function_\">sort\u003C/span>(\u003Cspan class=\"hljs-function\">(\u003Cspan class=\"hljs-params\">a, b\u003C/span>) =&gt;\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">switch\u003C/span> (sortBy) {\n                    \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>:\n                        \u003Cspan class=\"hljs-keyword\">return\u003C/span> a.\u003Cspan class=\"hljs-property\">title\u003C/span>.\u003Cspan class=\"hljs-title function_\">localeCompare\u003C/span>(b.\u003Cspan class=\"hljs-property\">title\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;filename&#x27;\u003C/span>:\n                        \u003Cspan class=\"hljs-keyword\">return\u003C/span> path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(a.\u003Cspan class=\"hljs-property\">filePath\u003C/span>).\u003Cspan class=\"hljs-title function_\">localeCompare\u003C/span>(path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(b.\u003Cspan class=\"hljs-property\">filePath\u003C/span>));\n                    \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;modified&#x27;\u003C/span>:\n                        \u003Cspan class=\"hljs-comment\">// Would need to get file stats\u003C/span>\n                        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>;\n                    \u003Cspan class=\"hljs-keyword\">case\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;headingCount&#x27;\u003C/span>:\n                        \u003Cspan class=\"hljs-keyword\">return\u003C/span> b.\u003Cspan class=\"hljs-property\">headingCount\u003C/span> - a.\u003Cspan class=\"hljs-property\">headingCount\u003C/span>;\n                    \u003Cspan class=\"hljs-attr\">default\u003C/span>:\n                        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>;\n                }\n            });\n            \n            sorted.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(groupKey, sortedDocs);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> sorted;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">buildNavigationStructure\u003C/span>(\u003Cspan class=\"hljs-params\">sortedGroups, options\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> structure = {\n            \u003Cspan class=\"hljs-attr\">groups\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">totalDocuments\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">generatedAt\u003C/span>: \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Date\u003C/span>().\u003Cspan class=\"hljs-title function_\">toISOString\u003C/span>()\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [groupKey, docs] \u003Cspan class=\"hljs-keyword\">of\u003C/span> sortedGroups) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> group = {\n                \u003Cspan class=\"hljs-attr\">name\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">formatGroupName\u003C/span>(groupKey),\n                \u003Cspan class=\"hljs-attr\">key\u003C/span>: groupKey,\n                \u003Cspan class=\"hljs-attr\">documents\u003C/span>: []\n            };\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> docs) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> docEntry = {\n                    \u003Cspan class=\"hljs-attr\">title\u003C/span>: doc.\u003Cspan class=\"hljs-property\">title\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">path\u003C/span>: doc.\u003Cspan class=\"hljs-property\">filePath\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">relativePath\u003C/span>: path.\u003Cspan class=\"hljs-title function_\">relative\u003C/span>(process.\u003Cspan class=\"hljs-title function_\">cwd\u003C/span>(), doc.\u003Cspan class=\"hljs-property\">filePath\u003C/span>),\n                    \u003Cspan class=\"hljs-attr\">headingCount\u003C/span>: doc.\u003Cspan class=\"hljs-property\">headingCount\u003C/span>\n                };\n                \n                \u003Cspan class=\"hljs-comment\">// Add table of contents if requested\u003C/span>\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (options.\u003Cspan class=\"hljs-property\">includeToC\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">tree\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    docEntry.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">buildDocumentToC\u003C/span>(\n                        doc.\u003Cspan class=\"hljs-property\">tree\u003C/span>, \n                        options.\u003Cspan class=\"hljs-property\">maxDepth\u003C/span>\n                    );\n                }\n                \n                group.\u003Cspan class=\"hljs-property\">documents\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(docEntry);\n                structure.\u003Cspan class=\"hljs-property\">totalDocuments\u003C/span>++;\n            }\n            \n            structure.\u003Cspan class=\"hljs-property\">groups\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(group);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> structure;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">formatGroupName\u003C/span>(\u003Cspan class=\"hljs-params\">groupKey\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (groupKey === \u003Cspan class=\"hljs-string\">&#x27;all&#x27;\u003C/span> || groupKey === \u003Cspan class=\"hljs-string\">&#x27;uncategorized&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> groupKey.\u003Cspan class=\"hljs-title function_\">charAt\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>).\u003Cspan class=\"hljs-title function_\">toUpperCase\u003C/span>() + groupKey.\u003Cspan class=\"hljs-title function_\">slice\u003C/span>(\u003Cspan class=\"hljs-number\">1\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Format directory paths\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (groupKey.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;/&#x27;\u003C/span>) || groupKey.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\\\&#x27;\u003C/span>)) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> path.\u003Cspan class=\"hljs-title function_\">basename\u003C/span>(groupKey)\n                .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[-_]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n                .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\b\\w/g\u003C/span>, \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">l\u003C/span> =&gt;\u003C/span> l.\u003Cspan class=\"hljs-title function_\">toUpperCase\u003C/span>());\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Format other keys\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> groupKey\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[-_]/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>)\n            .\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\b\\w/g\u003C/span>, \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">l\u003C/span> =&gt;\u003C/span> l.\u003Cspan class=\"hljs-title function_\">toUpperCase\u003C/span>());\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">buildDocumentToC\u003C/span>(\u003Cspan class=\"hljs-params\">headingTree, maxDepth\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> toc = [];\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> \u003Cspan class=\"hljs-title function_\">processHeadings\u003C/span> = (\u003Cspan class=\"hljs-params\">headings, currentDepth = \u003Cspan class=\"hljs-number\">1\u003C/span>\u003C/span>) =&gt; {\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (currentDepth &gt; maxDepth) \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n                toc.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">level\u003C/span>: heading.\u003Cspan class=\"hljs-property\">level\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">text\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">anchor\u003C/span>: heading.\u003Cspan class=\"hljs-property\">anchor\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">depth\u003C/span>: currentDepth\n                });\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-property\">children\u003C/span> &amp;&amp; heading.\u003Cspan class=\"hljs-property\">children\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-title function_\">processHeadings\u003C/span>(heading.\u003Cspan class=\"hljs-property\">children\u003C/span>, currentDepth + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                }\n            }\n        };\n        \n        \u003Cspan class=\"hljs-title function_\">processHeadings\u003C/span>(headingTree);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> toc;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">applyNavigationTemplate\u003C/span>(\u003Cspan class=\"hljs-params\">structure, templateName\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> template = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">loadNavigationTemplate\u003C/span>(templateName);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-keyword\">typeof\u003C/span> template === \u003Cspan class=\"hljs-string\">&#x27;function&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-title function_\">template\u003C/span>(structure);\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-keyword\">typeof\u003C/span> template === \u003Cspan class=\"hljs-string\">&#x27;string&#x27;\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">processTemplate\u003C/span>(template, structure);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Default template\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateDefaultNavigationMarkdown\u003C/span>(structure);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">loadNavigationTemplate\u003C/span>(\u003Cspan class=\"hljs-params\">templateName\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">templateCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(templateName)) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">templateCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(templateName);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> templates = {\n            \u003Cspan class=\"hljs-attr\">default\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">generateDefaultNavigationMarkdown\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">sidebar\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">generateSidebarNavigation\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">dropdown\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">generateDropdownNavigation\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">breadcrumb\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">generateBreadcrumbNavigation\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>),\n            \u003Cspan class=\"hljs-attr\">sitemap\u003C/span>: \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">generateSitemapNavigation\u003C/span>.\u003Cspan class=\"hljs-title function_\">bind\u003C/span>(\u003Cspan class=\"hljs-variable language_\">this\u003C/span>)\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> template = templates[templateName] || templates.\u003Cspan class=\"hljs-property\">default\u003C/span>;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">templateCache\u003C/span>.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(templateName, template);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> template;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateDefaultNavigationMarkdown\u003C/span>(\u003Cspan class=\"hljs-params\">structure\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = [];\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;# Site Navigation&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`Generated on \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-built_in\">Date\u003C/span>(structure.generatedAt).toLocaleString()}\u003C/span>`\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`Total documents: \u003Cspan class=\"hljs-subst\">${structure.totalDocuments}\u003C/span>`\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> group \u003Cspan class=\"hljs-keyword\">of\u003C/span> structure.\u003Cspan class=\"hljs-property\">groups\u003C/span>) {\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`## \u003Cspan class=\"hljs-subst\">${group.name}\u003C/span>`\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> group.\u003Cspan class=\"hljs-property\">documents\u003C/span>) {\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`### [\u003Cspan class=\"hljs-subst\">${doc.title}\u003C/span>](\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>)`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> indent = \u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>.\u003Cspan class=\"hljs-title function_\">repeat\u003C/span>(item.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${indent}\u003C/span>- [\u003Cspan class=\"hljs-subst\">${item.text}\u003C/span>](\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>#\u003Cspan class=\"hljs-subst\">${item.anchor}\u003C/span>)`\u003C/span>);\n                    }\n                    lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateSidebarNavigation\u003C/span>(\u003Cspan class=\"hljs-params\">structure\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = [];\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;!-- Sidebar Navigation --&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;nav class=&quot;sidebar-nav&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;div class=&quot;nav-header&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;h2&gt;Documentation&lt;/h2&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;/div&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> group \u003Cspan class=\"hljs-keyword\">of\u003C/span> structure.\u003Cspan class=\"hljs-property\">groups\u003C/span>) {\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;div class=&quot;nav-group&quot;&gt;&#x27;\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`    &lt;h3 class=&quot;nav-group-title&quot;&gt;\u003Cspan class=\"hljs-subst\">${group.name}\u003C/span>&lt;/h3&gt;`\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;ul class=&quot;nav-list&quot;&gt;&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> group.\u003Cspan class=\"hljs-property\">documents\u003C/span>) {\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`      &lt;li class=&quot;nav-item&quot;&gt;`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`        &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>&quot; class=&quot;nav-link&quot;&gt;`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`          \u003Cspan class=\"hljs-subst\">${doc.title}\u003C/span>`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`        &lt;/a&gt;`\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;        &lt;ul class=&quot;nav-sublist&quot;&gt;&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>) {\n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (item.\u003Cspan class=\"hljs-property\">level\u003C/span> &lt;= \u003Cspan class=\"hljs-number\">3\u003C/span>) { \u003Cspan class=\"hljs-comment\">// Limit depth in sidebar\u003C/span>\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`          &lt;li class=&quot;nav-subitem level-\u003Cspan class=\"hljs-subst\">${item.level}\u003C/span>&quot;&gt;`\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`            &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>#\u003Cspan class=\"hljs-subst\">${item.anchor}\u003C/span>&quot; class=&quot;nav-sublink&quot;&gt;`\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`              \u003Cspan class=\"hljs-subst\">${item.text}\u003C/span>`\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;            &lt;/a&gt;&#x27;\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;          &lt;/li&gt;&#x27;\u003C/span>);\n                        }\n                    }\n                    lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;        &lt;/ul&gt;&#x27;\u003C/span>);\n                }\n                \n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;      &lt;/li&gt;&#x27;\u003C/span>);\n            }\n            \n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;/ul&gt;&#x27;\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;/div&gt;&#x27;\u003C/span>);\n        }\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/nav&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateDropdownNavigation\u003C/span>(\u003Cspan class=\"hljs-params\">structure\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = [];\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;!-- Dropdown Navigation --&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;nav class=&quot;dropdown-nav&quot;&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> group \u003Cspan class=\"hljs-keyword\">of\u003C/span> structure.\u003Cspan class=\"hljs-property\">groups\u003C/span>) {\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;div class=&quot;dropdown&quot;&gt;&#x27;\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`    &lt;button class=&quot;dropdown-toggle&quot;&gt;\u003Cspan class=\"hljs-subst\">${group.name}\u003C/span>&lt;/button&gt;`\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;div class=&quot;dropdown-menu&quot;&gt;&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> group.\u003Cspan class=\"hljs-property\">documents\u003C/span>) {\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`      &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>&quot; class=&quot;dropdown-item&quot;&gt;`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`        \u003Cspan class=\"hljs-subst\">${doc.title}\u003C/span>`\u003C/span>);\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;      &lt;/a&gt;&#x27;\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>) {\n                        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (item.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">2\u003C/span>) { \u003Cspan class=\"hljs-comment\">// Show only H2s in dropdown\u003C/span>\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`      &lt;a href=&quot;\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>#\u003Cspan class=\"hljs-subst\">${item.anchor}\u003C/span>&quot; class=&quot;dropdown-subitem&quot;&gt;`\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`        \u003Cspan class=\"hljs-subst\">${item.text}\u003C/span>`\u003C/span>);\n                            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;      &lt;/a&gt;&#x27;\u003C/span>);\n                        }\n                    }\n                }\n            }\n            \n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;/div&gt;&#x27;\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;/div&gt;&#x27;\u003C/span>);\n        }\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/nav&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateBreadcrumbNavigation\u003C/span>(\u003Cspan class=\"hljs-params\">structure\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = [];\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;!-- Breadcrumb Navigation Template --&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;nav aria-label=&quot;Breadcrumb&quot; class=&quot;breadcrumb-nav&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;ol class=&quot;breadcrumb&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;li class=&quot;breadcrumb-item&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;      &lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;/li&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// This would be dynamically filled based on current page\u003C/span>\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;!-- Dynamic breadcrumb items --&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;li class=&quot;breadcrumb-item active&quot; aria-current=&quot;page&quot;&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;      Current Page&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;    &lt;/li&gt;&#x27;\u003C/span>);\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &lt;/ol&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/nav&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Add JavaScript for dynamic breadcrumb generation\u003C/span>\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;script&gt;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;// Dynamic breadcrumb generation&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;function generateBreadcrumb() {&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  const currentPath = window.location.pathname;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  const pathSegments = currentPath.split(&quot;/&quot;).filter(segment =&gt; segment);&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  // Build breadcrumb based on site structure&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`  const siteStructure = \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-built_in\">JSON\u003C/span>.stringify(structure, \u003Cspan class=\"hljs-literal\">null\u003C/span>, \u003Cspan class=\"hljs-number\">2\u003C/span>)}\u003C/span>;`\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  // Implementation would match current path to structure&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;  // and build appropriate breadcrumb&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;}&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&lt;/script&gt;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateSitemapNavigation\u003C/span>(\u003Cspan class=\"hljs-params\">structure\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lines = [];\n        \n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;# Site Map&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`Last updated: \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-built_in\">Date\u003C/span>().toLocaleString()}\u003C/span>`\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`Total pages: \u003Cspan class=\"hljs-subst\">${structure.totalDocuments}\u003C/span>`\u003C/span>);\n        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Hierarchical sitemap\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> group \u003Cspan class=\"hljs-keyword\">of\u003C/span> structure.\u003Cspan class=\"hljs-property\">groups\u003C/span>) {\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`## \u003Cspan class=\"hljs-subst\">${group.name}\u003C/span> (\u003Cspan class=\"hljs-subst\">${group.documents.length}\u003C/span> pages)`\u003C/span>);\n            lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> doc \u003Cspan class=\"hljs-keyword\">of\u003C/span> group.\u003Cspan class=\"hljs-property\">documents\u003C/span>) {\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`- **[\u003Cspan class=\"hljs-subst\">${doc.title}\u003C/span>](\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>)**`\u003C/span>);\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span> &amp;&amp; doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> item \u003Cspan class=\"hljs-keyword\">of\u003C/span> doc.\u003Cspan class=\"hljs-property\">tableOfContents\u003C/span>) {\n                        \u003Cspan class=\"hljs-keyword\">const\u003C/span> indent = \u003Cspan class=\"hljs-string\">&#x27;  &#x27;\u003C/span>.\u003Cspan class=\"hljs-title function_\">repeat\u003C/span>(item.\u003Cspan class=\"hljs-property\">level\u003C/span> - \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                        lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">`  \u003Cspan class=\"hljs-subst\">${indent}\u003C/span>- [\u003Cspan class=\"hljs-subst\">${item.text}\u003C/span>](\u003Cspan class=\"hljs-subst\">${doc.relativePath}\u003C/span>#\u003Cspan class=\"hljs-subst\">${item.anchor}\u003C/span>)`\u003C/span>);\n                    }\n                }\n                lines.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> lines.\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>);\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">generateToCForAllFiles\u003C/span>(\u003Cspan class=\"hljs-params\">options = {}\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> {\n            outputFormat = \u003Cspan class=\"hljs-string\">&#x27;markdown&#x27;\u003C/span>,\n            inPlace = \u003Cspan class=\"hljs-literal\">true\u003C/span>,\n            tocMarker = \u003Cspan class=\"hljs-string\">&#x27;&lt;!-- TOC --&gt;&#x27;\u003C/span>,\n            tocEndMarker = \u003Cspan class=\"hljs-string\">&#x27;&lt;!-- /TOC --&gt;&#x27;\u003C/span>,\n            ...tocOptions\n        } = options;\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;Generating table of contents for all files...&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> results = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> [filePath, fileData] \u003Cspan class=\"hljs-keyword\">of\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span> {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> toc = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateTableOfContents\u003C/span>(\n                    filePath, \n                    { \u003Cspan class=\"hljs-attr\">format\u003C/span>: outputFormat, ...tocOptions }\n                );\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!toc) \u003Cspan class=\"hljs-keyword\">continue\u003C/span>;\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (inPlace) {\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">insertToCInFile\u003C/span>(filePath, toc, tocMarker, tocEndMarker);\n                    results.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">file\u003C/span>: filePath,\n                        \u003Cspan class=\"hljs-attr\">status\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;updated&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">tocLength\u003C/span>: toc.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>\n                    });\n                } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                    \u003Cspan class=\"hljs-keyword\">const\u003C/span> tocFile = filePath.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;.md&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;-toc.md&#x27;\u003C/span>);\n                    \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(tocFile, toc, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n                    results.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                        \u003Cspan class=\"hljs-attr\">file\u003C/span>: filePath,\n                        tocFile,\n                        \u003Cspan class=\"hljs-attr\">status\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;generated&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-attr\">tocLength\u003C/span>: toc.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>\n                    });\n                }\n                \n            } \u003Cspan class=\"hljs-keyword\">catch\u003C/span> (error) {\n                \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">error\u003C/span>(\u003Cspan class=\"hljs-string\">`Error generating ToC for \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>: \u003Cspan class=\"hljs-subst\">${error.message}\u003C/span>`\u003C/span>);\n                results.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">file\u003C/span>: filePath,\n                    \u003Cspan class=\"hljs-attr\">status\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">error\u003C/span>: error.\u003Cspan class=\"hljs-property\">message\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">log\u003C/span>(\u003Cspan class=\"hljs-string\">`Generated ToC for \u003Cspan class=\"hljs-subst\">${results.filter(r =&gt; r.status !== \u003Cspan class=\"hljs-string\">&#x27;error&#x27;\u003C/span>).length}\u003C/span> files`\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> results;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">insertToCInFile\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, toc, tocMarker, tocEndMarker\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> content = \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">readFile\u003C/span>(filePath, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> startIndex = content.\u003Cspan class=\"hljs-title function_\">indexOf\u003C/span>(tocMarker);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> endIndex = content.\u003Cspan class=\"hljs-title function_\">indexOf\u003C/span>(tocEndMarker);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (startIndex === -\u003Cspan class=\"hljs-number\">1\u003C/span>) {\n            \u003Cspan class=\"hljs-comment\">// No ToC marker found - insert after first heading\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> firstHeadingMatch = content.\u003Cspan class=\"hljs-title function_\">match\u003C/span>(\u003Cspan class=\"hljs-regexp\">/^#{1,6}\\s+.+$/m\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (firstHeadingMatch) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> insertPoint = firstHeadingMatch.\u003Cspan class=\"hljs-property\">index\u003C/span> + firstHeadingMatch[\u003Cspan class=\"hljs-number\">0\u003C/span>].\u003Cspan class=\"hljs-property\">length\u003C/span>;\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> updatedContent = content.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, insertPoint) + \n                    \u003Cspan class=\"hljs-string\">&#x27;\\n\\n&#x27;\u003C/span> + tocMarker + \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span> + toc + \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span> + tocEndMarker + \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span> + \n                    content.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(insertPoint);\n                    \n                \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(filePath, updatedContent, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n            }\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (endIndex === -\u003Cspan class=\"hljs-number\">1\u003C/span> || endIndex &lt;= startIndex) {\n            \u003Cspan class=\"hljs-variable language_\">console\u003C/span>.\u003Cspan class=\"hljs-title function_\">warn\u003C/span>(\u003Cspan class=\"hljs-string\">`Invalid ToC markers in \u003Cspan class=\"hljs-subst\">${filePath}\u003C/span>`\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Replace existing ToC\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> before = content.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, startIndex + tocMarker.\u003Cspan class=\"hljs-property\">length\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> after = content.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(endIndex);\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> updatedContent = before + \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span> + toc + \u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span> + after;\n        \n        \u003Cspan class=\"hljs-keyword\">await\u003C/span> fs.\u003Cspan class=\"hljs-title function_\">writeFile\u003C/span>(filePath, updatedContent, \u003Cspan class=\"hljs-string\">&#x27;utf8&#x27;\u003C/span>);\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">NavigationGenerator\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"integration-with-documentation-workflows\">Integration with Documentation Workflows\u003C/h2>\n\u003Ch3 id=\"heading-based-content-management\">Heading-Based Content Management\u003C/h3>\n\u003Cp>Creating content management systems driven by heading structure:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-python\">\u003Cspan class=\"hljs-comment\"># heading-content-manager.py - Content management based on heading structure\u003C/span>\n\u003Cspan class=\"hljs-keyword\">import\u003C/span> re\n\u003Cspan class=\"hljs-keyword\">import\u003C/span> os\n\u003Cspan class=\"hljs-keyword\">import\u003C/span> json\n\u003Cspan class=\"hljs-keyword\">import\u003C/span> yaml\n\u003Cspan class=\"hljs-keyword\">from\u003C/span> pathlib \u003Cspan class=\"hljs-keyword\">import\u003C/span> Path\n\u003Cspan class=\"hljs-keyword\">from\u003C/span> typing \u003Cspan class=\"hljs-keyword\">import\u003C/span> \u003Cspan class=\"hljs-type\">Dict\u003C/span>, \u003Cspan class=\"hljs-type\">List\u003C/span>, \u003Cspan class=\"hljs-type\">Optional\u003C/span>, \u003Cspan class=\"hljs-type\">Tuple\u003C/span>\n\u003Cspan class=\"hljs-keyword\">from\u003C/span> dataclasses \u003Cspan class=\"hljs-keyword\">import\u003C/span> dataclass\n\u003Cspan class=\"hljs-keyword\">from\u003C/span> datetime \u003Cspan class=\"hljs-keyword\">import\u003C/span> datetime\n\n\u003Cspan class=\"hljs-meta\">@dataclass\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">HeadingNode\u003C/span>:\n    level: \u003Cspan class=\"hljs-built_in\">int\u003C/span>\n    text: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\n    anchor: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\n    content: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\n    line_number: \u003Cspan class=\"hljs-built_in\">int\u003C/span>\n    children: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-string\">&#x27;HeadingNode&#x27;\u003C/span>]\n    metadata: \u003Cspan class=\"hljs-type\">Dict\u003C/span>\n\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">HeadingContentManager\u003C/span>:\n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">__init__\u003C/span>(\u003Cspan class=\"hljs-params\">self, content_dir: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>):\n        self.content_dir = Path(content_dir)\n        self.heading_pattern = re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^(#{1,6})\\s+(.+)$&#x27;\u003C/span>, re.MULTILINE)\n        self.frontmatter_pattern = re.\u003Cspan class=\"hljs-built_in\">compile\u003C/span>(\u003Cspan class=\"hljs-string\">r&#x27;^---\\n(.*?)\\n---\\n&#x27;\u003C/span>, re.DOTALL)\n        \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">analyze_document_structure\u003C/span>(\u003Cspan class=\"hljs-params\">self, file_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Analyze document structure and extract hierarchical content&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">with\u003C/span> \u003Cspan class=\"hljs-built_in\">open\u003C/span>(file_path, \u003Cspan class=\"hljs-string\">&#x27;r&#x27;\u003C/span>, encoding=\u003Cspan class=\"hljs-string\">&#x27;utf-8&#x27;\u003C/span>) \u003Cspan class=\"hljs-keyword\">as\u003C/span> f:\n            content = f.read()\n        \n        \u003Cspan class=\"hljs-comment\"># Extract frontmatter\u003C/span>\n        frontmatter = {}\n        fm_match = self.frontmatter_pattern.\u003Cspan class=\"hljs-keyword\">match\u003C/span>(content)\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> fm_match:\n            \u003Cspan class=\"hljs-keyword\">try\u003C/span>:\n                frontmatter = yaml.safe_load(fm_match.group(\u003Cspan class=\"hljs-number\">1\u003C/span>))\n                content = content[fm_match.end():]\n            \u003Cspan class=\"hljs-keyword\">except\u003C/span> yaml.YAMLError:\n                \u003Cspan class=\"hljs-keyword\">pass\u003C/span>\n        \n        \u003Cspan class=\"hljs-comment\"># Extract headings and build hierarchy\u003C/span>\n        headings = self._extract_headings(content)\n        hierarchy = self._build_heading_hierarchy(headings, content)\n        \n        \u003Cspan class=\"hljs-comment\"># Analyze content sections\u003C/span>\n        sections = self._extract_sections(hierarchy, content)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-string\">&#x27;file_path&#x27;\u003C/span>: file_path,\n            \u003Cspan class=\"hljs-string\">&#x27;frontmatter&#x27;\u003C/span>: frontmatter,\n            \u003Cspan class=\"hljs-string\">&#x27;hierarchy&#x27;\u003C/span>: hierarchy,\n            \u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>: sections,\n            \u003Cspan class=\"hljs-string\">&#x27;statistics&#x27;\u003C/span>: self._calculate_section_stats(sections)\n        }\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_extract_headings\u003C/span>(\u003Cspan class=\"hljs-params\">self, content: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Extract all headings with positions&quot;&quot;&quot;\u003C/span>\n        headings = []\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> \u003Cspan class=\"hljs-keyword\">match\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> self.heading_pattern.finditer(content):\n            level = \u003Cspan class=\"hljs-built_in\">len\u003C/span>(\u003Cspan class=\"hljs-keyword\">match\u003C/span>.group(\u003Cspan class=\"hljs-number\">1\u003C/span>))\n            text = \u003Cspan class=\"hljs-keyword\">match\u003C/span>.group(\u003Cspan class=\"hljs-number\">2\u003C/span>).strip()\n            anchor = self._generate_anchor_id(text)\n            line_number = content[:\u003Cspan class=\"hljs-keyword\">match\u003C/span>.start()].count(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n            \n            headings.append({\n                \u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>: level,\n                \u003Cspan class=\"hljs-string\">&#x27;text&#x27;\u003C/span>: text,\n                \u003Cspan class=\"hljs-string\">&#x27;anchor&#x27;\u003C/span>: anchor,\n                \u003Cspan class=\"hljs-string\">&#x27;position&#x27;\u003C/span>: \u003Cspan class=\"hljs-keyword\">match\u003C/span>.start(),\n                \u003Cspan class=\"hljs-string\">&#x27;end_position&#x27;\u003C/span>: \u003Cspan class=\"hljs-keyword\">match\u003C/span>.end(),\n                \u003Cspan class=\"hljs-string\">&#x27;line_number&#x27;\u003C/span>: line_number,\n                \u003Cspan class=\"hljs-string\">&#x27;raw&#x27;\u003C/span>: \u003Cspan class=\"hljs-keyword\">match\u003C/span>.group(\u003Cspan class=\"hljs-number\">0\u003C/span>)\n            })\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> headings\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_generate_anchor_id\u003C/span>(\u003Cspan class=\"hljs-params\">self, text: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">str\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Generate GitHub-style anchor ID&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> re.sub(\u003Cspan class=\"hljs-string\">r&#x27;[^\\w\\s-]&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>, text.lower()).replace(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;-&#x27;\u003C/span>)\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_build_heading_hierarchy\u003C/span>(\u003Cspan class=\"hljs-params\">self, headings: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>], content: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[HeadingNode]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Build hierarchical structure of headings&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> headings:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> []\n        \n        root_nodes = []\n        stack = []\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> i, heading \u003Cspan class=\"hljs-keyword\">in\u003C/span> \u003Cspan class=\"hljs-built_in\">enumerate\u003C/span>(headings):\n            \u003Cspan class=\"hljs-comment\"># Extract content for this heading\u003C/span>\n            start_pos = heading[\u003Cspan class=\"hljs-string\">&#x27;end_position&#x27;\u003C/span>]\n            end_pos = headings[i + \u003Cspan class=\"hljs-number\">1\u003C/span>][\u003Cspan class=\"hljs-string\">&#x27;position&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">if\u003C/span> i + \u003Cspan class=\"hljs-number\">1\u003C/span> &lt; \u003Cspan class=\"hljs-built_in\">len\u003C/span>(headings) \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-built_in\">len\u003C/span>(content)\n            heading_content = content[start_pos:end_pos].strip()\n            \n            node = HeadingNode(\n                level=heading[\u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>],\n                text=heading[\u003Cspan class=\"hljs-string\">&#x27;text&#x27;\u003C/span>],\n                anchor=heading[\u003Cspan class=\"hljs-string\">&#x27;anchor&#x27;\u003C/span>],\n                content=heading_content,\n                line_number=heading[\u003Cspan class=\"hljs-string\">&#x27;line_number&#x27;\u003C/span>],\n                children=[],\n                metadata={}\n            )\n            \n            \u003Cspan class=\"hljs-comment\"># Find appropriate parent\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">while\u003C/span> stack \u003Cspan class=\"hljs-keyword\">and\u003C/span> stack[-\u003Cspan class=\"hljs-number\">1\u003C/span>].level &gt;= node.level:\n                stack.pop()\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> stack:\n                stack[-\u003Cspan class=\"hljs-number\">1\u003C/span>].children.append(node)\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                root_nodes.append(node)\n            \n            stack.append(node)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> root_nodes\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_extract_sections\u003C/span>(\u003Cspan class=\"hljs-params\">self, hierarchy: \u003Cspan class=\"hljs-type\">List\u003C/span>[HeadingNode], content: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Extract content sections with metadata&quot;&quot;&quot;\u003C/span>\n        sections = []\n        \n        \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">process_node\u003C/span>(\u003Cspan class=\"hljs-params\">node: HeadingNode, parent_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span> = \u003Cspan class=\"hljs-string\">&quot;&quot;\u003C/span>\u003C/span>):\n            path = \u003Cspan class=\"hljs-string\">f&quot;\u003Cspan class=\"hljs-subst\">{parent_path}\u003C/span>/\u003Cspan class=\"hljs-subst\">{node.anchor}\u003C/span>&quot;\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> parent_path \u003Cspan class=\"hljs-keyword\">else\u003C/span> node.anchor\n            \n            section = {\n                \u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>: path,\n                \u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>: node.level,\n                \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>: node.text,\n                \u003Cspan class=\"hljs-string\">&#x27;anchor&#x27;\u003C/span>: node.anchor,\n                \u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>: node.content,\n                \u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>(node.content.split()),\n                \u003Cspan class=\"hljs-string\">&#x27;line_count&#x27;\u003C/span>: node.content.count(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>),\n                \u003Cspan class=\"hljs-string\">&#x27;has_code_blocks&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;```&#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> node.content,\n                \u003Cspan class=\"hljs-string\">&#x27;has_links&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;[&#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> node.content \u003Cspan class=\"hljs-keyword\">and\u003C/span> \u003Cspan class=\"hljs-string\">&#x27;](&#x27;\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> node.content,\n                \u003Cspan class=\"hljs-string\">&#x27;children_count&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>(node.children),\n                \u003Cspan class=\"hljs-string\">&#x27;metadata&#x27;\u003C/span>: node.metadata\n            }\n            \n            sections.append(section)\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> child \u003Cspan class=\"hljs-keyword\">in\u003C/span> node.children:\n                process_node(child, path)\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> root_node \u003Cspan class=\"hljs-keyword\">in\u003C/span> hierarchy:\n            process_node(root_node)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> sections\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_calculate_section_stats\u003C/span>(\u003Cspan class=\"hljs-params\">self, sections: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Calculate statistics for document sections&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> sections:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {}\n        \n        total_words = \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections)\n        total_lines = \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(s[\u003Cspan class=\"hljs-string\">&#x27;line_count&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections)\n        \n        level_counts = {}\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> section \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections:\n            level = section[\u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>]\n            level_counts[level] = level_counts.get(level, \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-string\">&#x27;total_sections&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">len\u003C/span>(sections),\n            \u003Cspan class=\"hljs-string\">&#x27;total_words&#x27;\u003C/span>: total_words,\n            \u003Cspan class=\"hljs-string\">&#x27;total_lines&#x27;\u003C/span>: total_lines,\n            \u003Cspan class=\"hljs-string\">&#x27;average_words_per_section&#x27;\u003C/span>: total_words / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(sections),\n            \u003Cspan class=\"hljs-string\">&#x27;average_lines_per_section&#x27;\u003C/span>: total_lines / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(sections),\n            \u003Cspan class=\"hljs-string\">&#x27;level_distribution&#x27;\u003C/span>: level_counts,\n            \u003Cspan class=\"hljs-string\">&#x27;sections_with_code&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(\u003Cspan class=\"hljs-number\">1\u003C/span> \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;has_code_blocks&#x27;\u003C/span>]),\n            \u003Cspan class=\"hljs-string\">&#x27;sections_with_links&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(\u003Cspan class=\"hljs-number\">1\u003C/span> \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;has_links&#x27;\u003C/span>])\n        }\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">extract_section_content\u003C/span>(\u003Cspan class=\"hljs-params\">self, file_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, section_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Optional\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Extract content from a specific section&quot;&quot;&quot;\u003C/span>\n        analysis = self.analyze_document_structure(file_path)\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> section \u003Cspan class=\"hljs-keyword\">in\u003C/span> analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>]:\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> section[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] == section_path:\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> section[\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>]\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">None\u003C/span>\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">update_section_content\u003C/span>(\u003Cspan class=\"hljs-params\">self, file_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, section_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, new_content: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">bool\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Update content in a specific section&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">with\u003C/span> \u003Cspan class=\"hljs-built_in\">open\u003C/span>(file_path, \u003Cspan class=\"hljs-string\">&#x27;r&#x27;\u003C/span>, encoding=\u003Cspan class=\"hljs-string\">&#x27;utf-8&#x27;\u003C/span>) \u003Cspan class=\"hljs-keyword\">as\u003C/span> f:\n                content = f.read()\n            \n            analysis = self.analyze_document_structure(file_path)\n            target_section = \u003Cspan class=\"hljs-literal\">None\u003C/span>\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> section \u003Cspan class=\"hljs-keyword\">in\u003C/span> analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>]:\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> section[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] == section_path:\n                    target_section = section\n                    \u003Cspan class=\"hljs-keyword\">break\u003C/span>\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> target_section:\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">False\u003C/span>\n            \n            \u003Cspan class=\"hljs-comment\"># Find the section in the original content and replace\u003C/span>\n            \u003Cspan class=\"hljs-comment\"># This is a simplified approach - would need more sophisticated handling\u003C/span>\n            updated_content = content.replace(target_section[\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>], new_content)\n            \n            \u003Cspan class=\"hljs-keyword\">with\u003C/span> \u003Cspan class=\"hljs-built_in\">open\u003C/span>(file_path, \u003Cspan class=\"hljs-string\">&#x27;w&#x27;\u003C/span>, encoding=\u003Cspan class=\"hljs-string\">&#x27;utf-8&#x27;\u003C/span>) \u003Cspan class=\"hljs-keyword\">as\u003C/span> f:\n                f.write(updated_content)\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">True\u003C/span>\n            \n        \u003Cspan class=\"hljs-keyword\">except\u003C/span> Exception \u003Cspan class=\"hljs-keyword\">as\u003C/span> e:\n            \u003Cspan class=\"hljs-built_in\">print\u003C/span>(\u003Cspan class=\"hljs-string\">f&quot;Error updating section: \u003Cspan class=\"hljs-subst\">{e}\u003C/span>&quot;\u003C/span>)\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">False\u003C/span>\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">reorganize_document_structure\u003C/span>(\u003Cspan class=\"hljs-params\">self, file_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>, new_structure: \u003Cspan class=\"hljs-type\">Dict\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">bool\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Reorganize document based on new heading structure&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">try\u003C/span>:\n            analysis = self.analyze_document_structure(file_path)\n            \n            \u003Cspan class=\"hljs-comment\"># Build new content based on structure specification\u003C/span>\n            new_content_parts = []\n            \n            \u003Cspan class=\"hljs-comment\"># Preserve frontmatter\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> analysis[\u003Cspan class=\"hljs-string\">&#x27;frontmatter&#x27;\u003C/span>]:\n                new_content_parts.append(\u003Cspan class=\"hljs-string\">&#x27;---&#x27;\u003C/span>)\n                new_content_parts.append(yaml.dump(analysis[\u003Cspan class=\"hljs-string\">&#x27;frontmatter&#x27;\u003C/span>], default_flow_style=\u003Cspan class=\"hljs-literal\">False\u003C/span>))\n                new_content_parts.append(\u003Cspan class=\"hljs-string\">&#x27;---&#x27;\u003C/span>)\n                new_content_parts.append(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \n            \u003Cspan class=\"hljs-comment\"># Rebuild content according to new structure\u003C/span>\n            self._build_restructured_content(\n                new_structure, \n                analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>], \n                new_content_parts\n            )\n            \n            \u003Cspan class=\"hljs-comment\"># Write updated content\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">with\u003C/span> \u003Cspan class=\"hljs-built_in\">open\u003C/span>(file_path, \u003Cspan class=\"hljs-string\">&#x27;w&#x27;\u003C/span>, encoding=\u003Cspan class=\"hljs-string\">&#x27;utf-8&#x27;\u003C/span>) \u003Cspan class=\"hljs-keyword\">as\u003C/span> f:\n                f.write(\u003Cspan class=\"hljs-string\">&#x27;\\n&#x27;\u003C/span>.join(new_content_parts))\n            \n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">True\u003C/span>\n            \n        \u003Cspan class=\"hljs-keyword\">except\u003C/span> Exception \u003Cspan class=\"hljs-keyword\">as\u003C/span> e:\n            \u003Cspan class=\"hljs-built_in\">print\u003C/span>(\u003Cspan class=\"hljs-string\">f&quot;Error reorganizing document: \u003Cspan class=\"hljs-subst\">{e}\u003C/span>&quot;\u003C/span>)\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">False\u003C/span>\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_build_restructured_content\u003C/span>(\u003Cspan class=\"hljs-params\">self, structure: \u003Cspan class=\"hljs-type\">Dict\u003C/span>, sections: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>], output: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-built_in\">str\u003C/span>]\u003C/span>):\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Recursively build restructured content&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> item \u003Cspan class=\"hljs-keyword\">in\u003C/span> structure.get(\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>, []):\n            level = item.get(\u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>, \u003Cspan class=\"hljs-number\">1\u003C/span>)\n            title = item.get(\u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            source_path = item.get(\u003Cspan class=\"hljs-string\">&#x27;source_path&#x27;\u003C/span>)\n            \n            \u003Cspan class=\"hljs-comment\"># Add heading\u003C/span>\n            heading = \u003Cspan class=\"hljs-string\">&#x27;#&#x27;\u003C/span> * level + \u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span> + title\n            output.append(heading)\n            output.append(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \n            \u003Cspan class=\"hljs-comment\"># Add content from source section if specified\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> source_path:\n                source_section = \u003Cspan class=\"hljs-built_in\">next\u003C/span>((s \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] == source_path), \u003Cspan class=\"hljs-literal\">None\u003C/span>)\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> source_section:\n                    output.append(source_section[\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>])\n                    output.append(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \n            \u003Cspan class=\"hljs-comment\"># Add custom content if specified\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> item.get(\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>):\n                output.append(item[\u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>])\n                output.append(\u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>)\n            \n            \u003Cspan class=\"hljs-comment\"># Process subsections recursively\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> item.get(\u003Cspan class=\"hljs-string\">&#x27;subsections&#x27;\u003C/span>):\n                self._build_restructured_content(\n                    {\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>: item[\u003Cspan class=\"hljs-string\">&#x27;subsections&#x27;\u003C/span>]}, \n                    sections, \n                    output\n                )\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">generate_section_report\u003C/span>(\u003Cspan class=\"hljs-params\">self, file_path: \u003Cspan class=\"hljs-built_in\">str\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Generate comprehensive report on document sections&quot;&quot;&quot;\u003C/span>\n        analysis = self.analyze_document_structure(file_path)\n        \n        report = {\n            \u003Cspan class=\"hljs-string\">&#x27;file&#x27;\u003C/span>: file_path,\n            \u003Cspan class=\"hljs-string\">&#x27;generated_at&#x27;\u003C/span>: datetime.now().isoformat(),\n            \u003Cspan class=\"hljs-string\">&#x27;overview&#x27;\u003C/span>: analysis[\u003Cspan class=\"hljs-string\">&#x27;statistics&#x27;\u003C/span>],\n            \u003Cspan class=\"hljs-string\">&#x27;structure_analysis&#x27;\u003C/span>: {\n                \u003Cspan class=\"hljs-string\">&#x27;depth&#x27;\u003C/span>: self._calculate_structure_depth(analysis[\u003Cspan class=\"hljs-string\">&#x27;hierarchy&#x27;\u003C/span>]),\n                \u003Cspan class=\"hljs-string\">&#x27;balance&#x27;\u003C/span>: self._analyze_structure_balance(analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>]),\n                \u003Cspan class=\"hljs-string\">&#x27;consistency&#x27;\u003C/span>: self._check_heading_consistency(analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>])\n            },\n            \u003Cspan class=\"hljs-string\">&#x27;content_analysis&#x27;\u003C/span>: {\n                \u003Cspan class=\"hljs-string\">&#x27;top_sections_by_content&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">sorted\u003C/span>(\n                    analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>], \n                    key=\u003Cspan class=\"hljs-keyword\">lambda\u003C/span> x: x[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>], \n                    reverse=\u003Cspan class=\"hljs-literal\">True\u003C/span>\n                )[:\u003Cspan class=\"hljs-number\">10\u003C/span>],\n                \u003Cspan class=\"hljs-string\">&#x27;sections_needing_content&#x27;\u003C/span>: [\n                    s \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>] \n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] &lt; \u003Cspan class=\"hljs-number\">20\u003C/span> \u003Cspan class=\"hljs-keyword\">and\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;children_count&#x27;\u003C/span>] == \u003Cspan class=\"hljs-number\">0\u003C/span>\n                ],\n                \u003Cspan class=\"hljs-string\">&#x27;sections_with_rich_content&#x27;\u003C/span>: [\n                    s \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>]\n                    \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;has_code_blocks&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">and\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;has_links&#x27;\u003C/span>]\n                ]\n            },\n            \u003Cspan class=\"hljs-string\">&#x27;recommendations&#x27;\u003C/span>: self._generate_section_recommendations(analysis)\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> report\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_calculate_structure_depth\u003C/span>(\u003Cspan class=\"hljs-params\">self, hierarchy: \u003Cspan class=\"hljs-type\">List\u003C/span>[HeadingNode]\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">int\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Calculate maximum depth of heading structure&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> hierarchy:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">get_depth\u003C/span>(\u003Cspan class=\"hljs-params\">node: HeadingNode\u003C/span>) -&gt; \u003Cspan class=\"hljs-built_in\">int\u003C/span>:\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> node.children:\n                \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">1\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-number\">1\u003C/span> + \u003Cspan class=\"hljs-built_in\">max\u003C/span>(get_depth(child) \u003Cspan class=\"hljs-keyword\">for\u003C/span> child \u003Cspan class=\"hljs-keyword\">in\u003C/span> node.children)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-built_in\">max\u003C/span>(get_depth(node) \u003Cspan class=\"hljs-keyword\">for\u003C/span> node \u003Cspan class=\"hljs-keyword\">in\u003C/span> hierarchy)\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_analyze_structure_balance\u003C/span>(\u003Cspan class=\"hljs-params\">self, sections: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Analyze balance of content across sections&quot;&quot;&quot;\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> sections:\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> {}\n        \n        word_counts = [s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections]\n        avg_words = \u003Cspan class=\"hljs-built_in\">sum\u003C/span>(word_counts) / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(word_counts)\n        \n        \u003Cspan class=\"hljs-comment\"># Calculate variance\u003C/span>\n        variance = \u003Cspan class=\"hljs-built_in\">sum\u003C/span>((wc - avg_words) ** \u003Cspan class=\"hljs-number\">2\u003C/span> \u003Cspan class=\"hljs-keyword\">for\u003C/span> wc \u003Cspan class=\"hljs-keyword\">in\u003C/span> word_counts) / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(word_counts)\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-string\">&#x27;average_words_per_section&#x27;\u003C/span>: avg_words,\n            \u003Cspan class=\"hljs-string\">&#x27;variance&#x27;\u003C/span>: variance,\n            \u003Cspan class=\"hljs-string\">&#x27;imbalanced_sections&#x27;\u003C/span>: [\n                s[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> \u003Cspan class=\"hljs-built_in\">abs\u003C/span>(s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] - avg_words) &gt; variance * \u003Cspan class=\"hljs-number\">2\u003C/span>\n            ]\n        }\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_check_heading_consistency\u003C/span>(\u003Cspan class=\"hljs-params\">self, sections: \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">Dict\u003C/span>:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Check consistency of heading patterns&quot;&quot;&quot;\u003C/span>\n        level_patterns = {}\n        inconsistencies = []\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> section \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections:\n            level = section[\u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>]\n            title = section[\u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>]\n            \n            \u003Cspan class=\"hljs-comment\"># Check title casing patterns\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> level \u003Cspan class=\"hljs-keyword\">not\u003C/span> \u003Cspan class=\"hljs-keyword\">in\u003C/span> level_patterns:\n                level_patterns[level] = {\n                    \u003Cspan class=\"hljs-string\">&#x27;title_case&#x27;\u003C/span>: title.istitle(),\n                    \u003Cspan class=\"hljs-string\">&#x27;sentence_case&#x27;\u003C/span>: title[\u003Cspan class=\"hljs-number\">0\u003C/span>].isupper() \u003Cspan class=\"hljs-keyword\">and\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> title.istitle(),\n                    \u003Cspan class=\"hljs-string\">&#x27;lower_case&#x27;\u003C/span>: title.islower(),\n                    \u003Cspan class=\"hljs-string\">&#x27;count&#x27;\u003C/span>: \u003Cspan class=\"hljs-number\">1\u003C/span>\n                }\n            \u003Cspan class=\"hljs-keyword\">else\u003C/span>:\n                pattern = level_patterns[level]\n                \n                \u003Cspan class=\"hljs-comment\"># Check if this title follows the established pattern\u003C/span>\n                current_title_case = title.istitle()\n                current_sentence_case = title[\u003Cspan class=\"hljs-number\">0\u003C/span>].isupper() \u003Cspan class=\"hljs-keyword\">and\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> title.istitle()\n                current_lower_case = title.islower()\n                \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> pattern[\u003Cspan class=\"hljs-string\">&#x27;title_case&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">and\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> current_title_case:\n                    inconsistencies.append({\n                        \u003Cspan class=\"hljs-string\">&#x27;section&#x27;\u003C/span>: section[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>],\n                        \u003Cspan class=\"hljs-string\">&#x27;issue&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;inconsistent_casing&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-string\">&#x27;expected&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;title_case&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-string\">&#x27;found&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;other&#x27;\u003C/span>\n                    })\n                \u003Cspan class=\"hljs-keyword\">elif\u003C/span> pattern[\u003Cspan class=\"hljs-string\">&#x27;sentence_case&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">and\u003C/span> \u003Cspan class=\"hljs-keyword\">not\u003C/span> current_sentence_case:\n                    inconsistencies.append({\n                        \u003Cspan class=\"hljs-string\">&#x27;section&#x27;\u003C/span>: section[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>],\n                        \u003Cspan class=\"hljs-string\">&#x27;issue&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;inconsistent_casing&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-string\">&#x27;expected&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;sentence_case&#x27;\u003C/span>,\n                        \u003Cspan class=\"hljs-string\">&#x27;found&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;other&#x27;\u003C/span>\n                    })\n                \n                pattern[\u003Cspan class=\"hljs-string\">&#x27;count&#x27;\u003C/span>] += \u003Cspan class=\"hljs-number\">1\u003C/span>\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> {\n            \u003Cspan class=\"hljs-string\">&#x27;level_patterns&#x27;\u003C/span>: level_patterns,\n            \u003Cspan class=\"hljs-string\">&#x27;inconsistencies&#x27;\u003C/span>: inconsistencies,\n            \u003Cspan class=\"hljs-string\">&#x27;consistency_score&#x27;\u003C/span>: \u003Cspan class=\"hljs-built_in\">max\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, \u003Cspan class=\"hljs-number\">1\u003C/span> - \u003Cspan class=\"hljs-built_in\">len\u003C/span>(inconsistencies) / \u003Cspan class=\"hljs-built_in\">len\u003C/span>(sections))\n        }\n    \n    \u003Cspan class=\"hljs-keyword\">def\u003C/span> \u003Cspan class=\"hljs-title function_\">_generate_section_recommendations\u003C/span>(\u003Cspan class=\"hljs-params\">self, analysis: \u003Cspan class=\"hljs-type\">Dict\u003C/span>\u003C/span>) -&gt; \u003Cspan class=\"hljs-type\">List\u003C/span>[\u003Cspan class=\"hljs-type\">Dict\u003C/span>]:\n        \u003Cspan class=\"hljs-string\">&quot;&quot;&quot;Generate recommendations for improving document structure&quot;&quot;&quot;\u003C/span>\n        recommendations = []\n        stats = analysis[\u003Cspan class=\"hljs-string\">&#x27;statistics&#x27;\u003C/span>]\n        sections = analysis[\u003Cspan class=\"hljs-string\">&#x27;sections&#x27;\u003C/span>]\n        \n        \u003Cspan class=\"hljs-comment\"># Check for very short sections\u003C/span>\n        short_sections = [s \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] &lt; \u003Cspan class=\"hljs-number\">20\u003C/span> \u003Cspan class=\"hljs-keyword\">and\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;children_count&#x27;\u003C/span>] == \u003Cspan class=\"hljs-number\">0\u003C/span>]\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> short_sections:\n            recommendations.append({\n                \u003Cspan class=\"hljs-string\">&#x27;type&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;content&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;priority&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Expand Short Sections&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;description&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">f&#x27;\u003Cspan class=\"hljs-subst\">{\u003Cspan class=\"hljs-built_in\">len\u003C/span>(short_sections)}\u003C/span> sections have very little content&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;affected_sections&#x27;\u003C/span>: [s[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> short_sections],\n                \u003Cspan class=\"hljs-string\">&#x27;suggestion&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider expanding these sections or merging them with related content&#x27;\u003C/span>\n            })\n        \n        \u003Cspan class=\"hljs-comment\"># Check for very long sections\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> stats.get(\u003Cspan class=\"hljs-string\">&#x27;average_words_per_section&#x27;\u003C/span>, \u003Cspan class=\"hljs-number\">0\u003C/span>) &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>:\n            long_sections = [\n                s \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections \n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> s[\u003Cspan class=\"hljs-string\">&#x27;word_count&#x27;\u003C/span>] &gt; stats[\u003Cspan class=\"hljs-string\">&#x27;average_words_per_section&#x27;\u003C/span>] * \u003Cspan class=\"hljs-number\">3\u003C/span>\n            ]\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> long_sections:\n                recommendations.append({\n                    \u003Cspan class=\"hljs-string\">&#x27;type&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;priority&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;low&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider Breaking Up Long Sections&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;description&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">f&#x27;\u003Cspan class=\"hljs-subst\">{\u003Cspan class=\"hljs-built_in\">len\u003C/span>(long_sections)}\u003C/span> sections are significantly longer than average&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;affected_sections&#x27;\u003C/span>: [s[\u003Cspan class=\"hljs-string\">&#x27;path&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> long_sections],\n                    \u003Cspan class=\"hljs-string\">&#x27;suggestion&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider adding subsections to improve readability&#x27;\u003C/span>\n                })\n        \n        \u003Cspan class=\"hljs-comment\"># Check depth\u003C/span>\n        max_level = \u003Cspan class=\"hljs-built_in\">max\u003C/span>(s[\u003Cspan class=\"hljs-string\">&#x27;level&#x27;\u003C/span>] \u003Cspan class=\"hljs-keyword\">for\u003C/span> s \u003Cspan class=\"hljs-keyword\">in\u003C/span> sections) \u003Cspan class=\"hljs-keyword\">if\u003C/span> sections \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-number\">0\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> max_level &gt; \u003Cspan class=\"hljs-number\">4\u003C/span>:\n            recommendations.append({\n                \u003Cspan class=\"hljs-string\">&#x27;type&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;priority&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;title&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Deep Heading Hierarchy&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;description&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">f&#x27;Document uses heading levels up to H\u003Cspan class=\"hljs-subst\">{max_level}\u003C/span>&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-string\">&#x27;suggestion&#x27;\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Consider restructuring to reduce nesting depth for better readability&#x27;\u003C/span>\n            })\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> recommendations\n\u003C/code>\u003C/pre>\u003Ch2 id=\"integration-with-documentation-systems\">Integration with Documentation Systems\u003C/h2>\n\u003Cp>Heading management systems integrate seamlessly with modern documentation workflows. When combined with \u003Ca href=\"/blog/markdown-automation-workflows-complete-guide\">automation systems and workflow integration\u003C/a>, heading structures become the foundation for automated content organization, navigation generation, and documentation maintenance processes that scale effectively across large content repositories.\u003C/p>\n\u003Cp>For comprehensive content architectures, heading systems work effectively with \u003Ca href=\"/blog/markdown-link-management-cross-referencing-complete-guide\">link management and cross-referencing systems\u003C/a> to create cohesive information networks where heading structures drive link organization, cross-reference generation, and content relationship mapping across complex documentation ecosystems.\u003C/p>\n\u003Cp>When building advanced documentation platforms, heading management complements \u003Ca href=\"/blog/markdown-table-sorting-filtering-interactive-guide\">table organization and interactive content systems\u003C/a> by providing the structural foundation for organizing tabular data, creating hierarchical data presentations, and maintaining consistency between content structure and data organization patterns.\u003C/p>\n\u003Ch2 id=\"advanced-heading-optimization-techniques\">Advanced Heading Optimization Techniques\u003C/h2>\n\u003Ch3 id=\"seo-and-accessibility-optimization\">SEO and Accessibility Optimization\u003C/h3>\n\u003Cp>Optimizing heading structures for search engines and accessibility:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// seo-heading-optimizer.js - SEO and accessibility heading optimization\u003C/span>\n\u003Cspan class=\"hljs-keyword\">class\u003C/span> \u003Cspan class=\"hljs-title class_\">SEOHeadingOptimizer\u003C/span> {\n    \u003Cspan class=\"hljs-title function_\">constructor\u003C/span>(\u003Cspan class=\"hljs-params\">headingManager\u003C/span>) {\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span> = headingManager;\n        \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span> = {\n            \u003Cspan class=\"hljs-attr\">maxH1Length\u003C/span>: \u003Cspan class=\"hljs-number\">60\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxH2Length\u003C/span>: \u003Cspan class=\"hljs-number\">80\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxGeneralLength\u003C/span>: \u003Cspan class=\"hljs-number\">100\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">keywordDensity\u003C/span>: \u003Cspan class=\"hljs-number\">0.02\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">readabilityScore\u003C/span>: \u003Cspan class=\"hljs-number\">60\u003C/span>\n        };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeForSEO\u003C/span>(\u003Cspan class=\"hljs-params\">filePath, targetKeywords = []\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fileData = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">headingManager\u003C/span>.\u003Cspan class=\"hljs-property\">headingDatabase\u003C/span>.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(filePath);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (!fileData) \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-literal\">null\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimization = {\n            \u003Cspan class=\"hljs-attr\">currentScore\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">maxScore\u003C/span>: \u003Cspan class=\"hljs-number\">100\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">issues\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">suggestions\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">optimizedHeadings\u003C/span>: []\n        };\n        \n        \u003Cspan class=\"hljs-comment\">// Analyze current headings\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> headingAnalysis = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeHeadingSEO\u003C/span>(fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>, targetKeywords);\n        optimization.\u003Cspan class=\"hljs-property\">currentScore\u003C/span> = headingAnalysis.\u003Cspan class=\"hljs-property\">score\u003C/span>;\n        optimization.\u003Cspan class=\"hljs-property\">issues\u003C/span> = headingAnalysis.\u003Cspan class=\"hljs-property\">issues\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Generate optimized versions\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> fileData.\u003Cspan class=\"hljs-property\">headings\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimized = \u003Cspan class=\"hljs-keyword\">await\u003C/span> \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">optimizeHeading\u003C/span>(heading, targetKeywords);\n            optimization.\u003Cspan class=\"hljs-property\">optimizedHeadings\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(optimized);\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Generate improvement suggestions\u003C/span>\n        optimization.\u003Cspan class=\"hljs-property\">suggestions\u003C/span> = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">generateSEOSuggestions\u003C/span>(headingAnalysis);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> optimization;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">analyzeHeadingSEO\u003C/span>(\u003Cspan class=\"hljs-params\">headings, targetKeywords\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> score = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> maxScore = \u003Cspan class=\"hljs-number\">100\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (headings.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;No headings found in document&#x27;\u003C/span>\n            });\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">score\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, issues };\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check H1 presence and optimization\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> h1s = headings.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1s.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;No H1 heading found - critical for SEO&#x27;\u003C/span>\n            });\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1s.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>, \n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${h1s.length}\u003C/span> H1 headings found - should have exactly one`\u003C/span>\n            });\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            score += \u003Cspan class=\"hljs-number\">20\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good H1 structure\u003C/span>\n            \n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> h1 = h1s[\u003Cspan class=\"hljs-number\">0\u003C/span>];\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxH1Length\u003C/span>) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;length&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`H1 too long (\u003Cspan class=\"hljs-subst\">${h1.text.length}\u003C/span> chars) - recommended max \u003Cspan class=\"hljs-subst\">${\u003Cspan class=\"hljs-variable language_\">this\u003C/span>.seoRules.maxH1Length}\u003C/span>`\u003C/span>\n                });\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                score += \u003Cspan class=\"hljs-number\">10\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good H1 length\u003C/span>\n            }\n            \n            \u003Cspan class=\"hljs-comment\">// Check keyword usage in H1\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordInH1 = targetKeywords.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">keyword\u003C/span> =&gt;\u003C/span> \n                h1.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>().\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(keyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())\n            );\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (keywordInH1) {\n                score += \u003Cspan class=\"hljs-number\">15\u003C/span>; \u003Cspan class=\"hljs-comment\">// Keyword in H1\u003C/span>\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (targetKeywords.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Target keywords not found in H1&#x27;\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check heading hierarchy\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> hierarchyScore = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">checkHeadingHierarchy\u003C/span>(headings);\n        score += hierarchyScore.\u003Cspan class=\"hljs-property\">score\u003C/span>;\n        issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(...hierarchyScore.\u003Cspan class=\"hljs-property\">issues\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Check keyword distribution\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordScore = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">analyzeKeywordDistribution\u003C/span>(headings, targetKeywords);\n        score += keywordScore.\u003Cspan class=\"hljs-property\">score\u003C/span>;\n        issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(...keywordScore.\u003Cspan class=\"hljs-property\">issues\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Check heading lengths\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lengthScore = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">checkHeadingLengths\u003C/span>(headings);\n        score += lengthScore.\u003Cspan class=\"hljs-property\">score\u003C/span>;\n        issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(...lengthScore.\u003Cspan class=\"hljs-property\">issues\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">score\u003C/span>: \u003Cspan class=\"hljs-title class_\">Math\u003C/span>.\u003Cspan class=\"hljs-title function_\">min\u003C/span>(score, maxScore), issues };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">checkHeadingHierarchy\u003C/span>(\u003Cspan class=\"hljs-params\">headings\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> score = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> previousLevel = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-comment\">// Check for skipped levels\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-property\">level\u003C/span> &gt; previousLevel + \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;hierarchy&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Heading level \u003Cspan class=\"hljs-subst\">${heading.level}\u003C/span> follows level \u003Cspan class=\"hljs-subst\">${previousLevel}\u003C/span> - levels should not be skipped`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">heading\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>\n                });\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                score += \u003Cspan class=\"hljs-number\">2\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good hierarchy progression\u003C/span>\n            }\n            \n            previousLevel = heading.\u003Cspan class=\"hljs-property\">level\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check for good H2 usage\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> h2Count = headings.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">2\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h2Count &gt;= \u003Cspan class=\"hljs-number\">2\u003C/span> &amp;&amp; h2Count &lt;= \u003Cspan class=\"hljs-number\">6\u003C/span>) {\n            score += \u003Cspan class=\"hljs-number\">10\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good H2 structure for SEO\u003C/span>\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h2Count &gt; \u003Cspan class=\"hljs-number\">6\u003C/span>) {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;low&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${h2Count}\u003C/span> H2 headings - consider consolidating for better structure`\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { score, issues };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">analyzeKeywordDistribution\u003C/span>(\u003Cspan class=\"hljs-params\">headings, targetKeywords\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> score = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (targetKeywords.\u003Cspan class=\"hljs-property\">length\u003C/span> === \u003Cspan class=\"hljs-number\">0\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> { \u003Cspan class=\"hljs-attr\">score\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>, issues };\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> keywordCount = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordUsage = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> headingLower = heading.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>();\n            \n            \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> keyword \u003Cspan class=\"hljs-keyword\">of\u003C/span> targetKeywords) {\n                \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordLower = keyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>();\n                \u003Cspan class=\"hljs-keyword\">if\u003C/span> (headingLower.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(keywordLower)) {\n                    keywordCount++;\n                    keywordUsage.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(keyword, (keywordUsage.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(keyword) || \u003Cspan class=\"hljs-number\">0\u003C/span>) + \u003Cspan class=\"hljs-number\">1\u003C/span>);\n                }\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Check keyword distribution\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (keywordCount &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            score += \u003Cspan class=\"hljs-number\">10\u003C/span>; \u003Cspan class=\"hljs-comment\">// Keywords found in headings\u003C/span>\n            \n            \u003Cspan class=\"hljs-comment\">// Check if keywords are well distributed\u003C/span>\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> avgUsage = keywordCount / targetKeywords.\u003Cspan class=\"hljs-property\">length\u003C/span>;\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (avgUsage &gt;= \u003Cspan class=\"hljs-number\">1\u003C/span> &amp;&amp; avgUsage &lt;= \u003Cspan class=\"hljs-number\">3\u003C/span>) {\n                score += \u003Cspan class=\"hljs-number\">5\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good keyword distribution\u003C/span>\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (avgUsage &gt; \u003Cspan class=\"hljs-number\">3\u003C/span>) {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;low&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Keywords may be overused in headings - could appear spammy&#x27;\u003C/span>\n                });\n            }\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">severity\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Target keywords not found in any headings&#x27;\u003C/span>\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { score, issues };\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">checkHeadingLengths\u003C/span>(\u003Cspan class=\"hljs-params\">headings\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> score = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> maxLength = heading.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxH1Length\u003C/span> :\n                            heading.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">2\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxH2Length\u003C/span> :\n                            \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxGeneralLength\u003C/span>;\n            \n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-property\">text\u003C/span>.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt;= maxLength) {\n                score += \u003Cspan class=\"hljs-number\">1\u003C/span>; \u003Cspan class=\"hljs-comment\">// Good length\u003C/span>\n            } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n                issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                    \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;length&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">severity\u003C/span>: heading.\u003Cspan class=\"hljs-property\">level\u003C/span> &lt;= \u003Cspan class=\"hljs-number\">2\u003C/span> ? \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span> : \u003Cspan class=\"hljs-string\">&#x27;low&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`H\u003Cspan class=\"hljs-subst\">${heading.level}\u003C/span> too long: \u003Cspan class=\"hljs-subst\">${heading.text.length}\u003C/span> chars (max \u003Cspan class=\"hljs-subst\">${maxLength}\u003C/span>)`\u003C/span>,\n                    \u003Cspan class=\"hljs-attr\">heading\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>\n                });\n            }\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> { score, issues };\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">async\u003C/span> \u003Cspan class=\"hljs-title function_\">optimizeHeading\u003C/span>(\u003Cspan class=\"hljs-params\">heading, targetKeywords\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> optimization = {\n            \u003Cspan class=\"hljs-attr\">original\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">optimized\u003C/span>: heading.\u003Cspan class=\"hljs-property\">text\u003C/span>,\n            \u003Cspan class=\"hljs-attr\">changes\u003C/span>: [],\n            \u003Cspan class=\"hljs-attr\">score\u003C/span>: \u003Cspan class=\"hljs-number\">0\u003C/span>\n        };\n        \n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> optimizedText = heading.\u003Cspan class=\"hljs-property\">text\u003C/span>;\n        \n        \u003Cspan class=\"hljs-comment\">// Length optimization\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> maxLength = heading.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxH1Length\u003C/span> :\n                         heading.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">2\u003C/span> ? \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxH2Length\u003C/span> :\n                         \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-property\">seoRules\u003C/span>.\u003Cspan class=\"hljs-property\">maxGeneralLength\u003C/span>;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (optimizedText.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; maxLength) {\n            optimizedText = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">shortenHeading\u003C/span>(optimizedText, maxLength);\n            optimization.\u003Cspan class=\"hljs-property\">changes\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;shortened_for_length&#x27;\u003C/span>);\n            optimization.\u003Cspan class=\"hljs-property\">score\u003C/span> += \u003Cspan class=\"hljs-number\">5\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Keyword optimization\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (targetKeywords.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordOptimized = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">optimizeForKeywords\u003C/span>(optimizedText, targetKeywords, heading.\u003Cspan class=\"hljs-property\">level\u003C/span>);\n            \u003Cspan class=\"hljs-keyword\">if\u003C/span> (keywordOptimized !== optimizedText) {\n                optimizedText = keywordOptimized;\n                optimization.\u003Cspan class=\"hljs-property\">changes\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;keyword_optimization&#x27;\u003C/span>);\n                optimization.\u003Cspan class=\"hljs-property\">score\u003C/span> += \u003Cspan class=\"hljs-number\">10\u003C/span>;\n            }\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Readability optimization\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> readabilityOptimized = \u003Cspan class=\"hljs-variable language_\">this\u003C/span>.\u003Cspan class=\"hljs-title function_\">improveReadability\u003C/span>(optimizedText);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (readabilityOptimized !== optimizedText) {\n            optimizedText = readabilityOptimized;\n            optimization.\u003Cspan class=\"hljs-property\">changes\u003C/span>.\u003Cspan class=\"hljs-title function_\">push\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27;readability_improvement&#x27;\u003C/span>);\n            optimization.\u003Cspan class=\"hljs-property\">score\u003C/span> += \u003Cspan class=\"hljs-number\">5\u003C/span>;\n        }\n        \n        optimization.\u003Cspan class=\"hljs-property\">optimized\u003C/span> = optimizedText;\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> optimization;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">shortenHeading\u003C/span>(\u003Cspan class=\"hljs-params\">text, maxLength\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (text.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt;= maxLength) \u003Cspan class=\"hljs-keyword\">return\u003C/span> text;\n        \n        \u003Cspan class=\"hljs-comment\">// Try to shorten while preserving meaning\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> words = text.\u003Cspan class=\"hljs-title function_\">split\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Remove filler words first\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> fillerWords = [\u003Cspan class=\"hljs-string\">&#x27;the&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;a&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;an&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;and&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;or&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;but&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;in&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;on&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;at&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;to&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;for&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;of&#x27;\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;with&#x27;\u003C/span>];\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> shortened = words.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">word\u003C/span> =&gt;\u003C/span> !fillerWords.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(word.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())).\u003Cspan class=\"hljs-title function_\">join\u003C/span>(\u003Cspan class=\"hljs-string\">&#x27; &#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (shortened.\u003Cspan class=\"hljs-property\">length\u003C/span> &lt;= maxLength) \u003Cspan class=\"hljs-keyword\">return\u003C/span> shortened;\n        \n        \u003Cspan class=\"hljs-comment\">// Truncate and add ellipsis\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> text.\u003Cspan class=\"hljs-title function_\">substring\u003C/span>(\u003Cspan class=\"hljs-number\">0\u003C/span>, maxLength - \u003Cspan class=\"hljs-number\">3\u003C/span>).\u003Cspan class=\"hljs-title function_\">trim\u003C/span>() + \u003Cspan class=\"hljs-string\">&#x27;...&#x27;\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">optimizeForKeywords\u003C/span>(\u003Cspan class=\"hljs-params\">text, targetKeywords, level\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Only optimize H1 and H2 for keywords to avoid over-optimization\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (level &gt; \u003Cspan class=\"hljs-number\">2\u003C/span>) \u003Cspan class=\"hljs-keyword\">return\u003C/span> text;\n        \n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> textLower = text.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>();\n        \n        \u003Cspan class=\"hljs-comment\">// Check if any target keyword is already present\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> hasKeyword = targetKeywords.\u003Cspan class=\"hljs-title function_\">some\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">keyword\u003C/span> =&gt;\u003C/span> \n            textLower.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(keyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())\n        );\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (hasKeyword) \u003Cspan class=\"hljs-keyword\">return\u003C/span> text;\n        \n        \u003Cspan class=\"hljs-comment\">// Try to naturally incorporate the primary keyword\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> primaryKeyword = targetKeywords[\u003Cspan class=\"hljs-number\">0\u003C/span>];\n        \n        \u003Cspan class=\"hljs-comment\">// Simple keyword integration - in practice, this would be more sophisticated\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (level === \u003Cspan class=\"hljs-number\">1\u003C/span> &amp;&amp; !textLower.\u003Cspan class=\"hljs-title function_\">includes\u003C/span>(primaryKeyword.\u003Cspan class=\"hljs-title function_\">toLowerCase\u003C/span>())) {\n            \u003Cspan class=\"hljs-keyword\">return\u003C/span> \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${primaryKeyword}\u003C/span>: \u003Cspan class=\"hljs-subst\">${text}\u003C/span>`\u003C/span>;\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> text;\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">improveReadability\u003C/span>(\u003Cspan class=\"hljs-params\">text\u003C/span>) {\n        \u003Cspan class=\"hljs-comment\">// Simple readability improvements\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> improved = text;\n        \n        \u003Cspan class=\"hljs-comment\">// Remove excessive punctuation\u003C/span>\n        improved = improved.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[!]{2,}/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;!&#x27;\u003C/span>);\n        improved = improved.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/[?]{2,}/g\u003C/span>, \u003Cspan class=\"hljs-string\">&#x27;?&#x27;\u003C/span>);\n        \n        \u003Cspan class=\"hljs-comment\">// Fix capitalization\u003C/span>\n        improved = improved.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(\u003Cspan class=\"hljs-regexp\">/\\b\\w/g\u003C/span>, \u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">l\u003C/span> =&gt;\u003C/span> l.\u003Cspan class=\"hljs-title function_\">toUpperCase\u003C/span>());\n        \n        \u003Cspan class=\"hljs-comment\">// Remove redundant words\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> redundantPatterns = [\n            \u003Cspan class=\"hljs-regexp\">/\\b(very|really|quite|rather)\\s+/gi\u003C/span>,\n            \u003Cspan class=\"hljs-regexp\">/\\b(the|a|an)\\s+(the|a|an)\\s+/gi\u003C/span>\n        ];\n        \n        \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> pattern \u003Cspan class=\"hljs-keyword\">of\u003C/span> redundantPatterns) {\n            improved = improved.\u003Cspan class=\"hljs-title function_\">replace\u003C/span>(pattern, \u003Cspan class=\"hljs-string\">&#x27;&#x27;\u003C/span>);\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> improved.\u003Cspan class=\"hljs-title function_\">trim\u003C/span>();\n    }\n    \n    \u003Cspan class=\"hljs-title function_\">generateSEOSuggestions\u003C/span>(\u003Cspan class=\"hljs-params\">analysis\u003C/span>) {\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> suggestions = [];\n        \n        \u003Cspan class=\"hljs-comment\">// Structure suggestions\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> structureIssues = analysis.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">type\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (structureIssues.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            suggestions.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;high&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Improve Heading Structure&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Fix heading hierarchy and structure issues&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">actions\u003C/span>: structureIssues.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">issue\u003C/span> =&gt;\u003C/span> issue.\u003Cspan class=\"hljs-property\">message\u003C/span>)\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Keyword suggestions\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> keywordIssues = analysis.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">type\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (keywordIssues.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            suggestions.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;keywords&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Optimize Keyword Usage&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Improve keyword distribution in headings&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">actions\u003C/span>: [\n                    \u003Cspan class=\"hljs-string\">&#x27;Include target keywords in H1 and H2 headings&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;Ensure natural keyword integration&#x27;\u003C/span>,\n                    \u003Cspan class=\"hljs-string\">&#x27;Avoid keyword stuffing&#x27;\u003C/span>\n                ]\n            });\n        }\n        \n        \u003Cspan class=\"hljs-comment\">// Length suggestions\u003C/span>\n        \u003Cspan class=\"hljs-keyword\">const\u003C/span> lengthIssues = analysis.\u003Cspan class=\"hljs-property\">issues\u003C/span>.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">i\u003C/span> =&gt;\u003C/span> i.\u003Cspan class=\"hljs-property\">type\u003C/span> === \u003Cspan class=\"hljs-string\">&#x27;length&#x27;\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (lengthIssues.\u003Cspan class=\"hljs-property\">length\u003C/span> &gt; \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n            suggestions.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">category\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;length&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">priority\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;medium&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">title\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Optimize Heading Lengths&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">description\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Shorten overly long headings for better SEO&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">actions\u003C/span>: lengthIssues.\u003Cspan class=\"hljs-title function_\">map\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">issue\u003C/span> =&gt;\u003C/span> \u003Cspan class=\"hljs-string\">`Shorten: &quot;\u003Cspan class=\"hljs-subst\">${issue.heading}\u003C/span>&quot;`\u003C/span>)\n            });\n        }\n        \n        \u003Cspan class=\"hljs-keyword\">return\u003C/span> suggestions;\n    }\n}\n\n\u003Cspan class=\"hljs-variable language_\">module\u003C/span>.\u003Cspan class=\"hljs-property\">exports\u003C/span> = \u003Cspan class=\"hljs-title class_\">SEOHeadingOptimizer\u003C/span>;\n\u003C/code>\u003C/pre>\u003Ch2 id=\"troubleshooting-common-heading-issues\">Troubleshooting Common Heading Issues\u003C/h2>\n\u003Ch3 id=\"heading-structure-problems\">Heading Structure Problems\u003C/h3>\n\u003Cp>\u003Cstrong>Problem\u003C/strong>: Inconsistent heading hierarchy breaking navigation\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-markdown\">&lt;!-- Problem: Skipped levels --&gt;\n\u003Cspan class=\"hljs-section\"># Main Title\u003C/span>\n\u003Cspan class=\"hljs-section\">### Subsection (skipped H2)\u003C/span>\n\n&lt;!-- Solution: Proper hierarchy --&gt;\n\u003Cspan class=\"hljs-section\"># Main Title\u003C/span>\n\u003Cspan class=\"hljs-section\">## Main Section  \u003C/span>\n\u003Cspan class=\"hljs-section\">### Subsection\u003C/span>\n\u003C/code>\u003C/pre>\u003Cp>\u003Cstrong>Problem\u003C/strong>: Multiple H1 headings causing SEO issues\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// heading-validator.js - Validate heading structure\u003C/span>\n\u003Cspan class=\"hljs-keyword\">function\u003C/span> \u003Cspan class=\"hljs-title function_\">validateHeadingStructure\u003C/span>(\u003Cspan class=\"hljs-params\">content\u003C/span>) {\n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> headings = \u003Cspan class=\"hljs-title function_\">extractHeadings\u003C/span>(content);\n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> issues = [];\n    \n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> h1Count = headings.\u003Cspan class=\"hljs-title function_\">filter\u003C/span>(\u003Cspan class=\"hljs-function\">\u003Cspan class=\"hljs-params\">h\u003C/span> =&gt;\u003C/span> h.\u003Cspan class=\"hljs-property\">level\u003C/span> === \u003Cspan class=\"hljs-number\">1\u003C/span>).\u003Cspan class=\"hljs-property\">length\u003C/span>;\n    \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1Count === \u003Cspan class=\"hljs-number\">0\u003C/span>) {\n        issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({ \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;missing-h1&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Document needs an H1 heading&#x27;\u003C/span> });\n    } \u003Cspan class=\"hljs-keyword\">else\u003C/span> \u003Cspan class=\"hljs-keyword\">if\u003C/span> (h1Count &gt; \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n        issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({ \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;multiple-h1&#x27;\u003C/span>, \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;Only one H1 heading per document&#x27;\u003C/span> });\n    }\n    \n    \u003Cspan class=\"hljs-comment\">// Check for skipped levels\u003C/span>\n    \u003Cspan class=\"hljs-keyword\">let\u003C/span> previousLevel = \u003Cspan class=\"hljs-number\">0\u003C/span>;\n    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (heading.\u003Cspan class=\"hljs-property\">level\u003C/span> &gt; previousLevel + \u003Cspan class=\"hljs-number\">1\u003C/span>) {\n            issues.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n                \u003Cspan class=\"hljs-attr\">type\u003C/span>: \u003Cspan class=\"hljs-string\">&#x27;skipped-level&#x27;\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">message\u003C/span>: \u003Cspan class=\"hljs-string\">`Level \u003Cspan class=\"hljs-subst\">${heading.level}\u003C/span> follows \u003Cspan class=\"hljs-subst\">${previousLevel}\u003C/span>`\u003C/span>,\n                \u003Cspan class=\"hljs-attr\">line\u003C/span>: heading.\u003Cspan class=\"hljs-property\">line\u003C/span>\n            });\n        }\n        previousLevel = heading.\u003Cspan class=\"hljs-property\">level\u003C/span>;\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">return\u003C/span> issues;\n}\n\u003C/code>\u003C/pre>\u003Ch3 id=\"anchor-link-conflicts\">Anchor Link Conflicts\u003C/h3>\n\u003Cp>\u003Cstrong>Problem\u003C/strong>: Duplicate anchor IDs breaking navigation\u003C/p>\n\u003Cp>\u003Cstrong>Solutions\u003C/strong>:\u003C/p>\n\u003Cpre>\u003Ccode class=\"hljs language-javascript\">\u003Cspan class=\"hljs-comment\">// anchor-resolver.js - Resolve duplicate anchors\u003C/span>\n\u003Cspan class=\"hljs-keyword\">function\u003C/span> \u003Cspan class=\"hljs-title function_\">generateUniqueAnchors\u003C/span>(\u003Cspan class=\"hljs-params\">headings\u003C/span>) {\n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> anchorCounts = \u003Cspan class=\"hljs-keyword\">new\u003C/span> \u003Cspan class=\"hljs-title class_\">Map\u003C/span>();\n    \u003Cspan class=\"hljs-keyword\">const\u003C/span> resolvedHeadings = [];\n    \n    \u003Cspan class=\"hljs-keyword\">for\u003C/span> (\u003Cspan class=\"hljs-keyword\">const\u003C/span> heading \u003Cspan class=\"hljs-keyword\">of\u003C/span> headings) {\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> baseAnchor = \u003Cspan class=\"hljs-title function_\">generateAnchorId\u003C/span>(heading.\u003Cspan class=\"hljs-property\">text\u003C/span>);\n        \u003Cspan class=\"hljs-keyword\">let\u003C/span> uniqueAnchor = baseAnchor;\n        \n        \u003Cspan class=\"hljs-keyword\">if\u003C/span> (anchorCounts.\u003Cspan class=\"hljs-title function_\">has\u003C/span>(baseAnchor)) {\n            \u003Cspan class=\"hljs-keyword\">const\u003C/span> count = anchorCounts.\u003Cspan class=\"hljs-title function_\">get\u003C/span>(baseAnchor) + \u003Cspan class=\"hljs-number\">1\u003C/span>;\n            anchorCounts.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(baseAnchor, count);\n            uniqueAnchor = \u003Cspan class=\"hljs-string\">`\u003Cspan class=\"hljs-subst\">${baseAnchor}\u003C/span>-\u003Cspan class=\"hljs-subst\">${count}\u003C/span>`\u003C/span>;\n        } \u003Cspan class=\"hljs-keyword\">else\u003C/span> {\n            anchorCounts.\u003Cspan class=\"hljs-title function_\">set\u003C/span>(baseAnchor, \u003Cspan class=\"hljs-number\">0\u003C/span>);\n        }\n        \n        resolvedHeadings.\u003Cspan class=\"hljs-title function_\">push\u003C/span>({\n            ...heading,\n            \u003Cspan class=\"hljs-attr\">anchor\u003C/span>: uniqueAnchor\n        });\n    }\n    \n    \u003Cspan class=\"hljs-keyword\">return\u003C/span> resolvedHeadings;\n}\n\u003C/code>\u003C/pre>\u003Ch2 id=\"conclusion\">Conclusion\u003C/h2>\n\u003Cp>Advanced Markdown heading hierarchy and navigation systems represent a fundamental pillar of sophisticated documentation architecture that enables clear information organization, intuitive user experiences, and scalable content management across large documentation ecosystems. By mastering heading management principles, automated navigation generation, and SEO optimization techniques, technical writers and documentation teams can create comprehensive information architectures that serve both human readers and automated systems effectively.\u003C/p>\n\u003Cp>The key to successful heading management lies in understanding the dual nature of headings as both structural elements and navigation tools, ensuring that heading hierarchies support content comprehension while enabling automated processing for table of contents generation, cross-referencing, and search optimization. Whether you&#39;re building technical documentation, knowledge bases, or content management systems, the techniques covered in this guide provide the foundation for creating maintainable, accessible, and discoverable content structures.\u003C/p>\n\u003Cp>Remember to implement heading validation as part of your content workflow, regularly audit your heading structures for consistency and optimization opportunities, and continuously refine your navigation systems based on user feedback and analytics data. With proper implementation of advanced heading management systems, your Markdown-based content can deliver exceptional user experiences that guide readers effectively through complex information while maintaining the flexibility and simplicity that makes Markdown such a powerful documentation format.\u003C/p>\n",[15,19,22,25,28,31,34],{"id":16,"text":17,"level":18},"why-master-heading-hierarchy-and-navigation","Why Master Heading Hierarchy and Navigation?",2,{"id":20,"text":21,"level":18},"foundation-heading-principles","Foundation Heading Principles",{"id":23,"text":24,"level":18},"integration-with-documentation-workflows","Integration with Documentation Workflows",{"id":26,"text":27,"level":18},"integration-with-documentation-systems","Integration with Documentation Systems",{"id":29,"text":30,"level":18},"advanced-heading-optimization-techniques","Advanced Heading Optimization Techniques",{"id":32,"text":33,"level":18},"troubleshooting-common-heading-issues","Troubleshooting Common Heading Issues",{"id":35,"text":36,"level":18},"conclusion","Conclusion",[],[39,47,55],{"slug":40,"title":41,"description":42,"excerpt":43,"date":44,"category":9,"author":10,"keywords":45,"readingMinutes":46},"markdown-content-organization-project-structure-complete-guide","Markdown Content Organization and Project Structure: Complete Guide for Scalable Documentation Systems","Master advanced Markdown content organization strategies for large-scale documentation projects, including hierarchical structures, content categorization, automated organization systems, and scalable project architectures that grow with your needs.","Effective Markdown content organization and project structure design enables scalable documentation systems that maintain clarity, findability, and maintainability across large content…","2025-10-19","markdown content organization, documentation structure, content management markdown, project structure documentation, scalable markdown, content categorization, documentation architecture, markdown organization systems",18,{"slug":48,"title":49,"description":50,"excerpt":51,"date":52,"category":9,"author":10,"keywords":53,"readingMinutes":54},"markdown-file-organization-project-structure-complete-guide","Markdown File Organization and Project Structure: Complete Guide for Scalable Documentation Systems","Master Markdown file organization strategies for large projects, teams, and documentation systems. Learn directory structures, naming conventions, content management patterns, and scalable organization principles.","Effective Markdown file organization forms the foundation of maintainable, scalable documentation systems that serve teams, users, and automated processes efficiently over time. Strategic…","2025-12-05","markdown file organization, markdown project structure, documentation organization, markdown directory structure, content management markdown, markdown naming conventions, documentation architecture",19,{"slug":56,"title":57,"description":58,"excerpt":59,"date":60,"category":9,"author":10,"keywords":61,"readingMinutes":54},"markdown-link-management-cross-referencing-complete-guide","Markdown Link Management and Cross-Referencing: Complete Guide for Documentation Systems and Content Organization","Master advanced Markdown link management techniques for documentation systems, cross-referencing content, and maintaining link integrity across large content repositories. Learn automated link validation, reference management, and organization strategies.","Advanced Markdown link management and cross-referencing systems enable sophisticated documentation architectures that maintain content relationships, ensure link integrity, and provide seamless…","2025-09-27","markdown link management, markdown cross references, documentation links, markdown references, link validation markdown, markdown link organization, content cross-referencing, markdown documentation systems",1792184943364]