Skip to content

Conversation

@kelvinsjk
Copy link

@kelvinsjk kelvinsjk commented Aug 27, 2024

Description

Prettier currently only formats markdown tagged template literals when there is no interpolation. This PR adds the functionality for when interpolations are detected, mimicking the code flow of how interpolations are handled in the html-embed file.

Closes #16612

Change in result in existing test js/multiparser-comments/comment-inside.js

Currently md`hello`; produces

md`
hello
`;

The existing test has

markdown`${
      foo
  /* comment */
}`;

left verbatim. With this PR, the code above is formatted to

markdown`
${
      foo
  /* comment */
}
`;

I believe this is more consistent with Prettier's behavior with non-interpolated markdown template strings.

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

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.

Interpolation in markdown tagged literal breaks formatting

1 participant