prettier-plugin-go-template icon indicating copy to clipboard operation
prettier-plugin-go-template copied to clipboard

prettier-ignore comments don't work for html fragments

Open josharian opened this issue 3 years ago • 3 comments

We have a series of templates that are used to render headers and footers piecemeal. They contain mismatch html tags, by design.

I figured we could work around this by using ignore comments. However, this doesn't work.

{{/* prettier-ignore-start */}}
</head>
{{/* prettier-ignore-end */}}

This yields:

Error: An error occured during printing. Found invalid node block.

josharian avatar Oct 13 '22 22:10 josharian

Yep, as you probably figured out, mismatched HTML tags are currently a problem as the parser is just a derivation from the regular HTML parser with additions.

NiklasPor avatar Oct 14 '22 05:10 NiklasPor

Yep. :)

The thing I was surprised by here is that the ignore comments didn’t resolve the problem—I guess I expected them to cause the intervening contents to be completely skipped during the analysis.

josharian avatar Oct 14 '22 05:10 josharian

For anyone else stumbling across this:

If you have a comment that you don't want prettier to format, do the following:

{{/* prettier-ignore-start */}}
{{/*
      my multiline comment with
         weird indentation
               that prettier would destroy
*/}}
{{/* prettier-ignore-end */}}

The following will not work:

{{/* prettier-ignore */}}
{{/*
      my multiline comment with
         weird indentation
               that prettier would destroy
*/}}

nikwen avatar Oct 11 '23 17:10 nikwen