Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +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 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

Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Formatting.Markdown/MarkdownUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions tests/FSharp.Markdown.Tests/Markdown.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,33 @@ let ``ToMd preserves an unordered list`` () =
result |> should contain "banana"
result |> should contain "cherry"

[<Test>]
let ``ToMd preserves emphasis (italic) text`` () =
// Emphasis must serialise as *...* not **...** (bold)
"*italic*" |> toMd |> should contain "*italic*"

[<Test>]
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*"

[<Test>]
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"

[<Test>]
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"

[<Test>]
let ``ToMd preserves a fenced code block`` () =
let md = "```fsharp\nlet x = 1\n```"
Expand Down
Loading