JavaScript syntax highlighter with language auto-detection and zero dependencies.

Overview

Highlight.js

latest version license install size minified NPM downloads weekly jsDelivr CDN downloads

build and CI status code quality vulnerabilities dev deps

discord open issues help welcome issues good first issue

Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It can work with pretty much any markup, doesn’t depend on any other frameworks, and has automatic language detection.

Contents


Upgrade to Version 10

Version 10 is one of the biggest releases in quite some time. If you're upgrading from version 9, there are some breaking changes and things you may want to double check first.

Please read VERSION_10_UPGRADE.md for high-level summary of breaking changes and any actions you may need to take. See VERSION_10_BREAKING_CHANGES.md for a more detailed list and CHANGES.md to learn what else is new.

Support for older versions

Please see SECURITY.md for support information.

Basic Usage

In the Browser

The bare minimum for using highlight.js on a web page is linking to the library along with one of the styles and calling highlightAll:

<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.min.js"></script>
<script>hljs.highlightAll();</script>

This will find and highlight code inside of <pre><code> tags; it tries to detect the language automatically. If automatic detection doesn’t work for you, or you simply prefer to be explicit, you can specify the language manually in the using the class attribute:

<pre><code class="language-html">...</code></pre>

Plaintext Code Blocks

To apply the Highlight.js styling to plaintext without actually highlighting it, use the plaintext language:

<pre><code class="language-plaintext">...</code></pre>

Ignoring a Code Block

To skip highlighting of a code block completely, use the nohighlight class:

<pre><code class="nohighlight">...</code></pre>

Node.js on the Server

The bare minimum to auto-detect the language and highlight some code.

// load the library and ALL languages
hljs = require('highlight.js');
html = hljs.highlightAuto('<h1>Hello World!</h1>').value

To load only a "common" subset of popular languages:

hljs = require('highlight.js/lib/common');

To highlight code with a specific language, use highlight:

html = hljs.highlight('<h1>Hello World!</h1>', {language: 'xml'}).value

See Importing the Library for more examples of require vs import usage, etc. For more information about the result object returned by highlight or highlightAuto refer to the api docs.

Supported Languages

Highlight.js supports over 180 languages in the core library. There are also 3rd party language definitions available to support even more languages. You can find the full list of supported languages in SUPPORTED_LANGUAGES.md.

Custom Usage

If you need a bit more control over the initialization of Highlight.js, you can use the highlightElement and configure functions. This allows you to better control what to highlight and when.

For example, here’s the rough equivalent of calling highlightAll but doing the work manually instead:

document.addEventListener('DOMContentLoaded', (event) => {
  document.querySelectorAll('pre code').forEach((el) => {
    hljs.highlightElement(el);
  });
});

Please refer to the documentation for configure options.

Using custom HTML

We strongly recommend <pre><code> wrapping for code blocks. It's quite semantic and "just works" out of the box with zero fiddling. It is possible to use other HTML elements (or combos), but you may need to pay special attention to preserving linebreaks.

Let's say your markup for code blocks uses divs:

<div class='code'>...</div>

To highlight such blocks manually:

// first, find all the div.code blocks
document.querySelectorAll('div.code').forEach(el => {
  // then highlight each
  hljs.highlightElement(el);
});

Without using a tag that preserves linebreaks (like pre) you'll need some additional CSS to help preserve them. You could also pre and post-process line breaks with a plug-in, but we recommend using CSS.

To preserve linebreaks inside a div using CSS:

div.code {
  white-space: pre;
}

Using with Vue.js

Simply register the plugin with Vue:

Vue.use(hljs.vuePlugin);

And you'll be provided with a highlightjs component for use in your templates:

  <div id="app">
    <!-- bind to a data property named `code` -->
    <highlightjs autodetect :code="code" />
    <!-- or literal code works as well -->
    <highlightjs language='javascript' code="var x = 5;" />
  </div>

Using Web Workers

You can run highlighting inside a web worker to avoid freezing the browser window while dealing with very big chunks of code.

In your main script:

addEventListener('load', () => {
  const code = document.querySelector('#code');
  const worker = new Worker('worker.js');
  worker.onmessage = (event) => { code.innerHTML = event.data; }
  worker.postMessage(code.textContent);
});

In worker.js:

onmessage = (event) => {
  importScripts('<path>/highlight.min.js');
  const result = self.hljs.highlightAuto(event.data);
  postMessage(result.value);
};

Importing the Library

First, you'll likely be installing the library via npm or yarn -- see Getting the Library.

Node.js / require

Requiring the top-level library will load all languages:

// require the highlight.js library, including all languages
const hljs = require('./highlight.js');
const highlightedCode = hljs.highlightAuto('<span>Hello World!</span>').value

For a smaller footprint, load only the languages you need.

const hljs = require('highlight.js/lib/core');  // require only the core library
// separately require languages
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));

const highlightedCode = hljs.highlight('<span>Hello World!</span>', {language: 'xml'}).value

ES6 Modules / import

The default import will register all languages:

import hljs from 'highlight.js';

It is more efficient to import only the library and register the languages you need:

import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
hljs.registerLanguage('javascript', javascript);

If your build tool processes CSS imports, you can also import the theme directly as a module:

import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';

Getting the Library

You can get highlight.js as a hosted, or custom-build, browser script or as a server module. Right out of the box the browser script supports both AMD and CommonJS, so if you wish you can use RequireJS or Browserify without having to build from source. The server module also works perfectly fine with Browserify, but there is the option to use a build specific to browsers rather than something meant for a server.

Do not link to GitHub directly. The library is not supposed to work straight from the source, it requires building. If none of the pre-packaged options work for you refer to the building documentation.

On Almond. You need to use the optimizer to give the module a name. For example:

r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js

Fetch via CDN

A prebuilt version of Highlight.js bundled with many common languages is hosted by several popular CDNs. When using Highlight.js via CDN you can use Subresource Integrity for additional security. For details see DIGESTS.md.

cdnjs (link)

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.1/languages/go.min.js"></script>

jsdelivr (link)

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/default.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/languages/go.min.js"></script>

unpkg (link)

<link rel="stylesheet" href="https://unpkg.com/@highlightjs/[email protected]/styles/default.min.css">
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<script src="https://unpkg.com/@highlightjs/[email protected]/languages/go.min.js"></script>

Note: The CDN-hosted highlight.min.js package doesn't bundle every language. It would be very large. You can find our list of "common" languages that we bundle by default on our download page.

Download prebuilt CDN assets

You can also download and self-host the same assets we serve up via our own CDNs. We publish those builds to the cdn-release GitHub repository. You can easily pull individual files off the CDN endpoints with curl, etc; if say you only needed highlight.min.js and a single CSS file.

There is also an npm package @highlightjs/cdn-assets if pulling the assets in via npm or yarn would be easier for your build process.

Download from our website

The download page can quickly generate a custom single-file minified bundle including only the languages you desire.

Note: Building from source can produce slightly smaller builds than the website download.

Install via NPM package

Our NPM package including all supported languages can be installed with NPM or Yarn:

npm install highlight.js
# or
yarn add highlight.js

Alternatively, you can build the NPM package from source.

Build from Source

The current source code is always available on GitHub.

node tools/build.js -t node
node tools/build.js -t browser :common
node tools/build.js -t cdn :common

See our building documentation for more information.

Requirements

Highlight.js works on all modern browsers and currently supported Node.js versions. You'll need the following software to contribute to the core library:

  • Node.js >= 12.x
  • npm >= 6.x

License

Highlight.js is released under the BSD License. See our LICENSE file for details.

Links

The official website for the library is https://highlightjs.org/.

Further in-depth documentation for the API and other topics is at http://highlightjs.readthedocs.io/.

A list of the Core Team and contributors can be found in the CONTRIBUTORS.md file.

