Hacker News new | ask | show | jobs
by rlx0x 4134 days ago
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...

7 comments

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.
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.

You don't want the line numbers.
Oh if that's what he meant then I read it the wrong way.
Prism is pretty damn good. Although the name sounds like an NSA plan to intercept all the javascript libraries in the world.
I already like this one better, to be honest. It also already has Julia and Rust support. If it were to include Elixir support as well, it'd be perfect.
Line numbers are really helpful when presenting code at an event, in a meeting, etc.
Genuine question, why?
"So if you look at line 7, you'll see..."
... that the presenter should buy a laser pointer!
Laser pointers don't work if the video is being recorded or screencast at the same time. They only work when the viewer is in the same room, and even then, they are typically pretty poor.
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.

This also applies to comments within the presentation, not just the verbal part of the presentation.
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.

Many popular syntax highlighting libraries do include this functionality. For example, the popular Python syntax highlighter "Pygments" supports line numbers[0].

[0] - http://pygments.org/docs/formatters/#HtmlFormatter

I personally use Prism.js for my blogging, which is what Smashing Magazine and CSS-tricks uses. Prism includes line numbers.

I like Prism so far and don't have any issues with it yet

I understand the author's point-of-view on this, but disabling line numbers sounds like something that should be user-controllable. Right now it feels like a misfeature, whereas "we don't implement line numbers by default, but if you want them, do this and that and you can have them" would feel way more like a good feature to have.
Has anyone actually tried submitting a patch that implements it yet?

https://groups.google.com/d/msg/highlightjs/UVJaQcQNC1c/1C6U...

It's free software so that's no problem if you feel the need.