[Repo Assist] fix: Markdown.ToMd uses correct backtick fence for inline code containing backticks#1147
Open
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
…ackticks When InlineCode body contains backtick characters, the previous single-backtick wrapping produced invalid Markdown that would not re-parse as the original inline code span. Fix: compute the longest run of consecutive backticks in the body and use a fence of (run + 1) backticks. When the body starts or ends with a backtick, add surrounding spaces so the fence and body do not merge. Add two round-trip tests covering single-backtick and double-backtick content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14 tasks
dsyme
approved these changes
Apr 7, 2026
nojaf
approved these changes
Apr 8, 2026
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.
Problem
Markdown.ToMdalways wrappedInlineCodespans with a single backtick:When
bodyitself contains backtick characters this produces invalid Markdown. For example,InlineCode("ab", _)serialised to ``ab, which a parser would read as the empty spanafollowed by literal `b`` `` — not the intended inline code.The fsdocs inline parser already supports N-backtick fences (
List.DelimitedNTimes) and the backtick-with-spaces form, so a serialiser that produces multi-backtick fences round-trips correctly.Fix
MarkdownUtils.formatSpanfor theInlineCodecase now:Changes
src/FSharp.Formatting.Markdown/MarkdownUtils.fsInlineCodeserialisation with adaptive fencetests/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— 283/283 passed (includes 2 new tests)dotnet test FSharp.Formatting.sln --configuration Release --no-build— full suite passes (fsdocs-tool: 12, CodeFormat: 30, Literate: 143, ApiDocs: 88, Markdown: 283)dotnet fantomas … --check— formatting unchanged