style-guide.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Style guide
  2. ===========
  3. Key principle
  4. -------------
  5. Highlight.js themes are language agnostic.
  6. Instead of trying to make a *rich* set of highlightable classes look good in a
  7. handful of languages we have a *limited* set of classes that work for all
  8. languages.
  9. Hence, there are two important implications:
  10. * Highlight.js styles tend to be minimalistic.
  11. * It's not possible to exactly emulate themes from other highlighting engines.
  12. Defining a theme
  13. ----------------
  14. A theme is a single CSS defining styles for class names listed in the
  15. :doc:`class reference </css-classes-reference>`. The general guideline is to
  16. style all available classes, however an author may deliberately choose to
  17. exclude some (for example, ``.attr`` is usually left unstyled).
  18. You are not required to invent a separate styling for every group of class
  19. names, it's perfectly okay to group them:
  20. ::
  21. .hljs-string,
  22. .hljs-section,
  23. .hljs-selector-class,
  24. .hljs-template-variable,
  25. .hljs-deletion {
  26. color: #800;
  27. }
  28. Use as few or as many unique style combinations as you want.
  29. Typography and layout dos and don'ts
  30. ------------------------------------
  31. Don't use:
  32. * non-standard borders/margin/paddings for the root container ``.hljs``
  33. * specific font faces
  34. * font size, line height and anything that affects position and size of
  35. characters within the container
  36. Okay to use:
  37. * colors (obviously!)
  38. * italic, bold, underlining, etc.
  39. * image backgrounds
  40. These may seem arbitrary at first but it's what has shown to make sense in
  41. practice.
  42. There's also a common set of rules that *has* to be defined for the root
  43. container verbatim:
  44. ::
  45. .hljs {
  46. display: block;
  47. overflow-x: auto;
  48. padding: 0.5em;
  49. }
  50. ``.subst``
  51. ----------
  52. One important caveat: don't forget to style ``.subst``. It's used for parsed
  53. sections within strings and almost always should be reset to the default color:
  54. ::
  55. .hljs,
  56. .hljs-subst {
  57. color: black;
  58. }
  59. Contributing
  60. ------------
  61. You should include a comment at the top of the CSS file with attribution and
  62. other meta data if necessary. The format is free:
  63. ::
  64. /*
  65. Fancy style (c) John Smith <email@domain.com>
  66. */
  67. If you're a new contributor add yourself to the authors list in AUTHORS.*.txt
  68. (use either English and/or Russian version). Also update CHANGES.md with your
  69. contribution.
  70. Send your contribution as a pull request on GitHub.