Skip to content

bracketSameLine splits closing tags across lines, breaking Hugo parsing #124

@markgoho

Description

@markgoho

Bug Report: bracketSameLine option splits closing tags across lines

Description

When using bracketSameLine: true, the plugin incorrectly splits closing HTML tags across multiple lines (e.g., </a> becomes </a on one line and > on the next), which breaks Hugo template parsing.

Configuration

.prettierrc:

{
  "plugins": ["prettier-plugin-go-template"],
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "go-template",
        "bracketSameLine": true
      }
    }
  ]
}

Input

{{- $url := "https://example.com" -}}
<a href="{{ $url }}" class="link" target="_blank">Link Text</a>

Current Output (buggy)

{{- $url := "https://example.com" -}}
<a
  href="{{ $url }}"
  class="link"
  target="_blank"
  >Link Text</a
>

Note: The closing </a> tag is split into </a and > on separate lines.

Expected Output

{{- $url := "https://example.com" -}}
<a href="{{ $url }}" class="link" target="_blank">Link Text</a>

With bracketSameLine: true, the entire tag should remain on one line, or at minimum, the closing tag should not be split.

Impact

Hugo's template parser generates malformed HTML when the closing tag is split:

<a< p="">

This makes the link invisible/non-functional.

Environment

  • prettier-plugin-go-template: 0.0.15
  • prettier: 3.8.0
  • Hugo shortcode context (.html files in layouts/shortcodes/)

Workaround

Currently using .prettierignore to exclude shortcode files from formatting.

Note on Project Status

I'm aware from #123 that this project may be archived. Filing this issue to document the bug for anyone who forks/maintains the project in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions