-
Notifications
You must be signed in to change notification settings - Fork 30
Fix LLM markdown output to preserve .md extensions for internal links and cross-links #1959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…tput - Modified LlmLinkInlineRenderer to detect internal markdown links - Internal markdown links now preserve .md extension - External links and cross-links continue to use absolute URLs - Added comprehensive test coverage for link handling - Verified functionality with CLI tool output Co-authored-by: reakaleek <[email protected]>
.md
link} | ||
else | ||
{ | ||
// For external links and cross-links, make absolute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cross-links are absolute, but should also get a .md
extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 8b0f20c. Cross-links to markdown files now preserve the .md
extension and render as relative paths (e.g., solutions/observability/apps/apm-server-binary.md
) instead of absolute URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right. It still needs to become a full URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This doesn't look right. It still needs to become a full URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 75e3a94. Cross-links to markdown files now become full URLs with .md
extensions (e.g., https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/solutions/observability/apps/apm-server-binary.md
) instead of relative paths.
- Store original cross-link URL before resolution - Detect cross-links pointing to .md files - Extract relative path with .md extension for LLM output - Update test to validate cross-link behavior - Maintain absolute URLs for non-markdown cross-links Co-authored-by: reakaleek <[email protected]>
- Cross-links to markdown now become full URLs with .md extensions - Update logic to use MakeAbsoluteUrl + EnsureMarkdownExtension for cross-links - Remove unused ExtractMarkdownPath method - Update test expectations to match corrected behavior - Use pattern matching to fix code analysis warning Co-authored-by: reakaleek <[email protected]>
Fixes the LLM markdown renderer to preserve
.md
file extensions for internal markdown links and cross-links to markdown files while keeping external links and non-markdown cross-links as absolute URLs.Problem
The LLM markdown output was converting all links to absolute URLs, including internal links to markdown pages and cross-links pointing to markdown files. This made the output less useful for LLM consumption where relative
.md
links are preferred for navigating between documentation pages.For example, a link like
[Getting Started](getting-started.md)
would be rendered as[Getting Started](https://www.elastic.co/getting-started)
in the LLM output, and a cross-link like[APM Guide](docs-content:/apm/guide.md)
would become[APM Guide](https://docs.elastic.co/apm/guide)
.Solution
Modified the
LlmLinkInlineRenderer
to intelligently detect different link types:.md
extensions (e.g.,page.md
)https://example.com
).md
extensions as absolute URLs (e.g.,https://docs.elastic.co/path/file.md
)https://docs.elastic.co/api
)The detection works by checking the
Target{NavigationRoot}
data that the diagnostic link parser sets on links pointing to markdown files, combined with the existingisCrossLink
flag. For cross-links, the original URL is stored before resolution to determine if it pointed to a.md
file.Example
Given this markdown input:
The LLM output now correctly renders as:
Testing
--exporters llm
This change makes the LLM markdown output more useful for AI systems that need to understand the structure and relationships between documentation pages across different documentation sets.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.