Skip to content

Conversation

enescakir
Copy link

CSS classes cannot begin with digits. For this reason, Tailwind uses \3 to escape them. For instance, 2xl:col-span-10 is transformed into .\32xl\:col-span-10 { grid-column: span 10 / span 10; } in the final CSS file.

tailwindlabs/tailwindcss#3069

The current Tailwind CSS class sorter implementation does not handle this correctly. As it cannot identify suitable classes beginning with digits, it places them at the start of the sorted list.

Expected output:

divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10

Current output:

2xl:col-span-10 divide-y divide-gray-200 pb-10 lg:col-span-8 xl:col-span-9

I simply remove the escape characters from the class name.

CSS classes cannot begin with digits. For this reason, Tailwind uses
`\3` to escape them. For instance, `2xl:col-span-10` is transformed into
`.\32xl\:col-span-10 { grid-column: span 10 / span 10; }` in the final
CSS file.

tailwindlabs/tailwindcss#3069

The current Tailwind CSS class sorter implementation does not handle
this correctly. As it cannot identify suitable classes beginning with
digits, it places them at the start of the sorted list.

Expected output:

    divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10

Current output:

    2xl:col-span-10 divide-y divide-gray-200 pb-10 lg:col-span-8 xl:col-span-9

I simply remove the escape characters from the class name.
@enescakir
Copy link
Author

Hi @elia, do you have any reviews for this PR?

1 similar comment
@enescakir
Copy link
Author

Hi @elia, do you have any reviews for this PR?

enescakir added a commit to ubicloud/ubicloud that referenced this pull request Nov 7, 2024
We were using a forked version of nebula/erb-formatter due to these two
commits:
- ubicloud/erb-formatter@05b30f6
- ubicloud/erb-formatter@a9ff000

These issues have been fixed upstream, so I initially planned to switch
to the official package. However, I encountered another problem and
created two PRs to address them. Unfortunately, I didn't receive any
response from the maintainer. Thus, I've decided to continue using our
updated forked version.
- nebulab/erb-formatter#58
- nebulab/erb-formatter#59
enescakir added a commit to ubicloud/ubicloud that referenced this pull request Nov 7, 2024
We were using a forked version of nebula/erb-formatter due to these two
commits:
- ubicloud/erb-formatter@05b30f6
- ubicloud/erb-formatter@a9ff000

These issues have been fixed upstream, so I initially planned to switch
to the official package. However, I encountered another problem and
created two PRs to address them. Unfortunately, I didn't receive any
response from the maintainer. Thus, I've decided to continue using our
updated forked version.
- nebulab/erb-formatter#58
- nebulab/erb-formatter#59
@elia elia requested a review from Copilot April 7, 2025 10:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

lib/erb/formatter/command_line.rb:12

  • Ensure that the sequential gsub calls correctly handle all variants of escaped digit prefixes. Consider combining them into a single regex for clarity and to avoid potential mismatches in edge cases.
classes = css.tr(","," ").split(" ").grep(/\./).uniq.map { _1.split('.').last.gsub("\3", "").gsub("\", "") }

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.

1 participant