-
Notifications
You must be signed in to change notification settings - Fork 31
Emit error for empty crosslink text #1954
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
Emit error for empty crosslink text #1954
Conversation
Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>
Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>
src/Elastic.Documentation.Links/CrossLinks/CrossLinkResolver.cs
Outdated
Show resolved
Hide resolved
@copilot confirm my assumption. So this will start adding the title to the link metadata. As long as it's null or empty. it will behave as before. But as soon as the link index started adding the title, the title will be rendered. |
Correct. The implementation is fully backwards compatible:
The |
@copilot can you ensure that when using crosslink syntax with empty text like , the link would render with no text, even when the target page has a title. Now instead emits an error notifying the user this is not supported. We don't want to store titles for now |
…lable Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
Done in commit This ensures authors are notified when crosslinks would render without text, rather than silently failing. |
|
||
[JsonPropertyName("title")] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
public string? Title { get; init; } |
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 remove this property and associated changes in CrossLinkResolver
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.
Done in commit 6b2c4ca
. Removed the Title
property from LinkMetadata
and the TryGetLinkMetadata
method from ICrossLinkResolver
and all implementations. The behavior now simply emits an error when encountering empty crosslink text, without trying to fetch or store titles.
Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
Fixes an issue where empty link text in crosslinks would render with no text, creating broken or unclear documentation links.
Problem
When using crosslink syntax with empty text like
[](docs-content:///solutions/search/semantic-search.md)
, the link would render with no visible text, making it appear broken or confusing to readers. This was different from internal links where empty text triggers auto-population of the target page's title.Solution
Modified crosslink processing to emit a clear error when empty link text is encountered:
ProcessCrossLink
now checks for empty link text (link.FirstChild == null
)LinkMetadata
structure or links.json filesBehavior
[](crosslink://file.md)
) now emit an error requiring authors to provide explicit link textThis ensures authors are immediately notified when crosslinks have empty text, preventing broken or unclear links in published documentation.
Testing
Updated tests to verify:
All 622 tests pass, ensuring no regressions.
Fixes #1953
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.