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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Dev Improvements:

- chore(dev) add theme picker to the tools/developer tool (#2770) [Josh Goebel][]
- fix(ruby) add support for expontential, real, and imaginary notation (#2766) [Kevin Hamer][]

[Josh Goebel]: https://github.com/joshgoebel

Expand Down
2 changes: 1 addition & 1 deletion src/languages/ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?

relevance: 0
},
{
Expand Down
3 changes: 3 additions & 0 deletions test/markup/ruby/numbers.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
number = <span class="hljs-number">1.0e1_2</span>
number = <span class="hljs-number">1.0e1_2i</span>
number = <span class="hljs-number">1.0r</span>
3 changes: 3 additions & 0 deletions test/markup/ruby/numbers.txt
Original file line number Diff line number Diff line change
@@ -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?