Skip to content

Support Elixir#1084

Open
patrols wants to merge 1 commit into
basecamp:mainfrom
patrols:add-elixir-language
Open

Support Elixir#1084
patrols wants to merge 1 commit into
basecamp:mainfrom
patrols:add-elixir-language

Conversation

@patrols

@patrols patrols commented May 31, 2026

Copy link
Copy Markdown

What

Adds Elixir as a supported code-block language, so it appears in the language picker and gets syntax highlighting.

Why

Elixir was missing from the picker (the dropdown jumps from Diff to Go), so code blocks couldn't be highlighted as Elixir. Prism ships an Elixir grammar, so this is a small, self-contained addition.

How

Mirrors the existing manual language entries (Ruby/PHP/Go/Bash/JSON/Diff/Kotlin):

  • src/config/prism.js — register the grammar: import "prismjs/components/prism-elixir".
  • src/elements/code_language_picker.js — add languages.elixir ||= "Elixir" to the picker (needed because @lexical/code's CODE_LANGUAGE_FRIENDLY_NAME_MAP doesn't include Elixir — same reason the other languages above are hand-added). The getter sorts alphabetically, so it slots in automatically.
  • test/javascript/unit/helpers/code_highlighting_helper.test.js — add "elixir" to expectedGrammars so the parametric test asserts the grammar loads.
  • test/dummy/app/views/sandbox/_code.html.erb — add an Elixir example (alphabetically between Diff and Go).

prismjs/components/prism-elixir has no extra Prism dependency (no require in components.json), so nothing else needs importing.

Testing

  • yarn test — passes, including the new Prism includes the elixir grammar assertion.
  • yarn lint — clean.
  • yarn build — builds cleanly with the new import.

Register the Prism Elixir grammar and add Elixir to the code-block language picker, mirroring the existing Ruby/Kotlin entries. Also adds a unit-test grammar assertion and a sandbox example.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@samuelpecher

Copy link
Copy Markdown
Collaborator

Hey @patrols. I think the best way to go here would be introducing a straightforward way for implementers to customize the list for their app rather than trying to support a large super-set in Lexxy core.

@patrols

patrols commented Jun 1, 2026

Copy link
Copy Markdown
Author

@samuelpecher Yeah, fair enough. no point growing the core list forever, and it all gets bundled eagerly right now anyway.

I think configure() is already a decent hook for this, since it runs before the editor elements mount. Something like:

Lexxy.configure({ languages: { elixir: "Elixir" } })

and the picker merges that on top of the Lexical map + the built-in names, instead of me hardcoding each one.

Couple of things I wasn't sure about:

  • That only handles the dropdown name. the highlighting still needs the grammar on Lexxy's Prism. In a bundler app the consumer can just import "prismjs/components/prism-elixir" and it lands on the shared instance, but since Lexxy ships prebuilt, an importmap app (like mine) can only reach that instance through the window.Prism global. So: leave grammar registration to the app that way, or have Lexxy expose its Prism / take the grammar so there's a blessed path?
  • Want me to trim the built-in list down to a smaller default as part of this, or just add the hook and leave the current set for now?

Can rework the PR around whatever you'd prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants