chroma icon indicating copy to clipboard operation
chroma copied to clipboard

Elixir lexer missing builtin keywords

Open mroach opened this issue 4 years ago • 0 comments

Bug description

The ElixirLexer from pygments appears to have a non-standard way of declaring all of the builtin terms. This makes the rendering of Elixir code appear nearly broken since not even function declarations are highlighted.

Sample code

defmodule MyApp.Languages do
  require Logger
  use MyApp.Stats
  alias MyApp.Config

  @iso_codes for line <- File.stream!("priv/data/iso-639-3.tab"),
                 row = String.split(line, "\t"),
                 code = Enum.at(row, 3),
                 String.length(code) == 2,
                 code = String.to_atom(code),
                 Enum.at(row, 5) == "L",
                 name = Enum.at(row, 6),
                 do: {code, name},
                 into: %{}

  def iso_codes, do: @iso_codes

  for {code, name} <- @iso_codes do
    def get_lang_name(unquote(code)), do: {:ok, unquote(name)}
  end

  def get_lang_name(_), do: {:error, :invalid}
end

Compare the highlighting here on GitHub with the Chroma Playground. Words missing highlighting include defmodule, do, require, use, alias, def, for, end, quote, unquote

Screenshot from Chroma Playground

Screenshot 2020-07-11 at 17 28 19

Steps taken

I ran pygments2chroma.py for pygments.lexers.erlang.ElixirLexer which produces nearly the same code as exists now, so there's something either wrong with the pygments lexer or the invocation of it to create a Chroma lexer.

mroach avatar Jul 11 '20 21:07 mroach