<%# --------------------------------------------------------------- # docmd : the zero-config documentation engine. # @website https://docmd.io # [docmd-source] - Please do not remove this header. # --------------------------------------------------------------- %> <% function decodeHtmlEntities(html) { return html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/ /g, ' '); } const shouldShowToc = typeof isActivePage !== 'undefined' ? isActivePage : (typeof navigationHtml !== 'undefined' && navigationHtml && navigationHtml.includes('class="active"')); if (shouldShowToc && !frontmatter?.toc || frontmatter?.toc !== 'false') { let tocHeadings = []; if (headings && headings.length > 0) { tocHeadings = headings.filter(h => h.level >= 1 && h.level <= 4); } else if (content) { const headingRegex = /]*?(?:id="([^"]*)")?[^>]*?>([\s\S]*?)<\/h\1>/g; let match; let contentStr = content.toString(); while ((match = headingRegex.exec(contentStr)) !== null) { const level = parseInt(match[1], 10); let id = match[2]; const text = decodeHtmlEntities(match[3].replace(/<\/?\w+[^>]*>/g, '')); // Stripped tags if (!id) id = text.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]/g, '').replace(/--+/g, '-').replace(/^-+|-+$/g, ''); tocHeadings.push({ id, level, text }); } } if (tocHeadings.length > 1) { %>

<%= typeof t === 'function' ? t('onThisPage') : 'On This Page' %><%- renderIcon("chevron-down") %>

<% } } %>