From 4bb700c516d6010bcd28851be18185284862759a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Mar 2026 08:53:38 +0000 Subject: [PATCH 1/4] Fix Markdown.ToMd: Emphasis serialised as bold, ordered list 0-indexed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs in MarkdownUtils.fs formatSpan/formatParagraph: 1. Emphasis (italic) was serialised as **...** (bold) instead of *...*, causing round-trip loss: *italic* → **italic** 2. Ordered list items used 0-based indexing with no period: "0 first", "1 second" instead of "1. first", "2. second" Fix both and add four regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- RELEASE_NOTES.md | 2 ++ .../MarkdownUtils.fs | 4 +-- tests/FSharp.Markdown.Tests/Markdown.fs | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 374650bf..804ac320 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,6 +5,8 @@ ### Fixed * Add regression test confirming that types whose name matches their enclosing namespace are correctly included in generated API docs. [#944](https://github.com/fsprojects/FSharp.Formatting/issues/944) * Fix crash (`failwith "tbd - IndirectImage"`) when `Markdown.ToMd` is called on a document containing reference-style images (`![alt][ref]`). The indirect image is now serialised as `![alt](url)` when the reference is resolved, or `![alt][ref]` when it is not. +* Fix `Markdown.ToMd` serialising `*emphasis*` (italic) spans as `**...**` (bold) instead of `*...*`. +* Fix `Markdown.ToMd` serialising ordered list items with 0-based numbering and no period (e.g. `0 first`) instead of 1-based with a period (e.g. `1. first`). ## 22.0.0-alpha.2 - 2026-03-13 diff --git a/src/FSharp.Formatting.Markdown/MarkdownUtils.fs b/src/FSharp.Formatting.Markdown/MarkdownUtils.fs index c90f1c96..59bf09a3 100644 --- a/src/FSharp.Formatting.Markdown/MarkdownUtils.fs +++ b/src/FSharp.Formatting.Markdown/MarkdownUtils.fs @@ -115,7 +115,7 @@ module internal MarkdownUtils = | DirectImage(body, link, _, _) -> sprintf "![%s](%s)" body link | Strong(body, _) -> "**" + formatSpans ctx body + "**" | InlineCode(body, _) -> "`" + body + "`" - | Emphasis(body, _) -> "**" + formatSpans ctx body + "**" + | Emphasis(body, _) -> "*" + formatSpans ctx body + "*" /// Format a list of MarkdownSpan and formatSpans ctx spans = @@ -177,7 +177,7 @@ module internal MarkdownUtils = for (j, line) in List.indexed lines do if i = 0 && j = 0 then - yield $"%i{n} " + line + yield $"%i{n + 1}. " + line else yield " " + line diff --git a/tests/FSharp.Markdown.Tests/Markdown.fs b/tests/FSharp.Markdown.Tests/Markdown.fs index 57e928bc..984047f7 100644 --- a/tests/FSharp.Markdown.Tests/Markdown.fs +++ b/tests/FSharp.Markdown.Tests/Markdown.fs @@ -1257,6 +1257,33 @@ let ``ToMd preserves an unordered list`` () = result |> should contain "banana" result |> should contain "cherry" +[] +let ``ToMd preserves emphasis (italic) text`` () = + // Emphasis must serialise as *...* not **...** (bold) + "*italic*" |> toMd |> should contain "*italic*" + +[] +let ``ToMd preserves emphasis distinct from strong`` () = + let result = "**bold** and *italic*" |> toMd + result |> should contain "**bold**" + // Emphasis must not be rendered with double asterisks + result |> should not' (contain "**italic**") + result |> should contain "*italic*" + +[] +let ``ToMd preserves an ordered list with correct numbering`` () = + let result = "1. first\n2. second\n3. third" |> toMd + result |> should contain "1. first" + result |> should contain "2. second" + result |> should contain "3. third" + +[] +let ``ToMd ordered list does not use zero-based numbering`` () = + // Before fix: ordered list items were prefixed "0 ", "1 ", "2 " (0-indexed, no period) + let result = "1. only item" |> toMd + result |> should not' (contain "0 only item") + result |> should contain "1. only item" + [] let ``ToMd preserves a fenced code block`` () = let md = "```fsharp\nlet x = 1\n```" From 36bfcf2b3faf8176b578955a42d1ba5abf9f3e2a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Mar 2026 08:58:29 +0000 Subject: [PATCH 2/4] ci: trigger checks From 8dd8f8a2a48a3159dd4033395423db7f252bf365 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Mar 2026 15:41:19 +0000 Subject: [PATCH 3/4] docs: add issue/PR links to all Unreleased release note entries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- RELEASE_NOTES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 804ac320..02b87c37 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,9 +4,9 @@ ### Fixed * Add regression test confirming that types whose name matches their enclosing namespace are correctly included in generated API docs. [#944](https://github.com/fsprojects/FSharp.Formatting/issues/944) -* Fix crash (`failwith "tbd - IndirectImage"`) when `Markdown.ToMd` is called on a document containing reference-style images (`![alt][ref]`). The indirect image is now serialised as `![alt](url)` when the reference is resolved, or `![alt][ref]` when it is not. -* Fix `Markdown.ToMd` serialising `*emphasis*` (italic) spans as `**...**` (bold) instead of `*...*`. -* Fix `Markdown.ToMd` serialising ordered list items with 0-based numbering and no period (e.g. `0 first`) instead of 1-based with a period (e.g. `1. first`). +* Fix crash (`failwith "tbd - IndirectImage"`) when `Markdown.ToMd` is called on a document containing reference-style images (`![alt][ref]`). The indirect image is now serialised as `![alt](url)` when the reference is resolved, or `![alt][ref]` when it is not. [#1094](https://github.com/fsprojects/FSharp.Formatting/pull/1094) +* Fix `Markdown.ToMd` serialising `*emphasis*` (italic) spans as `**...**` (bold) instead of `*...*`. [#1102](https://github.com/fsprojects/FSharp.Formatting/pull/1102) +* Fix `Markdown.ToMd` serialising ordered list items with 0-based numbering and no period (e.g. `0 first`) instead of 1-based with a period (e.g. `1. first`). [#1102](https://github.com/fsprojects/FSharp.Formatting/pull/1102) ## 22.0.0-alpha.2 - 2026-03-13 From b8d952f22e94691f4a1c55258c6909123cb7ba22 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Mar 2026 15:43:07 +0000 Subject: [PATCH 4/4] ci: trigger checks