Prism tokens

Prism identifies tokens in your code, which are in turn styled by CSS to produce the syntax highlighting. This page provides an overview of the standard tokens and corresponding examples.

Standard tokens

When defining a new language, you will need to provide token names for each 'type' of code, such as keywords and operators, so Prism's themes can assign colors (and other styles) accordingly. Prism's themes (both official and non-official) only guarantee coverage for these standard tokens, so it is recommended to make use of the following standard tokens to ensure that code will be highlighted.

General purpose
keyword Pre-defined and reserved words.
for (const foo of bar) {
	if (foo === 'foobar') break;
	await foo;
builtin Functions/Methods/Classes/Types that are available out of the box.
pi = round(float('3.14159'), 2)
type SearchFunc = (source: string, subStr: string) => boolean;
class-name The name of a class, interface, trait, or type.
class Rectangle extends Square { /* ... */ }
public class CameraController : MonoBehaviour { /* ... */ }
function The name of a function or method.
function isEven(number) {
	return Number(number) % 2 === 0;
const isOdd = (number) => !isEven(number);
boolean True and false, and pairs with similar concepts (e.g. yes and no).
console.log(true === false); // prints false
console.log(true === !false); // prints true
number A numerical value, regardless of base and order, and no matter real or imaginary.
print(3.14159 * 42)
print(1e100 + .001j)
return foo & 0xdeadbeef
string Literal text, including numbers and symbols and maybe even more special characters.
let greeting = 'Hello World!';
char A string that can comprise only a single character, enforced by the language.
['A', 'z', '0', '-', '\t', '\u{2728}']
symbol A primitive data type found in some languages, can be thought of as an identifier.
#myFirstSymbol "#myFirstSymbol is a symbol in Smalltalk"
regex A regular expression.
let entity = /&#x?[\da-f]{1,8};/;
url A link to another page or resource.
body {
	background: url(foo.png);
[Prism]( is a cool syntax highlighter.
operator A symbol that represents an action or process, whether it's a mathematical operation, logical operation, and so on.
x += (y + 4 >> -z === w) ? b ** c : ~a;
variable The name of a variable. This token is intended to be used sparingly. It's generally used on special variables (e.g. Less or Bash), not general variables from imperative and procedural programming languages (e.g. C, JavaScript, Python).
@nice-blue: #5B83AD;
@light-blue: lighten(@nice-blue, 20%);
echo $STRING
echo ${args[0]} ${args[1]} ${args[2]}
constant The name of a constant.
const PI = 3.14159;
const THING: u32 = 0xABAD1DEA;
fprintf(stdout, "hello world\n");
property An attribute/characteristic or object/map key.
body {
	color: red;
	line-height: normal;
	"data": { "labels": ["foo", "bar"], },
	"error": null,
	"status": "Ok"
punctuation Punctuation such as brackets, parentheses, commas, and more.
def median(pool):
	copy = sorted(pool)
	size = len(copy)
	if size % 2 == 1:
		return copy[(size - 1) / 2]
		return (copy[size/2 - 1] + copy[size/2]) / 2
important Anything that is important and needs special highlighting.
body {
	color: red !important;
# This is a heading. Headings are important.
comment Code comments.
<!-- Here's a comment -->
	/* Here's another comment */
// Here's yet another comment
Markup languages
tag A markup tag (e.g. HTML and XML tags).
<p>Hello World!</p>
attr-name, attr-value Kind of like a property of a markup tag and its value/argument respectively.
<p id="greeting">Hello World!</p>
<video width="1280" height="720" allowfullscreen controls>
	<source src="hello_world.mp4" type="video/mp4" />
namespace Used to provide uniquely named elements and attributes in XML documents. Outside of markup languages, it is used to tokenize the package/namespace part of identifiers.
<html:p foo:bar="baz" foo:weee></html:p>
class Foo extends {
	java.util.List<> bar( bat) {
		throw new java.lang.UnsupportedOperationException();
use std::sync::Arc;
prolog The first part of an XML document.
<?xml version="1.0" encoding="utf-8"?>
doctype Document type declaration, specific to markup languages.
<!DOCTYPE html>
cdata Character data, specific to markup languages.
  CDATA is <not> magical.
entity Code used to display reserved characters in markup languages.
&amp; &#x2665; &#160; &#x152;
Document-markup languages
bold Bolded text. Mostly found in document-markup languages.
**I am bolded text!**
italic Italicised text. Mostly found in document-markup languages.
*I am italicised text!*
atrule Literally @ rules (statements) in stylesheets.
@font-family {
	font-family: Questrial;
	src: url(questrial.otf);
@media screen and (min-width: 768px) { /* ... */ }
selector Code that identifies or picks something out of a group to operate on, such as the names of HTML elements in stylesheets.
section h1,
#features li strong,
header h2,
footer p { /* ... */ }
inserted, deleted Added or modified line and deleted line respectively, mainly for diffs. In general, also the idea of something being increased and decreased/removed respectively.
--- bar.yml	2014-12-16 11:43:41 +0800
+++ /Users/foo/Desktop/bar.yml	2014-12-31 11:28:08 +0800
@@ -4,5 +4,5 @@
	sources: "src/*.cpp"
	headers: "src/*.h"
-    qt: core
+    qt: core gui
public_headers: "src/*.h"

Embedded languages

In addition to the standard tokens above, Prism also has a token for languages that are embedded in another language, such as CSS in HTML, JS in HTML, Bash in Shell-session, and CSS in JS, allowing Prism's themes to highlight the tokens in the embedded languages more accurately. All embedded languages are wrapped in their own special token, which includes a CSS class language-xxxx corresponding to the embedded language.

Open your browser's developer tools and check out the example below to see it in action!

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8" />
	<title>I can haz embedded CSS and JS</title>
		@media print {
			p { color: red !important; }
	<h1>I can haz embedded CSS and JS</h1>
	if (true) {


Non-standard tokens

Sometimes, a language might use a particular name to refer to certain pieces of code, but which is not one of Prism's standard token names, such as function-defintion. Since function-definition is not a standard token, you might want to alias it with a standard token such as function, which is semantically similar, and will ensure that Prism's themes will highlight it. Here's an example:

fn main() {
	println!("Hello World");