line-numbers.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Line numbers
  2. ============
  3. Highlight.js' notable lack of line numbers support is not an oversight but a
  4. feature. Following is the explanation of this policy from the current project
  5. maintainer (hey guys!):
  6. One of the defining design principles for highlight.js from the start was
  7. simplicity. Not the simplicity of code (in fact, it's quite complex) but
  8. the simplicity of usage and of the actual look of highlighted snippets on
  9. HTML pages. Many highlighters, in my opinion, are overdoing it with such
  10. things as separate colors for every single type of lexemes, striped
  11. backgrounds, fancy buttons around code blocks and — yes — line numbers.
  12. The more fancy stuff resides around the code the more it distracts a
  13. reader from understanding it.
  14. This is why it's not a straightforward decision: this new feature will not
  15. just make highlight.js better, it might actually make it worse simply by
  16. making it look more bloated in blog posts around the Internet. This is why
  17. I'm asking people to show that it's worth it.
  18. The only real use-case that ever was brought up in support of line numbers
  19. is referencing code from the descriptive text around it. On my own blog I
  20. was always solving this either with comments within the code itself or by
  21. breaking the larger snippets into smaller ones and describing each small
  22. part separately. I'm not saying that my solution is better. But I don't
  23. see how line numbers are better either. And the only way to show that they
  24. are better is to set up some usability research on the subject. I doubt
  25. anyone would bother to do it.
  26. Then there's maintenance. So far the core code of highlight.js is
  27. maintained by only one person — yours truly. Inclusion of any new code in
  28. highlight.js means that from that moment I will have to fix bugs in it,
  29. improve it further, make it work together with the rest of the code,
  30. defend its design. And I don't want to do all this for the feature that I
  31. consider "evil" and probably will never use myself.
  32. This position is `subject to discuss <http://groups.google.com/group/highlightjs>`_.
  33. Also it doesn't stop anyone from forking the code and maintaining line-numbers implementation separately.