4

I notice that Elixir snippets are not highlighted. It's supported by the Highlight.js project but using 'elixir' directly after backticks does not do anything:

module Foo do
  def test(arg) do
    IO.inspect(arg)
  end
end
2
  • 1
    related: meta.stackexchange.com/questions/208528/…
    – rene
    Commented Feb 4, 2021 at 16:11
  • @rene just to note with that other question, it's my understanding that the syntax highlighting library has completely changed since that question was asked. So I felt it was relevant to ask anew! Commented Feb 4, 2021 at 16:18

1 Answer 1

5

Edit: this is merely making the syntax highlighting switch to a default mode. Which is an improvement, but still not using the correct syntax highlighting.

Ok I see the issue is that it needs to be in the format: lang-elixir

module Foo do
  def test(arg) do
    IO.inspect(arg)
  end
end

I was going off this line in What is syntax highlighting and how does it work?:

If you are using code fences (three back-ticks above and below the code block, put the language name right after the opening back-ticks, the lang- prefix is not needed:

But I guess there is a differentiation if it's not an officially supported language from this list: What is syntax highlighting and how does it work?

If anyone knows how to get it officially supported, that would be great.

Sorry for the confusion.

9
  • 1
    Using elixir as the syntax hint means "use the language defined for the tag elixir" while lang-elixir is "use the syntax highlighting for the elixir language". I guess that means that the elixir tag doesn't have an associated style.
    – VLAZ
    Commented Feb 4, 2021 at 16:24
  • 2
    Nope, that is lang-default you have now because Any language identifiers used in a post that go unrecognized by highlight.js will functionally default to lang-default.
    – rene
    Commented Feb 4, 2021 at 16:25
  • The [elixir] tag has no default syntax highlighting set. However, there is no lang-elixir option available for us to set for that tag. The official list does not indicate that Elixir formatting is even supported. @VLAZ
    – Cody Gray Mod
    Commented Feb 4, 2021 at 16:29
  • Oh dear @rene, I'll have to downvote my answer! I see now that the highlighting doesn't match the Elixir samples from HighlightJS. I don't understand why the lang code is not working even though it's supported by the lib. Commented Feb 4, 2021 at 22:38
  • SE doesn't include all languages: github.com/highlightjs/highlight.js/tree/master/src/languages instead it carefully picked the ones to support to balance size, performance and applicability. They never had the goal to add the full highlight.js package. See also meta.stackexchange.com/questions/353983/…
    – rene
    Commented Feb 4, 2021 at 22:50
  • Thanks for the detailed explanation @rene. I don't suppose you know if there's a process to request Elixir be added? Commented Feb 5, 2021 at 10:18
  • 1
    You could start a bounty on that FR on MSE, maybe with adding an comment that highlight.js has support for the language. If you're able to give some numbers on how much added size would be expected with adding elixir to the highlight.js package would be helpful to see if it is worth adding without too much overhead for all other users across the SE network.
    – rene
    Commented Feb 5, 2021 at 10:25
  • Request posted, thanks for your help @rene. meta.stackexchange.com/questions/360682/… Commented Feb 7, 2021 at 22:13
  • 1
    [Author of Highlight.js here] I wrote Chrome extension to solve some of these issues, but I don't really have the time to keep it updated. But if it might help anyone: github.com/joshgoebel/se_highlightjs It bundles it's own local copy of Highlight.js so all languages we support are supported. Your mileage may vary. If someone wanted to step up and keep it maintained that'd be awesome. Commented Feb 15, 2021 at 2:35

Not the answer you're looking for? Browse other questions tagged .