Skip to content
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

fix(tsx): prevent slashes in html comment from causing premature closing of comments in the tsx output #929

Merged
merged 4 commits into from
Jan 2, 2024

Conversation

MoustaphaDev
Copy link
Member

Changes

Testing

Added TS tests:

  • For escaping curly braces, didn't find any that covered that.
  • For escaping */
  • To make sure a space is always inserted after an opening comment in the tsx output

Docs

N/A bug fix only

Copy link

changeset-bot bot commented Dec 27, 2023

🦋 Changeset detected

Latest commit: 6f8eac9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -217,6 +217,10 @@ declare const Astro: Readonly<import('astro').AstroGlobal<%s, typeof %s`, propsI
// p.addSourceMapping(n.Loc[0])
p.addNilSourceMapping()
p.print("{/**")
if !unicode.IsSpace(rune(n.Data[0])) {
// always add a space after the opening comment
Copy link
Member Author

@MoustaphaDev MoustaphaDev Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to this approach would be to just escape all slashes in the comment

@MoustaphaDev
Copy link
Member Author

!preview escaped-slash-tsx

Copy link
Contributor

 > [email protected] release /home/runner/work/compiler/compiler > changeset publish "--tag" "next--escaped-slash-tsx" 🦋 warn ===============================IMPORTANT!=============================== 🦋 warn Packages will be released under the next--escaped-slash-tsx tag 🦋 warn ---------------------------------------------------------------------- 🦋 info npm info @astrojs/compiler 🦋 info @astrojs/compiler is being published because our local version (0.0.0-escaped-slash-tsx-20231227120419) has not been published on npm 🦋 info Publishing "@astrojs/compiler" at "0.0.0-escaped-slash-tsx-20231227120419" 🦋 success packages published successfully: 🦋 @astrojs/[email protected] 🦋 Creating git tag... 🦋 New tag: @astrojs/[email protected]

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@ematipico ematipico merged commit fe2f0c8 into main Jan 2, 2024
5 checks passed
@ematipico ematipico deleted the escape-comment-in-tsx branch January 2, 2024 14:41
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.

🐛 BUG: TSX output does not properly escape slashes in HTML comments
3 participants