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

New regex for matching numbers #2995

Closed
wants to merge 6 commits into from
Closed

Conversation

Roopesh2
Copy link

The old regex for detecting number doesn't work in following edge cases:
0xf_f_f_f_ffn,
0xf_f_f_f_f,
0b1_1_1_1,
0b0_0_1_0_1_0_1n,
0o1_1_3_2,
0o1_1_3_2n,
2.2_4_54e64_33,
2.2_4_54e+64_33,
2.2_4_54e-64_33,
3_4_5,
3_4_5.5_5_6

The new one also detects these kind of numbers. (I know these are rare and not encouraged, but I think it should be also supported because they are also valid numbers).

@github-actions
Copy link

github-actions bot commented Jul 11, 2021

JS File Size Changes (gzipped)

A total of 1 files have changed, with a combined diff of -1 B (-0.1%).

file master pull size diff % diff
components/prism-javascript.min.js 1.5 KB 1.5 KB -1 B -0.1%

Generated by 🚫 dangerJS against 0464021

@RunDevelopment
Copy link
Member

Thank you for the PR @Roopesh2!

Please rebuild Prism by running npm ci && npm run build. Also, please add your discovered edge cases to the JS number test and run npm run test:languages -- --update to update the snapshot (if needed, more info about tests can be found here).

@Roopesh2
Copy link
Author

Roopesh2 commented Jul 12, 2021

@RunDevelopment I've rebuilt code and updated test codes

@Roopesh2
Copy link
Author

@RunDevelopment Please don't merge this PR now. I've to work more on this as I found another critical bug. Bug is that number in a variable starting with '$' gets matched.

@Roopesh2 Roopesh2 marked this pull request as draft July 13, 2021 07:56
@RunDevelopment
Copy link
Member

Closed in favor of #3149.

Thank you for reporting these problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants