Live data from Hacker News

Highlight.js – Syntax highlighting for the Web

highlightjs.org

41–50 of 72 posts

Re: Highlight.js – Syntax highlighting for the Web

#41
post #16

Earlier quoted context omitted.

"So if you look at line 7, you'll see..."

... that the presenter should buy a laser pointer!

Out of several dozen different uses of laser pointers, I've only ever been able to (easily) see perhaps 3 or 4 of them, plus another small portion if focusing entirely on the game of spot-the-laser-pointer. It's related to my colourblindness.

As such, verbal cues (or a long stick) are preferable to a laser pointer. Of course, use a laser pointer to assist those who can see it, but it's better assume half the people in the room can't and use words to this effect.

Re: Highlight.js – Syntax highlighting for the Web

#43

Used this in a project[0] a little while ago and found it really easy to work with. The syntax detection was an added bonus that I had expected to need another library for. http://cmdv.io edit: I should mention that this might be a cool example for someone looking to use hljs in React/Flux-- I tried to make it fairly clean. There's a github link on the bottom-left of the website.

Out of curiosity, are there any decent libraries you looked at for doing language detection? Thhat's the main reason I'm using Highlight.js in one of my projects instead of Prism or Rainbow.

Unfortunately, the tradeoff is no support for generating a display with line numbers. In my case, that was the lesser of two evils, but I wouldn't mind using two libraries if it meant I could get everything I want.

Re: Highlight.js – Syntax highlighting for the Web

#44
post #10

It should be mentioned that this does not support and will indeed never support line numbers due to some strange opinions of the lead developer: http://highlightjs.readthedocs.org/en/latest/line-numbers.ht...

I think this comment/discussion ends up over-emphasizing the 'strangeness' of the line-number situation with this library, the page linked ends with: 'This position is subject to discuss. Also it doesn’t stop anyone from forking the code and maintaining line-numbers implementation separately.', which seems pretty reasonable to me!

Yeah, this is pretty much the behavior that I want to see from open source maintainers: make decisions and build conventions but be open to having your mind convinced of alternatives.

Re: Highlight.js – Syntax highlighting for the Web

#45
post #43

Used this in a project[0] a little while ago and found it really easy to work with. The syntax detection was an added bonus that I had expected to need another library for. http://cmdv.io edit: I should mention that this might be a cool example for someone looking to use hljs in React/Flux-- I tried to make it fairly clean. There's a github link on the bottom-left of the website.

Out of curiosity, are there any decent libraries you looked at for doing language detection? Thhat's the main reason I'm using Highlight.js in one of my projects instead of Prism or Rainbow. Unfortunately, the tradeoff is no support for generating a display with line numbers. In my case, that was the lesser of two evils, but I wouldn't mind using two libraries if it meant I could get everything I want.

Just reading out of my notes, the only non-highlighting detector I was looking at was https://github.com/blakeembrey/node-language-detect, but it's not widely used or developed as far as i can tell.

If you have Ruby in your stack, it's easy -- use github's own https://github.com/github/linguist

You might also be able to use just the language definition files from https://github.com/syntaxhighlighter

Re: Highlight.js – Syntax highlighting for the Web

#46
post #24

Earlier quoted context omitted.

Is line numbers considered "highlighting"? I mean, I get why you would want it but I never would have thought to ask for it.

It does seem more appropriate to have a separate module for line numbers. I would definitely understand the separation of concerns argument, but the maintainer instead makes some sort of emotional appeal about clutter and simplicity to explain why there is no line number support.

> the maintainer instead makes some sort of emotional appeal about clutter and simplicity to explain why there is no line number support

Clutter and simplicity is not an emotional argument. It becomes verifiably more difficult to maintain a code base with each new line. And since he's the one doing the maintaining, his position seems quite reasonable.

Secondly, he seems to have a strong aesthetic aversion to line numbers, and I can totally respect that. Frankly, among popular open source projects, those whose developers have the strongest sense of style and design and usually (not always) the best.

Re: Highlight.js – Syntax highlighting for the Web

#47
post #25

Earlier quoted context omitted.

http://prismjs.com/ is an alternative that supports line numbers.

And in particular prismjs lets you select lines of code without selecting the line numbers, which you probably do not want.

Why wouldn't I want that?

If I am copying and pasting code from a website, it usually goes to my editor and I don't want to have to delete the line numbers from it.

Re: Highlight.js – Syntax highlighting for the Web

#49
This isn't really related to the act of highlighting syntax, but I noticed the example code for Elixir at https://highlightjs.org/static/demo/ is quite out of date. Records generally aren't used anymore, and the syntax to send a message to a process has changed from `pid <- message` to `send(pid, message)`

Re: Highlight.js – Syntax highlighting for the Web

#50
post #47

Earlier quoted context omitted.

And in particular prismjs lets you select lines of code without selecting the line numbers, which you probably do not want.

Why wouldn't I want that? If I am copying and pasting code from a website, it usually goes to my editor and I don't want to have to delete the line numbers from it.

You don't want the line numbers.
Post reply on HN