Skip to content

Only parse front matter at the top of the document - #245

Merged
g-plane merged 4 commits into
g-plane:mainfrom
UnknownPlatypus:fix-front-matter-position
Aug 12, 2026
Merged

Only parse front matter at the top of the document#245
g-plane merged 4 commits into
g-plane:mainfrom
UnknownPlatypus:fix-front-matter-position

Conversation

@UnknownPlatypus

@UnknownPlatypus UnknownPlatypus commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #244

This is a minimal fix but I'm wondering if we should not do the frontmatter check in parse_root instead since frontmatter is only expected at the start of the file ?

We currently pay (and were paying) the frontmatter check on every - in the document

Maybe something like that

pub fn parse_root(&mut self) -> PResult<Root<'s>> {
    let mut children = vec![];

    if matches!(
        self.language,
        Language::Html
            | Language::Astro
            | Language::Django
            | Language::Jinja
            | Language::Vento
            | Language::Mustache
    ) && self.source.starts_with("---")
    {
        let (kind, raw) = self.with_taken(|parser| {
            parser.parse_front_matter().map(NodeKind::FrontMatter)
        })?;
        children.push(Node { kind, raw });
    }

    while self.chars.peek().is_some() {
        children.push(self.parse_node()?);
    }

    Ok(Root { children })
}
  • The pull request description was written manually by me and was not generated by an AI tool or agent.
  • I have read and understood the relevant parts of the existing codebase before making these changes.
  • I have carefully reviewed and understood all code changes, and ensured that they match the style, architecture, and conventions of the existing codebase.
  • I understand that pull requests containing blindly generated or unreviewed AI-generated code may be closed without review.

@netlify

netlify Bot commented Aug 9, 2026

Copy link
Copy Markdown

Deploy Preview for markup-fmt ready!

Name Link
🔨 Latest commit 1bb015f
🔍 Latest deploy log https://app.netlify.com/projects/markup-fmt/deploys/6a7bea0b84e99a000817aa45
😎 Deploy Preview https://deploy-preview-245--markup-fmt.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread markup_fmt/src/parser.rs Outdated
@g-plane
g-plane merged commit cd66e26 into g-plane:main Aug 12, 2026
5 checks passed
@UnknownPlatypus
UnknownPlatypus deleted the fix-front-matter-position branch August 12, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<span>---</span> fails to parse

2 participants