Examples

HTML

To use this language, use the class language-markup.

Embedded JS and CSS


<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>I can haz embedded CSS and JS</title>
  <style>
    @media print {
      p { color: red !important; }
    }
  </style>
</head>
<body>
  <h1>I can haz embedded CSS and JS</h1>
  <script>
    if (true) {
      console.log('foo');
    }
  </script>
</body>
</html>

Namespaces


<html:p foo:bar="baz" foo:weee></html:p>

CSS

To use this language, use the class language-css.

Empty rule


ul,
ol {}

Simple rule


p { color: red; }

Important rule


p { color: red !important; }

@ rule


@media screen and (min-width: 100px) {}

LESS variable


@main-color: red;

.foo {
	background: @main-color;
}

Comment


/* Simple comment here */

String


content: 'foo';

URL


content: url(foo.png);

Sass

To use this language, use the class language-scss.

At-rules


@import "foo.scss";

@media (min-width: 600px) {}
.seriousError {
    @extend .error;
}

@for $i from 1 through 3 {}

Compass URLs


@font-face {
	font-family: "opensans";
	src: font-url("opensans.ttf");
}

Variables


$width: 5em;

#main {
    width: $width;
}

Interpolations


p.#{$name} {
    #{$attr}-color: blue;
}

Javascript

To use this language, use the class language-javascript.

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


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

Nested strings


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

A division operator on the same line as a regex


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

PHP

To use this language, use the class language-php.

Variables


$some_var = 5;
$otherVar = "Some text";
$null = null;
$false = false;

Functions


$json = json_encode($my_object);
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);

Constants


define('MAXSIZE', 42);
echo MAXSIZE;
json_decode($json, false, 512, JSON_BIGINT_AS_STRING);

PHP 5.3+ support


namespace my\name;
$c = new \my\name\MyClass;
$arr = [1,2,3];
trait ezcReflectionReturnInfo {
    function getReturnType() { /*1*/ }
    function getReturnDescription() { /*2*/ }
}
function gen_one_to_three() {
    for ($i = 1; $i <= 3; $i++) {
        // Note that $i is preserved between yields.
        yield $i;
    }
}

PHP embedded in HTML


<div class="<?php echo $a ? 'foo' : 'bar'; ?>">
<?php if($var < 42) {
    echo "Something";
} else {
    echo "Something else";
} ?>
</div>

Markdown

To use this language, use the class language-markdown.

Titles


Title 1
==

Title 2
-------

# Title 1
## Title 2
### Title 3
#### Title 4
##### Title 5
###### Title 6

Bold and italic


*Italic*
**Bold on
multiple lines**
*Italic on
multiple lines too*
__It also works with underscores__
_It also works with underscores_

__An empty line

is not allowed__

Links


[Prism](http://www.prismjs.com)
[Prism](http://www.prismjs.com "Prism")

[prism link]: http://www.prismjs.com (Prism)
[Prism] [prism link]

Lists and quotes


* This is
* an unordered list

1. This is an
2. ordered list

* *List item in italic*
* **List item in bold**
* [List item as a link](http://example.com "This is an example")

> This is a quotation
>> With another quotation inside
> _italic here_, __bold there__
> And a [link](http://example.com)

Code


Inline code between backticks `

Paragraph

` some_code(); /* Indented with four spaces */ some_code(); /* Indented with a tab */

YAML

To use this language, use the class language-yaml.

Full example


%YAML 1.2
--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
  given  : Chris
  family : Dumars
  address:
    lines: |
      458 Walkman Dr.
      Suite #292
    city    : Royal Oak
    state   : MI
    postal  : 48046
ship-to:
  <<: *id001
  product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy