Skip to content

[Repo Assist] fix: handle EmbedParagraphs in Markdown.ToMd serialiser#1145

Open
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-embed-paragraphs-tomd-2026-04-05-e2fc6ffbda28ed0b
Open

[Repo Assist] fix: handle EmbedParagraphs in Markdown.ToMd serialiser#1145
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/fix-embed-paragraphs-tomd-2026-04-05-e2fc6ffbda28ed0b

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 5, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Markdown.ToMd (the Markdown-to-Markdown serialiser in MarkdownUtils.formatParagraph) did not handle the EmbedParagraphs AST node. It fell through to a catch-all | _ branch that:

  1. Printed a debug message to stdout: // can't yet format <EmbedParagraphs …> to markdown
  2. Yielded an empty string, silently dropping the paragraph's content

Both the HTML formatter (HtmlFormatting.fs line 169) and the LaTeX formatter (LatexFormatting.fs line 124) already handle EmbedParagraphs by calling cmd.Render() and recursing. This PR brings MarkdownUtils.formatParagraph into consistency with them.

Root cause

The | EmbedParagraphs(cmd, _) case was simply missing from formatParagraph in MarkdownUtils.fs.

Fix

Add:

| EmbedParagraphs(cmd, _) -> yield! cmd.Render() |> Seq.collect (formatParagraph ctx)
```

Once all `MarkdownParagraph` DU cases are explicitly handled, the old `| _` catch-all becomes dead code (the compiler now warns FS0026 on it), so it is removed. The exhaustiveness checker will catch any future `MarkdownParagraph` case that lacks a `formatParagraph` clause.

## Changes

- `src/FSharp.Formatting.Markdown/MarkdownUtils.fs` — add `EmbedParagraphs` case; remove dead catch-all
- `tests/FSharp.Markdown.Tests/Markdown.fs` — new test verifying `ToMd` delegates to `Render()`
- `RELEASE_NOTES.md` — entry under `[Unreleased]`

## Test Status

```
Build succeeded.
    0 Warning(s)
    0 Error(s)

Passed!  - Failed: 0, Passed: 282, Skipped: 0, Total: 282  (FSharp.Markdown.Tests)
Passed!  - Failed: 0, Passed: 143, Skipped: 0, Total: 143  (FSharp.Literate.Tests)
Passed!  - Failed: 0, Passed:  88, Skipped: 4, Total:  92  (FSharp.ApiDocs.Tests)
Passed!  - Failed: 0, Passed:  30, Skipped: 2, Total:  32  (FSharp.CodeFormat.Tests)
Passed!  - Failed: 0, Passed:  12, Skipped: 0, Total:  12  (fsdocs-tool.Tests)

All tests pass; new test ToMd serialises EmbedParagraphs by delegating to Render() confirms the fix.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@e1ecf341a90b7bc2021e77c58685d7e269e20b99

Previously EmbedParagraphs fell through to the catch-all '| _' branch in
MarkdownUtils.formatParagraph, emitting a debug printfn to stdout and
yielding an empty string.  All other formatters (HTML, LaTeX) delegate
to cmd.Render() and recurse; this commit brings the Markdown-to-Markdown
back-end into line with them.

The now-dead catch-all branch is removed so the exhaustiveness checker
will catch any new MarkdownParagraph cases that are added without a
corresponding formatParagraph clause.

Fixes: the debug 'can't yet format' output that appeared on stdout
whenever a document containing EmbedParagraphs was serialised via
Markdown.ToMd.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review April 6, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants