[Repo Assist] fix: Markdown.ToMd preserves [body][key] form for unresolved indirect links#1185
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
Conversation
… links Previously the unresolved-key fallback for IndirectLink used the second field (original) as a direct-link URL, producing '[body](key)' which treats the reference key as a URL. This was inconsistent with IndirectImage, which preserves '![body][key]' when the key is unresolved. Fix: split the two IndirectLink cases so the resolved path produces a direct link '[body](url)' and the unresolved path preserves the indirect form '[body][key]', matching IndirectImage behaviour. Added test: 'ToMd preserves indirect link form when key is unresolved' (347/347 Markdown tests pass). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes an inconsistency in
Markdown.ToMdwhere unresolved indirect links were serialised as broken direct links[body](key)instead of the correct indirect form[body][key].Root Cause
In
MarkdownUtils.fs,formatSpanhad a combined case forIndirectLink:When the reference key was not in
ctx.Links, the second pattern matched withlinkbound to theoriginalfield — the raw reference text, not a URL. This produced[body](original)which treats the reference key as a URL, breaking the link.Compare with
IndirectImage, which already handled this correctly:Fix
Split the two
IndirectLinkcases to match theIndirectImagepattern:Resolved links still produce a direct link (downconversion); unresolved links now preserve the
[body][key]indirect form.Changes
src/FSharp.Formatting.Markdown/MarkdownUtils.fs— fixIndirectLinkfallback casetests/FSharp.Markdown.Tests/Markdown.fs— add testToMd preserves indirect link form when key is unresolvedRELEASE_NOTES.md— changelog entry under[Unreleased] → FixedTest Status
✅
dotnet build FSharp.Formatting.sln --configuration Release— 0 errors, 0 warnings✅
dotnet test tests/FSharp.Markdown.Tests --configuration Release --no-build— 347/347 passed (includes new test)