Skip to content

[3.9 regression] Markdown: multi-line {{% … %}} shortcode corrupted — standalone %}} line rewritten to } #19488

Description

@chalin

Prettier 3.9.1 (also 3.9.0; both current latest). This is a regression — every 3.8.x release leaves the input untouched (verified on 3.8.3 and the latest 3.8.x, 3.8.5).

Playground link

Formatting Markdown that contains a multi-line Hugo shortcode whose closing %}} delimiter sits on its own line silently rewrites that line to a bare }, corrupting the document. No error or warning is emitted.

Input (prettier --parser markdown input.md):

{{% blocks/cover
title="Welcome"
%}}

Body text here.

{{% /blocks/cover %}}

Output (3.9.0 and 3.9.1):

{{% blocks/cover
title="Welcome"
}

Body text here.

{{% /blocks/cover %}}

Expected (unchanged — what every 3.8.x release produces):

{{% blocks/cover
title="Welcome"
%}}

Body text here.

{{% /blocks/cover %}}

Notes

  • The standalone %}} line becomes } — the %} is dropped and the document's meaning changes. A single-line {{% … %}} is fine; only the multi-line opener (closing delimiter on its own line) triggers it. Default options reproduce it (see Playground link).
  • This isn't a request to format Hugo shortcodes — only to leave them untouched, exactly as every 3.8.x release did. Silently rewriting syntax it doesn't fully parse is data corruption, and because multi-line shortcodes are common in Hugo content, 3.9.x is effectively unusable on many Hugo sites until this is fixed. (Re: the non-standard-syntax disclaimer — non-destructive pass-through is what's expected here, not bespoke shortcode support.)
  • Likely cause: the 3.9.0 Markdown parser swap remark-parse v8 → micromark v4 (Upgrade to latest micromark (markdown only) #18277).
  • Related but distinct: Markdown file fail to parse #19386 was a parse crash (RangeError) in the same {{ … }} area, fixed before 3.9.0 shipped; this is a different symptom — a silent rewrite, no crash.

Environment

  • Prettier 3.9.1 (and 3.9.0)
  • --parser markdown, default options

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:markdownIssues affecting Markdown

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions