sheharyarn
I would really like to see Syntax Highlighting support for Elixir on Stackoverflow. Someone already created a topic on Meta StackExchange but since SE relies on an external syntax highlighting tool (Google’s code-prettify), there hasn’t been any work to support Elixir (even though an issue was also opened there over a year ago).
I’m interested in making this happen (as someone who spends 5+ hours daily on SO - especially in the Elixir tag). So my questions are:
- How do I get started in adding Elixir support to code-prettify?
- How do I represent Elixir constructs that need to be highlighted?
- And should I even send in a pull request? There seems to be minimal activity in the project, and many pull requests haven’t been merged or closed for a while.
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
The obligatory hello world thread!
Who are you and where are you from? :stuck_out_tongue:
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog
It says that Fly is going all-in on sprites, which is a worry ...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
Is there a word for the ~> symbol used in Version strings?
Do you also just call it a Squiggle Arrow™ ?!
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
nietaki
I was thinking about the same thing and slowly started looking into that. It seems like the syntax highlighting definitions for erlang or Scala aren’t really that complicated, and I would argue Scala has a more ambiguous syntax than Elixir.
It also seems like the code-prettify project is still pretty alive and they do accept PRs, so that’s all looking good.
Is there a good place to get Elixir’s grammar or something similar? It would probably help make the highlighter more comprehensive.
tyro
In the Elixir issue for code-prettify (here), they link to the atom editor elixir grammar (here) which looks quite useful.
nietaki
I looked into how the google-prettify works and prepared a plugin for elixir that seems to be working. Now I could use you guys’ help making sure it’s nice and robust.
Here’s how you can try it out: I put an editable example in the
live-previewbranch of my fork of the repo. Clone it and open it in a browser or go to rawgit and you can play around with the source code and see how the prettifier behaves.Let me know what you think! Please point out what needs improving.
Notes:
1_000is a correct integer, but1__000isn’t and shouldn’t be highlighted like one.lang-elixirbranch - the live preview is just a utility and won’t be included in the PR for the main project.createSimpleLexerOvermindDL1
As long as their lexer is not something stupid like regex it should not be hard.
I really really hate the idiotic highlighting libraries that think everything can be lexed with regex, morons…
nietaki
Don’t look in the source then
It is what it is though, as long as it makes the StackOverflow questions/answers more readable, I’m a happy person.
nietaki
I have tried the highlighting with some more code and ironed out some issues. An updated interactive demo still available on rawgit.
I’m aiming to write some tests and submit a PR this weekend, so if you have any feedback, speak up
nietaki
It feels like I’m mostly talking to myself here, but here’s the PR for the Elixir support: Add Elixir language support by nietaki · Pull Request #478 · googlearchive/code-prettify · GitHub
OvermindDL1
Cool, better syntax highlighting on popular syntax highlighters, even if the syntax highlighter itself is stupidly made in regex but nothing you can do about that, is still a great help due to the visibility!
notriddle
Breaks when I type this in:
It might not support hilighting inside string interpolation, but it should at least ignore quotes inside of an interpolated part, so it doesn’t just look wrong.
notriddle
Your example here:
Both of them are atoms; :“also an atom” and :“yes, this compiles” are both atoms. Your syntax hilighter thinks that “yes, this compiles” is a string.