# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize

  def salute
    puts "Hello #{@name}!"

g = Greeter.new("world")

language: ...

style: tomorrow

Get version 8.7





  1. Version 8.7

    New languages:

    New Styles:

    Notable fixes and improvements to existing languages:

    • Fix encoding of images when copied over in certain builds
    • Fix incorrect highlighting of the word "bug" in comments
    • Treat decorators different from matrix multiplication in Python
    • Fix traits inheritance highlighting in Rust
    • Fix incorrect document
    • Oracle keywords added to SQL language definition by Vadimtro
    • Postgres keywords added to SQL language definition by Benjamin Auder
    • Fix registers in x86asm being highlighted as a hex number
    • Fix highlighting for numbers with a leading decimal point
    • Correctly highlight numbers and strings inside of C/C++ macros
    • C/C++ functions now support pointer, reference, and move returns
  2. Version 8.6

    New languages:

    New Styles:

    Notable fixes and improvements to existing languages:

    • Multi-line raw strings from C++11 are now supported
    • Fix class names with dashes in HAML
    • The async keyword from ES6/7 is now supported
    • TypeScript functions handle type and parameter complexity better
    • We unified phpdoc/javadoc/yardoc etc modes across all languages
    • CSS .class selectors relevance was dropped to prevent wrong language detection
    • Images is now included to CDN build
    • Release process is now automated
  3. Version 8.5

    New languages:

    New Styles:

    Notable fixes and improvements to existing languages:

    • ES6 features in JavaScript are better supported now by Gu Yiling.
    • Swift now recognizes body-less method definitions.
    • Single expression functions def foo, do: ... now work in Elixir.
    • More uniform detection of built-in classes in Objective C.
    • Fixes for number literals and processor directives in Rust.
    • HTML <script> tag now allows any language, not just JavaScript.
    • Multi-line comments are supported now in MatLab.
  4. Version 8.4

    We've got the new demo page! The obvious new feature is the new look, but apart from that it's got smarter: by presenting languages in groups it avoids running 10000 highlighting attempts after first load which was slowing it down and giving bad overall impression. It is now also being generated from test code snippets so the authors of new languages don't have to update both tests and the demo page with the same thing.

    Other notable changes:

    • The template_comment class is gone in favor of the more general comment.
    • Number parsing unified and improved across languages.
    • C++, Java and C# now use unified grammar to highlight titles in function/method definitions.
    • The browser build is now usable as an AMD module, there's no separate build target for that anymore.
    • OCaml has got a comprehensive overhaul by Mickaël Delahaye.
    • Clojure's data structures and literals are now highlighted outside of lists and we can now highlight Clojure's REPL sessions.

    New languages:

  5. Version 8.3

    We streamlined our tool chain, it is now based entirely on node.js instead of being a mix of node.js, Python and Java. The build script options and arguments remained the same, and we've noted all the changes in the documentation. Apart from reducing complexity, the new build script is also faster from not having to start Java machine repeatedly. The credits for the work go to Jeremy Hull.

    Some notable fixes:

    • PHP and JavaScript mixed in HTML now live happily with each other.
    • JavaScript regexes now understand ES6 flags "u" and "y".
    • throw keyword is no longer detected as a method name in Java.
    • Fixed parsing of numbers and symbols in Clojure thanks to input from Ivan Kleshnin.

    New languages in this release:

  6. Version 8.2

    We've finally got real tests and continuous testing on Travis thanks to Jeremy Hull and Chris Eidhof. The tests designed to cover everything: language detection, correct parsing of individual language features and various special cases. This is a very important change that gives us confidence in extending language definitions and refactoring library core.

    We're going to redesign the old demo/test suite into an interactive demo web app. If you're confident front-end developer or designer and want to help us with it, drop a comment into the issue on GitHub.

    As usually there's a handful of new languages in this release:

    Other improvements:

    • Erik Osheim heavily reworked Scala definitions making it richer.
    • Lucas Mazza fixed Ruby hashes highlighting
    • Lisp variants (Lisp, Clojure and Scheme) are unified in regard to naming the first symbol in parentheses: it's "keyword" in general case and also "built_in" for built-in functions in Clojure and Scheme.
  7. Version 8.1

    New languages:

    New styles:

    Other improvements:

    • The README is heavily reworked and brought up to date by Jeremy Hull.
    • Added listLanguages() method in the API.
    • Improved C/C++/C# detection.
    • Added a bunch of new language aliases, documented the existing ones. Thanks to Sindre Sorhus for background research.
    • Added phrasal English words to boost relevance in comments.
    • Many improvements to SQL definition made by Heiko August, Nikolay Lisienko and Travis Odom.
    • The shorter lang- prefix for language names in HTML classes supported alongside language-. Thanks to Jeff Escalante.
    • Ruby's got support for interactive console sessions. Thanks to Pascal Hurni.
    • Added built-in functions for R language. Thanks to Artem A. Klevtsov.
    • Rust's got definition for lifetime parameters and improved string syntax. Thanks to Roman Shmatov.
    • Various improvements to Objective-C definition by Matt Diephouse.
    • Fixed highlighting of generics in Java.
  8. Version 8.0

    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:

      <script type="text/javascript">
        hljs.configure({classPrefix: ''});
    • tabReplace and useBR that 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 highlightBlock and fixMarkup which are now also rely on configure.

    • We removed public-facing (though undocumented) object hljs.LANGUAGES which was used to register languages with the library in favor of two new methods: registerLanguage and getLanguage. Both are documented in our API docs.

    • Result returned from highlight and highlightAuto no longer contains two separate attributes contributing to relevance score, relevance and keyword_count. They are now unified in relevance.

    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.

    New features:

    • Languages now can be recognized by multiple names like "js" for JavaScript or "html" for, well, HTML (which earlier insisted on calling it "xml"). These aliases can be specified in the class attribute of the code container in your HTML as well as in various API calls. For now there are only a few very common aliases but we'll expand it in the future. All of them are listed in the [class reference][].

    • 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 highlightAuto and configure).

    • Language definition syntax streamlined with variants and beginKeywords.

    New languages and styles:

    Miscelleanous improvements:

    • Highlighting => 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!
  9. Version 7.5

    A catch-up release dealing with some of the accumulated contributions. This one is probably will be the last before the 8.0 which will be slightly backwards incompatible regarding some advanced use-cases.

    One outstanding change in this version is the addition of 6 languages to the hosted script: Markdown, ObjectiveC, CoffeeScript, Apache, Nginx and Makefile. It now weighs about 6K more but we're going to keep it under 30K.

    New languages:


    • Ruby's got support for characters like ?A, ?1, ?\012 etc. and %r{..} regexps.
    • Clojure now allows a function call in the beginning of s-expressions (($filter "myCount") (arr 1 2 3 4 5)).
    • Haskell's got new keywords and now recognizes more things like pragmas, preprocessors, modules, containers, FFIs etc. Thanks to Zena Treep for the implementation and to Jeremy Hull for guiding it.
    • Miscelleanous fixes in PHP, Brainfuck, SCSS, Asciidoc, CMake, Python and F#.
  10. New core developers

    The latest long period of almost complete inactivity in the project coincided with growing interest to it led to a decision that now seems completely obvious: we need more core developers.

    So without further ado let me welcome to the core team two long-time contributors: Jeremy Hull and Oleg Efimov.

    Hope now we'll be able to work through stuff faster!

    P.S. The historical commit is here for the record.