highlight.js support

134 views
Skip to first unread message

Dave Thomas

unread,
Nov 18, 2013, 5:33:41 PM11/18/13
to elixir-l...@googlegroups.com
Before I spend a few hours on it, does anyone already have a highlight.js module for Elixir?


Dave

Gustavo Brunoro

unread,
Nov 18, 2013, 6:40:39 PM11/18/13
to elixir-l...@googlegroups.com
I don't know about highlight.js, but pygments (http://pygments.org/) has an Elixir lexer and can generate HTML/CSS output.


2013/11/18 Dave Thomas <da...@pragprog.com>
Before I spend a few hours on it, does anyone already have a highlight.js module for Elixir?


Dave

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dave Thomas

unread,
Nov 18, 2013, 7:02:51 PM11/18/13
to elixir-l...@googlegroups.com
Yeah, but unfortunately I need this in-browser. 

José Valim

unread,
Nov 19, 2013, 2:07:43 AM11/19/13
to elixir-l...@googlegroups.com
As a side-note, in case anyone is interested, the pygments parser really needs improving since the last updates were a long time ago. Github uses pygments and we can from time to time see Github failing to highlight the latest Elixir versions (sigils in particular come to mind).



José Valim
Skype: jv.ptec
Founder and Lead Developer

Josh Adams

unread,
Dec 1, 2013, 4:42:27 PM12/1/13
to elixir-l...@googlegroups.com, da...@pragprog.com
Dave,

Did you ever find an in-browser highlighter that supported elixir, or write a language file for it?  I'm about to embark down the exact same path (or I'll just use vimdeck and like three different programs to manage one presentation, which will be an orchestration nightmare but I can pull it off)

Josh Adams

unread,
Dec 1, 2013, 6:54:29 PM12/1/13
to elixir-l...@googlegroups.com, da...@pragprog.com
For the record, I went ahead and opened a pull request with decent elixir support here https://github.com/isagalaev/highlight.js/pull/317

I'd love a more representative sample of various edge cases, so I can check to see how well it handles them.  It's presently mostly a clone of the ruby language support, with minor support added for various bits.

Some nice-to-haves to make it actually good:

- A nice dense example code block with expected output
- A list of elixir lang keywords - right now it's just using the list of ruby keywords, which is obviously wrong but I didn't want to touch it until i had a known-good replacement

Things I know are missing/unrepresented presently:

- defrecord
- use
- alias
- <-
- ->
- fn

I'm going to start on a more elaborate example that includes those use cases and see what I can come up with.  I know they'll be necessary for me to present, so...

Also, since I'm running a three hour presentation through this (at least, that's the plan), it should be easy enough to find bugs as I go through it.

Thoughts?

Josh Adams

unread,
Dec 1, 2013, 7:09:16 PM12/1/13
to elixir-l...@googlegroups.com, da...@pragprog.com
Spent a little more time on it, got it a bit nicer (though defrecord still needs work).  Also figured I'd provide a screenshot of the output :)

Dave Thomas

unread,
Dec 2, 2013, 4:18:43 AM12/2/13
to elixir-l...@googlegroups.com

No, I took a different approach and went with Pygments.

The story is that I wanted to syntax highlight a lot of code in a long Keynote presentation. I wrote a trivial Sinatra server that would serve code fragments according to the path, and then used Keynote's web linking to embed to code in each page. Worked great, and the code in the presentation updated if I changed its on disk. But Keynote 6 no longer supports web linking...

Dave

--

Peter Minten

unread,
Dec 2, 2013, 4:55:06 AM12/2/13
to elixir-l...@googlegroups.com
This is awesome!

Are you planning on supporting doctest code blocks as well? The pygments
Elixir lexer knows about the "iex>" convention and is smart enough not
to highlight the output from iex.

On 12/02/2013 01:09 AM, Josh Adams wrote:
> Spent a little more time on it, got it a bit nicer (though defrecord still
> needs work). Also figured I'd provide a screenshot of the output :)
>
> <https://lh5.googleusercontent.com/-gECR5V5GQKk/UpvPofhQJEI/AAAAAAAANCc/pBx0lNk4Xx4/s1600/Screenshot+from+2013-12-01+18%3A07%3A50.png>

Josh Adams

unread,
Dec 2, 2013, 8:55:24 AM12/2/13
to elixir-l...@googlegroups.com
I just need to add them to the example that's in the test page. Sending myself a reminder since I'm in a drive thru :)
Reply all
Reply to author
Forward
0 new messages