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

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

g = Greeter.new("world")
g.salute

language: ...

style: dracula

Get version 10.1.1

Usage

Contribute

@highlightjs

News

  1. Version 10.1.1

    Fixes:

  2. Version 10.1.0

    New themes:

    Parser Engine:

    • (parser) Now escapes quotes in text content when escaping HTML (#2564) Josh Goebel
    • (parser) Adds keywords.$pattern key to grammar definitions (#2519) Josh Goebel
    • (parser) Adds SHEBANG utility mode Josh Goebel
    • (parser) Adds registerAliases method (#2540) [Taufik Nurrohman][]
    • (enh) Added on:begin callback for modes (#2261) Josh Goebel
    • (enh) Added on:end callback for modes (#2261) Josh Goebel
    • (enh) Added ability to programatically ignore begin and end matches (#2261) Josh Goebel
    • (enh) Added END_SAME_AS_BEGIN mode to replace endSameAsBegin parser attribute (#2261) Josh Goebel
    • (fix) fixMarkup would rarely destroy markup when useBR was enabled (#2532) Josh Goebel

    Deprecations:

    • htmlbars grammar is now deprecated. Use handlebars instead. (#2344) Nils Knappmeier
    • when using highlightBlock result.re deprecated. Use result.relevance instead. (#2552) Josh Goebel
    • ditto for result.second_best.re => result.second_best.relevance (#2552)
    • lexemes is now deprecated in favor of keywords.$pattern key (#2519) Josh Goebel
    • endSameAsBegin is now deprecated. (#2261) Josh Goebel

    Language Improvements:

    • fix(groovy) strings are not allowed inside ternary clauses (#2217) Josh Goebel
    • fix(typescript) add readonly keyword (#2562) Martin (Lhoerion)
    • fix(javascript) fix regex inside parens after a non-regex (#2530) Josh Goebel
    • enh(typescript) use identifier to match potential keywords, preventing false positivites (#2519) Josh Goebel
    • enh(javascript) use identifier to match potential keywords, preventing false positivites (#2519) Josh Goebel
    • [enh] Add OPTIMIZE: and HACK: to the labels highlighted inside comments Josh Goebel
    • enh(typescript/javascript/coffeescript/livescript) derive ECMAscript keywords from a common foudation (#2518) Josh Goebel
    • enh(typescript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) Josh Goebel
    • enh(javascript) add setInterval, setTimeout, clearInterval, clearTimeout (#2514) Vania Kucher
    • enh(cpp) add pair, make_pair, priority_queue as built-ins (#2538) Hankun Lin
    • enh(cpp) recognize priority_queue pair as cpp containers (#2541) Hankun Lin
    • fix(javascript) prevent set keyword conflicting with setTimeout, etc. (#2514) Vania Kucher
    • fix(cpp) Fix highlighting of unterminated raw strings (#2261) David Benjamin
    • fix(javascript) => function with nested () in params now works (#2502) Josh Goebel
    • fix(typescript) => function with nested () in params now works (#2502) Josh Goebel
    • fix(yaml) Fix tags to include non-word characters (#2486) Peter Plantinga
    • fix(swift) @objcMembers was being partially highlighted (#2543) Nick Randall
    • enh(dart) Add late and required keywords, the Never built-in type, and nullable built-in types (#2550) Sam Rawlins
    • enh(erlang) Add underscore separators to numeric literals (#2554) Sergey Prokhorov
    • enh(handlebars) Support for sub-expressions, path-expressions, hashes, block-parameters and literals (#2344) Nils Knappmeier
    • enh(protobuf) Support multiline comments (#2597) Pavel Evstigneev
    • fix(toml) Improve key parsing (#2595) Antoine du Hamel
  3. Version 10.0.3

  4. Version 10.0.2

    Brower build:

    • Issue (bug) Fix: Version 10 fails to load as CommonJS module. (#2511) Josh Goebel
    • Issue (removal) AMD module loading support has been removed. (#2511) Josh Goebel

    Parser Engine Changes:

    • Issue fix(parser) Fix freeze issue with illegal 0 width matches (#2524) Josh Goebel
  5. Version 10.0.1

    Parser Engine Changes:

    • (bug) Fix sublanguage with no relevance score (#2506) Josh Goebel
  6. Version 10.0.0

    New languages:

    • add(php-template) Explicit language to detect PHP templates (vs xml) Josh Goebel
    • enh(python) Added python-repl for Python REPL sessions
    • add(never) Added 3rd party Never language support

    New themes:

    Parser Engine Changes:

    • (bug) Fix beginKeywords to ignore . matches (#2434) Josh Goebel
    • (enh) add before:highlight plugin API callback (#2395) Josh Goebel
    • (enh) add after:highlight plugin API callback (#2395) Josh Goebel
    • (enh) split out parse tree generation and HTML rendering concerns (#2404) Josh Goebel
    • (enh) every language can have a name attribute now (#2400) Josh Goebel
    • (enh) improve regular expression detect (less false-positives) (#2380) Josh Goebel
    • (enh) make noHighlightRe and languagePrefixRe configurable (#2374) Josh Goebel

    Language Improvements:

    • enh(python) Exclude parens from functions params (#2490) Álvaro Mondéjar
    • enh(swift) Add compactMap to keywords as built_in (#2478) Omid Golparvar
    • enh(nim) adds func keyword (#2468) Adnan Yaqoob
    • enh(xml) deprecate ActionScript inside script tags (#2444) Josh Goebel
    • fix(javascript) prevent get/set variables conflicting with keywords (#2440) Josh Goebel
    • bug(clojure) Now highlights defn- properly (#2438) Josh Goebel
    • enh(bash) default value is another variable (#2439) Josh Goebel
    • enh(bash) string nested within string (#2439) Josh Goebel
    • enh(bash) Add arithmetic expression support (#2439) Josh Goebel
    • enh(clojure) Add support for global definitions name (#2347) Alexandre Grison
    • enh(fortran) Support Fortran 77 style comments (#2416) Josh Goebel
    • (csharp) add support for @identifier style identifiers (#2414) Josh Goebel
    • fix(elixir) Support function names with a slash (#2406) Josh Goebel
    • fix(javascript) comma is allowed in a "value container" (#2403) Josh Goebel
    • enh(apache) add deny and allow keywords Josh Goebel
    • enh(apache) highlight numeric attributes values Josh Goebel
    • enh(apache) highlight IP addresses, ports, and strings in sections Josh Goebel
    • enh(php) added more keywords and include <?= syntax to meta Taufik Nurrohman
    • fix(protobuf) Fix rpc when followed by a block (#) Josh Goebel
    • enh(zephir) almost complete rework of the zephir grammar (#2387) Josh Goebel
    • (markdown) much improved code block support (#2382) Josh Goebel
    • (markdown) improve bold/italic nesting (#2382) Josh Goebel
    • enh(csharp) Support where keyword as class constraint (#2378) Josh Goebel
    • enh(csharp) Allow reference path in class inheritance lists (#2378) Josh Goebel
    • enh(csharp) Add generic modifiers (in, out) (#2378) Josh Goebel
    • (fortran) enh(fortran) support intrinsic data types (#2379) Josh Goebel
    • enh(java) annotations can include numbers (#2377) Josh Goebel
    • enh(java) annotations can take params (#2377) Josh Goebel
    • enh(java) allow annotations inside function call params (#2377) Josh Goebel
    • enh(parser) pre/post-highlightBlock callbacks via plugin (#2285) Josh Goebel
    • (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) Sam Miller
    • (delphi) highlight hexadecimal, octal, and binary numbers (#2370) Robert Riebisch
    • enh(plaintext) added text and txt as alias (#2360) Taufik Nurrohman
    • enh(powershell) added PowerShell v5.1/v7 default aliases as "built_in"s (#2423) Sean Williams
    • enh(yaml) added support for timestamps (#2475) [Peter Plantinga][]

    Developer Tools:

    • added Dockerfile for optionally developing with a container
  7. Version 9.18.1

    Grammar Improvements:

    • bug(coffeescript) fix freezing bug due to badly behaved regex (#2376) Josh Goebel
  8. Version 9.18.0

    New languages:

    • none.

    New themes:

    • none.

    Core Changes:

    • none.

    Language Improvements:

    • (javascript) fix JSX self-closing tag issues (#2322) Josh Goebel
    • (fortran) added block and endblock keywords (#2343) Philipp Engel
    • (javascript) support jsx fragments (#2333) Josh Goebel
    • (ini) support TOML arrays, clean up grammar (#2335) Josh Goebel
    • (vbnet) add nameof operator to the keywords (#2329) Youssef Victor
    • (stan) updated with improved coverage of language keywords and patterns. (#1829) Jeffrey Arnold
    • enh(cpp) Detect namespaced function types (A::typeName func(...)) (#2332) Josh Goebel
    • enh(cpp) Detect namespaced functions also (A::functionName) (#2332) Josh Goebel
    • enh(cpp) Properly detect decltype(auto) (#2332) Josh Goebel
    • enh(cpp) recognize primitive types (int8_t, etc.) as function types (#2332) Josh Goebel

    Developer Tools:

    • feat(developer): add button to show parsed structure (#2345) Nils Knappmeier
  9. Version 9.17.1

    Fixes:

    • fix(parser): resolve IE 11 issue with Object.freeze() (#2319) [Josh Goebel][]
  10. Version 9.17.0

    New languages:

    • none.

    New themes:

    Core Improvements:

    • chore(parser): switch from createElementNS to createElement (#2314) Josh Goebel
    • enh(parser): add better error when a language requirement is missing (#2311) Josh Goebel
    • fix(parser/docs): disallow self mode at the top-level of a language (#2294) Josh Goebel
    • enh(parser) add safe & debug modes. Better error handling for crash conditions. (#2286) Josh Goebel
    • fix(parser): Fix merger HTML attribute quoting (#2235) Josh Goebel
    • fix(parser): Look-ahead regex now work for end matches also (#2237) Josh Goebel
    • fix(parser): Better errors when a language is missing (#2236) Josh Goebel
    • fix(parser): freeze built-in modes to prevent grammars altering them (#2271) Josh Goebel
    • fix(themes): fix inconsistencies between some themes padding/spacing (#2300) Josh Goebel
    • ehh(build) Add CI check for building a "use strict" safe rollup package from NPM builds (#2247) Josh Goebel
    • fix(pkg): Prefix global addEventListener with window to be able to minify with closure compiler (#2305) Kirill Saksin

    Language Improvements:

    • fix(sql): backslash is not used to escape in strings in standard SQL (#1748) Mike Schall
    • enh(ebnf) add backticks as additional string variant (#2290) Chris Marchesi
    • chore(javascript): add esm related extensions to aliases (#2298) Rongjian Zhang
    • fix(kotlin): fix termination of """ string literals (#2295) Josh Goebel
    • fix(mercury): don't change global STRING modes (#2271) Josh Goebel
    • enh(xml) expand and improve document type highlighting (#2287) w3suli
    • enh(ebnf) add underscore as allowed meta identifier character, and dot as terminator (#2281) Chris Marchesi
    • fix(makefile) fix double relevance for assigns, improves auto-detection (#2278) Josh Goebel
    • enh(xml) support for highlighting entities (#2260) w3suli
    • enh(gml) fix naming of keyword class (consistency fix) (#2254) Liam Nobel
    • enh(javascript): Add support for jsdoc comments (#2245) Milutin Kristofic
    • fix(python) fix if getting confused as an f-string (#2200) Josh Goebel and Carl Baxter
    • enh(powershell) major overhaul, huge improvements (#2224)
    • enh(css) Improve @rule highlighting, including properties (#2241) Josh Goebel
    • enh(css) Improve highlighting of numbers inside expr/func calc(2px+3px) (#2241)
    • enh(scss) Pull some of the CSS improvements back into SCSS (#2241)
    • fix(go): Fix escaped character literals (#2266) David Benjamin
    • fix(objectivec): Fix various preprocessor highlighting issues (#2265) David Benjamin
    • fix(objectivec): Handle multibyte character literals (#2268) David Benjamin
    • enh(cpp): Add additional keywords (#2289) Adrian Ostrowski