- {@html asciidoctor.convert(
- `${"=".repeat(section.level)} ${section.title}`,
- {
- standalone: false,
- attributes: {
- showtitle: false,
- sectids: false,
+
+
+ {@html asciidoctor.convert(
+ `${"=".repeat(section.level)} ${section.title}`,
+ {
+ standalone: false,
+ attributes: {
+ showtitle: false,
+ sectids: false,
+ },
},
- },
- )}
-
-
-
- {#if section.tags && section.tags.length > 0}
- {@const tTags = section.tags.filter((tag) => tag[0] === 't')}
- {@const wTags = section.tags.filter((tag) => tag[0] === 'w')}
-
- {#if tTags.length > 0 || wTags.length > 0}
-
-
- {#if tTags.length > 0}
-
- {#each tTags as tag}
-
- #{tag[1]}
-
- {/each}
-
- {/if}
+ )}
+
-
- {#if wTags.length > 0}
-
- {#each wTags as tag}
-
- 🔗 {tag[2] || tag[1]}
-
- {/each}
+
+ {#if section.tags && section.tags.length > 0}
+ {@const tTags = section.tags.filter(
+ (tag: any) => tag[0] === "t",
+ )}
+ {@const wTags = section.tags.filter(
+ (tag: any) => tag[0] === "w",
+ )}
+
+ {#if tTags.length > 0 || wTags.length > 0}
+
+
+ {#if tTags.length > 0}
+
+ {#each tTags as tag}
+
+ #{tag[1]}
+
+ {/each}
+
+ {/if}
+
+
+ {#if wTags.length > 0}
+
+ {#each wTags as tag}
+
+ 🔗 {tag[2] || tag[1]}
+
+ {/each}
+
+ {/if}
{/if}
-
{/if}
- {/if}
-
- {#if section.content}
-
- {@html (() => {
- // Extract wiki links and replace with placeholders BEFORE Asciidoctor
- const wikiLinks = extractWikiLinks(section.content);
- let contentWithPlaceholders = section.content;
- const placeholders = new Map();
-
- wikiLinks.forEach((link, index) => {
- // Use a placeholder inside a passthrough macro - Asciidoctor will strip pass:[...] and leave the inner text
- const innerPlaceholder = `WIKILINK${index}PLACEHOLDER`;
- const placeholder = `pass:[${innerPlaceholder}]`;
- placeholders.set(innerPlaceholder, link); // Store by inner placeholder (what will remain after Asciidoctor)
- contentWithPlaceholders = contentWithPlaceholders.replace(link.fullMatch, placeholder);
- });
-
- // Check if content contains nested headers
- const hasNestedHeaders = contentWithPlaceholders.includes('\n===') || contentWithPlaceholders.includes('\n====');
-
- let rendered;
- if (hasNestedHeaders) {
- // For proper nested header parsing, we need full document context
- // Create a complete AsciiDoc document structure
- // Important: Ensure proper level sequence for nested headers
- const fullDoc = `= Temporary Document\n\n${"=".repeat(section.level)} ${section.title}\n\n${contentWithPlaceholders}`;
-
- rendered = asciidoctor.convert(fullDoc, {
- standalone: false,
- attributes: {
- showtitle: false,
- sectids: false,
- },
+
+ {#if section.content}
+
+ {@html (() => {
+ // Extract wiki links and replace with placeholders BEFORE Asciidoctor
+ const wikiLinks = extractWikiLinks(
+ section.content,
+ );
+ let contentWithPlaceholders = section.content;
+ const placeholders = new Map();
+
+ wikiLinks.forEach((link, index) => {
+ // Use a placeholder inside a passthrough macro - Asciidoctor will strip pass:[...] and leave the inner text
+ const innerPlaceholder = `WIKILINK${index}PLACEHOLDER`;
+ const placeholder = `pass:[${innerPlaceholder}]`;
+ placeholders.set(innerPlaceholder, link); // Store by inner placeholder (what will remain after Asciidoctor)
+ contentWithPlaceholders =
+ contentWithPlaceholders.replace(
+ link.fullMatch,
+ placeholder,
+ );
});
- // Extract just the content we want (remove the temporary structure)
- // Find the section we care about
- const sectionStart = rendered.indexOf(``, sectionStart);
- if (nextSectionStart !== -1) {
- // Get everything after our section header
- const afterHeader = rendered.substring(nextSectionStart + ``.length);
- // Find where the section ends (at the closing div)
- const sectionEnd = afterHeader.lastIndexOf('
');
- if (sectionEnd !== -1) {
- rendered = afterHeader.substring(0, sectionEnd);
+ // Check if content contains nested headers
+ const hasNestedHeaders =
+ contentWithPlaceholders.includes("\n===") ||
+ contentWithPlaceholders.includes("\n====");
+
+ let rendered: string | Document;
+ if (hasNestedHeaders) {
+ // For proper nested header parsing, we need full document context
+ // Create a complete AsciiDoc document structure
+ // Important: Ensure proper level sequence for nested headers
+ const fullDoc = `= Temporary Document\n\n${"=".repeat(section.level)} ${section.title}\n\n${contentWithPlaceholders}`;
+
+ rendered = asciidoctor.convert(fullDoc, {
+ standalone: false,
+ attributes: {
+ showtitle: false,
+ sectids: false,
+ },
+ });
+
+ // Extract just the content we want (remove the temporary structure)
+ // Find the section we care about
+ const sectionStart = rendered
+ .toString()
+ .indexOf(`
`,
+ sectionStart,
+ );
+ if (nextSectionStart !== -1) {
+ // Get everything after our section header
+ const afterHeader = rendered
+ .toString()
+ .substring(
+ nextSectionStart +
+ ``.length,
+ );
+ // Find where the section ends (at the closing div)
+ const sectionEnd =
+ afterHeader.lastIndexOf("
");
+ if (sectionEnd !== -1) {
+ rendered = afterHeader.substring(
+ 0,
+ sectionEnd,
+ );
+ }
}
}
+ } else {
+ // Simple content without nested headers
+ rendered = asciidoctor.convert(
+ contentWithPlaceholders,
+ {
+ standalone: false,
+ attributes: {
+ showtitle: false,
+ sectids: false,
+ },
+ },
+ );
}
- } else {
- // Simple content without nested headers
- rendered = asciidoctor.convert(contentWithPlaceholders, {
- standalone: false,
- attributes: {
- showtitle: false,
- sectids: false,
- },
+
+ // Replace placeholders with actual wiki link HTML
+ // Use a global regex to catch all occurrences (Asciidoctor might have duplicated them)
+ placeholders.forEach((link, placeholder) => {
+ const className =
+ link.type === "auto"
+ ? "wiki-link wiki-link-auto"
+ : link.type === "w"
+ ? "wiki-link wiki-link-ref"
+ : "wiki-link wiki-link-def";
+
+ const title =
+ link.type === "w"
+ ? "Wiki reference (mentions this concept)"
+ : link.type === "d"
+ ? "Wiki definition (defines this concept)"
+ : "Wiki link (searches both references and definitions)";
+
+ const html = `
${link.displayText}`;
+
+ // Use global replace to handle all occurrences
+ const regex = new RegExp(
+ placeholder.replace(
+ /[.*+?^${}()|[\]\\]/g,
+ "\\$&",
+ ),
+ "g",
+ );
+ rendered = rendered
+ .toString()
+ .replace(regex, html);
});
- }
-
- // Replace placeholders with actual wiki link HTML
- // Use a global regex to catch all occurrences (Asciidoctor might have duplicated them)
- placeholders.forEach((link, placeholder) => {
- const className =
- link.type === 'auto'
- ? 'wiki-link wiki-link-auto'
- : link.type === 'w'
- ? 'wiki-link wiki-link-ref'
- : 'wiki-link wiki-link-def';
-
- const title =
- link.type === 'w'
- ? 'Wiki reference (mentions this concept)'
- : link.type === 'd'
- ? 'Wiki definition (defines this concept)'
- : 'Wiki link (searches both references and definitions)';
-
- const html = `
${link.displayText}`;
-
- // Use global replace to handle all occurrences
- const regex = new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
- rendered = rendered.replace(regex, html);
- });
-
- return rendered;
- })()}
-