|
10 | 10 | using Elastic.Documentation.Configuration.Versions; |
11 | 11 | using Elastic.Documentation.Site.FileProviders; |
12 | 12 | using Elastic.Documentation.Tooling; |
| 13 | +using Elastic.Markdown.Exporters; |
13 | 14 | using Elastic.Markdown.IO; |
| 15 | +using Elastic.Markdown.Myst.Renderers; |
| 16 | +using Markdig.Syntax; |
14 | 17 | using Microsoft.AspNetCore.Builder; |
15 | 18 | using Microsoft.AspNetCore.Hosting; |
16 | 19 | using Microsoft.AspNetCore.Http; |
@@ -187,6 +190,17 @@ private static async Task<IResult> ServeDocumentationFile(ReloadableGeneratorSta |
187 | 190 | { |
188 | 191 | var generator = holder.Generator; |
189 | 192 | const string navPartialSuffix = ".nav.html"; |
| 193 | + |
| 194 | + // Check if the original request is asking for LLM-rendered markdown |
| 195 | + var requestLlmMarkdown = slug.EndsWith(".md"); |
| 196 | + var originalSlug = slug; |
| 197 | + |
| 198 | + // If requesting .md output, remove the .md extension to find the source file |
| 199 | + if (requestLlmMarkdown) |
| 200 | + { |
| 201 | + slug = slug[..^3]; // Remove ".md" extension |
| 202 | + } |
| 203 | + |
190 | 204 | if (slug.EndsWith(navPartialSuffix)) |
191 | 205 | { |
192 | 206 | var segments = slug.Split("/"); |
@@ -218,8 +232,18 @@ private static async Task<IResult> ServeDocumentationFile(ReloadableGeneratorSta |
218 | 232 | switch (documentationFile) |
219 | 233 | { |
220 | 234 | case MarkdownFile markdown: |
221 | | - var rendered = await generator.RenderLayout(markdown, ctx); |
222 | | - return Results.Content(rendered.Html, "text/html"); |
| 235 | + if (requestLlmMarkdown) |
| 236 | + { |
| 237 | + // Render using LLM pipeline for CommonMark output |
| 238 | + var llmRendered = await generator.RenderLlmMarkdown(markdown, ctx); |
| 239 | + return Results.Content(llmRendered, "text/markdown; charset=utf-8"); |
| 240 | + } |
| 241 | + else |
| 242 | + { |
| 243 | + // Regular HTML rendering |
| 244 | + var rendered = await generator.RenderLayout(markdown, ctx); |
| 245 | + return Results.Content(rendered.Html, "text/html"); |
| 246 | + } |
223 | 247 |
|
224 | 248 | case ImageFile image: |
225 | 249 | return Results.File(image.SourceFile.FullName, image.MimeType); |
|
0 commit comments