Merge pull request #445 from Golmote/prism-examples New examples page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
diff --git a/components.js b/components.js
index 67b3da3..6eb2372 100644
--- a/components.js
+++ b/components.js
@@ -34,7 +34,8 @@ var components = {
"languages": {
"meta": {
"path": "components/prism-{id}",
- "noCSS": true
+ "noCSS": true,
+ "examplesPath": "examples/prism-{id}"
},
"markup": {
"title": "Markup",
diff --git a/examples.html b/examples.html
index 7872235..82b37a7 100644
--- a/examples.html
+++ b/examples.html
@@ -7,6 +7,35 @@
<title>Examples ▲ Prism</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="themes/prism.css" data-noprefix />
+<style>
+#languages {
+ column-count: 4;
+}
+ #languages > h1 {
+ margin-top: 0;
+ column-span: all;
+ }
+ #languages label {
+ display: block;
+ padding: .2em;
+ }
+ #languages .unavailable {
+ color: #aaa;
+ }
+ #languages input {
+ margin-right: .7em;
+ }
+
+#examples > section {
+ display: block;
+ margin: auto;
+ max-width: 900px;
+}
+ #examples h3 {
+ margin: 1em 0 0.3em;
+ }
+
+</style>
<script src="prefixfree.min.js"></script>
<script>var _gaq = [['_setAccount', 'UA-33746269-1'], ['_trackPageview']];</script>
@@ -55,397 +84,20 @@
<code class="language-none"><p>hi!</p></code>
</section>
-<section class="language-markup">
- <h1>Markup</h1>
-
- <h2>Empty tag</h2>
- <pre><code><p></p></code></pre>
-
- <h2>Tag that spans multiple lines</h2>
- <pre><code><p
->hello!
-</p></code></pre>
-
- <h2>Name-attribute pair</h2>
- <pre><code><p></p></code></pre>
-
- <h2>Name-attribute pair without quotes</h2>
- <pre><code><p class=prism></p></code></pre>
-
- <h2>Attribute without value</h2>
- <pre><code><p data-foo></p></code></pre>
- <pre><code><p data-foo ></p></code></pre>
-
- <h2>Namespaces</h2>
- <pre><code><html:p foo:bar="baz" foo:weee></html:p></code></pre>
-
- <h2>XML prolog</h2>
- <pre><code><?xml version="1.0" encoding="utf-8"?>
-<svg></svg></code></pre>
-
- <h2>DOCTYPE</h2>
- <pre><code><!DOCTYPE html>
-<html></html></code></pre>
-
- <h2>CDATA section</h2>
- <pre><code><ns1:description><![CDATA[
- CDATA is <not> magical.
-]]></ns1:description></code></pre>
-
- <h2>Comment</h2>
- <pre><code><!-- I'm a comment -->
-And i'm not</code></pre>
-
- <h2>Entities</h2>
- <pre><code>&amp; &#x2665; &#160; &#x152;</code></pre>
-
- <h2>Embedded JS and CSS</h2>
- <pre><code><!DOCTYPE html>
-<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></code></pre>
-
- <h2>Invalid HTML</h2>
- <pre><code><l </ul></code></pre>
-
- <h2>Multi-line attribute values</h2>
- <pre><code><p title="foo
-bar
-baz"></code></pre>
-</section>
-
-<section class="language-css">
- <h1>CSS</h1>
-
- <h2>Empty rule</h2>
- <pre><code>*{} * {} p {}</code></pre>
- <pre><code>ul,
-ol {}</code></pre>
-
- <h2>Simple rule</h2>
- <pre><code>p { color: red; }</code></pre>
-
- <h2>Important rule</h2>
- <pre><code>p { color: red !important; }</code></pre>
-
- <h2>@ rule</h2>
- <pre><code>@media screen and (min-width: 100px) {}</code></pre>
-
- <h2>LESS variable</h2>
- <pre><code>@main-color: red;
-.foo {
- background: @main-color;
-}</code></pre>
-
- <h2>Comment</h2>
- <pre><code>/* Simple comment here */</code></pre>
-
- <h2>String</h2>
- <pre><code>content: 'foo';</code></pre>
-
- <h2>URL</h2>
- <pre><code>content: url(foo.png);</code></pre>
-</section>
-
-<section class="language-javascript">
- <h1>JavaScript</h1>
-
- <h2>Variable assignment</h2>
- <pre><code>var foo = "bar", baz = 5;</code></pre>
-
- <h2>Operators</h2>
- <pre><code>(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7</code></pre>
-
- <h2>Indented code</h2>
- <pre><code>if (true) {
- while (true) {
- doSomething();
- }
-}</code></pre>
-
- <h2>Regex with slashes</h2>
- <pre><code>var foo = /([^/])\/(\\?.|\[.+?])+?\/[gim]{0,3}/g;</code></pre>
-
- <h2>Regex that ends with double slash</h2>
- <pre><code>var bar = /\/\*[\w\W]*?\*\//g;</code></pre>
-
- <h2>Single line comments & regexes</h2>
- <pre><code>// http://lea.verou.me
-var comment = /\/\*[\w\W]*?\*\//g;</code></pre>
-
- <h2>Link in comment</h2>
- <pre><code>// http://lea.verou.me
-/* http://lea.verou.me */</code></pre>
-
- <h2>Nested strings</h2>
- <pre><code>var foo = "foo", bar = "He \"said\" 'hi'!"</code></pre>
-
- <h2>Strings inside comments</h2>
- <pre><code>// "foo"</code></pre>
- <pre><code>/* "foo" */</code></pre>
-
- <h2>Strings with slashes</h2>
- <pre><code>env.content + '</' + env.tag + '>'</code></pre>
- <pre><code>var foo = "/" + "/";</code></pre>
- <pre><code>var foo = "http://prismjs.com"; // Strings are strings and comments are comments ;)</code></pre>
-
- <h2>Regex inside single line comment</h2>
- <pre><code>// hey, /this doesn’t fail!/ :D</code></pre>
-
- <h2>Two or more division operators on the same line</h2>
- <pre><code>var foo = 5 / 6 / 7;</code></pre>
-
- <h2>A division operator on the same line as a regex</h2>
- <pre><code>var foo = 1/2, bar = /a/g;</code></pre>
- <pre><code>var foo = /a/, bar = 3/4;</code></pre>
-</section>
-
-<section class="language-java">
- <h1>Java</h1>
-
- <h2>Java Language Keywords</h2>
- <pre><code>
-abstract continue for new switch
-assert default goto package synchronized
-boolean do if private this
-break double implements protected throw
-byte else import public throws
-case enum instanceof return transient
-catch extends int short try
-char final interface static void
-class finally long strictfp volatile
-const float native super while
-
- </code></pre>
-
- <h2>Operators</h2>
- <pre><code>// postfix
-expr++ expr--
-// unary
-++expr --expr +expr -expr ~ !
-// multiplicative
-* / %
-// additive
-+ -
-// shift
-<< >> >>>
-// relational
-< > <= >= instanceof
-// equality
-== !=
-// bitwise AND
-&
-// bitwise exclusive OR
-^
-// bitwise inclusive OR
-|
-// logical AND
-&&
-// logical OR
-||
-// ternary
-? :
-// assignment
-= += -= *= /= %= &= ^= |= <<= >>= >>>=
- </code></pre>
-
- <h2>Simple class example</h2>
-
- <pre><code>package com.prismjs;
-
-import java.io.*;
-
-@SuppressWarnings("unchecked")
-public class PrismJS {
-
- public static Integer test = 0;
-
- /**
- * Javadoc style comment
- *
- * @param args
- */
- public static void main(String[] args) {
- // Let's create some variables
- int numArgs = args.length;
- Integer a = 0x1;
- String test = "" + "Hello" + " \"World\"!";
- double dvalue = 1.23;
- int optest = 0;
- optest += 321 - 45 * 1247 / 425 % 123;
-
- /*
- * Multiline comment
- */
- for (int i = 0; i < numArgs; i++) {
- // Simple line comment
- System.out.println("Arg value= " + args[i]);
- }
-
- do {
- System.out.println("Do while ok!");
- } while (false);
- }
-}
-
- </code></pre>
- <p>As you can notice String keyword is not highlighted because it's not a Java language keyword (cf. <a href="http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html">Java Language Keywords</a>). The main reason is that String is not a primitive type such as <em>int</em> but a class type like <em>Integer</em>.</p>
-</section>
-
-<section class="language-coffeescript">
- <h1>Coffeescript</h1>
-
- <h2>Variable assignment</h2>
- <pre><code>foo = "bar"</code></pre>
-
- <h2>Operators</h2>
- <pre><code>(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7</code></pre>
-
- <h2>Indented code</h2>
- <pre><code>if true
- while true
- doSomething()
- </code></pre>
-
- <h2>Regex with slashes</h2>
- <pre><code>var foo = /([^/])\/(\\?.|\[.+?])+?\/[gim]{0,3}/g;</code></pre>
-
- <h2>Single line comments</h2>
- <pre><code># This is a comment</code></pre>
-
- <h2>Link in comment</h2>
- <pre><code># http://lea.verou.me
-###
-Block Comment
-### </code></pre>
-
- <h2>Nested strings</h2>
- <pre><code>var foo = "foo", bar = "He \"said\" 'hi'!"</code></pre>
-
- <h2>String inside comment</h2>
- <pre><code># "foo"</code></pre>
-
-
- <h2>Strings with slashes</h2>
- <pre><code>env.content + '</' + env.tag + '>'</code></pre>
- <pre><code>var foo = "/" + "/";</code></pre>
-
- <h2>Two or more division operators on the same line</h2>
- <pre><code>foo = 5 / 6 / 7;</code></pre>
-
- <h2>A division operator on the same line as a regex</h2>
- <pre><code>foo = 1/2, bar = /a/g;</code></pre>
- <pre><code>foo = /a/, bar = 3/4;</code></pre>
-
- <h2>A function</h2>
- <pre><code>
-_buttonClick: (a, b) ->
- @hide()
- </code></pre>
-
- <h2>An Object</h2>
- <pre><code>
-code = {
- css: "Cascading Style Sheets"
- cs: "CoffeeScript"
-}
- </code></pre>
-
- <h2>Class Definition</h2>
- <pre><code>
-class CoffeeScript extends Prism.Javascript
- </code></pre>
-</section>
-
-<section class="language-http">
- <h1>HTTP</h1>
-
- <h2>Request Examples</h2>
- <p>A simple HTTP GET request:</p>
- <pre><code>GET https://example.tld/v1/:serviceName/users.json?sort=:sortMethod HTTP/1.1</code></pre>
- <p>Here is an HTTP POST with a body:</p>
- <pre><code>POST https://example.tld/v1/:serviceName/users.json HTTP/1.1
-Content-Type: application/json
-
-{
- "names": ["test1", "test2"],
- "version": 1.0
-}
-</code></pre>
-
- <h2>Response Examples</h2>
- <p>JSON response body:</p>
- <pre><code>HTTP/1.1 200 OK
-Content-Type: application/json
-X-Response-Time: 6ms
-
-{
- "users": [
- {
- "name": "John",
- "points": 24
- },
- {
- "name": "Lea",
- "points": 15
- }
- ]
-}
-</code></pre>
- <p>XML response body:</p>
- <pre><code>HTTP/1.1 200 OK
-Content-Type: application/xml
-X-Response-Time: 10ms
-
-<root>
- <status code="0">
- Successful
- </status>
-</root>
-</code></pre>
-</section>
-
-<section id="failures" class="language-javascript">
- <h1>Known failures (JavaScript)</h1>
- <p>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.
- </p>
-
- <h2>Comment-like substrings</h2>
- <pre><code>"foo /* bar */ baz"; "foo // bar";</code></pre>
-
- <h2>Two quotes of the same type (i.e. both single or both double) inside a regex</h2>
- <pre><code>foo = /"foo"/;</code></pre>
+<section>
+ <h1>Per language examples</h1>
+ <div id="languages"></div>
</section>
+<section id="examples"></section>
<footer data-src="templates/footer.html" data-type="text/html"></footer>
<script src="prism.js"></script>
-<script src="components/prism-java.js"></script>
-<script src="components/prism-http.js"></script>
-<script src="components/prism-coffeescript.js"></script>
<script src="utopia.js"></script>
<script src="components.js"></script>
<script src="code.js"></script>
+<script src="vendor/promise.js"></script>
+<script src="examples.js"></script>
</body>
</html>
diff --git a/examples.js b/examples.js
new file mode 100644
index 0000000..d178525
--- /dev/null
+++ b/examples.js
@@ -0,0 +1,182 @@
+/**
+ * Manage examples
+ */
+
+(function() {
+
+var examples = {};
+
+// TODO change treeURL before commit !
+var treeURL = 'https://api.github.com/repos/Golmote/prism/git/trees/prism-examples?recursive=1';
+var treePromise = new Promise(function (resolve) {
+ $u.xhr({
+ url: treeURL,
+ callback: function (xhr) {
+ if (xhr.status < 400) {
+ resolve(JSON.parse(xhr.responseText).tree);
+ }
+ }
+ });
+});
+
+var languages = components.languages;
+
+for (var id in languages) {
+ if (id === 'meta') {
+ continue;
+ }
+
+ (function (id) {
+ var language = languages[id];
+ var checked = false;
+
+ if (language.option === 'default') {
+ checked = true;
+ }
+
+ language.enabled = checked;
+ language.path = languages.meta.path.replace(/\{id}/g, id) + '.js';
+ language.examplesPath = languages.meta.examplesPath.replace(/\{id}/g, id) + '.html';
+
+ fileExists(language.examplesPath).then(function (exists) {
+ $u.element.create('label', {
+ attributes: {
+ 'data-id': id,
+ 'title': !exists ? 'No examples are available for this language.' : ''
+ },
+ className: !exists ? 'unavailable' : '',
+ contents: [
+ {
+ tag: 'input',
+ properties: {
+ type: 'checkbox',
+ name: 'language',
+ value: id,
+ checked: checked && exists,
+ disabled: !exists,
+ onclick: function () {
+ $$('input[name="' + this.name + '"]').forEach(function (input) {
+ languages[input.value].enabled = input.checked;
+ });
+
+ update(id);
+ }
+ }
+ },
+ language.title
+ ],
+ inside: '#languages'
+ });
+ examples[id] = $u.element.create('section', {
+ 'id': 'language-' + id,
+ 'className': 'language-' + id,
+ inside: '#examples'
+ });
+ if (checked) {
+ update(id);
+ }
+ });
+ }(id));
+}
+
+function fileExists(filepath) {
+ return treePromise.then(function (tree) {
+ for (var i = 0, l = tree.length; i < l; i++) {
+ if (tree[i].path === filepath) {
+ return true;
+ }
+ }
+ return false;
+ });
+}
+
+function getFileContents(filepath) {
+ return new Promise(function (resolve, reject) {
+ $u.xhr({
+ url: filepath,
+ callback: function (xhr) {
+ if (xhr.status < 400 && xhr.responseText) {
+ resolve(xhr.responseText);
+ } else {
+ reject();
+ }
+ }
+ });
+ });
+}
+
+function update(id) {
+ var language = languages[id];
+ if (language.enabled) {
+ if (!language.examplesPromise) {
+ language.examplesPromise = getFileContents(language.examplesPath);
+ }
+ language.examplesPromise.then(function (contents) {
+ examples[id].innerHTML = contents;
+
+ loadLanguage(id).then(function () {
+ var elements = examples[id].querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
+
+ for (var i=0, element; element = elements[i++];) {
+ Prism.highlightElement(element);
+ }
+ });
+ });
+ } else {
+ examples[id].innerHTML = '';
+ }
+}
+
+/**
+ * Loads a language, including all dependencies
+ *
+ * @param {string} lang the language to load
+ * @type {Promise} the promise which resolves as soon as everything is loaded
+ */
+function loadLanguage (lang)
+{
+ // at first we need to fetch all dependencies for the main language
+ // Note: we need to do this, even if the main language already is loaded (just to be sure..)
+ //
+ // We load an array of all dependencies and call recursively this function on each entry
+ //
+ // dependencies is now an (possibly empty) array of loading-promises
+ var dependencies = getDependenciesOfLanguage(lang).map(loadLanguage);
+
+ // We create a promise, which will resolve, as soon as all dependencies are loaded.
+ // They need to be fully loaded because the main language may extend them.
+ return Promise.all(dependencies)
+ .then(function () {
+
+ // If the main language itself isn't already loaded, load it now
+ // and return the newly created promise (we chain the promises).
+ // If the language is already loaded, just do nothing - the next .then()
+ // will immediately be called
+ if (!Prism.languages[lang]) {
+ return new Promise(function (resolve) {
+ $u.script('components/prism-' + lang + '.js', resolve);
+ });
+ }
+ });
+}
+
+
+/**
+ * Returns all dependencies (as identifiers) of a specific language
+ *
+ * @param {string} lang
+ * @returns {Array.<string>} the list of dependencies. Empty if the language has none.
+ */
+function getDependenciesOfLanguage (lang)
+{
+ if (!components.languages[lang] || !components.languages[lang].require)
+ {
+ return [];
+ }
+
+ return ($u.type(components.languages[lang].require) === "Array")
+ ? components.languages[lang].require
+ : [components.languages[lang].require];
+}
+
+}());
\ No newline at end of file
diff --git a/examples/prism-css.html b/examples/prism-css.html
new file mode 100644
index 0000000..73cda7e
--- /dev/null
+++ b/examples/prism-css.html
@@ -0,0 +1,31 @@
+<h1>CSS</h1>
+<p>To use this language, use the class "language-css".</p>
+
+<h2>Empty rule</h2>
+<pre><code>*{} * {} p {}</code></pre>
+<pre><code>ul,
+ol {}</code></pre>
+
+<h2>Simple rule</h2>
+<pre><code>p { color: red; }</code></pre>
+
+<h2>Important rule</h2>
+<pre><code>p { color: red !important; }</code></pre>
+
+<h2>@ rule</h2>
+<pre><code>@media screen and (min-width: 100px) {}</code></pre>
+
+<h2>LESS variable</h2>
+<pre><code>@main-color: red;
+.foo {
+ background: @main-color;
+}</code></pre>
+
+<h2>Comment</h2>
+<pre><code>/* Simple comment here */</code></pre>
+
+<h2>String</h2>
+<pre><code>content: 'foo';</code></pre>
+
+<h2>URL</h2>
+<pre><code>content: url(foo.png);</code></pre>
\ No newline at end of file
diff --git a/examples/prism-javascript.html b/examples/prism-javascript.html
new file mode 100644
index 0000000..2ecd0a4
--- /dev/null
+++ b/examples/prism-javascript.html
@@ -0,0 +1,64 @@
+<h1>JavaScript</h1>
+<p>To use this language, use the class "language-javascript".</p>
+
+<h2>Variable assignment</h2>
+<pre><code>var foo = "bar", baz = 5;</code></pre>
+
+<h2>Operators</h2>
+<pre><code>(1 + 2 * 3)/4 >= 3 && 4 < 5 || 6 > 7</code></pre>
+
+<h2>Indented code</h2>
+<pre><code>if (true) {
+ while (true) {
+ doSomething();
+ }
+}</code></pre>
+
+<h2>Regex with slashes</h2>
+<pre><code>var foo = /([^/])\/(\\?.|\[.+?])+?\/[gim]{0,3}/g;</code></pre>
+
+<h2>Regex that ends with double slash</h2>
+<pre><code>var bar = /\/\*[\w\W]*?\*\//g;</code></pre>
+
+<h2>Single line comments & regexes</h2>
+<pre><code>// http://lea.verou.me
+var comment = /\/\*[\w\W]*?\*\//g;</code></pre>
+
+<h2>Link in comment</h2>
+<pre><code>// http://lea.verou.me
+/* http://lea.verou.me */</code></pre>
+
+<h2>Nested strings</h2>
+<pre><code>var foo = "foo", bar = "He \"said\" 'hi'!"</code></pre>
+
+<h2>Strings inside comments</h2>
+<pre><code>// "foo"
+/* "foo" */</code></pre>
+
+<h2>Strings with slashes</h2>
+<pre><code>env.content + '</' + env.tag + '>'
+var foo = "/" + "/";
+var foo = "http://prismjs.com"; // Strings are strings and comments are comments ;)</code></pre>
+
+<h2>Regex inside single line comment</h2>
+<pre><code>// hey, /this doesn’t fail!/ :D</code></pre>
+
+<h2>Two or more division operators on the same line</h2>
+<pre><code>var foo = 5 / 6 / 7;</code></pre>
+
+<h2>A division operator on the same line as a regex</h2>
+<pre><code>var foo = 1/2, bar = /a/g;
+var foo = /a/, bar = 3/4;</code></pre>
+
+<h2>Known failures</h2>
+<p>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.
+</p>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"foo /* bar */ baz"; "foo // bar";</code></pre>
+
+<h3>Two quotes of the same type (i.e. both single or both double) inside a regex</h3>
+<pre><code>foo = /"foo"/;</code></pre>
\ No newline at end of file
diff --git a/examples/prism-markup.html b/examples/prism-markup.html
new file mode 100644
index 0000000..d3a333c
--- /dev/null
+++ b/examples/prism-markup.html
@@ -0,0 +1,75 @@
+<h1>Markup</h1>
+<p>To use this language, use the class "language-markup".</p>
+
+<h2>Empty tag</h2>
+<pre><code><p></p></code></pre>
+
+<h2>Tag that spans multiple lines</h2>
+<pre><code><p
+>hello!
+</p></code></pre>
+
+<h2>Name-attribute pair</h2>
+<pre><code><p></p></code></pre>
+
+<h2>Name-attribute pair without quotes</h2>
+<pre><code><p class=prism></p></code></pre>
+
+<h2>Attribute without value</h2>
+<pre><code><p data-foo></p>
+<p data-foo ></p>
+</code></pre>
+
+<h2>Namespaces</h2>
+<pre><code><html:p foo:bar="baz" foo:weee></html:p></code></pre>
+
+<h2>XML prolog</h2>
+<pre><code><?xml version="1.0" encoding="utf-8"?>
+<svg></svg></code></pre>
+
+<h2>DOCTYPE</h2>
+<pre><code><!DOCTYPE html>
+<html></html></code></pre>
+
+<h2>CDATA section</h2>
+<pre><code><ns1:description><![CDATA[
+ CDATA is <not> magical.
+]]></ns1:description></code></pre>
+
+<h2>Comment</h2>
+<pre><code><!-- I'm a comment -->
+And i'm not</code></pre>
+
+<h2>Entities</h2>
+<pre><code>&amp; &#x2665; &#160; &#x152;</code></pre>
+
+<h2>Embedded JS and CSS</h2>
+<pre><code><!DOCTYPE html>
+<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></code></pre>
+
+<h2>Invalid HTML</h2>
+<pre><code><l </ul></code></pre>
+
+<h2>Multi-line attribute values</h2>
+<pre><code><p title="foo
+bar
+baz"></code></pre>
\ No newline at end of file
diff --git a/examples/prism-rust.html b/examples/prism-rust.html
new file mode 100644
index 0000000..bd4d2c0
--- /dev/null
+++ b/examples/prism-rust.html
@@ -0,0 +1,79 @@
+<h1>Rust</h1>
+<p>To use this language, use the class "language-rust".</p>
+
+<h2>Comments</h2>
+<pre><code>// Single line comment
+/// Doc comments
+/* Multiline
+comment */</code></pre>
+
+<h2>Strings</h2>
+<pre><code>'C'; '\''; '\n'; '\u7FFF'; // Characters
+"foo \"bar\" baz"; // String
+r##"foo #"bar"# baz"##; // Raw string with # pairs
+b'C'; b'\''; b'\n'; // Bytes
+b"foo \"bar\" baz"; // Byte string
+br##"foo #"bar"# baz"##; // Raw byte string with # pairs
+</code></pre>
+
+<h2>Numbers</h2>
+<pre><code>123i; // type int
+123u; // type uint
+123_u; // type uint
+0xff_u8; // type u8
+0o70_i16; // type i16
+0b1111_1111_1001_0000_i32; // type i32
+
+123.0f64; // type f64
+0.1f64; // type f64
+0.1f32; // type f32
+12E+99_f64; // type f64
+</code></pre>
+
+<h2>Booleans</h2>
+<pre><code>true; false;</code></pre>
+
+<h2>Functions and macros</h2>
+<pre><code>println!("x is {}", x);
+fn next_two(x: int) -> (int, int) { (x + 1i, x + 2i) }
+next_two(5i);
+vec![1i, 2, 3];
+</code></pre>
+
+<h2>Attributes</h2>
+<pre><code>
+#![warn(unstable)]
+#[test]
+fn a_test() {
+ // ...
+}</code></pre>
+
+<h2>Closure parameters and bitwise OR</h2>
+<pre><code>
+let x = a | b;
+let y = c || d;
+let add_one = |x: int| -> int { 1i + x };
+let printer = || { println!("x is: {}", x); };
+</code></pre>
+
+<h2>Known failures</h2>
+<p>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.
+</p>
+
+<h3>Nested block comments</h3>
+<pre><code>/* Nested block
+ /* comments
+ are */
+not supported */</code></pre>
+
+<h3>Comment-like substrings</h3>
+<pre><code>"foo /* bar */ baz"; "foo // bar";</code></pre>
+
+<h3>Attribute containing string</h3>
+<pre><code>#[cfg(unix, target_word_size = "32")]</code></pre>
+
+<h3>Delimiters of parameters for closures that don't use braces</h3>
+<pre><code>|x| x + 1i;</code></pre>
\ No newline at end of file