[Repo Assist] fix: Markdown.ToMd preserves DirectLink and DirectImage titles#1150
Open
github-actions[bot] wants to merge 2 commits intomainfrom
Open
[Repo Assist] fix: Markdown.ToMd preserves DirectLink and DirectImage titles#1150github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
When serialising a document with ToMd, link and image titles were
silently dropped. A Markdown fragment such as
[text](url "My Title")
would round-trip as
[text](url)
because the `DirectLink` / `DirectImage` formatSpan cases matched the
title field with a wildcard.
Fix: give DirectLink and DirectImage their own branches so the optional
title can be appended in CommonMark form ( \"title\").
Three new round-trip tests cover:
- DirectLink with title
- DirectLink without title (unchanged behaviour)
- DirectImage with title
All 284 Markdown tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme
approved these changes
Apr 7, 2026
nojaf
approved these changes
Apr 8, 2026
This was referenced Apr 8, 2026
Draft
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 is an automated PR from Repo Assist.
Root Cause
Markdown.ToMdserialisedDirectLinkandDirectImagespans by grouping them in an F# OR-pattern that used a wildcard for thetitlefield:A Markdown fragment such as
[text](url "My Title")would round-trip as[text](url), silently losing the title attribute.Fix
Give
DirectLinkandDirectImagetheir own match branches so the optionaltitlecan be emitted in CommonMark form ("title"):The title value is escaped to handle embedded double-quote characters per CommonMark spec.
Changes
src/FSharp.Formatting.Markdown/MarkdownUtils.fsDirectLink/DirectImagefrom OR-pattern; emit title when presenttests/FSharp.Markdown.Tests/Markdown.fsRELEASE_NOTES.md[Unreleased] / FixedTest Status
dotnet build FSharp.Formatting.sln --configuration Release— 0 warnings, 0 errorsdotnet test tests/FSharp.Markdown.Tests --configuration Release --no-build— 284/284 passed (includes 3 new tests)dotnet fantomas … --check— formatting verified