Skip to content

Commit

Permalink
Detect Elixir syntax by shebang (#2001)
Browse files Browse the repository at this point in the history
  • Loading branch information
arathunku authored Oct 25, 2023
1 parent 55d2b48 commit c71fa2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rouge/lexers/elixir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Elixir < RegexLexer

filenames '*.ex', '*.exs'

def self.detect?(text)
return true if text.shebang?('elixir')
end

mimetypes 'text/x-elixir', 'application/x-elixir'

state :root do
Expand Down
4 changes: 4 additions & 0 deletions spec/lexers/elixir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
assert_guess :mimetype => 'text/x-elixir'
assert_guess :mimetype => 'application/x-elixir'
end

it 'guesses by source' do
assert_guess :source => '#!/usr/bin/env elixir'
end
end
end

0 comments on commit c71fa2f

Please sign in to comment.