Skip to content

Formatter: Preserve Frontmatter when formatting documents#797

Merged
marcoroth merged 2 commits into
mainfrom
formatter-frontmatter
Nov 7, 2025
Merged

Formatter: Preserve Frontmatter when formatting documents#797
marcoroth merged 2 commits into
mainfrom
formatter-frontmatter

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request adds support for preserving frontmatter when formatting HTML+ERB documents.

When the first Node within the DocumentNode is a HTMLTextNode and starts/ends with --- we treat that HTMLTextNode as frontmatter content and preserve/format it exactly as-is.

Example

The following document is now being preserved:

---
title: My Page
layout: application
published: true
---

<div class="container">
  <h1><%= @title %></h1>
</div>

Previously it was formatted as:

--- title: My Page layout: application published: true ---

<div class="container">
  <h1><%= @title %></h1>
</div>

Thanks to @joshuap for the nudge!

@marcoroth marcoroth merged commit d6c87e3 into main Nov 7, 2025
12 checks passed
@marcoroth marcoroth deleted the formatter-frontmatter branch November 7, 2025 05:24
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