Comments
  • enh(latex) complete ground up rewrite of the LaTeX grammar

    enh(latex) complete ground up rewrite of the LaTeX grammar

    Resolves #2708. Resolves #2709.


    This is a complete redo of the LaTeX language parser. It aims to solve #2708 and #2709 as well as some other problems not reported in the issue tracker but collected on tex.sx. Since TeX is a macro expansion language, its syntax has some peculiarities compared to other programming languages that require special handling by a syntax highlighter. I will try to outline the main issues and my approach to tackling them here.

    The Problem: Category Codes

    Every character in a TeX program has a so-called category code (catcode for short). Characters with special catcodes like %, {, }, #, &, $, ^ or _ can be recognized by a syntax parser easily enough. It gets a bit difficult when it comes to control sequences, though.

    Recognizing control sequences (these are tokens representing macros or primitive commands) is the main task of any (La)TeX syntax highlighter. They consist of a backslash \ followed by either an arbitrary number of letters or a single non-letter. If a character is a letter is decided by its catcode. Usually, letters are what one would expect: a-zA-Z. However, catcodes can differ between files and even change in the middle of a program. It is impossible to determine the correct catcodes of every character in a program without executing it (using TeX). However, there are two very common and standardized ways of changing which characters are considered letters:

    1. The character @ is usually not a letter, but is commonly made one in order to use it in internal macro names. This done using \makeatletter. \makeatother makes it a non-letter again. An example:

      \@gobble \foo@bar
      \makeatletter
        \@gobble \foo@bar
      \makeatother
      

      Assuming that the default LaTeX catcodes are in effect, the first line contains the control sequences \@ and \foo. (The rest of the line consist of normal text.) After making @ a letter, the third line contains the control sequences \@gobble and \foo@bar. (As you can see, the GitHub syntax highlighter always treats @ as a letter, which is not always correct but a better choice than never treating it as one.

    2. The long term future of LaTeX is called LaTeX3 (the current version is called LaTeX2e). It provides a collection of macros that greatly simplify writing TeX programs which is also known as expl3 ("experimental LaTeX3"). In order to use this programming layer, one has to enter a category code regime where (among some other changes) _ and : are letters. It is entered using \ExplSyntaxOn and left using \ExplSyntaxOff. An example:

      \tl_set_eq:NN \l_tmpa_tl \l_tmpb_tl
      \ExplSyntaxOn
        \tl_set_eq:NN \l_tmpa_tl \l_tmpb_tl
      \ExplSyntaxOff
      

      With the default LaTeX catcodes, the first line contains the control sequences \tl, \l and \l. It is also utter nonsense and would in fact cause an error when compiling (due to _ being used outside math mode). After an \ExplSyntaxOn however, it consists of the control sequences \tl_set_eq:NN, \l_tmpa_tl and \l_tmpb_tl. (As you can see, the GitHub syntax highlighter does not know about this.)

      Importantly, while it is an okay choice to just always treat @ as a letter when highlighting syntax, this is not true for : and _. Unlike @, these characters commonly occur in normal LaTeX code, often directly after control sequences.

    Both of these cases (and in fact their combination) are already present in many LaTeX packages and online posts, where \makeatletter and \ExplSyntaxOn may not be present.

    I write all of this to try and convince you of the following:

    • highlight.js should support both the "normal" LaTeX and LaTeX3.
    • In order to support LaTeX3, we need a separate language file latex3.js and we need to support switching to and from that language using \ExplSyntaxOn and \ExplSyntaxOff.
    • If we are already at it, we can do the same for \makeatletter and \makeatother. Apart from providing correct highlighting, this would also help beginners finding code snippets online (for example on tex.sx) by correctly pointing out where control sequences end. (Not understanding \makeatletter and forgetting to use it are common problems among LaTeX newbies.)

    What should be highlighted?

    I decided the parser should be able to recognize the following elements:

    • Control sequences (as described above)

    • Macro parameters: These consist of one or more # usually followed by a digit.

      (Actually, the number of # should be 2^n for some n, but the parser doesn't have to know this, in my opinion.)

    • Comments: These start with % and contain the rest of the line.

    • Characters with special catcodes (that have not yet been covered): Namely {, }, $, &, ^ and _.

    I decided not to include (for now):

    • The ^^ syntax: A double ^ followed by any character should be recognized as a single character.

    • Tagging the different elements of LaTeX macro names: The LaTeX3 programming layer follows a strict naming scheme. For example \hljs_do_somehthing:Ncx is a function in the module hljs with the name do_something and the signature Ncx, whereas \l_hljs_some_value_tl is a local (l) variable of the module hljs of type tl with the name some_value.

      I'm not sure if this should be inside or outside the scope of highlight.js.

    • Units, stretch values and the like: These are impossible to differentiate from normal text and the value added by highlighting them is very limited.

    • Math mode: The same is true. While it would be feasible to cover the most common macros that contain / switch to math mode, there will always be non-edge cases that are not recognized. It is clearer to not differentiate at all.

    How to parse control sequences

    I settled on the following method for detecting control sequences and switching languages ("changing catcodes"):

    • Upon finding a backslash \, enter the mode control_sequence.
      • Now, first check if the control sequence is one that indicates that this is in fact LaTeX (with special catcodes)
      • If so, give it a high relevance.
      • Otherwise, scan for any other control sequence and give it the relevance 0.
    • After the control sequence is complete, check if it was one that changes catcodes.
      • If it was, switch to the corresponding language for the rest of the code.

    Which classes to use

    In this first draft, I have not yet decided which CSS classes to use for highlighting. Since LaTeX does not have the same syntax elements as most other languages, there is quite some room for interpretation here. I guess, one should survey the existing color schemes and select keywords that make LaTeX look "right" in most of those.

    Any notes on this?

    What I'm unclear on

    As I am new to highlight.js, there are some things I am not totally clear on:

    Does the circular dependency of the languages work?

    When I remove the Requires: line from the header of all four language files and compile them with

    node ./tools/build.js -n latex latex@ latex3 latex3@
    

    everything works fine.

    Adding the Requires: line leads to an error as described in #2725.

    However, when I try to compile everything

    node ./tools/build.js
    

    the script complains about a circular reference.

    Are circular references not allowed at all? That would greatly complicate the task at hand, since LaTeX2e can occur inside LaTeX3 and vice versa.

    Could nesting the languages lead to problems?

    In my current approach, the parser does not switch back from a sublanguage before the end of the code. After saying \ExplSyntaxOn\ExplSyntaxOff, there is a latex sublanguage inside a latex3 sublanguage.

    Avoiding this is not trivial, as \ExplSyntaxOn\makeatletter\ExplsyntaxOff is possible: \ExplSyntaxOff reverts the changes done by \ExplSyntaxOn but not those done by \makeatletter.

    Could we instead change the grammar dynamically?

    Having an array containing all "letters" that is used when scanning for control sequences and that can be changed when one of the category code changing macros is found would be somewhat more natural. (I guess we would still need several languages for the state at the start of parsing to differ.) Is this possible?

    Is @ in the language name legal?

    The language names latex and latex3 are fairly obvious. I decided to append an @ to the name for those langauges where it is a letter. Is this safe or is that character not allowed in language names? (I did not experience any problems in my tests.)

    Can control sequences have a relevance of 1 (instead of 0)?

    In the existing latex.js placeholder*, control sequences were given a relevance of 0. I left it that way for now.

    I would consider it more natural to give them a relevance of 1 in order to also support auto-detection in short code snippets that do not contain any of the more obvious macros that are given high relevance. This is not very pressing, though, I believe, since sites where LaTeX is to be expected can set it as the default language.

    I guess the decision was made because the backslash can also appear in paths or as an escape character. I don't feel I have a good sense of how often other code snippets would be falsely identified as LaTeX if it got a relevance of 1 for every backslash.

    Should I worry about efficiency?

    Every time a backslash is found, latex.js checks for 34 known control sequences for language detection. Is this a lot? Should this be reduced in order not to slow down the parser? I have no idea how fast this thing runs / should run.


    I look forward to any feedback or advice!

    hacktoberfest-accepted 
    opened by schtandard 118
  • Provide access to a parse tree as an alternative to HTML output

    Provide access to a parse tree as an alternative to HTML output

    I've just had a quick look at hightlight.js and didn't any discussion on this. So forgive me if this is not the right place or has already been discussed.

    I'd like to propose to make highlight.js more generally usable, or at least pull out the core highlighting logic to make it independent from the output format. Just like the famous Pygments has formatters, the HTML generation would be done by a separate module/package.

    highlight.js seems to be the de factor standard from syntax highlighting, even among porject not related to HTML/browsers. See the slap editor and hicat for examples: Both use it and later on manually walk/manipulate the HTML generated by highlight.js.

    In the world of lightweight do-one-thing NPM packages, it would make sense to split highlight.js into two parts, one generating an treeish object representation (possibly streaming), and the second generating HTML from it.

    enhancement parser 
    opened by derhuerst 94
  • Task: Create theme maintainers team and see who is still wanting to help maintain themes

    Task: Create theme maintainers team and see who is still wanting to help maintain themes

    Need to create a theme maintainers list so that theme maintainers who desire can keep their themes up-to-date.

    The overall idea being that themes (like grammars) are never "one and done" that over time they require a (small) amount of maintenance to keep up with changes in the core library, grammars, theming in general, etc. Themes that have no owner/maintainer should possibly be moved into an old_themes repository/folder with a README that indicates they may not provide the best results compared to core themes.

    Of course we'd love it if all themes were maintained and provided a great experience.

    What kind of things require upkeep? See #2500, #2521, etc... plus the recent additions of property, punctuation, operator, and other prior and upcoming changes... but this issue is just trying to get everyone onto a team so I can more easily contact you. After that I'll focus on typing up a list of things you may want to consider when refreshing your themes to take advantage of recent changes and improvements.

    Added by HLJS Team

    • [x] default.css
    • [ ] mono-blue.css
    • [x] ascetic.css (Ivan)
    • [x] dark.css (Ivan)
    • [ ] googlecode.css

    Unmaintained

    • [x] androidstudio.css
    • [x] arduino-light.css (not with Arduino anymore, forwarded request along to Arduino peoples)
    • [x] arta.css ([email protected]) (email bounced)
    • [x] docco.css
    • [x] ir-black.css ([email protected]) (email bounced)
    • [x] vs.css
    • [x] foundation.css - " Since Foundation has moved on substantially, I'm not even sure the existing theme makes much sense anymore. It would be best if someone recreated it anew."
    • [ ] gml.css - (thumbs down on maintaining)

    Base16

    These should be auto-build from Base16 sources... see #3132.

    • [x] atelier-cave-dark.css
    • [x] atelier-cave-light.css
    • [x] atelier-dune-dark.css
    • [x] atelier-dune-light.css
    • [x] atelier-estuary-dark.css
    • [x] atelier-estuary-light.css
    • [x] atelier-forest-dark.css
    • [x] atelier-forest-light.css
    • [x] atelier-heath-dark.css
    • [x] atelier-heath-light.css
    • [x] atelier-lakeside-dark.css
    • [x] atelier-lakeside-light.css
    • [x] atelier-plateau-dark.css
    • [x] atelier-plateau-light.css
    • [x] atelier-savanna-dark.css
    • [x] atelier-savanna-light.css
    • [x] atelier-seaside-dark.css
    • [x] atelier-seaside-light.css
    • [x] atelier-sulphurpool-dark.css
    • [x] atelier-sulphurpool-light.css
    • [x] darcula.css
    • [ ] dracula.css
    • [ ] gruvbox-dark.css
    • [ ] gruvbox-light.css
    • [ ] solarized-dark.css
    • [x] solarized-light.css
    • [ ] tomorrow-night-blue.css
    • [ ] tomorrow-night-bright.css
    • [ ] tomorrow-night-eighties.css
    • [ ] tomorrow-night.css
    • [ ] tomorrow.css
    • [x] zenburn.css
    • [x] ocean.css
    • [x] railscasts.css
    • [x] hopscotch.css (idleberg)

    Reached out

    • [x] a11y-dark.css
    • [x] a11y-light.css
    • [x] agate.css
    • [x] an-old-hope.css
    • [ ] atom-one-dark-reasonable.css
    • [ ] atom-one-dark.css
    • [ ] atom-one-light.css
    • [x] brown-paper.css ([email protected])
    • [x] codepen-embed.css
    • [ ] color-brewer.css
    • [x] far.css - ([email protected])
    • [ ] github-gist.css
    • [ ] github.css
    • [x] gradient-dark.css
    • [x] gradient-light.css
    • [x] grayscale.css
    • [x] hybrid.css
    • [x] idea.css
    • [x] isbl-editor-dark.css
    • [x] isbl-editor-light.css
    • [x] kimbie.dark.css
    • [x] kimbie.light.css
    • [x] lightfair.css
    • [x] lioshi.css
    • [x] magula.css
    • [ ] monokai-sublime.css
    • [ ] monokai.css
    • [x] night-owl.css
    • [x] nnfx-dark.css
    • [x] nnfx.css
    • [ ] nord.css
    • [x] obsidian.css
    • [x] paraiso-dark.css
    • [x] paraiso-light.css
    • [x] pojoaque.css - perhaps atelierbram wants to help here? Pinged Jason Tate on Twitter
    • [x] purebasic.css
    • [x] qtcreator_dark.css
    • [x] qtcreator_light.css
    • [x] rainbow.css
    • [x] routeros.css
    • [x] school-book.css
    • [x] shades-of-purple.css
    • [x] srcery.css
    • [x] stackoverflow-dark.css
    • [x] stackoverflow-light.css
    • [x] sunburst.css
    • [x] vs2015.css
    • [x] xcode.css
    • [x] xt256.css
    enhancement help welcome good first issue autoclose 
    opened by joshgoebel 85
  • WIP: Proper highlighting for the Wolfram Language (Mathematica)

    WIP: Proper highlighting for the Wolfram Language (Mathematica)

    This is work-in-progress and not ready for merging, but I wanted to start a discussion about what is feasable/wanted for highlight.js. The Wolfram Language (WL) is one of those languages that are very different in some points. Most notably, it has close to 7000 built-in symbols and none of the usual "keywords" that other languages have. I rewrote the entire Mathematica (it's the same as "WL", don't ask, it's confusing) highlighter and here are the major changes:

    • The many ways how a number can be specified is now handled correctly
    • All built-in functions and so-called named-characters (a way to represent e.g. Alpha or Arrows) are matched correctly and updated for the most recent version of Mathematica
    • Instead of using lists of keywords for the built-in symbols, I created a trie to compress the regex. This basically shaves 30kB from the regex of the built-in symbols.

    I'll attach an image of a more realistic test-case at the end, but first I'll have some questions:

    • Is it OK to use such a trie in favor of a human readable list of keywords?
    • Does anyone have experience regarding the performance of such a trie? In theory, it should be faster but I was never really able to measure this. On the other hand, I'm a JS noob and I'd like to keep it that way :)
    • Am I doing this right by using begin: and specifying the regex there? I mean, it works but what do I know?
    • Are there formatting guide-lines? Specifically, can I leave these long regex on one line?

    Any tips are appreciated.

    image

    language enhancement hacktoberfest-accepted 
    opened by halirutan 79
  • Discuss: 3rd party language packages spec

    Discuss: 3rd party language packages spec

    Starting a discussion for an official 3rd party grammar format/spec (directory structure, how modules are exported, etc). I've been working on adding support to the build process for seamlessly building 3rd party grammars. The idea being that you just check them out:

    mkdir extra
    cd extra
    git clone [email protected]:highlightjs/highlightjs-robots-txt.git
    git clone [email protected]:highlightjs/highlightjs-tsql.git
    

    And then building "just works":

    node ./tools/build.js -t browser :common tsql robots-txt
    

    And high-level grammar testing just works (detect tests, markup tests, etc) in context of the whole test suite. Just run tests like normal. The tests for extra languages are bundled with the extra languages, but magically "just work".

    In looking at the existing 3rd party stuff it seems we have two major types of layouts. I think perhaps we could support both.

    The slightly flatter npm package: Screen Shot 2019-12-19 at 9 03 10 AM

    A more "bundled"/traditional layout: Screen Shot 2019-12-19 at 9 03 21 AM

    One alternative to supporting both is to always prefer/require the bundled layout. I prefer this layout slightly as it makes it easier to add multiple languages to a single "package/repo". For example you might bundle Python, Python REPL... bundled layout gives you an easy way to do that (keeping the same directly structure we use internally). Also if we ever again decided to pull a 3rd party into the core library it'd be trivial to do with the bundled layout as it'd just essentially be copying files from one repo to another.

    As to how NPM would work with bundled layout I'd suggest an index.js that simply required the individual modules and exported a hash of them by name:

    # index.js
    const python = require("./src/languages/python")
    const pythonREPL = require("./src/languages/python_repl")
    module.exports = { python, pythonREPL }
    

    Thoughts?

    language big picture 
    opened by joshgoebel 76
  • Version 9 EOL & End of Support (even for security issues)

    Version 9 EOL & End of Support (even for security issues)

    If you're trying to upgrade your (or someone else's dependencies) you may want to see A note about upgrading dependencies from version 9 version 10 big picture


    A recent vulnerability has brought the topic of version 9 support back into the forefront. The core team doesn't really have the time or focus to maintain two very different forks of the project. Especially since the version 9 only truly exits to service a tiny audience (IE11, <1% browser share by caniuse.com). We were kind of OK letting it live a bit longer as long as it didn't require any time/effort from us, but that's no longer proving to be the case.

    • Many, many issues and bugs have been fixed since the v10 release.
    • Many, many new features have been added.
    • Many grammars highlight WAY better than they did previously.
    • The v10 parsing engine is so much more flexible and reliable.
    • There are quite likely numerous vulnerabilities we've fixed along the way without even realizing it.

    It's so obvious that v10 and modern browsers (released in the last ~4-5 years) is where we need to be focusing our time, not supporting very old browsers. So if you're still using version 9:

    If you aren't supporting IE11 users (or others with very obscure browsers)

    You need to upgrade to v10. No question. For 90% of simple cases it's a trivial upgrade. For complex integrations it may be a bit more effort (like most things). https://github.com/highlightjs/highlight.js/blob/master/VERSION_10_UPGRADE.md

    If you're supporting IE11 users (or others with very obscure browsers)

    Someone truly requiring IE11 support for "enterprisey" projects should perhaps look at Prism.js, which is a great project that still supports IE11. Or perhaps consider maintaining their own private fork of version 10 that supports IE11. This should still technically be possible now (AFAIK) but may prove more difficult as time goes on.

    So here is the current plan:

    • [x] One last v9 release (security fix).
    • [x] That release's release notes will mention the EOL and link to this issue. (and perhaps spew some other output, need to look at what is possible with npm).
    • [x] That release itself (and the current v9 release) will both be marked deprecated with a message to upgrade to v10.
    • [x] We may mark other prior releases deprecated as well. I'm really curious why more npm projects don't do this. Does anyone know?
    • [x] SECURITY.md will be updated accordingly.
    • [x] v9 support will then be official EOLed.

    So v9 users would want to upgrade to the latest v9 release and then either start working on upgrading to v10 or come up with other plans.

    big picture parser security 
    opened by joshgoebel 66
  • Policy: Discuss extras repository for additional languages

    Policy: Discuss extras repository for additional languages

    I see we have a lot of requests for new languages in the PRs... if the issue is time/maintenance over time, etc... might we perhaps consider an "extra" respository or something with community/unsupported syntaxes? That way the criteria to be approved could be lessened a little and obscure languages that might not really make sense in Highlight.js proper could still have a home?

    Or is the idea that eventually we'll get to them?

    big picture 
    opened by joshgoebel 64
  • [Discussion] Is an ES5 build/distribution necessary?

    [Discussion] Is an ES5 build/distribution necessary?

    Editor: Adding some answers here at the tope for anyone else who finds this with Google.

    If you're using the library as a direct dependency

    There is no need for an ES5 build if you're using the library as a first-order dependency. Just build us separately and drop the web build of the library directly into your project. (either as a separate JS <script> tag) or concat it to the end of your monolithic build. Simply:

    # from any unix shell
    cat highlight.min.js your_monolithic_js_bundle.js > final_build.js
    

    And of course you can do this easily with a build system as well.

    If you're using Browserify

    Evidently you can simply enable the global option. [more details would be helpful]


    The original issue:

    Ref: https://github.com/highlightjs/highlight.js/issues/2501

    As you know, v10 announced stop support of IE11. But, indirectly, published releases become not es5-compatible any more. If you have cases where es5 (babelified src) is still needed (except IE11) - please post here details.

    Support of es5 may be considered for prolong if a lot of demand exists.


    [Maintainer]: I know it's mentioned above, but just to be very clear this issue is NOT about IE11 (or other legacy browsers) support. The ship has sailed on that. This is only about whether there is value in proving a pre-build ES5 distribution to use with picky/older build systems that haven't caught up to ES6 yet.

    package/build 
    opened by puzrin 63
  • Extend cpp keyword set

    Extend cpp keyword set

    Added a set of commonly used C++ keywords/identifiers. We can't add them all of course, but things like optional and variant which are common vocabulary types since 2017 should be in there in my opinion.

    I would also like to order the lists in the language file lexicographically, making extension easier (without having to search). Is this OK? I will update this PR if desired.

    Changes

    • Extend set of common keywords/identifiers for C++.

    Checklist / TODO

    • [x] Remove redundant primitive types from keyword list.
    • [x] Cleanup keyword/function list.
    • [x] Update/review tests where needed.
    • [x] Explode dense lists and order lexicographically.
    • [x] Update the changelog at CHANGES.md.
    opened by krisvanrens 58
  • Discuss: Should Highlight.js version 11 npm release be ESM only?

    Discuss: Should Highlight.js version 11 npm release be ESM only?

    Is your request related to a specific problem you're having?

    I'm always frustrated when starting a project, I don't want to set up a whole build chain and just want to get started:

    import highlight from './node_modules/highlight.js/lib/core.js'
    

    And I get an error Error: 'default' is not exported by /node_modules/highlight.js/lib/core.js...

    The solution you'd prefer / feature you'd like to see added...

    I'd much rather prefer having standard ES6 modules in the npm package, and being able to use them as advertised in the README.md.

    Any alternative solutions you considered...

    s/module.exports =/export default/ on the node_modules/highlight.js/ files, but that's not very convenient.

    Additional context...

    Support for ESM has landed in Node.js current and LTS lines recently, with features such as Conditional Exports (useful in case we want to keep the CJS version around, still required for Node.js v10 support).

    Having ESM files would also make the library compatible with Deno for free, which would be nice.

    enhancement package/build autoclose 
    opened by aduh95 56
  • Detect HTML/JS injection attacks and warn users pro-actively

    Detect HTML/JS injection attacks and warn users pro-actively

    Is your request related to a specific problem you're having?

    https://github.com/highlightjs/highlight.js/issues/2884 https://github.com/ccampbell/rainbow/issues/249

    This comes up again and again (though thankfully not TOO often). Beginners are VERY confused about this whole HTML escaping thing.

    The solution you'd prefer / feature you'd like to see added...

    While we can't do anything smart about this yet (because we unfortunately allow HTML inside code blocks for "clever" users) I'd like this to change with v11. With v11 we should drop this HTML pass-thru behavior and move it to a plugin (making it very much opt-in). The default behavior should be that HTML is silently dropped and I'd even consider adding some sort of error:

    [code block]
    WARNING.
    Are you missing a bunch of HTML code you expected to see here? 
    Your HTML wasn't properly escaped and that can lead to serious
    security issues. _Learn More_
    
    Properly escape your code and the highlighting you expect will kick in.
    [/code block]
    

    This would of course be a breaking change so we'd need to wait until v11. For 95% of users I can't see the downside to this and it seems we could potentially educate and prevent a lot of harm. Someone wanting the HTML to pass thru would install a plug-in and thus change the behavior, get the old behavior back, etc.

    Any alternative solutions you considered...

    Silent dropping but no error... but that just leads to support issues... I suppose we could log the error to the console vs actually showing it on the webpage.

    enhancement big picture parser discuss/propose 
    opened by joshgoebel 53
  • Module not found: Error: Package path ./lib/index is not exported from package /node_modules/highlight.js

    Module not found: Error: Package path ./lib/index is not exported from package /node_modules/highlight.js

    I'm using Laravel, When I run npm run dev, it shows this:

    ERROR in ./resources/assets/vendor/libs/highlight/highlight.js 4:0-42
    Module not found: Error: Package path ./lib/index is not exported from package /home/wwwroot/myproject/node_modules/highlight.js (see exports field in /home/wwwroot/myproject/node_modules/highlight.js/package.json)
    

    I checked /home/wwwroot/myproject/node_modules/highlight.js and there is ./lib/index.js I've changed these in myproject before running npm run dev with root, but nothing changed:

    chmod 775 myproject -R

    chown www:www -R myproject

    bug help welcome parser 
    opened by JamesTang616 3
  • [Request] Alternate output formats, including SVG, images

    [Request] Alternate output formats, including SVG, images

    Is your request related to a specific problem you're having?

    I'd like to be able to produce syntax highlighting of code that is able to display in places where custom html/css is not allowed... for example inside of markdown on github. Additionally: inside PDFs, in comments on reddit/stackoverflow, etc.

    As such, it'd be preferable if there was an alternate output mode besides the default.

    The solution you'd prefer / feature you'd like to see added...

    If this library could produce SVG (with all the colors/styling included inline), that SVG output could be sent to a .svg file, which could then be displayed in these places. For markdown display, the solution I've seen in other places is including the image itself and then right below it, a <details> element (collapsed by default) with a code block in it, to be able to easily copy-paste the code that was rendered in the image.

    Additionally, an image rendering library could be included/used to produce a .PNG file equivalent of the syntax highlighting. Again, the <details> trick for markdown makes the text still accessible/copy-paste'able.

    Any alternative solutions you considered...

    Converting the HTML/CSS to SVG is possible, but it seems to be rather messy in my early experiments.

    Additional context...

    I have designed a new programming language, and written my own tokenizer logic (in JS). Right now, I can output HTML/CSS for syntax highlighting. But I don't yet have a way for my syntax highlighting to be shown on markdown pages/etc.

    While I was exploring just building this SVG output capability into my own tool, I decided to explore if perhaps this could just be something that the popular syntax highlighter tools (HighlightJS, PrismJS) could support.

    That way, I could use the same tool/workflow for producing syntax highlighting of my language, but other languages as well (JS, Haskell, etc). This would be useful in showing people comparisons of the same code snippet equivalent in various languages.

    I searched and didn't find anyone talking about this type of alternate output. Apologies if I missed prior support/discussions of such capabilities.

    enhancement parser 
    opened by getify 5
  • Updated GML.js to 2023.1 version

    Updated GML.js to 2023.1 version

    Updated GML language data to most up-to-date version, based on 2023.100.0.264 runtime (January 2023 release), with many features added in recent months. Many functions in current definition file were outdated (they were marked as deprecated for around 5-10 years or even already removed in recent months and years).

    Changes

    Generated from GameMaker runtime internal fnames file, with rule:

    • KEYWORDS: manually, as they are built-in in IDE and not mentioned in fnames file
    • BUILT_INS: functions; everything that have [a-z_]+\(.*?\) in definition (both UK and US spelling)
    • SYMBOLS: macros; everything that ended with # in fnames
    • LANGUAGE_VARIABLES: various global/local variables (reserved words); everything that ended by * (readonly), @ (instance variable), or didn't ended with (...) That exact fnames file can be found here: https://gist.github.com/gnysek/a69ec324df61131b2546d1580f29a760

    Checklist

    • [x] Added markup tests, or they don't apply here because... (only keyword updates)
    • [x] Updated the changelog at CHANGES.md
    opened by gnysek 0
  • PHP Comments inside function invoke & declaration

    PHP Comments inside function invoke & declaration

    PHP language not supported php comments inside function invoke and function declaration.

    Changes

    Added: hljs.C_LINE_COMMENT_MODE hljs.HASH_COMMENT_MODE

    Was: image

    Become: image

    Checklist

    • [x] Added markup tests, or they don't apply here because...
    • [ ] Updated the changelog at CHANGES.md
    opened by doiftrue 2
  • PHP NOWDOC Support

    PHP NOWDOC Support

    Support NOWDOC syntax for php.js.

    NOTE: NOWDOC don't parse php variables inside the string.

    HEREDOC improvements: quote syntax support <<<"END".

    Checklist

    • [x] Added markup tests.
    • [x] Updated the changelog at CHANGES.md
    opened by doiftrue 0
Releases(11.7.0)
  • 11.7.0(Nov 23, 2022)

    Version 11.7.0

    New Grammars:

    • added 3rd party LookML grammar to SUPPORTED_LANGUAGES Josh Temple
    • added 3rd party FunC grammar to SUPPORTED_LANGUAGES [Nikita Sobolev][]
    • Added 3rd party Flix grammar to SUPPORTED_LANGUAGES The Flix Organisation
    • Added 3rd party RVT grammar to SUPPORTED_LANGUAGES Sopitive

    Grammars:

    • enh(scheme) add scm alias for Scheme matyklug18
    • fix(typescript) patterns like <T = are not JSX Josh Goebel
    • fix(bash) recognize the (( keyword Nick Chambers
    • enh(Ruby) misc improvements (kws, class names, etc) Josh Goebel
    • fix(js) do not flag import() as a function, rather a keyword nathnolt
    • fix(bash) recognize the (( keyword Nick Chambers
    • fix(nix) support escaped dollar signs in strings h7x4
    • enh(cmake) support bracket comments Hirse
    • enh(java) add yield keyword to java MBoegers
    • enh(java) add permits keyword to java MBoegers
    • fix(javascript/typescript) correct identifier matching when using numbers Lachlan Heywood

    Improvements:

    Source code(tar.gz)
    Source code(zip)
  • 11.6.0(Jul 13, 2022)

    Version 11.6.0

    Supported Node.js versions:

    • (chore) Drops support for Node 12.x, which is no longer supported by Node.js.

    Default build changes:

    • add wasm to default :common build (#3526) [Josh Goebel][]
    • add graphql to default :common build (#3526) [Josh Goebel][]

    Grammars:

    • fix(json) changed null/booleans from keyword to literal shikhar13012001
    • enh(gml) reorganized and added additional keywords Bluecoreg
    • enh(csharp) Added support for the new scoped keyword in C# (#3571) [David Pine][]
    • enh(scala) add transparent keyword Matt Bovel
    • fix(rust) highlight types immediately preceeding :: (#3540) [Josh Goebel][]
    • Added 3rd party Apex grammar to SUPPORTED_LANGUAGES (#3546) David Schach
    • fix(rust) recognize include_bytes! macro (#3541) Serial-ATA
    • fix(java) do not intepret == as a variable declaration Mousetail
    • enh(swift) add SE-0335 existential any keyword (#3515) Bradley Mackey
    • enh(swift) add support for distributed keyword Marcus Ortiz
    • enh(xml) recognize Unicode letters instead of only ASCII letters in XML element and attribute names (#3256)Martin Honnen
    • Added 3rd party Toit grammar to SUPPORTED_LANGUAGES Serzhan Nasredin
    • Use substring() instead of deprecated substr() Tobias Buschor
    • Added 3rd party Oak grammar to SUPPORTED_LANGUAGES Tim Smith
    • enh(python) add match and case keywords Avrumy Lunger
    Source code(tar.gz)
    Source code(zip)
  • 11.5.1(Apr 11, 2022)

    Just a tiny release to hopefully fix the issues some are having with CSS not seen as having side effects with web pack, etc...


    Packaging:

    • (chore) explicitly set sideEffect for css and scss files, fixes #3504
    Source code(tar.gz)
    Source code(zip)
  • 11.5.0(Mar 12, 2022)

    Changes from CHANGELOG:

    Themes:

    New Grammars:

    Grammars:

    • enh(ruby) lots of small Ruby cleanups/improvements Josh Goebel
    • enh(objectivec) add type and variable.language scopes Josh Goebel
    • enh(xml) support processing instructions (#3492) Josh Goebel
    • enh(ruby ) better support multi-line IRB prompts
    • enh(bash) improved keyword $pattern (numbers allowed in command names) Martin Mattel
    • add meta.prompt scope for REPL prompts, etc Josh Goebel
    • fix(markdown) Handle ***Hello world*** without breaking Josh Goebel
    • enh(php) add support for PHP Attributes Wojciech Kania
    • fix(java) prevent false positive variable init on else Josh Goebel
    • enh(php) named arguments Wojciech Kania
    • fix(php) PHP constants Wojciech Kania
    • fix(angelscript) incomplete int8, int16, int32, int64 highlighting Melissa Geels
    • enh(ts) modify TypeScript-specific keywords and types list anydonym
    • fix(brainfuck) fix highlighting of initial ++/-- Christina Hanson
    • fix(llvm) escaping in strings and number formats Flakebi
    • enh(elixir) recognize references to modules Mark Ericksen
    • enh(css): add support for more properties Nicolaos Skimas
    Source code(tar.gz)
    Source code(zip)
  • 11.4.0(Jan 6, 2022)

    This is a big one. Holidays and all. Wishing all of you the best for 2022! See the note below about theme changes if you're super picky about your theming.

    New Languages:

    • Added 3rd party Pine Script grammar to SUPPORTED_LANGUAGES Jeylani B
    • Added 3rd party cURL grammar to SUPPORTED_LANGUAGES highlightjs-curl

    Themes:

    • Default is now much closer WCAG AA (contrast) (#3402) Josh Goebel
    • Dark now meets WCAG AA (contrast) (#3402) Josh Goebel
    • Added intellij-light theme Pegasis

    These changes should be for the better and should not be super noticeable but if you're super picky about your colors you may want to intervene here or copy over the older themes from 11.3 or prior.

    Grammars:

    • enh(arcade) updated to ArcGIS Arcade version 1.16 John Foster
    • enh(php) Left and right-side of double colon Wojciech Kania
    • enh(php) add PHP constants Wojciech Kania
    • enh(php) add PHP 8.1 keywords Wojciech Kania
    • fix(cpp) fix vector<< template false positive (#3437) Josh Goebel
    • enh(php) support First-class Callable Syntax (#3427) Wojciech Kania
    • enh(php) support class constructor call (#3427) Wojciech Kania
    • enh(php) support function invoke (#3427) Wojciech Kania
    • enh(php) Switch highlighter to partially case-insensitive (#3427) Wojciech Kania
    • enh(php) improve namespace and use highlighting (#3427) Josh Goebel
    • enh(php) $this is a variable.language now (#3427) Josh Goebel
    • enh(php) add __COMPILER_HALT_OFFSET__ (#3427) Josh Goebel
    • enh(js/ts) fix => async function title highlights (#3405) Josh Goebel
    • enh(twig) update keywords list (#3415) Matthieu Lempereur
    • fix(python) def, class keywords detected mid-identifier (#3381) Josh Goebel
    • fix(python) Fix recognition of numeric literals followed by keywords without whitespace (#2985) Richard Gibson
    • enh(swift) add SE-0290 unavailability condition (#3382) Bradley Mackey
    • fix(fsharp) Highlight operators, match type names only in type annotations, support quoted identifiers, and other smaller fixes. Melvyn Laïly
    • enh(java) add sealed and non-sealed keywords (#3386) Bradley Mackey
    • enh(js/ts) improve CLASS_REFERENCE (#3411) Josh Goebel
    • enh(nsis) Update defines pattern to allow ! (#3417) idleberg
    • enh(nsis) Update language strings pattern to allow ! (#3420) idleberg
    • fix(stan) Updated for Stan 2.28 and other misc. improvements (#3410)
    • enh(nsis) Update variables pattern (#3416) idleberg
    • fix(clojure) Several issues with Clojure highlighting (#3397) Björn Ebbinghaus
      • fix(clojure) comment macro catches more than it should (#3395)
      • fix(clojure) $ in symbol breaks highlighting
      • fix(clojure) Add complete regex for number detection
      • enh(clojure) Add character mode for character literals
      • fix(clojure) Inconsistent namespaced map highlighting
      • enh(clojure) Add regex mode to regex literal
      • fix(clojure) Remove inconsistent/broken highlighting for metadata
      • enh(clojure) Add punctuation mode for commas.
    • fix(julia) Enable the jldoctest alias (#3432) Fons van der Plas

    Developer Tools:

    Themes:

    • Modified background color in css for Gradient Light and Gradient Dark themes Samia Ali
    Source code(tar.gz)
    Source code(zip)
  • 11.3.1(Oct 17, 2021)

    Version 11.3.1

    Same as 11.3.0 except for the fix to generating optional CDN grammar modules.

    Build:

    • (fix) Grammar CDN modules not generated correctly. (#3363) Josh Goebel
    • add HighlightJS named export (#3295) Josh Goebel
    • add .default named export to CJS builds (#3333) Josh Goebel

    Parser:

    • add first rough performance testing script (#3280) Austin Schick
    • add throwUnescapedHTML to warn against potential HTML injection Josh Goebel
    • expose regex helper functions via hljs injection Josh Goebel
      • concat
      • lookahead
      • either
      • optional
      • anyNumberOfTimes

    Grammars:

    • fix(ts) some complex types would classify as JSX (#3278) Josh Goebel
    • fix(js/ts) less false positives for class X extends Y (#3278) Josh Goebel
    • enh(css): add properties from several W3C (Candidate) Recommendations (#3308)
    • fix(js/ts) Float32Array highlighted incorrectly (#3353) Josh Goebel
    • fix(css) single-colon psuedo-elements no longer break highlighting (#3240) Josh Goebel
    • fix(scss) single-colon psuedo-elements no longer break highlighting (#3240) Josh Goebel
    • enh(fsharp) rewrite most of the grammar, with many improvements Melvyn Laïly
    • enh(go) better type highlighting, add error type Josh Goebel
    • fix(js/ts) regex inside SUBST is no longer highlighted Josh Goebel
    • fix(python) added support for unicode identifiers (#3280) Austin Schick
    • enh(css/less/stylus/scss) improve consistency of function dispatch (#3301) Josh Goebel
    • enh(css/less/stylus/scss) detect block comments more fully (#3301) Josh Goebel
    • fix(cpp) switch is a keyword (#3312) Josh Goebel
    • fix(cpp) fix xor_eq keyword highlighting. Denis Kovalchuk
    • enh(c,cpp) highlight type modifiers as type (#3316) Josh Goebel
    • enh(css/less/stylus/scss) add support for CSS Grid properties monochromer
    • enh(java) add support for Java Text Block (#3322) Teletha
    • enh(scala) add missing do and then keyword (#3323) Nicolas Stucki
    • enh(scala) add missing enum, export and given keywords (#3328) Nicolas Stucki
    • enh(scala) remove symbol syntax and fix quoted code syntax (#3324) Nicolas Stucki
    • enh(scala) add Scala 3 extension soft keyword (#3326) Nicolas Stucki
    • enh(scala) add Scala 3 end soft keyword (#3327) Nicolas Stucki
    • enh(scala) add inline soft keyword (#3329) Nicolas Stucki
    • enh(scala) add using soft keyword (#3330) Nicolas Stucki
    • enh(fsharp) added f# alias (#3337) Bahnschrift
    • enh(bash) added gnu core utilities (#3342) katzeprior
    • enh(nsis) add new NSIS commands (#3351) idleberg
    • fix(nsis) set case_insensitive to true (#3351) idleberg
    • fix(css/less/stylus/scss) highlight single-colon psuedo-elements properly (#3240) zsoltlengyelit
    • fix(css) add css hex color alpha support (#3360) ierehon1905
    Source code(tar.gz)
    Source code(zip)
  • 11.3.0(Oct 17, 2021)

    Version 11.3.0

    Build:

    • add HighlightJS named export (#3295) Josh Goebel
    • add .default named export to CJS builds (#3333) Josh Goebel

    Parser:

    • add first rough performance testing script (#3280) Austin Schick
    • add throwUnescapedHTML to warn against potential HTML injection Josh Goebel
    • expose regex helper functions via hljs injection Josh Goebel
      • concat
      • lookahead
      • either
      • optional
      • anyNumberOfTimes

    Grammars:

    • fix(ts) some complex types would classify as JSX (#3278) Josh Goebel
    • fix(js/ts) less false positives for class X extends Y (#3278) Josh Goebel
    • enh(css): add properties from several W3C (Candidate) Recommendations (#3308)
    • fix(js/ts) Float32Array highlighted incorrectly (#3353) Josh Goebel
    • fix(css) single-colon psuedo-elements no longer break highlighting (#3240) Josh Goebel
    • fix(scss) single-colon psuedo-elements no longer break highlighting (#3240) Josh Goebel
    • enh(fsharp) rewrite most of the grammar, with many improvements Melvyn Laïly
    • enh(go) better type highlighting, add error type Josh Goebel
    • fix(js/ts) regex inside SUBST is no longer highlighted Josh Goebel
    • fix(python) added support for unicode identifiers (#3280) Austin Schick
    • enh(css/less/stylus/scss) improve consistency of function dispatch (#3301) Josh Goebel
    • enh(css/less/stylus/scss) detect block comments more fully (#3301) Josh Goebel
    • fix(cpp) switch is a keyword (#3312) Josh Goebel
    • fix(cpp) fix xor_eq keyword highlighting. Denis Kovalchuk
    • enh(c,cpp) highlight type modifiers as type (#3316) Josh Goebel
    • enh(css/less/stylus/scss) add support for CSS Grid properties monochromer
    • enh(java) add support for Java Text Block (#3322) Teletha
    • enh(scala) add missing do and then keyword (#3323) Nicolas Stucki
    • enh(scala) add missing enum, export and given keywords (#3328) Nicolas Stucki
    • enh(scala) remove symbol syntax and fix quoted code syntax (#3324) Nicolas Stucki
    • enh(scala) add Scala 3 extension soft keyword (#3326) Nicolas Stucki
    • enh(scala) add Scala 3 end soft keyword (#3327) Nicolas Stucki
    • enh(scala) add inline soft keyword (#3329) Nicolas Stucki
    • enh(scala) add using soft keyword (#3330) Nicolas Stucki
    • enh(fsharp) added f# alias (#3337) Bahnschrift
    • enh(bash) added gnu core utilities (#3342) katzeprior
    • enh(nsis) add new NSIS commands (#3351) idleberg
    • fix(nsis) set case_insensitive to true (#3351) idleberg
    • fix(css/less/stylus/scss) highlight single-colon psuedo-elements properly (#3240) zsoltlengyelit
    • fix(css) add css hex color alpha support (#3360) ierehon1905
    Source code(tar.gz)
    Source code(zip)
  • 11.2.0(Aug 2, 2021)

  • 11.1.0(Jul 8, 2021)

    Grammars:

    • fix(csharp) add missing catch keyword (#3251) Konrad Rudolph
    • add additional keywords to csp.js (#3244) Elijah Conners
    • feat(css) handle css variables syntax (#3239) Thanos Karagiannis
    • fix(markdown) Images with empty alt or links with empty text (#3233) Josh Goebel
    • enh(powershell) added pwsh alias (#3236) tebeco
    • fix(r) fix bug highlighting examples in doc comments Konrad Rudolph
    • fix(python) identifiers starting with underscore not highlighted (#3221) Antoine Lambert
    • enh(clojure) added edn alias (#3213) Stel Abrego
    • enh(elixir) much improved regular expression sigil support (#3207) Josh Goebel
    • enh(elixir) updated list of keywords (#3212) Angelika Tyborska
    • fix(elixir) fixed number detection when numbers start with a zero (#3212) Angelika Tyborska
    • fix(ps1) Flag highlighted incorrectly (#3167) Pankaj Patil
    • fix(latex) Allow wider syntax for magic comments (#3243) Benedikt Wilde
    • fix(js/ts) Constants may include numbers Josh Goebel
    Source code(tar.gz)
    Source code(zip)
  • 11.0.1(Jun 18, 2021)

  • 10.7.3(Jun 4, 2021)

  • 11.0.0(May 30, 2021)

    Potentially Breaking Changes

    This is a major release. As such it contains breaking changes which may require action from users. Most of the breaking changes work was done by the current maintainer Josh Goebel (ref: #2558) while many other contributors contributed many other changes for this release. You'll find that list below the breaking changes summary.

    Please read VERSION_11_UPGRADE.md for a detailed summary of all breaking changes. The below list should only be considered to be a summary.

    Deprecations / Removals / API Changes:

    • initHighlighting() and initHighlightingOnLoad() deprecated. Use highlightAll().
    • highlightBlock(el) deprecated. Use highlightElement(el)
    • before:highlightBlock & after:highlightBlock callbacks deprecated. Use equivalent highlightElement callbacks.
    • highlight(languageName, code, ignoreIllegals, continuation) signature deprecated. Use highlight(code, {language, ignoreIllegals}).
    • Deprecated highlight() signature no longer supports continuation argument.
    • tabReplace option removed. Consider a plugin.
    • useBR option removed. Consider a plugin or CSS.
    • requireLanguage() removed. Use getLanguage().
    • endSameAsBegin mode key removed. Use hljs.END_SAME_AS_BEGIN.
    • lexemes mode key removed. Use keywords.$pattern.
    • The return values/keys of some APIs have changed slightly.

    Security:

    • HTML auto-passthru has been removed. Consider a plugin.
    • Unescaped HTML is now stripped (for security). A warning is logged to the console. (#3057) Josh Goebel

    Themes:

    • The default padding of all themes increases (0.5em => 1em).
    • schoolbook has been updated to remove the lined background.
    • github updated to better match modern GitHub (#1616) Jan Pilzer
    • github-gist has been removed in favor of github Jan Pilzer
    • Base16 named themes have been updated to their "canonical" versions
    • nnfx updated for v11 xml styles and improved css support

    Language Grammars:

    • Default CDN build drops support for several languages.
    • Some language grammar files have been removed.
    • Some redundant language aliases have been removed.

    Other changes

    Parser:

    • enh(vala) improve language detection for Vala (#3195) [Konrad Rudolph][]
    • enh(r) add support for operators, fix number highlighting bug (#3194, #3195) [Konrad Rudolph][]
    • enh(parser) add beginScope and endScope to allow separate scoping begin and end (#3159) Josh Goebel
    • enh(parsed) endScope now supports multi-class matchers as well (#3159) Josh Goebel
    • enh(parser) highlightElement now always tags blocks with a consistent language-[name] class Josh Goebel
      • subLanguage span tags now also always have the language- prefix added
    • enh(parser) support multi-class matchers (#3081) Josh Goebel
    • enh(parser) Detect comments based on english like text, rather than keyword list Josh Goebel
    • adds title.class.inherited sub-scope support Josh Goebel
    • adds title.class sub-scope support (#3078) Josh Goebel
    • adds title.function sub-scope support (#3078) Josh Goebel
    • adds beforeMatch compiler extension (#3078) Josh Goebel
    • adds cssSelector configuration option (#3180) James Edington

    Grammars:

    • enh(all) .meta-keyword => .meta .keyword (nested scopes) (#3167) Josh Goebel
    • enh(all) .meta-string => .meta .string (nested scopes) (#3167) Josh Goebel
    • enh(swift) add actor keyword (#3171) Bradley Mackey
    • enh(crystal) highlight variables (#3154) Josh Goebel
    • fix(ruby) Heredoc without interpolation (#3154) Josh Goebel
    • enh(swift) add @resultBuilder attribute (#3151) Bradley Mackey
    • enh(processing) added pde alias (#3142) Dylan McBean
    • enh(thrift) Use proper scope for types Josh Goebel
    • enh(java) Simplified class-like matcher (#3078) Josh Goebel
    • enh(cpp) Simplified class-like matcher (#3078) Josh Goebel
    • enh(rust) Simplified class-like matcher (#3078) Josh Goebel
    • enh(actionscript) Simplified class-like matcher (#3078) Josh Goebel
    • enh(arcade) function.title => title.function (#3078) Josh Goebel
    • enh(autoit) function.title => title.function (#3078) Josh Goebel
    • enh(c) function.title => title.function (#3078) Josh Goebel
    • enh(rust) support function invoke and impl (#3078) Josh Goebel
    • chore(properties) disable auto-detection #3102 Josh Goebel
    • fix(properties) fix incorrect handling of non-alphanumeric keys #3102 [Egor Rogov][]
    • enh(java) support functions with nested template types (#2641) Josh Goebel
    • enh(java) highlight types and literals separate from keywords (#3074) Josh Goebel
    • enh(shell) add alias ShellSession Ryan Mulligan
    • enh(shell) consider one space after prompt as part of prompt Ryan Mulligan
    • fix(nginx) fix bug with $ and @ variables Josh Goebel
    • enh(nginx) improving highlighting of some sections Josh Goebel
    • fix(vim) variable names may not be zero length Josh Goebel
    • enh(sqf) Updated keywords to Arma 3 v2.02 (#3084) R3voA3
    • enh(sqf) Refactored function regex to match CBA component func naming scheme (#3181) JonBons
    • enh(nim) highlight types properly (not as built-ins) Josh Goebel
    • (chore) throttle deprecation messages (#3092) [Mihkel Eidast][]
    • enh(c) Update keyword list for C11/C18 (#3010) Josh Goebel
    • enh(parser) highlight object properties (#3072) Josh Goebel
    • enh(javascript/typescript) highlight object properties (#3072) Josh Goebel
    • enh(haskell) add support for BinaryLiterals (#3150) Martijn Bastiaan
    • enh(haskell) add support for NumericUnderscores (#3150) Martijn Bastiaan
    • enh(haskell) add support for HexFloatLiterals (#3150) Martijn Bastiaan
    • fix(c,cpp) allow declaring multiple functions and (for C++) parenthetical initializers (#3155) [Erik Demaine][]
    • enh(rust) highlight raw byte string literals correctly (#3173) Nico Abram
    • fix(cpp) fix detection of common functions that are function templates (#3178) Kris van Rens
    • enh(cpp) add various keywords and commonly used types for hinting (#3178) Kris van Rens
    • enh(cpp) cleanup reserved keywords and type lists (#3178) Kris van Rens

    New Languages:

    • Added 3rd party Glimmer grammar to SUPPORTED_LANGUAGES(#3123) NullVoxPopuli
    • Added Wren support Josh Goebel
    • Added NestedText support Josh Goebel
    • Added WebAssembly language grammar Josh Goebel
    • Added 3rd party Splunk search processing language grammar to SUPPORTED_LANGUAGES (#3090) Wei Su
    • Added 3rd party ZenScript grammar to SUPPORTED_LANGUAGES(#3106) Jared Luboff
    • Added 3rd party Papyrus grammar to SUPPORTED_LANGUAGES(#3125) Mike Watling

    Theme Improvements:

    • Added all official Base16 themes (over 150 new themes) Josh Goebel
    • chore(themes) remove builtin-name CSS class (#3119) Josh Goebel
    • chore(theme) Update GitHub theme css to match GitHub's current styling (#1616) Jan Pilzer
    • chore(theme) Update Srcery theme css to match its Emacs implementation [Chen Bin][]

    New Themes:

    Dev Improvements:

    • (chore) greatly improve match scope visualization in dev tool (#3126) NullVoxPopuli
    • (fix) CSS used for devtool needed an adjustment to fix too wide of content (#3133) NullVoxPopuli
    Source code(tar.gz)
    Source code(zip)
  • 11.0.0-beta1(May 16, 2021)

  • 11.0.0-beta0(May 4, 2021)

  • 11.0.0-alpha1(Apr 22, 2021)

    This is a major release. As such it contains breaking changes which may require action from users. Please read VERSION_11_UPGRADE.md for a detailed summary of all breaking changes.

    This release is:

    • main @ 3470e22f9eb8d5a4067b512e781ef9c6b6d46e3a
    • plus PR https://github.com/highlightjs/highlight.js/pull/3159
    • plus PR https://github.com/highlightjs/highlight.js/pull/3139

    Potentially breaking changes

    Unless otherwise attributed items below are thanks to Josh Goebel (ref: #2558).

    The below list should only be considered to be a high-level summary.

    Deprecations / Removals / API Changes:

    • initHighlighting() and initHighlightingOnLoad() deprecated. Use highlightAll().
    • highlightBlock(el) deprecated. Use highlightElement(el)
    • before:highlightBlock & after:highlightBlock callbacks deprecated. Use equivalent highlightElement callbacks.
    • highlight(languageName, code, ignoreIllegals, continuation) signature deprecated. Use highlight(code, {language, ignoreIllegals}).
    • Deprecated highlight() signature no longer supports continuation argument.
    • tabReplace option removed. Consider a plugin.
    • useBR option removed. Consider a plugin or CSS.
    • requireLanguage() removed. Use getLanguage().
    • endSameAsBegin mode key removed. Use hljs.END_SAME_AS_BEGIN.
    • lexemes mode key removed. Use keywords.$pattern.
    • The return values/keys of some APIs have changed slightly.

    Security:

    • HTML auto-passthru has been removed. Consider a plugin.
    • Unescaped HTML is now stripped (for security). A warning is logged to the console. (#3057) Josh Goebel

    Themes:

    • The default padding of all themes increases (0.5em => 1em).
    • schoolbook has been updated to remove the lined background.
    • github updated to better match modern GitHub (#1616) [Jan Pilzer][]
    • Base16 named themes have been updated to their "canonical" versions

    Language Grammars:

    • Default CDN build drops support for several languages.
    • Some language grammar files have been removed.
    • Some redundant language aliases have been removed.

    Other changes

    Parser:

    • enh(parser) add beginScope and endScope to allow separate scoping begin and end (#3159) Josh Goebel
    • enh(parsed) endScope now supports multi-class matchers as well (#3159) Josh Goebel
    • enh(parser) highlightElement now always tags blocks with a consistent language-[name] class Josh Goebel
      • subLanguage span tags now also always have the language- prefix added
    • enh(parser) support multi-class matchers (#3081) Josh Goebel
    • enh(parser) Detect comments based on english like text, rather than keyword list Josh Goebel
    • adds title.class.inherited sub-scope support Josh Goebel
    • adds title.class sub-scope support (#3078) Josh Goebel
    • adds title.function sub-scope support (#3078) Josh Goebel
    • adds beforeMatch compiler extension (#3078) Josh Goebel

    Grammars:

    • enh(crystal) highlight variables (#3154) Josh Goebel
    • fix(ruby) Heredoc without interpolation (#3154) Josh Goebel
    • enh(swift) add @resultBuilder attribute (#3151) Bradley Mackey
    • enh(processing) added pde alias (#3142) Dylan McBean
    • enh(thrift) Use proper scope for types Josh Goebel
    • enh(java) Simplified class-like matcher (#3078) Josh Goebel
    • enh(cpp) Simplified class-like matcher (#3078) Josh Goebel
    • enh(rust) Simplified class-like matcher (#3078) Josh Goebel
    • enh(actionscript) Simplified class-like matcher (#3078) Josh Goebel
    • enh(arcade) function.title => title.function (#3078) Josh Goebel
    • enh(autoit) function.title => title.function (#3078) Josh Goebel
    • enh(c) function.title => title.function (#3078) Josh Goebel
    • enh(rust) support function invoke and impl (#3078) Josh Goebel
    • chore(properties) disable auto-detection #3102 Josh Goebel
    • fix(properties) fix incorrect handling of non-alphanumeric keys #3102 [Egor Rogov][]
    • enh(java) support functions with nested template types (#2641) Josh Goebel
    • enh(java) highlight types and literals separate from keywords (#3074) Josh Goebel
    • enh(shell) add alias ShellSession Ryan Mulligan
    • enh(shell) consider one space after prompt as part of prompt Ryan Mulligan
    • fix(nginx) fix bug with $ and @ variables Josh Goebel
    • enh(nginx) improving highlighting of some sections Josh Goebel
    • fix(vim) variable names may not be zero length Josh Goebel
    • enh(sqf) Updated keywords to Arma 3 v2.02 (#3084) R3voA3
    • enh(nim) highlight types properly (not as built-ins) Josh Goebel
    • (chore) throttle deprecation messages (#3092) [Mihkel Eidast][]
    • enh(c) Update keyword list for C11/C18 (#3010) Josh Goebel
    • enh(parser) highlight object properties (#3072) Josh Goebel
    • enh(javascript/typescript) highlight object properties (#3072) Josh Goebel
    • enh(haskell) add support for BinaryLiterals (#3150) Martijn Bastiaan
    • enh(haskell) add support for NumericUnderscores (#3150) Martijn Bastiaan
    • enh(haskell) add support for HexFloatLiterals (#3150) Martijn Bastiaan

    New Languages:

    • Added 3rd party Glimmer grammar to SUPPORTED_LANGUAGES(#3123) NullVoxPopuli
    • Added NestedText support Josh Goebel
    • Added WebAssembly language grammar Josh Goebel
    • Added 3rd party Splunk search processing language grammar to SUPPORTED_LANGUAGES (#3090) Wei Su
    • Added 3rd party ZenScript grammar to SUPPORTED_LANGUAGES(#3106) Jared Luboff
    • Added 3rd party Papyrus grammar to SUPPORTED_LANGUAGES(#3125) Mike Watling

    Theme Improvements:

    • Added all official Base16 themes (over 150 new themes) Josh Goebel
    • chore(themes) remove builtin-name CSS class (#3119) Josh Goebel
    • chore(theme) Update GitHub theme css to match GitHub's current styling (#1616) [Jan Pilzer][]
    • chore(theme) Update Srcery theme css to match its Emacs implementation [Chen Bin][]

    New Themes:

    Dev Improvements:

    • (chore) greatly improve match scope visualization in dev tool (#3126) NullVoxPopuli
    Source code(tar.gz)
    Source code(zip)
  • 11.0.0-alpha0(Apr 13, 2021)

    This is a major alpha release. As such it contains breaking changes which may require action from users. Please read VERSION_11_UPGRADE.md for a detailed summary of all breaking changes.

    Potentially breaking changes

    Unless otherwise attributed items below are thanks to Josh Goebel (ref: #2558).

    The below list should only be considered to be a high-level summary.

    Deprecations / Removals / API Changes:

    • initHighlighting() and initHighlightingOnLoad() deprecated. Use highlightAll().
    • highlightBlock(el) deprecated. Use highlightElement(el)
    • before:highlightBlock & after:highlightBlock callbacks deprecated. Use equivalent highlightElement callbacks.
    • highlight(languageName, code, ignoreIllegals, continuation) signature deprecated. Use highlight(code, {language, ignoreIllegals}).
    • Deprecated highlight() signature no longer supports continuation argument.
    • tabReplace option removed. Consider a plugin.
    • useBR option removed. Consider a plugin or CSS.
    • requireLanguage() removed. Use getLanguage().
    • endSameAsBegin mode key removed. Use hljs.END_SAME_AS_BEGIN.
    • lexemes mode key removed. Use keywords.$pattern.
    • The return values/keys of some APIs have changed slightly.

    Security:

    • HTML auto-passthru has been removed. Consider a plugin.
    • Unescaped HTML is now stripped (for security). A warning is logged to the console. (#3057) Josh Goebel

    Themes:

    • The default padding of all themes increases (0.5em => 1em).
    • schoolbook has been updated to remove the lined background.
    • github updated to better match modern GitHub (#1616) [Jan Pilzer][]

    Language Grammars:

    • Default CDN build drops support for several languages.
    • Some language grammar files have been removed.
    • Some redundant language aliases have been removed.

    Other changes

    Parser:

    • enh(parser) support multi-class matchers (#3081) Josh Goebel
    • enh(parser) Detect comments based on english like text, rather than keyword list Josh Goebel
    • adds title.class sub-scope support (#3078) Josh Goebel
    • adds title.function sub-scope support (#3078) Josh Goebel
    • adds beforeMatch compiler extension (#3078) Josh Goebel

    Grammars:

    • enh(thrift) Use proper scope for types Josh Goebel
    • enh(java) Simplified class-like matcher (#3078) Josh Goebel
    • enh(cpp) Simplified class-like matcher (#3078) Josh Goebel
    • enh(rust) Simplified class-like matcher (#3078) Josh Goebel
    • enh(actionscript) Simplified class-like matcher (#3078) Josh Goebel
    • enh(arcade) function.title => title.function (#3078) Josh Goebel
    • enh(autoit) function.title => title.function (#3078) Josh Goebel
    • enh(c) function.title => title.function (#3078) Josh Goebel
    • enh(rust) support function invoke and impl (#3078) Josh Goebel
    • chore(properties) disable auto-detection #3102 Josh Goebel
    • fix(properties) fix incorrect handling of non-alphanumeric keys #3102 [Egor Rogov][]
    • enh(java) support functions with nested template types (#2641) Josh Goebel
    • enh(java) highlight types and literals separate from keywords (#3074) Josh Goebel
    • enh(shell) add alias ShellSession Ryan Mulligan
    • enh(shell) consider one space after prompt as part of prompt Ryan Mulligan
    • fix(nginx) fix bug with $ and @ variables Josh Goebel
    • enh(nginx) improving highlighting of some sections Josh Goebel
    • fix(vim) variable names may not be zero length Josh Goebel
    • enh(sqf) Updated keywords to Arma 3 v2.02 (#3084) R3voA3
    • enh(nim) highlight types properly (not as built-ins) Josh Goebel
    • (chore) throttle deprecation messages (#3092) [Mihkel Eidast][]
    • enh(c) Update keyword list for C11/C18 (#3010) Josh Goebel
    • enh(parser) highlight object properties (#3072) Josh Goebel
    • enh(javascript/typescript) highlight object properties (#3072) Josh Goebel

    New Languages:

    • Added 3rd party Splunk search processing language grammar to SUPPORTED_LANGUAGES (#3090) Wei Su
    • Added 3rd party ZenScript grammar to SUPPORTED_LANGUAGES(#3106) Jared Luboff
    • Added 3rd party Papyrus grammar to SUPPORTED_LANGUAGES(#3125) Mike Watling

    Theme Improvements:

    • chore(themes) remove builtin-name CSS class (#3119) Josh Goebel
    • chore(theme) Update GitHub theme css to match GitHub's current styling (#1616) [Jan Pilzer][]

    Dev Improvements:

    • (chore) greatly improve match scope visualization in dev tool (#3126) NullVoxPopuli
    Source code(tar.gz)
    Source code(zip)
  • 10.7.2(Apr 4, 2021)

  • 10.7.1(Mar 21, 2021)

    This .1 patch release fixes an issue with the TypeScript typing info in 10.7.0.

    Release notes from 10.7.0

    Parser:

    • enh(api) add unregisterLanguage method (#3009) Antoine du Hamel
    • enh: Make alias registration case insensitive (#3026) David Ostrovsky
    • fix(parser) highlightAll() now works if the library is lazy loaded Josh Goebel

    New Languages:

    • Added 3rd party RiScript grammar to SUPPORTED_LANGUAGES (#2988) [John C][]
    • Added 3rd party HLSL grammar to SUPPORTED_LANGUAGES (#3002) Stef Levesque
    • Added 3rd party Q# grammar to SUPPORTED_LANGUAGES(#3006) Vyron Vasileiadis

    Language grammar improvements:

    • fix(python) allow keywords immediately following numbers (#2985) Josh Goebel
    • fix(xml) char immediately following tag close mis-highlighted (#3044) Josh Goebel
    • fix(ruby) fix defined?() mis-highlighted as def (#3025) Josh Goebel
    • fix(c) comments after #include <str> blocks (#3041) Josh Goebel
    • fix(cpp) comments after #include <str> blocks (#3041) Josh Goebel
    • enh(cpp) Highlight all function dispatches (#3005) Josh Goebel
    • enh(python) support type hints and better type support (#2972) Josh Goebel
    • enh(gml) Add additional GML 2.3 keywords (#2984) xDGameStudios
    • fix(cpp) constructor support for initializers (#3001) Josh Goebel
    • enh(php) Add trait to class-like naming patterns (#2997) Ayesh
    • enh(php) Add Stringable, UnhandledMatchError, and WeakMap classes/interfaces (#2997) Ayesh
    • enh(php) Add mixed to list of keywords (#2997) Ayesh
    • enh(php) Add support binary, octal, hex and scientific numerals with underscore separator support (#2997) Ayesh
    • enh(php) Add support for Enums (#3004) Ayesh
    • enh(ecmascript) Add built-in types Vaibhav Chanana
    • enh(kotlin) Add kts as an alias for Kotlin (#3021) Vaibhav Chanana
    • enh(css) Add font-smoothing to attributes list for CSS (#3027) AndyKIron
    • fix(python) Highlight print and exec as a builtin (#1468) Samuel Colvin
    • fix(csharp) Fix unit being highlighted instead of uint (#3046) [Spacehamster][]
    • enh(swift) add async/await keywords (#3048) [Bradley Mackey][]

    Deprecations:

    • highlight(languageName, code, ignoreIllegals, continuation) deprecated as of 10.7
      • Please use the newer API which takes code and then accepts options as an object
      • IE: highlight(code, {language, ignoreIllegals})
      • continuation is for internal use only and no longer supported
    • highlightBlock(el) deprecated as of 10.7.
      • Please use highlightElement(el) instead.
      • Plugin callbacks renamed before/after:highlightBlock => before/after:highlightElement
      • Plugin callback now takes el vs block attribute
      • The old API and callbacks will be supported until v12.
    Source code(tar.gz)
    Source code(zip)
  • 10.7.0(Mar 20, 2021)

    Parser:

    • enh(api) add unregisterLanguage method (#3009) Antoine du Hamel
    • enh: Make alias registration case insensitive (#3026) David Ostrovsky
    • fix(parser) highlightAll() now works if the library is lazy loaded Josh Goebel

    New Languages:

    • Added 3rd party RiScript grammar to SUPPORTED_LANGUAGES (#2988) [John C][]
    • Added 3rd party HLSL grammar to SUPPORTED_LANGUAGES (#3002) Stef Levesque
    • Added 3rd party Q# grammar to SUPPORTED_LANGUAGES(#3006) Vyron Vasileiadis

    Language grammar improvements:

    • fix(python) allow keywords immediately following numbers (#2985) Josh Goebel
    • fix(xml) char immediately following tag close mis-highlighted (#3044) Josh Goebel
    • fix(ruby) fix defined?() mis-highlighted as def (#3025) Josh Goebel
    • fix(c) comments after #include <str> blocks (#3041) Josh Goebel
    • fix(cpp) comments after #include <str> blocks (#3041) Josh Goebel
    • enh(cpp) Highlight all function dispatches (#3005) Josh Goebel
    • enh(python) support type hints and better type support (#2972) Josh Goebel
    • enh(gml) Add additional GML 2.3 keywords (#2984) xDGameStudios
    • fix(cpp) constructor support for initializers (#3001) Josh Goebel
    • enh(php) Add trait to class-like naming patterns (#2997) Ayesh
    • enh(php) Add Stringable, UnhandledMatchError, and WeakMap classes/interfaces (#2997) Ayesh
    • enh(php) Add mixed to list of keywords (#2997) Ayesh
    • enh(php) Add support binary, octal, hex and scientific numerals with underscore separator support (#2997) Ayesh
    • enh(php) Add support for Enums (#3004) Ayesh
    • enh(ecmascript) Add built-in types Vaibhav Chanana
    • enh(kotlin) Add kts as an alias for Kotlin (#3021) Vaibhav Chanana
    • enh(css) Add font-smoothing to attributes list for CSS (#3027) AndyKIron
    • fix(python) Highlight print and exec as a builtin (#1468) Samuel Colvin
    • fix(csharp) Fix unit being highlighted instead of uint (#3046) [Spacehamster][]
    • enh(swift) add async/await keywords (#3048) [Bradley Mackey][]

    Deprecations:

    • highlight(languageName, code, ignoreIllegals, continuation) deprecated as of 10.7
      • Please use the newer API which takes code and then accepts options as an object
      • IE: highlight(code, {language, ignoreIllegals})
      • continuation is for internal use only and no longer supported
    • highlightBlock(el) deprecated as of 10.7.
      • Please use highlightElement(el) instead.
      • Plugin callbacks renamed before/after:highlightBlock => before/after:highlightElement
      • Plugin callback now takes el vs block attribute
      • The old API and callbacks will be supported until v12.
    Source code(tar.gz)
    Source code(zip)
  • 10.6.0(Feb 8, 2021)

    New Languages:

    • Added 3rd party Laravel Blade grammar to SUPPORTED_LANGUAGES (#2944) Michael Newton

    Language grammar improvements:

    • enh(scala) fix triple quoted strings (#2987) Josh Goebel
    • enh(perl) Much improved regex detection (#2960) Josh Goebel
    • enh(swift) Improved highlighting for operator and precedencegroup declarations. (#2938) Steven Van Impe
    • fix(xml) Support single-character namespaces. (#2957) [Jan Pilzer][]
    • enh(ruby) Support for character literals (#2950) Vaibhav Chanana
    • enh(powershell) Add three VALID_VERBS and update the reference link (#2981) davidhcefx

    Grammar Deprecations:

    • Deprecate c-like, though you should not be using it directly anyways.
      • will be removed in v11.
    • c and cpp are now wholly unique grammars that will diverge over time

    Parser:

    • new simpler highlightAll() API (#2962) Josh Goebel
      • this should be a drop-in replacement for both initHighlighting() and initHighlightingOnLoad()
      • note: it does not prevent itself from being called multiple times (as the previous API did)
    • beginKeyword no longer bestows double relevance (#2953) Josh Goebel
    • allow keywords to be an array of strings Josh Goebel
    • add modes.MATCH_NOTHING_RE that will never match
      • This can be used with end to hold a mode open (it must then be ended with endsParent in one of it's children modes) Josh Goebel

    Deprecations:

    • initHighlighting() and initHighlightingOnLoad() deprecated.
      • Please use the new highlightAll() API instead.
      • Deprecated as of 10.6.
      • These will both be aliases to highlightAll in v11.
    Source code(tar.gz)
    Source code(zip)
  • 10.5.0(Dec 23, 2020)

    What's New

    Build:

    • Add Subresource Integrity digest lists to cdn-assets Josh Goebel
    • R and VB.net grammars now ship in our default build (:common) Josh Goebel

    Parser:

    • add match as sugar for simple begin only matches (#2834) Josh Goebel
    • allow illegal to also be an array of regex (#2834) Josh Goebel
    • add compilerExtensions allows grammers to influence mode compilation (#2834) Josh Goebel
      • some internal pieces are now simple compiler extensions

    New Languages:

    • Added 3rd party Red & Rebol grammar to SUPPORTED_LANGUAGES (#2872) Oldes Huhuman

    Language grammar improvements:

    • enh(cpp): Support C++ pack expansion in function arguments Martin Dørum
    • enh(makefile): Add make as an alias (#2883) tripleee
    • enh(swift) Improved grammar for strings (#2819) Steven Van Impe
    • enh(swift) Grammar improvements (#2908) Steven Van Impe
      • New grammar for keywords and built-ins
      • Added support for operator highlighting
      • New grammar for attributes
      • Added support for quoted identifiers, implicit parameters, and property wrapper projections
      • Support for more complex expressions in string interpolation
    • enh(swift) Improved highlighting for types and generic arguments (#2920) Steven Van Impe
    • fix(http) avoid recursive sublanguage and tighten rules (#2893) Josh Goebel
    • fix(asciidoc): Handle section titles level 5 (#2868) Vaibhav Chanana
    • fix(asciidoc): Support unconstrained emphasis syntax (#2869) Guillaume Grossetie
    • enh(scheme) Allow [] for argument lists (#2913) Josh Goebel
    • enh(vb) Large rework of VB.net grammar (#2808) Jan Pilzer
      • Adds support for Date data types, see (#2775)
      • Adds support for REM comments and fixes ''' doctags (#2875) (#2851)
        • Custom number mode to support VB.net specific number flags
        • Hex (&H), Oct (&O), and binary (&B) prefixes
        • Separating digits with underscores: 90_946
      • Type suffixes: 123UI (unsigned integer)
      • Improves directives detection and adds support for Enable, Disable, and Then keywords
      • Adds more markup tests
    • fix(javascript) Empty block-comments break highlighting (#2896) Jan Pilzer
    • enh(dart) Fix empty block-comments from breaking highlighting (#2898) Jan Pilzer
    • enh(dart) Fix empty doc-comment eating next line Jan Pilzer
    • enh(asciidoc) Adds support for unconstrained bold syntax (#2869) Guillaume Grossetie
    • enh(c-like) Incorrect highlighting for interger suffix (#2919) Vaibhav Chanana
    • enh(properties) Correctly handle trailing backslash (#2922) Vaibhav Chanana

    Recent Deprecations:

    • HTML "merging" is deprecated. (#2873) Josh Goebel
      • HTML inside <pre> blocks will no longer be magically merged back into the highlighted code's HTML result - it will instead be silently removed.
      • Consider using a plugin if you truly need this functionality
      • Deprecated as of 10.5.0 - will be removed in v11.
    • tabReplace option deprecated. (#2873) Josh Goebel
      • Consider: Use the CSS tab-size property, or simply pre-process the text yourself before rendering the initial HTML
      • otherwise, use a plugin
      • Deprecated as of 10.5.0 - will be removed in v11.
    • useBR option deprecated. (#2559) Josh Goebel
      • Recommended: You really should just use the HTML <pre> tag
      • or perhaps try CSS white-space: pre;
      • otherwise, use a plugin
      • Deprecated as of 10.3.0 - will be removed in v11.
    • requireLanguage API is deprecated, will be removed in v11.0.
      • Consider: Use getLanguage (with custom error handling) or built-time dependencies.
      • See Library API for more information.
      • Deprecated as of 10.4.0 - will be removed in v11.
    Source code(tar.gz)
    Source code(zip)
  • 10.4.1(Dec 3, 2020)

    Security fixes:

    • (fix) Exponential backtracking fixes for: Josh Goebel
      • cpp
      • handlebars
      • gams
      • perl
      • jboss-cli
      • r
      • erlang-repl
      • powershell
      • routeros
    • (fix) Polynomial backtracking fixes for: Josh Goebel
      • asciidoc
      • reasonml
      • latex
      • kotlin
      • gcode
      • d
      • aspectj
      • moonscript
      • coffeescript/livescript
      • csharp
      • scilab
      • crystal
      • elixir
      • basic
      • ebnf
      • ruby
      • fortran/irpf90
      • livecodeserver
      • yaml
      • x86asm
      • dsconfig
      • markdown
      • ruleslanguage
      • xquery
      • sqf

    Very grateful to Michael Schmidt for all the help.

    Source code(tar.gz)
    Source code(zip)
  • 10.4.0(Nov 18, 2020)

    A largish release with many improvements and fixes from quite a few different contributors. Enjoy!

    Deprecations:

    • (chore) requireLanguage is deprecated.
      • Prefer getLanguage (with custom error handling) or built-time dependencies.
      • See Library API for more information.

    Parser:

    • enh(parser) use negative look-ahead for beginKeywords support (#2813) Josh Goebel
    • enh(grammars) allow classNameAliases for more complex grammars Josh Goebel
    • fix(vue): Language name now appears in CSS class (#2807) Michael Rush
    • (chore) Clean up all regexs to be UTF-8 compliant/ready (#2759) Josh Goebel

    New Languages:

    • Added 3rd party Chapel grammar to SUPPORTED_LANGUAGES (#2806) Brad Chamberlain
    • Added BBCode grammar to SUPPORTED_LANGUAGES (#2867) Paul Reid
    • enh(javascript) Added node-repl for Node.js REPL sessions (#2792) Marat Nagayev

    Language Improvements:

    • enh(shell) Recognize prompts which contain tilde ~ (#2859) Guillaume Grossetie
    • enh(shell) Add support for multiline commands with line continuation \ (#2861) Guillaume Grossetie
    • enh(autodetect) Over 30+ improvements to auto-detect (#2745) Josh Goebel
      • 4-5% improvement in auto-detect against large sample set
      • properties, angelscript, lsl, javascript, n1ql, ocaml, ruby
      • protobuf, hy, scheme, crystal, yaml, r, vbscript, groovy
      • python, java, php, lisp, matlab, clojure, csharp, css
    • fix(r) fixed keywords not properly spaced (#2852) Josh Goebel
    • fix(javascript) fix potential catastrophic backtracking (#2852) Josh Goebel
    • fix(livescript) fix potential catastrophic backtracking (#2852) Josh Goebel
    • bug(xml) XML grammar was far too imprecise/fuzzy Josh Goebel
    • enh(xml) Improve precision to prevent false auto-detect positives Josh Goebel
    • fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) Josh Goebel
    • enh(julia) Update keyword lists for Julia 1.x (#2781) Fredrik Ekre
    • enh(python) Match numeric literals per the language reference Richard Gibson
    • enh(ruby) Match numeric literals per language documentation Richard Gibson
    • enh(javascript) Match numeric literals per ECMA-262 spec Richard Gibson
    • enh(java) Match numeric literals per Java Language Specification Richard Gibson
    • enh(swift) Match numeric literals per language reference Richard Gibson
    • enh(php) highlight variables (#2785) Taufik Nurrohman
    • fix(python) Handle comments on decorators (#2804) Jonathan Sharpe
    • enh(diff) improve highlighting of diff for git patches [Florian Bezdeka][]
    • fix(llvm) lots of small improvements and fixes (#2830) Josh Goebel
    • enh(mathematica) Rework entire implementation Patrick Scheibe
      • Correct matching of the many variations of Mathematica's numbers
      • Matching of named-characters aka special symbols like \[Gamma]
      • Updated list of version 12.1 built-in symbols
      • Matching of patterns, slots, message-names and braces
    • fix(swift) Handle keywords that start with # Marcus Ortiz
    • enh(swift) Match some keyword Marcus Ortiz
    • enh(swift) Match @main attribute Marcus Ortiz

    Dev Improvements:

    • chore(dev) add theme picker to the tools/developer tool (#2770) Josh Goebel
    • fix(dev) the Vue.js plugin no longer throws an exception when hljs is not in the global namespace Kyle Brown

    New themes:

    Source code(tar.gz)
    Source code(zip)
  • 10.3.2(Oct 29, 2020)

    Tiny tiny release, just to fix the website incorrectly not listing Javascript in the list of languages you could choose for a custom build. NPM and CDN build should not have been affected so 10.3.1 is effectively the same as 10.3.2 for those builds.

    If you made a custom build from the website with 10.3 or 10.3.1 you may want to check and make sure it includes Javascript, and if not, build it again.

    Source code(tar.gz)
    Source code(zip)
  • 10.3.1(Oct 17, 2020)

    Prior version let some look-behind regex sneak in, which does not work yet on Safari. This release removes those incompatible regexes.

    Fixes:

    • fix(Safari) Remove currently unsupported look-behind regex (fix) Josh Goebel
    Source code(tar.gz)
    Source code(zip)
  • 10.3.0(Oct 17, 2020)

    Lots of large and small improvements to grammars including a major rewrite of our LaTeX grammar. See CHANGES.md for full list. Thanks for the interest from StackOverflow and Octoberfest!

    • The useBR option deprecated and will be removed in v11.0.

    Thanks to everyone who contributed to this release:

    • Chris Krycho
    • David Pine
    • Josh Goebel
    • Ryan Jonasson
    • Philipp Engel
    • Konrad Rudolph
    • Melissa Geels
    • Antoine du Hamel
    • Ayesh Karunaratne
    • Tom Wallace
    • schtandard
    Source code(tar.gz)
    Source code(zip)
  • 10.2.1(Oct 8, 2020)

  • 10.2.0(Sep 7, 2020)

    Version 10.2.0

    Parser Engine:

    • (fix) When ignoring a potential match highlighting can terminate early (#2649) Josh Goebel

    New themes:

    Deprecations:

    • fixMarkup is now deprecated and will be removed in v11.0. (#2534) Josh Goebel

    Big picture:

    • Add simple Vue plugin for basic use cases (#2544) Josh Goebel

    Language Improvements:

    • fix(bash) Fewer false positives for keywords in arguments (#2669) sirosen
    • fix(js) Prevent long series of /////// from causing freezes (#2656) Josh Goebel
    • enh(csharp) Add init and record keywords for C# 9.0 (#2660) Youssef Victor
    • enh(matlab) Add new R2019b arguments keyword and fix enumeration keyword (#2619) Andrew Janke
    • fix(kotlin) Remove very old keywords and update example code (#2623) kageru
    • fix(night) Prevent object prototypes method values from being returned in getLanguage (#2636) night
    • enh(java) Add support for enum, which will identify as a class now (#2643) ezksd
    • enh(nsis) Add support for NSIS 3.06 commands (#2653) idleberg
    • enh(php) detect newer more flexible HEREdoc syntax (#2658) eytienne
    Source code(tar.gz)
    Source code(zip)
  • 10.1.2(Jul 23, 2020)

  • 10.1.1(Jul 2, 2020)

    Fixes:

    • Resolve issue on Node 6 due to dangling comma (#2608) [Edwin Hoogerbeets][]
    • Resolve index.d.ts is not a module error (#2603) [Josh Goebel][]
    Source code(tar.gz)
    Source code(zip)
Owner
highlight.js
Syntax highlighting for the Web
highlight.js
Lightweight, robust, elegant syntax highlighting.

Prism Prism is a lightweight, robust, and elegant syntax highlighting library. It's a spin-off project from Dabblet. You can learn more on prismjs.com

Prism.js 10.9k Dec 30, 2022
Opinionated syntax highlighting with shiki for markdown-it.

式神 shikigami Opinionated syntax highlighting with shiki for markdown-it. Installation Just use your favorite package manager. npm i @nrsk/shikigami Th

Vladislav Mamon 6 Sep 30, 2022
✏️ Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped

Sugar High Introduction Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped Usage npm install --save sugar-high import { h

Jiachi Liu 67 Dec 8, 2022
Syntax Highlighter bot for Telegram.

??️ Syntax Highlighter Bot Kind of a copy; highly inspired from Piterden/syntax-highlighter-bot - Telegram Bot here Minimal syntax highlighting bot fo

Dunkan 18 Nov 11, 2022
An experimental syntax highlighter web app bot based on Telegram's WebApp update.

Syntax Highlighter WebApp Inspired by zubiden/tg-web-bot-demo. Try the demo bot running here: @syntaxyybot Recently Telegram released a big update for

Dunkan 12 Nov 8, 2022
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.

Crayon Syntax Highlighter Supports multiple languages, themes, fonts, highlighting from a URL, local file or post text. Written in PHP and jQuery. Cra

Aram Kocharyan 1.1k Nov 26, 2022
A beautiful Syntax Highlighter.

Shiki Shiki is a beautiful Syntax Highlighter. Demo. Usage npm i shiki const shiki = require('shiki') shiki .getHighlighter({ theme: 'nord' }

Shiki 4.2k Dec 31, 2022
Adds links to Discogs pages from various sites. Auto search for music on torrent and other sites. Does multi auto-search on Artist/Discography pages. Auto search local HDDs/filelists using Voidtools Everything search engine.

Discogs Scout: Adds links to Discogs pages from various sites. Auto search for music on torrent and other sites. Does multi auto-search on Artist/Disc

null 27 Dec 27, 2022
local storage wrapper for both react-native and browser. Support size controlling, auto expiring, remote data auto syncing and getting batch data in one query.

react-native-storage This is a local storage wrapper for both react native apps (using AsyncStorage) and web apps (using localStorage). ES6 syntax, pr

Sunny Luo 2.9k Dec 16, 2022
auto create and auto verif otp vconomics ! udah coid awkaowkaw

Vconomics Refferal Bot How to use : git clone https://github.com/dkmpostor/vconomics/ cd vconomics npm install node index.js Input refferal code Done

DK 2 Jan 10, 2022
1KB lightweight, fast & powerful JavaScript templating engine with zero dependencies. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

JavaScript Templates Contents Demo Description Usage Client-side Server-side Requirements API tmpl() function Templates cache Output encoding Local he

Sebastian Tschan 1.7k Jan 3, 2023
A beautiful, responsive, highly customizable and accessible replacement for JavaScript's popup boxes. Zero dependencies.Alerts ,dialogs

AsgarAlert (v1) for JS Install <script defer src="/asgar-alert.js"></script> Examples The most basic message: asgar("Hello world!"); A message signali

Asgar Aliyev 5 Dec 20, 2022
👌A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for drop an annoying pop-ups confirming the submission of form in your web apps.

Throw out pop-ups confirming the submission of form! A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for dro

Vic Shóstak 35 Aug 24, 2022
Syntax implementation of Laravel's's Blade language for highlight.js

Blade language definition for Highlight.js Syntax implementation of Laravel's's Blade language for highlight.js. Support us We invest a lot of resourc

Spatie 12 Jul 6, 2022
Zero Two Bot,A fully Modular Whatsapp Bot to do everything possible in WhatsApp by Team Zero Two

?? ???????? ?????? ???? ?? A Moduler WhatsApp Bot designed for both PM and Groups - To take your boring WhatsApp usage into a whole different level. T

Sam Pandey 69 Dec 25, 2022
Multiplies a number by zero. Useful for when you need to multiply a number by zero

multiply-by-zero Multiplies a number by zero. Useful for when you need to multiply a number by zero Please consider checking out the links of this pro

Dheirya Tyagi 2 Jul 3, 2022
Zero dependencies, lightweight, and asynchronous https requests package.

This project is a Work in Progress and currently in development. The API is subject to change without warning. A small fetching package for super simp

Ray Arayilakath 11 Dec 8, 2022
Simple, responsive, modern SVG Charts with zero dependencies

Frappe Charts GitHub-inspired modern, intuitive and responsive charts with zero dependencies Explore Demos » Edit at CodePen » Contents Installation U

Frappe 14.6k Jan 4, 2023