Skip to content

Feat: Support parsing markdown tagged template literals with interpolation #16614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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