Skip to content

[Repo Assist] fix: Markdown.ToMd preserves YAML frontmatter#1165

Merged
dsyme merged 5 commits intomainfrom
repo-assist/fix-tomd-yaml-frontmatter-2026-04-13-bca272bf909c4735
Apr 13, 2026
Merged

[Repo Assist] fix: Markdown.ToMd preserves YAML frontmatter#1165
dsyme merged 5 commits intomainfrom
repo-assist/fix-tomd-yaml-frontmatter-2026-04-13-bca272bf909c4735

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

Markdown.ToMd was silently dropping YAML front-matter blocks when serialising a parsed MarkdownDocument back to Markdown text. Any document opened with a ---...--- front-matter block would lose it on round-trip.

Root Cause

In MarkdownUtils.fs, the formatParagraph function had:

| YamlFrontmatter _ -> ()

This matched the YamlFrontmatter AST node and emitted nothing. For HTML and LaTeX output formats this is correct (front-matter is metadata, not content), but for the Markdown serialiser (ToMd) it means the front-matter is permanently lost.

Fix

Emit the --- delimiters and the front-matter lines in formatParagraph:

| YamlFrontmatter(lines, _) ->
    yield "---"
    for line in lines do
        yield line
    yield "---"
    yield ""

Tests

Two new [<Test>] cases added to FSharp.Markdown.Tests:

  • ToMd preserves YAML frontmatter — round-trips a document with populated front-matter
  • ToMd preserves empty YAML frontmatter — round-trips a document with empty ---\n--- block

Test Status

  • FSharp.Markdown.Tests: 283 passed, 0 failed (2 new tests added)
  • FSharp.Literate.Tests: 143 passed, 0 failed
  • i️ FSharp.ApiDocs.Tests: 80 pre-existing failures on main (unrelated to this change, verified by running on unmodified main)

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

To install this agentic workflow, run

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

When Markdown.ToMd serialises a parsed MarkdownDocument back to Markdown
text, YamlFrontmatter paragraphs were silently dropped. Documents
containing a YAML front-matter block (--- ... ---) would lose that block
on round-trip.

Fix: emit the --- delimiters and frontmatter lines in formatParagraph so
round-trips are lossless.

Add two new tests: one with populated frontmatter and one with an empty
block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review April 13, 2026 12:11
@dsyme dsyme merged commit d98e7e6 into main Apr 13, 2026
4 checks passed
@dsyme dsyme deleted the repo-assist/fix-tomd-yaml-frontmatter-2026-04-13-bca272bf909c4735 branch April 13, 2026 13: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.

1 participant