From 518d73dffbbb4ab7e6e72792cb44d0a41e5a1bae Mon Sep 17 00:00:00 2001 From: Thth Date: Wed, 10 Oct 2018 23:11:20 -0700 Subject: [PATCH 1/2] Improve Elixir lexer number rules --- lib/rouge/lexers/elixir.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/rouge/lexers/elixir.rb b/lib/rouge/lexers/elixir.rb index 80f795fe4c..6bcea49839 100644 --- a/lib/rouge/lexers/elixir.rb +++ b/lib/rouge/lexers/elixir.rb @@ -38,8 +38,11 @@ class Elixir < RegexLexer rule %r/[a-zA-Z_!]\w*[!\?]?/, Name rule %r{::|[%(){};,/\|:\\\[\]]}, Punctuation rule %r/@[a-zA-Z_]\w*|&\d/, Name::Variable - rule %r{\b(0[xX][0-9A-Fa-f]+|\d(_?\d)*(\.(?![^\d\s]) - (_?\d)*)?([eE][-+]?\d(_?\d)*)?|0[bB][01]+)\b}x, Num + rule %r{\b\d(_?\d)*(\.(?![^\d\s])(_?\d)+)([eE][-+]?\d(_?\d)*)?\b}, Num::Float + rule %r{\b0x[0-9A-Fa-f](_?[0-9A-Fa-f])*\b}, Num::Hex + rule %r{\b0o[0-7](_?[0-7])*\b}, Num::Oct + rule %r{\b0b[01](_?[01])*\b}, Num::Bin + rule %r{\b\d(_?\d)*\b}, Num::Integer mixin :strings mixin :sigil_strings From 8a6955daae511c07caed33e1064aa03686dc194e Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Wed, 26 Jun 2019 14:25:05 +0900 Subject: [PATCH 2/2] Add numbers to visual sample --- spec/visual/samples/elixir | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/visual/samples/elixir b/spec/visual/samples/elixir index ef83f0eeca..acc91c07e2 100644 --- a/spec/visual/samples/elixir +++ b/spec/visual/samples/elixir @@ -1,3 +1,10 @@ +# numbers +291 # integer +0b100100011 # binary +0o443 # octal +0x123 # hexadecimal +291.0 # float + # keywords with no following whitespace (cond) (do)