Skip to content

Commit bc50a2e

Browse files
committed
Simplify logic
1 parent 4a6948e commit bc50a2e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public static void RenderBlockWithIndentation(LlmMarkdownRenderer renderer, Mark
4848
return url;
4949

5050
// For documentation URLs (starting with /docs/), convert to .md format for LLM consistency
51-
if (!string.IsNullOrEmpty(url) && url.StartsWith("/docs/", StringComparison.Ordinal))
51+
// BUT exclude image files which should keep their original extensions
52+
if (!string.IsNullOrEmpty(url) && url.StartsWith("/docs/", StringComparison.Ordinal) && !IsImageFile(url))
5253
{
5354
var markdownUrl = ConvertToMarkdownUrl(url);
5455
return MakeAbsoluteUrl(renderer.BuildContext.CanonicalBaseUrl, markdownUrl);
@@ -107,10 +108,10 @@ private static string ConvertToMarkdownUrl(string url)
107108
if (markdownPath.StartsWith("docs/", StringComparison.Ordinal))
108109
markdownPath = markdownPath.Substring(5);
109110

110-
// Convert directory URLs to .md files, but don't convert image files
111+
// Convert directory URLs to .md files
111112
if (markdownPath.EndsWith('/'))
112113
markdownPath = markdownPath.TrimEnd('/') + ".md";
113-
else if (!markdownPath.EndsWith(".md", StringComparison.Ordinal) && !IsImageFile(markdownPath))
114+
else if (!markdownPath.EndsWith(".md", StringComparison.Ordinal))
114115
markdownPath += ".md";
115116

116117
return $"/docs/{markdownPath}";

0 commit comments

Comments
 (0)