This new major release is quite a big overhaul bringing both new features and some backwards incompatible changes. However, chances are that the majority of users won't be affected by the latter: the basic scenario described in the README is left intact.
Here's what did change in an incompatible way:
We're now prefixing all classes located in CSS classes reference with
hljs-, by default, because some class names would collide with other people's stylesheets. If you were using an older version, you might still want the previous behavior, but still want to upgrade. To suppress this new behavior, you would initialize like so:
useBRthat were used in different places are also unified into the global options object and are to be set using
configure(options). This function is documented in our API docs. Also note that these parameters are gone from
fixMarkupwhich are now also rely on
We removed public-facing (though undocumented) object
hljs.LANGUAGESwhich was used to register languages with the library in favor of two new methods:
getLanguage. Both are documented in our API docs.
Result returned from
highlightAutono longer contains two separate attributes contributing to relevance score,
keyword_count. They are now unified in
Another technically compatible change that nonetheless might need attention:
- The structure of the NPM package was refactored, so if you had installed it
locally, you'll have to update your paths. The usual
require('highlight.js')works as before. This is contributed by Dmitry Smolin.
Language detection can now be restricted to a subset of languages relevant in a given context — a web page or even a single highlighting call. This is especially useful for node.js build that includes all the known languages. Another example is a StackOverflow-style site where users specify languages as tags rather than in the markdown-formatted code snippets. This is documented in the API docs (see methods
New languages and styles:
- Oxygene by Carlo Kok
- Mathematica by Daniel Kvasnička
- Autohotkey by Seongwon Lee
- Atelier family of styles in 10 variants by Bram de Haan
- Paraíso styles by Jan T. Sott
=>prompts in Clojure.
- Jeremy Hull fixed a lot of styles for consistency.
- Finally, highlighting PHP and HTML mixed in peculiar ways.
- Objective C and C# now properly highlight titles in method definition.
- Big overhaul of relevance counting for a number of languages. Please do report bugs about mis-detection of non-trivial code snippets!