Prettier is breaking mustache template

Viewed 487

I'm running the monaco editor to edit my mustache files in browser. I have set up a custom code formatter using prettier. The issue is it's adding line breaks at the wrong times when there are style tags. Is it possible to prevent this formatting from happening?

<style>
      :root {
        --green: {{{data.colours.green}}};
        --blue: {{{data.colours.blue}}};
      }
  </style>
<h1>Formatting breaks for css templates</h1>
<p>{{{data.colours.red}}}</p>
</html>

Becomes

<html>
    <style>
  :root {
    --green: {
        {
          {
          data.colours.green
        }
      }
    }

    ;

    --blue: {
        {
          {
          data.colours.blue
        }
      }
    }

    ;
  }
</style>
    <h1>
        Formatting breaks for css templates
    </h1>
    <p>
        {{{data.colours.red}}}
    </p>
</html>

Mustache can not run with this formatting

      monaco.languages.registerDocumentFormattingEditProvider('text/html', {
        async provideDocumentFormattingEdits(model) {
          const text = prettier.format(model.getValue(), { parser: "glimmer", htmlWhitespaceSensitivity: 'strict' });      
          return [
            {
              range: model.getFullModelRange(),
              text,
            },
          ];
        },
      });
0 Answers
Related