Highlight.js themes are language agnostic.
Instead of trying to make a rich set of highlightable classes look good in a handful of languages we have a limited set of classes that work for all languages.
Hence, there are two important implications:
A theme is a single CSS defining styles for class names listed in the
:doc:`class reference </css-classes-reference>`. The general guideline is to
style all available classes, however an author may deliberately choose to
exclude some (for example, .attr
is usually left unstyled).
You are not required to invent a separate styling for every group of class names, it's perfectly okay to group them:
.hljs-string, .hljs-section, .hljs-selector-class, .hljs-template-variable, .hljs-deletion { color: #800; }
Use as few or as many unique style combinations as you want.
Don't use:
.hljs
Okay to use:
These may seem arbitrary at first but it's what has shown to make sense in practice.
There's also a common set of rules that has to be defined for the root container verbatim:
.hljs { display: block; overflow-x: auto; padding: 0.5em; }
.subst
One important caveat: don't forget to style .subst
. It's used for parsed
sections within strings and almost always should be reset to the default color:
.hljs, .hljs-subst { color: black; }
You should include a comment at the top of the CSS file with attribution and other meta data if necessary. The format is free:
/* Fancy style (c) John Smith <email@domain.com> */
If you're a new contributor add yourself to the authors list in AUTHORS.en.txt Also update CHANGES.md with your contribution.
Send your contribution as a pull request on GitHub.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。