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

enh(ruby) add support for real, imaginary, and e-notation numbers #2786

Closed
wants to merge 2 commits into from

Conversation

khamer
Copy link

@khamer khamer commented Oct 25, 2020

Changes to regex for matching numbers in ruby. Resolves #2766.

Changes

Changes the number regex for ruby to support exponential notation (1e123) as well as adding a trailing r or i - for real or imaginary numbers.

Checklist

  • Added new markup/ruby/numbers.txt tests
  • Added a note to the changelog
  • Added myself to AUTHORS.txt under Contributors

@@ -128,7 +128,7 @@ export default function(hljs) {
},
{
className: 'number',
begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?([ri]|[eE][-+]?[0-9_]+i?)?)|[0_]\\b',
Copy link
Member

Choose a reason for hiding this comment

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

Please break these out into variants as in the python?

@@ -0,0 +1,3 @@
number = 1.0e1_2
number = 1.0e1_2i
number = 1.0r
Copy link
Member

Choose a reason for hiding this comment

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

A few more tests for 0. and some other edge cases?

@joshgoebel joshgoebel changed the title add ruby support for real, imaginary, and e-notation enh(ruby) add support for real, imaginary, and e-notation numbers Oct 25, 2020
@joshgoebel joshgoebel added the hacktoberfest-accepted Hacktoberfest label Oct 25, 2020
Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

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

Please update (see notes).

@joshgoebel
Copy link
Member

Wait, are you all doing the same things?

#2786
#2788

Should one be build on the other or should one of you wait? Feels like we're duplicating effort here.

@gibson042
Copy link
Contributor

This PR is less correct and complete than #2788, which follows the patterns from #2780. I believe it should be closed.

@joshgoebel
Copy link
Member

Sorry @khamer I think that's accurate and we need to go with #2788 on this one. There are some other low hanging fruit issues if you'd like to find a different issue to contribute to. Not sure if you were jus looking to help out or really wanted to fix this one particular issue. Sorry for any confusion.

@joshgoebel joshgoebel closed this Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ruby) numeric literals with suffixes (exponent, real, imaginary) not highligted
3 participants