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
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

### Fixed
* Fix `Markdown.ToMd` silently dropping `EmbedParagraphs` nodes: the serialiser now delegates to the node's `Render()` method and formats the resulting paragraphs, consistent with the HTML and LaTeX back-ends.
* Fix `Markdown.ToMd` dropping link titles in `DirectLink` and `DirectImage` spans. Links with a title attribute (e.g. `[text](url "title")`) now round-trip correctly; without this fix the title was silently discarded on serialisation.
* Fix `Markdown.ToMd` serialising inline code spans that contain backtick characters. Previously, `InlineCode` was always wrapped in single backticks, producing syntactically incorrect Markdown when the code body contained backticks. Now the serialiser selects the shortest backtick fence that does not collide with the body content (e.g. a double-backtick fence for bodies containing single backticks, triple for double, etc.), matching the CommonMark spec.

Expand Down
4 changes: 1 addition & 3 deletions src/FSharp.Formatting.Markdown/MarkdownUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ module internal MarkdownUtils =
yield "> " + line

yield ""
| _ ->
printfn "// can't yet format %0A to markdown" paragraph
yield "" ]
| EmbedParagraphs(cmd, _) -> yield! cmd.Render() |> Seq.collect (formatParagraph ctx) ]

/// Strips <c>#if SYMBOL</c> / <c>#endif // SYMBOL</c> conditional compilation lines from an .fsx code block
/// so that format-specific sections are removed from non-target output formats.
Expand Down
14 changes: 14 additions & 0 deletions tests/FSharp.Markdown.Tests/Markdown.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,3 +1417,17 @@ let ``ToMd round-trip: indirect image with unresolved reference`` () =
let result = Markdown.ToMd(doc)
// When key is not resolved, should preserve the indirect form
result |> should contain "![alt text][unknown-ref]"

[<Test>]
let ``ToMd serialises EmbedParagraphs by delegating to Render()`` () =
// EmbedParagraphs was previously falling through to the catch-all '| _' branch,
// emitting a debug printfn and yielding an empty string. It should instead
// delegate to the Render() method and format the resulting paragraphs.
let inner =
{ new MarkdownEmbedParagraphs with
member _.Render() =
[ Paragraph([ Literal("embedded text", MarkdownRange.zero) ], MarkdownRange.zero) ] }

let doc = MarkdownDocument([ EmbedParagraphs(inner, MarkdownRange.zero) ], dict [])
let result = Markdown.ToMd(doc)
result |> should contain "embedded text"