Variable assignment

var foo = "bar", baz = 5;

Operators

(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7

Indented code

if (true) {
	while (true) {
		doSomething();
	}
}

Regex with slashes

var foo = /([^/])\/(\\?.|\[.+?])+?\/[gim]{0,3}/g;

Regex that ends with double slash

var bar = /\/\*[\w\W]*?\*\//g;

Single line comments & regexes

// http://lea.verou.me
var comment = /\/\*[\w\W]*?\*\//g;

Link in comment

// http://lea.verou.me
/* http://lea.verou.me */

Nested strings

var foo = "foo", bar = "He \"said\" 'hi'!"

Strings inside comments

// "foo"
/* "foo" */

Strings with slashes

env.content + '</' + env.tag + '>'
var foo = "/" + "/";
var foo = "http://prismjs.com"; // Strings are strings and comments are comments ;)

Regex inside single line comment

// hey, /this doesn’t fail!/ :D

Two or more division operators on the same line

var foo = 5 / 6 / 7;

A division operator on the same line as a regex

var foo = 1/2, bar = /a/g;
var foo = /a/, bar = 3/4;

ES6 features

// Regex "y" and "u" flags
var a = /[a-zA-Z]+/gimyu;

// for..of loops
for(let x of y) { }

// Modules: import
import { foo as bar } from "file.js"

// Template strings
`Only on ${y} one line`
`This template string ${x} is on

multiple lines.`
`40 + 2 = ${ 40 + 2 }`
`The squares of the first 3 natural integers are ${[for (x of [1,2,3]) x*x].join(', ')}`

Known failures

There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. However, Prism dares to be open and honest about them. If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.

String interpolation containing a closing brace

`${ {foo:'bar'}.foo }`
`${ '}' }`