From 4660a68028f9d66b70f7537ef5fe4334c70dea54 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 13 Nov 2013 22:41:32 -0500 Subject: [PATCH 001/153] Remove window.onload support --- js/rainbow.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/rainbow.js b/js/rainbow.js index 81904534..347be2d1 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -788,7 +788,6 @@ window['Rainbow'] = (function() { if (document.addEventListener) { return document.addEventListener('DOMContentLoaded', Rainbow.color, false); } - window.attachEvent('onload', Rainbow.color); }) (); // When using Google closure compiler in advanced mode some methods From 62ded69df32bdce1e2fb76d45e8f3541887ff5ab Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 13 Nov 2013 22:42:46 -0500 Subject: [PATCH 002/153] Remove _attr helper in favor of getAttribute --- js/rainbow.js | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/js/rainbow.js b/js/rainbow.js index 347be2d1..6b44d2d1 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -88,31 +88,6 @@ window['Rainbow'] = (function() { */ onHighlight; - /** - * cross browser get attribute for an element - * - * @see http://stackoverflow.com/questions/3755227/cross-browser-javascript-getattribute-method - * - * @param {Node} el - * @param {string} attr attribute you are trying to get - * @returns {string|number} - */ - function _attr(el, attr, attrs, i) { - var result = (el.getAttribute && el.getAttribute(attr)) || 0; - - if (!result) { - attrs = el.attributes; - - for (i = 0; i < attrs.length; ++i) { - if (attrs[i].nodeName === attr) { - return attrs[i].nodeValue; - } - } - } - - return result; - } - /** * adds a class to a given code block * @@ -147,7 +122,7 @@ window['Rainbow'] = (function() { // this means if for example you have:
         // with a bunch of  blocks inside then you do not have
         // to specify the language for each block
-        var language = _attr(block, 'data-language') || _attr(block.parentNode, 'data-language');
+        var language = block.getAttribute('data-language') || block.parentNode.getAttribute('data-language');
 
         // this adds support for specifying language via a css class
         // you can use the Google Code Prettify style: 

From eb0a5ab73fd07b18dfebc60f81c069f9a28dbce5 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:21:44 -0400
Subject: [PATCH 003/153] Switch some variables to camelCase

---
 js/rainbow.js | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 6b44d2d1..557bef3a 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -32,21 +32,21 @@ window['Rainbow'] = (function() {
          *
          * @type {Object}
          */
-        replacement_positions = {},
+        replacementPositions = {},
 
         /**
          * an array of the language patterns specified for each language
          *
          * @type {Object}
          */
-        language_patterns = {},
+        languagePatterns = {},
 
         /**
          * an array of languages and whether they should bypass the default patterns
          *
          * @type {Object}
          */
-        bypass_defaults = {},
+        bypassDefaults = {},
 
         /**
          * processing level
@@ -71,17 +71,17 @@ window['Rainbow'] = (function() {
          *
          * @type {number}
          */
-        match_counter = 0,
+        matchCounter = 0,
 
         /**
          * @type {number}
          */
-        replacement_counter = 0,
+        replacementCounter = 0,
 
         /**
          * @type {null|string}
          */
-        global_class,
+        globalClass,
 
         /**
          * @type {null|Function}
@@ -195,17 +195,17 @@ window['Rainbow'] = (function() {
      * @returns {boolean}
      */
     function _matchIsInsideOtherMatch(start, end) {
-        for (var key in replacement_positions[CURRENT_LEVEL]) {
+        for (var key in replacementPositions[CURRENT_LEVEL]) {
             key = parseInt(key, 10);
 
             // if this block completely overlaps with another block
             // then we should remove the other block and return false
-            if (_hasCompleteOverlap(key, replacement_positions[CURRENT_LEVEL][key], start, end)) {
-                delete replacement_positions[CURRENT_LEVEL][key];
+            if (_hasCompleteOverlap(key, replacementPositions[CURRENT_LEVEL][key], start, end)) {
+                delete replacementPositions[CURRENT_LEVEL][key];
                 delete replacements[CURRENT_LEVEL][key];
             }
 
-            if (_intersects(key, replacement_positions[CURRENT_LEVEL][key], start, end)) {
+            if (_intersects(key, replacementPositions[CURRENT_LEVEL][key], start, end)) {
                 return true;
             }
         }
@@ -221,7 +221,7 @@ window['Rainbow'] = (function() {
      * @returns {string}
      */
     function _wrapCodeInSpan(name, code) {
-        return '' + code + '';
+        return '' + code + '';
     }
 
     /**
@@ -270,7 +270,7 @@ window['Rainbow'] = (function() {
             return callback();
         }
 
-        ++match_counter;
+        ++matchCounter;
 
         // treat match 0 the same way as name
         if (!pattern['name'] && typeof pattern['matches'][0] == 'string') {
@@ -292,7 +292,7 @@ window['Rainbow'] = (function() {
 
                 // every 100 items we process let's call set timeout
                 // to let the ui breathe a little
-                return match_counter % 100 > 0 ? nextCall() : setTimeout(nextCall, 0);
+                return matchCounter % 100 > 0 ? nextCall() : setTimeout(nextCall, 0);
             };
 
         // if this is not a child match and it falls inside of another
@@ -318,7 +318,7 @@ window['Rainbow'] = (function() {
                 // store what needs to be replaced with what at this position
                 if (!replacements[CURRENT_LEVEL]) {
                     replacements[CURRENT_LEVEL] = {};
-                    replacement_positions[CURRENT_LEVEL] = {};
+                    replacementPositions[CURRENT_LEVEL] = {};
                 }
 
                 replacements[CURRENT_LEVEL][start_pos] = {
@@ -328,7 +328,7 @@ window['Rainbow'] = (function() {
 
                 // store the range of this match so we can use it for comparisons
                 // with other matches later
-                replacement_positions[CURRENT_LEVEL][start_pos] = end_pos;
+                replacementPositions[CURRENT_LEVEL][start_pos] = end_pos;
 
                 // process the next match
                 processNext();
@@ -438,7 +438,7 @@ window['Rainbow'] = (function() {
      */
     function _bypassDefaultPatterns(language)
     {
-        return bypass_defaults[language];
+        return bypassDefaults[language];
     }
 
     /**
@@ -448,8 +448,8 @@ window['Rainbow'] = (function() {
      * @returns {Array}
      */
     function _getPatternsForLanguage(language) {
-        var patterns = language_patterns[language] || [],
-            default_patterns = language_patterns[DEFAULT_LANGUAGE] || [];
+        var patterns = languagePatterns[language] || [],
+            default_patterns = languagePatterns[DEFAULT_LANGUAGE] || [];
 
         return _bypassDefaultPatterns(language) ? patterns : patterns.concat(default_patterns);
     }
@@ -522,7 +522,7 @@ window['Rainbow'] = (function() {
                 // when we are done processing replacements
                 // we are done at this level so we can go back down
                 delete replacements[CURRENT_LEVEL];
-                delete replacement_positions[CURRENT_LEVEL];
+                delete replacementPositions[CURRENT_LEVEL];
                 --CURRENT_LEVEL;
                 callback(code);
             });
@@ -551,7 +551,7 @@ window['Rainbow'] = (function() {
          */
         function _processReplacement(code, positions, i, onComplete) {
             if (i < positions.length) {
-                ++replacement_counter;
+                ++replacementCounter;
                 var pos = positions[i],
                     replacement = replacements[CURRENT_LEVEL][pos];
                 code = _replaceAtPosition(pos, replacement['replace'], replacement['with'], code);
@@ -562,7 +562,7 @@ window['Rainbow'] = (function() {
                 };
 
                 // use a timeout every 250 to not freeze up the UI
-                return replacement_counter % 250 > 0 ? next() : setTimeout(next, 0);
+                return replacementCounter % 250 > 0 ? next() : setTimeout(next, 0);
             }
 
             onComplete(code);
@@ -607,7 +607,7 @@ window['Rainbow'] = (function() {
 
                     // reset the replacement arrays
                     replacements = {};
-                    replacement_positions = {};
+                    replacementPositions = {};
 
                     // if you have a listener attached tell it that this block is now highlighted
                     if (onHighlight) {
@@ -708,8 +708,8 @@ window['Rainbow'] = (function() {
                 language = DEFAULT_LANGUAGE;
             }
 
-            bypass_defaults[language] = bypass;
-            language_patterns[language] = patterns.concat(language_patterns[language] || []);
+            bypassDefaults[language] = bypass;
+            languagePatterns[language] = patterns.concat(languagePatterns[language] || []);
         },
 
         /**
@@ -727,7 +727,7 @@ window['Rainbow'] = (function() {
          * @param {string} class_name
          */
         addClass: function(class_name) {
-            global_class = class_name;
+            globalClass = class_name;
         },
 
         /**

From f784a8dc49b5466bd441f66f3959b295965580af Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:23:17 -0400
Subject: [PATCH 004/153] Switch more variables to camelCase

---
 js/rainbow.js | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 557bef3a..7cddb208 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -92,22 +92,22 @@ window['Rainbow'] = (function() {
      * adds a class to a given code block
      *
      * @param {Element} el
-     * @param {string} class_name   class name to add
+     * @param {string} className   class name to add
      * @returns void
      */
-    function _addClass(el, class_name) {
-        el.className += el.className ? ' ' + class_name : class_name;
+    function _addClass(el, className) {
+        el.className += el.className ? ' ' + className : className;
     }
 
     /**
      * checks if a block has a given class
      *
      * @param {Element} el
-     * @param {string} class_name   class name to check for
+     * @param {string} className   class name to check for
      * @returns {boolean}
      */
-    function _hasClass(el, class_name) {
-        return (' ' + el.className + ' ').indexOf(' ' + class_name + ' ') > -1;
+    function _hasClass(el, className) {
+        return (' ' + el.className + ' ').indexOf(' ' + className + ' ') > -1;
     }
 
     /**
@@ -230,14 +230,14 @@ window['Rainbow'] = (function() {
      * @see http://stackoverflow.com/questions/1985594/how-to-find-index-of-groups-in-match
      *
      * @param {Object} match
-     * @param {number} group_number
+     * @param {number} groupNumber
      * @returns {number}
      */
-    function _indexOfGroup(match, group_number) {
+    function _indexOfGroup(match, groupNumber) {
         var index = 0,
             i;
 
-        for (i = 1; i < group_number; ++i) {
+        for (i = 1; i < groupNumber; ++i) {
             if (match[i]) {
                 index += match[i].length;
             }
@@ -279,8 +279,8 @@ window['Rainbow'] = (function() {
         }
 
         var replacement = match[0],
-            start_pos = match.index,
-            end_pos = match[0].length + start_pos,
+            startPos = match.index,
+            endPos = match[0].length + startPos,
 
             /**
              * callback to process the next match of this pattern
@@ -297,7 +297,7 @@ window['Rainbow'] = (function() {
 
         // if this is not a child match and it falls inside of another
         // match that already happened we should skip it and continue processing
-        if (_matchIsInsideOtherMatch(start_pos, end_pos)) {
+        if (_matchIsInsideOtherMatch(startPos, endPos)) {
             return processNext();
         }
 
@@ -313,7 +313,7 @@ window['Rainbow'] = (function() {
                     replacement = _wrapCodeInSpan(pattern['name'], replacement);
                 }
 
-                // console.log('LEVEL', CURRENT_LEVEL, 'replace', match[0], 'with', replacement, 'at position', start_pos, 'to', end_pos);
+                // console.log('LEVEL', CURRENT_LEVEL, 'replace', match[0], 'with', replacement, 'at position', startPos, 'to', endPos);
 
                 // store what needs to be replaced with what at this position
                 if (!replacements[CURRENT_LEVEL]) {
@@ -321,14 +321,14 @@ window['Rainbow'] = (function() {
                     replacementPositions[CURRENT_LEVEL] = {};
                 }
 
-                replacements[CURRENT_LEVEL][start_pos] = {
+                replacements[CURRENT_LEVEL][startPos] = {
                     'replace': match[0],
                     'with': replacement
                 };
 
                 // store the range of this match so we can use it for comparisons
                 // with other matches later
-                replacementPositions[CURRENT_LEVEL][start_pos] = end_pos;
+                replacementPositions[CURRENT_LEVEL][startPos] = endPos;
 
                 // process the next match
                 processNext();

From 2c715aef2b132f835bd87d5354efb68796800dd8 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:26:16 -0400
Subject: [PATCH 005/153] Switch more variables to camelCase

---
 js/rainbow.js | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 7cddb208..57bf92b7 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -341,31 +341,31 @@ window['Rainbow'] = (function() {
             // we run through them backwards because the match position of earlier
             // matches will not change depending on what gets replaced in later
             // matches
-            group_keys = keys(pattern['matches']),
+            groupKeys = keys(pattern['matches']),
 
             /**
              * callback for processing a sub group
              *
              * @param {number} i
-             * @param {Array} group_keys
+             * @param {Array} groupKeys
              * @param {Function} callback
              */
-            processGroup = function(i, group_keys, callback) {
-                if (i >= group_keys.length) {
+            processGroup = function(i, groupKeys, callback) {
+                if (i >= groupKeys.length) {
                     return callback(replacement);
                 }
 
                 var processNextGroup = function() {
-                        processGroup(++i, group_keys, callback);
+                        processGroup(++i, groupKeys, callback);
                     },
-                    block = match[group_keys[i]];
+                    block = match[groupKeys[i]];
 
                 // if there is no match here then move on
                 if (!block) {
                     return processNextGroup();
                 }
 
-                var group = pattern['matches'][group_keys[i]],
+                var group = pattern['matches'][groupKeys[i]],
                     language = group['language'],
 
                     /**
@@ -403,7 +403,7 @@ window['Rainbow'] = (function() {
                      * @param {string|null} match_name
                      */
                     _replaceAndContinue = function(block, replace_block, match_name) {
-                        replacement = _replaceAtPosition(_indexOfGroup(match, group_keys[i]), block, match_name ? _wrapCodeInSpan(match_name, replace_block) : replace_block, replacement);
+                        replacement = _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, match_name ? _wrapCodeInSpan(match_name, replace_block) : replace_block, replacement);
                         processNextGroup();
                     };
 
@@ -427,7 +427,7 @@ window['Rainbow'] = (function() {
                 });
             };
 
-        processGroup(0, group_keys, onMatchSuccess);
+        processGroup(0, groupKeys, onMatchSuccess);
     }
 
     /**

From 8c7266015a0bccaab646ac42d52759e30c176def Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:32:13 -0400
Subject: [PATCH 006/153] Switch everything else to camelCase

---
 js/rainbow.js | 68 +++++++++++++++++++++++++--------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 57bf92b7..c14e3851 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -391,7 +391,7 @@ window['Rainbow'] = (function() {
                      * we treat the 'matches' part as the pattern and keep
                      * the name around to wrap it with later
                      */
-                    process_group = group['name'] && group['matches'] ? group['matches'] : group,
+                    groupToProcess = group['name'] && group['matches'] ? group['matches'] : group,
 
                     /**
                      * takes the code block matched at this group, replaces it
@@ -399,11 +399,11 @@ window['Rainbow'] = (function() {
                      * a span with a name
                      *
                      * @param {string} block
-                     * @param {string} replace_block
-                     * @param {string|null} match_name
+                     * @param {string} replaceBlock
+                     * @param {string|null} matchName
                      */
-                    _replaceAndContinue = function(block, replace_block, match_name) {
-                        replacement = _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, match_name ? _wrapCodeInSpan(match_name, replace_block) : replace_block, replacement);
+                    _replaceAndContinue = function(block, replaceBlock, matchName) {
+                        replacement = _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
                         processNextGroup();
                     };
 
@@ -422,7 +422,7 @@ window['Rainbow'] = (function() {
 
                 // the process group can be a single pattern or an array of patterns
                 // _processCodeWithPatterns always expects an array so we convert it here
-                _processCodeWithPatterns(block, process_group.length ? process_group : [process_group], function(code) {
+                _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess], function(code) {
                     _replaceAndContinue(block, code, group['matches'] ? group['name'] : 0);
                 });
             };
@@ -449,9 +449,9 @@ window['Rainbow'] = (function() {
      */
     function _getPatternsForLanguage(language) {
         var patterns = languagePatterns[language] || [],
-            default_patterns = languagePatterns[DEFAULT_LANGUAGE] || [];
+            defaultPatterns = languagePatterns[DEFAULT_LANGUAGE] || [];
 
-        return _bypassDefaultPatterns(language) ? patterns : patterns.concat(default_patterns);
+        return _bypassDefaultPatterns(language) ? patterns : patterns.concat(defaultPatterns);
     }
 
     /**
@@ -459,13 +459,13 @@ window['Rainbow'] = (function() {
      *
      * @param {number} position         the position where the replacement should happen
      * @param {string} replace          the text we want to replace
-     * @param {string} replace_with     the text we want to replace it with
+     * @param {string} replaceWith      the text we want to replace it with
      * @param {string} code             the code we are doing the replacing in
      * @returns {string}
      */
-    function _replaceAtPosition(position, replace, replace_with, code) {
-        var sub_string = code.substr(position);
-        return code.substr(0, position) + sub_string.replace(replace, replace_with);
+    function _replaceAtPosition(position, replace, replaceWith, code) {
+        var subString = code.substr(position);
+        return code.substr(0, position) + subString.replace(replace, replaceWith);
     }
 
    /**
@@ -568,8 +568,8 @@ window['Rainbow'] = (function() {
             onComplete(code);
         }
 
-        var string_positions = keys(replacements[CURRENT_LEVEL]);
-        _processReplacement(code, string_positions, 0, onComplete);
+        var stringPositions = keys(replacements[CURRENT_LEVEL]);
+        _processReplacement(code, stringPositions, 0, onComplete);
     }
 
     /**
@@ -588,13 +588,13 @@ window['Rainbow'] = (function() {
     /**
      * highlight an individual code block
      *
-     * @param {Array} code_blocks
+     * @param {Array} codeBlocks
      * @param {number} i
      * @returns void
      */
-    function _highlightCodeBlock(code_blocks, i, onComplete) {
-        if (i < code_blocks.length) {
-            var block = code_blocks[i],
+    function _highlightCodeBlock(codeBlocks, i, onComplete) {
+        if (i < codeBlocks.length) {
+            var block = codeBlocks[i],
                 language = _getLanguageForBlock(block);
 
             if (!_hasClass(block, 'rainbow') && language) {
@@ -616,11 +616,11 @@ window['Rainbow'] = (function() {
 
                     // process the next block
                     setTimeout(function() {
-                        _highlightCodeBlock(code_blocks, ++i, onComplete);
+                        _highlightCodeBlock(codeBlocks, ++i, onComplete);
                     }, 0);
                 });
             }
-            return _highlightCodeBlock(code_blocks, ++i, onComplete);
+            return _highlightCodeBlock(codeBlocks, ++i, onComplete);
         }
 
         if (onComplete) {
@@ -643,15 +643,15 @@ window['Rainbow'] = (function() {
         //
         node = node && typeof node.getElementsByTagName == 'function' ? node : document;
 
-        var pre_blocks = node.getElementsByTagName('pre'),
-            code_blocks = node.getElementsByTagName('code'),
+        var preBlocks = node.getElementsByTagName('pre'),
+            codeBlocks = node.getElementsByTagName('code'),
             i,
-            final_pre_blocks = [],
-            final_code_blocks = [];
+            finalPreBlocks = [],
+            finalCodeBlocks = [];
 
         // first loop through all pre blocks to find which ones to highlight
         // also strip whitespace
-        for (i = 0; i < pre_blocks.length; ++i) {
+        for (i = 0; i < preBlocks.length; ++i) {
 
             // strip whitespace around code tags when they are inside of a pre tag
             // this makes the themes look better because you can't accidentally
@@ -668,23 +668,23 @@ window['Rainbow'] = (function() {
             //
             // if you want to preserve whitespace you can use a pre tag on its own
             // without a code tag inside of it
-            if (pre_blocks[i].getElementsByTagName('code').length) {
-                pre_blocks[i].innerHTML = pre_blocks[i].innerHTML.replace(/^\s+/, '').replace(/\s+$/, '');
+            if (preBlocks[i].getElementsByTagName('code').length) {
+                preBlocks[i].innerHTML = preBlocks[i].innerHTML.replace(/^\s+/, '').replace(/\s+$/, '');
                 continue;
             }
 
             // if the pre block has no code blocks then we are going to want to
             // process it directly
-            final_pre_blocks.push(pre_blocks[i]);
+            finalPreBlocks.push(preBlocks[i]);
         }
 
         // @see http://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript
         // we are going to process all  blocks
-        for (i = 0; i < code_blocks.length; ++i) {
-            final_code_blocks.push(code_blocks[i]);
+        for (i = 0; i < codeBlocks.length; ++i) {
+            finalCodeBlocks.push(codeBlocks[i]);
         }
 
-        _highlightCodeBlock(final_code_blocks.concat(final_pre_blocks), 0, onComplete);
+        _highlightCodeBlock(finalCodeBlocks.concat(finalPreBlocks), 0, onComplete);
     }
 
     /**
@@ -724,10 +724,10 @@ window['Rainbow'] = (function() {
         /**
          * method to set a global class that will be applied to all spans
          *
-         * @param {string} class_name
+         * @param {string} className
          */
-        addClass: function(class_name) {
-            globalClass = class_name;
+        addClass: function(className) {
+            globalClass = className;
         },
 
         /**

From a36d991c9c096cfa1fab1e82ef1f62f25a41b46a Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:32:39 -0400
Subject: [PATCH 007/153] Update year to 2014

---
 js/rainbow.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index c14e3851..cbc1eae1 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -1,5 +1,5 @@
 /**
- * Copyright 2013 Craig Campbell
+ * Copyright 2014 Craig Campbell
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

From 9075bca45b52875b42d9ddb49f795a9baf5e17a8 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:38:59 -0400
Subject: [PATCH 008/153] Clean up the way we reveal public methods

---
 js/rainbow.js | 124 +++++++++++++++++++++++++-------------------------
 1 file changed, 62 insertions(+), 62 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index cbc1eae1..b7ead248 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -18,7 +18,7 @@
  * @preserve @version 1.2
  * @url rainbowco.de
  */
-window['Rainbow'] = (function() {
+(function() {
 
     /**
      * array of replacements to process at the end
@@ -688,72 +688,78 @@ window['Rainbow'] = (function() {
     }
 
     /**
-     * public methods
+     * extends the language pattern matches
+     *
+     * @param {*} language     name of language
+     * @param {*} patterns      array of patterns to add on
+     * @param {boolean|null} bypass      if true this will bypass the default language patterns
      */
-    return {
+    function _extend(language, patterns, bypass) {
 
-        /**
-         * extends the language pattern matches
-         *
-         * @param {*} language     name of language
-         * @param {*} patterns      array of patterns to add on
-         * @param {boolean|null} bypass      if true this will bypass the default language patterns
-         */
-        extend: function(language, patterns, bypass) {
+        // if there is only one argument then we assume that we want to
+        // extend the default language rules
+        if (arguments.length == 1) {
+            patterns = language;
+            language = DEFAULT_LANGUAGE;
+        }
 
-            // if there is only one argument then we assume that we want to
-            // extend the default language rules
-            if (arguments.length == 1) {
-                patterns = language;
-                language = DEFAULT_LANGUAGE;
-            }
+        bypassDefaults[language] = bypass;
+        languagePatterns[language] = patterns.concat(languagePatterns[language] || []);
+    }
 
-            bypassDefaults[language] = bypass;
-            languagePatterns[language] = patterns.concat(languagePatterns[language] || []);
-        },
+    /**
+     * call back to let you do stuff in your app after a piece of code has been highlighted
+     *
+     * @param {Function} callback
+     */
+    function _onHighlight(callback) {
+        onHighlight = callback;
+    }
 
-        /**
-         * call back to let you do stuff in your app after a piece of code has been highlighted
-         *
-         * @param {Function} callback
-         */
-        onHighlight: function(callback) {
-            onHighlight = callback;
-        },
+    /**
+     * method to set a global class that will be applied to all spans
+     *
+     * @param {string} className
+     */
+    function _addClass(className) {
+        globalClass = className;
+    }
 
-        /**
-         * method to set a global class that will be applied to all spans
-         *
-         * @param {string} className
-         */
-        addClass: function(className) {
-            globalClass = className;
-        },
+    /**
+     * starts the magic rainbow
+     *
+     * @returns void
+     */
+    function _color() {
 
-        /**
-         * starts the magic rainbow
-         *
-         * @returns void
-         */
-        color: function() {
+        // if you want to straight up highlight a string you can pass the string of code,
+        // the language, and a callback function
+        if (typeof arguments[0] == 'string') {
+            return _highlightBlockForLanguage(arguments[0], arguments[1], arguments[2]);
+        }
 
-            // if you want to straight up highlight a string you can pass the string of code,
-            // the language, and a callback function
-            if (typeof arguments[0] == 'string') {
-                return _highlightBlockForLanguage(arguments[0], arguments[1], arguments[2]);
-            }
+        // if you pass a callback function then we rerun the color function
+        // on all the code and call the callback function on complete
+        if (typeof arguments[0] == 'function') {
+            return _highlight(0, arguments[0]);
+        }
 
-            // if you pass a callback function then we rerun the color function
-            // on all the code and call the callback function on complete
-            if (typeof arguments[0] == 'function') {
-                return _highlight(0, arguments[0]);
-            }
+        // otherwise we use whatever node you passed in with an optional
+        // callback function as the second parameter
+        _highlight(arguments[0], arguments[1]);
+    }
 
-            // otherwise we use whatever node you passed in with an optional
-            // callback function as the second parameter
-            _highlight(arguments[0], arguments[1]);
-        }
+    /**
+     * public methods
+     */
+    var _rainbow = {
+        extend: _extend,
+        onHighlight: _onHighlight,
+        addClass: _addClass,
+        color: _color
     };
+
+    window.Rainbow = _rainbow;
 }) ();
 
 /**
@@ -764,9 +770,3 @@ window['Rainbow'] = (function() {
         return document.addEventListener('DOMContentLoaded', Rainbow.color, false);
     }
 }) ();
-
-// When using Google closure compiler in advanced mode some methods
-// get renamed.  This keeps a public reference to these methods so they can
-// still be referenced from outside this library.
-Rainbow["onHighlight"] = Rainbow.onHighlight;
-Rainbow["addClass"] = Rainbow.addClass;

From 7753b054cdfd228acafd3924c21a89b502c0ed29 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:41:20 -0400
Subject: [PATCH 009/153] Rename duplicate class

---
 js/rainbow.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index b7ead248..e2625be7 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -721,7 +721,7 @@
      *
      * @param {string} className
      */
-    function _addClass(className) {
+    function _addGlobalClass(className) {
         globalClass = className;
     }
 
@@ -755,7 +755,7 @@
     var _rainbow = {
         extend: _extend,
         onHighlight: _onHighlight,
-        addClass: _addClass,
+        addClass: _addGlobalClass,
         color: _color
     };
 

From 8d10f73ed2e16b95ea98210bb5072e4e4fa9c38c Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Mon, 29 Sep 2014 22:41:47 -0400
Subject: [PATCH 010/153] Remove unused variables

---
 js/rainbow.js | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index e2625be7..55dedb02 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -475,9 +475,7 @@
      * @return {Array}
      */
     function keys(object) {
-        var locations = [],
-            replacement,
-            pos;
+        var locations = [];
 
         for(var location in object) {
             if (object.hasOwnProperty(location)) {

From 82be25c0bf1168be3cf3b055ad2fc777cd7be6f5 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Thu, 2 Oct 2014 02:11:30 -0400
Subject: [PATCH 011/153] Refactor all the things

This is currently in a somewhat broken state, but a lot of things have
been refactored.

- Change library itself to be synchronous
- Use web workers to do the heavy lifting in a separate thread
- Use a Raindrop object to encapsulate variables that should not be
used globally
- Use element.classList instead of _addClass and _hasClass
---
 js/rainbow.js | 711 +++++++++++++++++++++++---------------------------
 1 file changed, 325 insertions(+), 386 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 55dedb02..45e5a285 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -18,28 +18,13 @@
  * @preserve @version 1.2
  * @url rainbowco.de
  */
-(function() {
-
+(function(global) {
     /**
-     * array of replacements to process at the end
+     * an array of the language patterns specified for each language
      *
      * @type {Object}
      */
-    var replacements = {},
-
-        /**
-         * an array of start and end positions of blocks to be replaced
-         *
-         * @type {Object}
-         */
-        replacementPositions = {},
-
-        /**
-         * an array of the language patterns specified for each language
-         *
-         * @type {Object}
-         */
-        languagePatterns = {},
+    var languagePatterns = {},
 
         /**
          * an array of languages and whether they should bypass the default patterns
@@ -48,16 +33,6 @@
          */
         bypassDefaults = {},
 
-        /**
-         * processing level
-         *
-         * replacements are stored at this level so if there is a sub block of code
-         * (for example php inside of html) it runs at a different level
-         *
-         * @type {number}
-         */
-        CURRENT_LEVEL = 0,
-
         /**
          * constant used to refer to the default language
          *
@@ -65,14 +40,6 @@
          */
         DEFAULT_LANGUAGE = 0,
 
-        /**
-         * used as counters so we can selectively call setTimeout
-         * after processing a certain number of matches/replacements
-         *
-         * @type {number}
-         */
-        matchCounter = 0,
-
         /**
          * @type {number}
          */
@@ -86,29 +53,17 @@
         /**
          * @type {null|Function}
          */
-        onHighlight;
+        onHighlight,
 
-    /**
-     * adds a class to a given code block
-     *
-     * @param {Element} el
-     * @param {string} className   class name to add
-     * @returns void
-     */
-    function _addClass(el, className) {
-        el.className += el.className ? ' ' + className : className;
-    }
+        /**
+         * @type Worker
+         */
+        worker,
 
-    /**
-     * checks if a block has a given class
-     *
-     * @param {Element} el
-     * @param {string} className   class name to check for
-     * @returns {boolean}
-     */
-    function _hasClass(el, className) {
-        return (' ' + el.className + ' ').indexOf(' ' + className + ' ') > -1;
-    }
+        /**
+         * @type {Boolean}
+         */
+        isWorker = typeof document === 'undefined';
 
     /**
      * gets the language for this block of code
@@ -136,7 +91,7 @@
             }
         }
 
-        return language;
+        return language.toLowerCase();
     }
 
     /**
@@ -186,33 +141,6 @@
         return start2 <= start1 && end2 >= end1;
     }
 
-    /**
-     * determines if the match passed in falls inside of an existing match
-     * this prevents a regex pattern from matching inside of a bigger pattern
-     *
-     * @param {number} start - start position of new match
-     * @param {number} end - end position of new match
-     * @returns {boolean}
-     */
-    function _matchIsInsideOtherMatch(start, end) {
-        for (var key in replacementPositions[CURRENT_LEVEL]) {
-            key = parseInt(key, 10);
-
-            // if this block completely overlaps with another block
-            // then we should remove the other block and return false
-            if (_hasCompleteOverlap(key, replacementPositions[CURRENT_LEVEL][key], start, end)) {
-                delete replacementPositions[CURRENT_LEVEL][key];
-                delete replacements[CURRENT_LEVEL][key];
-            }
-
-            if (_intersects(key, replacementPositions[CURRENT_LEVEL][key], start, end)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     /**
      * takes a string of code and wraps it in a span tag based on the name
      *
@@ -246,190 +174,6 @@
         return index;
     }
 
-    /**
-     * matches a regex pattern against a block of code
-     * finds all matches that should be processed and stores the positions
-     * of where they should be replaced within the string
-     *
-     * this is where pretty much all the work is done but it should not
-     * be called directly
-     *
-     * @param {RegExp} pattern
-     * @param {string} code
-     * @returns void
-     */
-    function _processPattern(regex, pattern, code, callback)
-    {
-        if (typeof regex === "undefined" || regex === null) {
-            //console.warn("undefined regular expression")
-            return callback();
-        }
-        var match = regex.exec(code);
-
-        if (!match) {
-            return callback();
-        }
-
-        ++matchCounter;
-
-        // treat match 0 the same way as name
-        if (!pattern['name'] && typeof pattern['matches'][0] == 'string') {
-            pattern['name'] = pattern['matches'][0];
-            delete pattern['matches'][0];
-        }
-
-        var replacement = match[0],
-            startPos = match.index,
-            endPos = match[0].length + startPos,
-
-            /**
-             * callback to process the next match of this pattern
-             */
-            processNext = function() {
-                var nextCall = function() {
-                    _processPattern(regex, pattern, code, callback);
-                };
-
-                // every 100 items we process let's call set timeout
-                // to let the ui breathe a little
-                return matchCounter % 100 > 0 ? nextCall() : setTimeout(nextCall, 0);
-            };
-
-        // if this is not a child match and it falls inside of another
-        // match that already happened we should skip it and continue processing
-        if (_matchIsInsideOtherMatch(startPos, endPos)) {
-            return processNext();
-        }
-
-        /**
-         * callback for when a match was successfully processed
-         *
-         * @param {string} replacement
-         * @returns void
-         */
-        var onMatchSuccess = function(replacement) {
-                // if this match has a name then wrap it in a span tag
-                if (pattern['name']) {
-                    replacement = _wrapCodeInSpan(pattern['name'], replacement);
-                }
-
-                // console.log('LEVEL', CURRENT_LEVEL, 'replace', match[0], 'with', replacement, 'at position', startPos, 'to', endPos);
-
-                // store what needs to be replaced with what at this position
-                if (!replacements[CURRENT_LEVEL]) {
-                    replacements[CURRENT_LEVEL] = {};
-                    replacementPositions[CURRENT_LEVEL] = {};
-                }
-
-                replacements[CURRENT_LEVEL][startPos] = {
-                    'replace': match[0],
-                    'with': replacement
-                };
-
-                // store the range of this match so we can use it for comparisons
-                // with other matches later
-                replacementPositions[CURRENT_LEVEL][startPos] = endPos;
-
-                // process the next match
-                processNext();
-            },
-
-            // if this pattern has sub matches for different groups in the regex
-            // then we should process them one at a time by rerunning them through
-            // this function to generate the new replacement
-            //
-            // we run through them backwards because the match position of earlier
-            // matches will not change depending on what gets replaced in later
-            // matches
-            groupKeys = keys(pattern['matches']),
-
-            /**
-             * callback for processing a sub group
-             *
-             * @param {number} i
-             * @param {Array} groupKeys
-             * @param {Function} callback
-             */
-            processGroup = function(i, groupKeys, callback) {
-                if (i >= groupKeys.length) {
-                    return callback(replacement);
-                }
-
-                var processNextGroup = function() {
-                        processGroup(++i, groupKeys, callback);
-                    },
-                    block = match[groupKeys[i]];
-
-                // if there is no match here then move on
-                if (!block) {
-                    return processNextGroup();
-                }
-
-                var group = pattern['matches'][groupKeys[i]],
-                    language = group['language'],
-
-                    /**
-                     * process group is what group we should use to actually process
-                     * this match group
-                     *
-                     * for example if the subgroup pattern looks like this
-                     * 2: {
-                     *     'name': 'keyword',
-                     *     'pattern': /true/g
-                     * }
-                     *
-                     * then we use that as is, but if it looks like this
-                     *
-                     * 2: {
-                     *     'name': 'keyword',
-                     *     'matches': {
-                     *          'name': 'special',
-                     *          'pattern': /whatever/g
-                     *      }
-                     * }
-                     *
-                     * we treat the 'matches' part as the pattern and keep
-                     * the name around to wrap it with later
-                     */
-                    groupToProcess = group['name'] && group['matches'] ? group['matches'] : group,
-
-                    /**
-                     * takes the code block matched at this group, replaces it
-                     * with the highlighted block, and optionally wraps it with
-                     * a span with a name
-                     *
-                     * @param {string} block
-                     * @param {string} replaceBlock
-                     * @param {string|null} matchName
-                     */
-                    _replaceAndContinue = function(block, replaceBlock, matchName) {
-                        replacement = _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
-                        processNextGroup();
-                    };
-
-                // if this is a sublanguage go and process the block using that language
-                if (language) {
-                    return _highlightBlockForLanguage(block, language, function(code) {
-                        _replaceAndContinue(block, code);
-                    });
-                }
-
-                // if this is a string then this match is directly mapped to selector
-                // so all we have to do is wrap it in a span and continue
-                if (typeof group === 'string') {
-                    return _replaceAndContinue(block, block, group);
-                }
-
-                // the process group can be a single pattern or an array of patterns
-                // _processCodeWithPatterns always expects an array so we convert it here
-                _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess], function(code) {
-                    _replaceAndContinue(block, code, group['matches'] ? group['name'] : 0);
-                });
-            };
-
-        processGroup(0, groupKeys, onMatchSuccess);
-    }
-
     /**
      * should a language bypass the default patterns?
      *
@@ -489,140 +233,324 @@
         });
     }
 
-    /**
-     * processes a block of code using specified patterns
-     *
-     * @param {string} code
-     * @param {Array} patterns
-     * @returns void
-     */
-    function _processCodeWithPatterns(code, patterns, callback)
-    {
-        // we have to increase the level here so that the
-        // replacements will not conflict with each other when
-        // processing sub blocks of code
-        ++CURRENT_LEVEL;
-
-        // patterns are processed one at a time through this function
-        function _workOnPatterns(patterns, i)
-        {
-            // still have patterns to process, keep going
-            if (i < patterns.length) {
-                return _processPattern(patterns[i]['pattern'], patterns[i], code, function() {
-                    _workOnPatterns(patterns, ++i);
-                });
+    function Raindrop() {
+        /**
+         * array of replacements to process at the end
+         *
+         * @type {Object}
+         */
+        var replacements = {};
+
+        /**
+         * an array of start and end positions of blocks to be replaced
+         *
+         * @type {Object}
+         */
+        var replacementPositions = {};
+
+        /**
+         * processing level
+         *
+         * replacements are stored at this level so if there is a sub block of code
+         * (for example php inside of html) it runs at a different level
+         *
+         * @type {number}
+         */
+        var currentLevel = 0;
+
+        /**
+         * determines if the match passed in falls inside of an existing match
+         * this prevents a regex pattern from matching inside of a bigger pattern
+         *
+         * @param {number} start - start position of new match
+         * @param {number} end - end position of new match
+         * @returns {boolean}
+         */
+        function _matchIsInsideOtherMatch(start, end) {
+            for (var key in replacementPositions[currentLevel]) {
+                key = parseInt(key, 10);
+
+                // if this block completely overlaps with another block
+                // then we should remove the other block and return false
+                if (_hasCompleteOverlap(key, replacementPositions[currentLevel][key], start, end)) {
+                    delete replacementPositions[currentLevel][key];
+                    delete replacements[currentLevel][key];
+                }
+
+                if (_intersects(key, replacementPositions[currentLevel][key], start, end)) {
+                    return true;
+                }
             }
 
-            // we are done processing the patterns
-            // process the replacements and update the DOM
-            _processReplacements(code, function(code) {
-
-                // when we are done processing replacements
-                // we are done at this level so we can go back down
-                delete replacements[CURRENT_LEVEL];
-                delete replacementPositions[CURRENT_LEVEL];
-                --CURRENT_LEVEL;
-                callback(code);
-            });
+            return false;
         }
 
-        _workOnPatterns(patterns, 0);
-    }
-
-    /**
-     * process replacements in the string of code to actually update the markup
-     *
-     * @param {string} code         the code to process replacements in
-     * @param {Function} onComplete   what to do when we are done processing
-     * @returns void
-     */
-    function _processReplacements(code, onComplete) {
+        /**
+         * process replacements in the string of code to actually update the markup
+         *
+         * @param {string} code         the code to process replacements in
+         * @returns void
+         */
+        function _processReplacements(code) {
+            var positions = keys(replacements[currentLevel]);
+            for (var i = 0; i < positions.length; i++) {
+                var pos = positions[i];
+                var replacement = replacements[currentLevel][pos];
+                code = _replaceAtPosition(pos, replacement['replace'], replacement['with'], code);
+            }
+            return code;
+        }
 
         /**
-         * processes a single replacement
+         * matches a regex pattern against a block of code
+         * finds all matches that should be processed and stores the positions
+         * of where they should be replaced within the string
+         *
+         * this is where pretty much all the work is done but it should not
+         * be called directly
          *
+         * @param {Object} pattern
          * @param {string} code
-         * @param {Array} positions
-         * @param {number} i
-         * @param {Function} onComplete
          * @returns void
          */
-        function _processReplacement(code, positions, i, onComplete) {
-            if (i < positions.length) {
-                ++replacementCounter;
-                var pos = positions[i],
-                    replacement = replacements[CURRENT_LEVEL][pos];
-                code = _replaceAtPosition(pos, replacement['replace'], replacement['with'], code);
+        function _processPattern(pattern, code, callback) {
+            var regex = pattern.pattern;
+
+            if (typeof regex === 'undefined' || regex === null) {
+                //console.warn("undefined regular expression")
+                return;
+            }
+
+            var match = regex.exec(code);
+            if (!match) {
+                return;
+            }
+
+            // treat match 0 the same way as name
+            if (!pattern['name'] && typeof pattern['matches'][0] == 'string') {
+                pattern['name'] = pattern['matches'][0];
+                delete pattern['matches'][0];
+            }
+
+            var replacement = match[0];
+            var startPos = match.index;
+            var endPos = match[0].length + startPos;
+
+            // if this is not a child match and it falls inside of another
+            // match that already happened we should skip it and continue processing
+            if (_matchIsInsideOtherMatch(startPos, endPos)) {
+                return;
+            }
+
+            /**
+             * callback for when a match was successfully processed
+             *
+             * @param {string} replacement
+             * @returns void
+             */
+            function onMatchSuccess(replacement) {
+                // if this match has a name then wrap it in a span tag
+                if (pattern['name']) {
+                    replacement = _wrapCodeInSpan(pattern['name'], replacement);
+                }
+
+                // console.log('LEVEL', currentLevel, 'replace', match[0], 'with', replacement, 'at position', startPos, 'to', endPos);
+
+                // store what needs to be replaced with what at this position
+                if (!replacements[currentLevel]) {
+                    replacements[currentLevel] = {};
+                    replacementPositions[currentLevel] = {};
+                }
+
+                replacements[currentLevel][startPos] = {
+                    'replace': match[0],
+                    'with': replacement
+                };
+
+                // store the range of this match so we can use it for comparisons
+                // with other matches later
+                replacementPositions[currentLevel][startPos] = endPos;
+            }
+
+            /**
+             * callback for processing a sub group
+             *
+             * @param {number} i
+             * @param {Array} groupKeys
+             * @param {Function} callback
+             */
+            function _processGroup(groupKey) {
+                var block = match[groupKey];
 
-                // process next function
-                var next = function() {
-                    _processReplacement(code, positions, ++i, onComplete);
+                // if there is no match here then move on
+                if (!block) {
+                    return;
+                }
+
+                var group = pattern['matches'][groupKey];
+                var language = group['language'];
+
+                /**
+                 * process group is what group we should use to actually process
+                 * this match group
+                 *
+                 * for example if the subgroup pattern looks like this
+                 * 2: {
+                 *     'name': 'keyword',
+                 *     'pattern': /true/g
+                 * }
+                 *
+                 * then we use that as is, but if it looks like this
+                 *
+                 * 2: {
+                 *     'name': 'keyword',
+                 *     'matches': {
+                 *          'name': 'special',
+                 *          'pattern': /whatever/g
+                 *      }
+                 * }
+                 *
+                 * we treat the 'matches' part as the pattern and keep
+                 * the name around to wrap it with later
+                 */
+                var groupToProcess = group['name'] && group['matches'] ? group['matches'] : group;
+
+                /**
+                 * takes the code block matched at this group, replaces it
+                 * with the highlighted block, and optionally wraps it with
+                 * a span with a name
+                 *
+                 * @param {string} block
+                 * @param {string} replaceBlock
+                 * @param {string|null} matchName
+                 */
+                var _getReplacement = function(block, replaceBlock, matchName) {
+                    return _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
                 };
 
-                // use a timeout every 250 to not freeze up the UI
-                return replacementCounter % 250 > 0 ? next() : setTimeout(next, 0);
+                // if this is a sublanguage go and process the block using that language
+                if (language) {
+                    var code = _highlightBlockForLanguage(block, language);
+                    replacement = _getReplacement(block, code);
+                    onMatchSuccess(replacement);
+                    return;
+                }
+
+                // if this is a string then this match is directly mapped to selector
+                // so all we have to do is wrap it in a span and continue
+                if (typeof group === 'string') {
+                    replacement = _getReplacement(block, block, group);
+                    onMatchSuccess(replacement);
+                    return;
+                }
+
+                    // the process group can be a single pattern or an array of patterns
+                    // _processCodeWithPatterns always expects an array so we convert it here
+                var code = _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess]);
+                replacement = _getReplacement(block, code, group['matches'] ? group['name'] : 0);
+                onMatchSuccess(replacement);
             }
 
-            onComplete(code);
+            // if this pattern has sub matches for different groups in the regex
+            // then we should process them one at a time by rerunning them through
+            // this function to generate the new replacement
+            //
+            // we run through them backwards because the match position of earlier
+            // matches will not change depending on what gets replaced in later
+            // matches
+            var groupKeys = keys(pattern['matches']);
+            for (var i = 0; i < groupKeys.length; i++) {
+                _processGroup(groupKeys[i]);
+            }
         }
 
-        var stringPositions = keys(replacements[CURRENT_LEVEL]);
-        _processReplacement(code, stringPositions, 0, onComplete);
-    }
+        /**
+         * takes a string of code and highlights it according to the language specified
+         *
+         * @param {string} code
+         * @param {string} language
+         * @param {Function} onComplete
+         * @returns void
+         */
+        function _highlightBlockForLanguage(code, language) {
+            var patterns = _getPatternsForLanguage(language);
+            return _processCodeWithPatterns(_htmlEntities(code), patterns);
+        }
 
-    /**
-     * takes a string of code and highlights it according to the language specified
-     *
-     * @param {string} code
-     * @param {string} language
-     * @param {Function} onComplete
-     * @returns void
-     */
-    function _highlightBlockForLanguage(code, language, onComplete) {
-        var patterns = _getPatternsForLanguage(language);
-        _processCodeWithPatterns(_htmlEntities(code), patterns, onComplete);
-    }
+        /**
+         * processes a block of code using specified patterns
+         *
+         * @param {string} code
+         * @param {Array} patterns
+         * @returns void
+         */
+        function _processCodeWithPatterns(code, patterns) {
+            // we have to increase the level here so that the
+            // replacements will not conflict with each other when
+            // processing sub blocks of code
+            ++currentLevel;
+
+            for (var i = 0; i < patterns.length; i++) {
+                _processPattern(patterns[i], code);
+            }
 
-    /**
-     * highlight an individual code block
-     *
-     * @param {Array} codeBlocks
-     * @param {number} i
-     * @returns void
-     */
-    function _highlightCodeBlock(codeBlocks, i, onComplete) {
-        if (i < codeBlocks.length) {
-            var block = codeBlocks[i],
-                language = _getLanguageForBlock(block);
+            // we are done processing the patterns
+            // process the replacements and update the DOM
+            code = _processReplacements(code);
 
-            if (!_hasClass(block, 'rainbow') && language) {
-                language = language.toLowerCase();
+            // when we are done processing replacements
+            // we are done at this level so we can go back down
+            delete replacements[currentLevel];
+            delete replacementPositions[currentLevel];
+            --currentLevel;
 
-                _addClass(block, 'rainbow');
+            return code;
+        }
 
-                return _highlightBlockForLanguage(block.innerHTML, language, function(code) {
-                    block.innerHTML = code;
+        return {
+            refract: _highlightBlockForLanguage
+        };
+    }
 
-                    // reset the replacement arrays
-                    replacements = {};
-                    replacementPositions = {};
+    function _handleMessageFromRainbow(message) {
+        languagePatterns = message.data.languagePatterns;
+        bypassDefaults = message.data.bypassDefaults;
+        var drop = new Raindrop();
+        var result = drop.refract(message.data.code, message.data.lang);
+        postMessage({
+            id: message.data.id,
+            result: result
+        });
+    }
+
+    function _handleResponseFromWorker(message) {
+        var element = document.querySelector('.' + message.data.id);
+        if (element) {
+            element.innerHTML = message.data.result;
+        }
+        console.log(message.data);
+    }
 
-                    // if you have a listener attached tell it that this block is now highlighted
-                    if (onHighlight) {
-                        onHighlight(block, language);
-                    }
+    function _highlightCodeBlocks(codeBlocks, onComplete) {
+        for (var i = 0; i < codeBlocks.length; i++) {
+            var block = codeBlocks[i];
+            var language = _getLanguageForBlock(block);
 
-                    // process the next block
-                    setTimeout(function() {
-                        _highlightCodeBlock(codeBlocks, ++i, onComplete);
-                    }, 0);
-                });
+            if (block.classList.contains('rainbow') || !language) {
+                continue;
             }
-            return _highlightCodeBlock(codeBlocks, ++i, onComplete);
-        }
 
-        if (onComplete) {
-            onComplete();
+            var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
+            var uniqueId = randLetter.toLowerCase() + Date.now();
+            block.classList.add(uniqueId);
+
+            worker.postMessage({
+                id: uniqueId,
+                lang: language,
+                code: block.innerHTML,
+                languagePatterns: languagePatterns,
+                bypassDefaults: bypassDefaults
+            });
         }
     }
 
@@ -682,7 +610,7 @@
             finalCodeBlocks.push(codeBlocks[i]);
         }
 
-        _highlightCodeBlock(finalCodeBlocks.concat(finalPreBlocks), 0, onComplete);
+        _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks), onComplete);
     }
 
     /**
@@ -757,14 +685,25 @@
         color: _color
     };
 
-    window.Rainbow = _rainbow;
-}) ();
+    // @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file
+    if (!isWorker && typeof Worker !== 'undefined') {
+        var id = Date.now();
+        document.write('');
+        var src = document.getElementById('wts' + id).previousSibling.src;
+        worker = new Worker(src);
+        worker.addEventListener('message', _handleResponseFromWorker, false);
+    }
 
-/**
- * adds event listener to start highlighting
- */
-(function() {
-    if (document.addEventListener) {
-        return document.addEventListener('DOMContentLoaded', Rainbow.color, false);
+    global.Rainbow = _rainbow;
+
+    /**
+     * adds event listener to start highlighting
+     */
+    if (!isWorker && document.addEventListener) {
+        return document.addEventListener('DOMContentLoaded', _rainbow.color, false);
+    }
+
+    if (isWorker) {
+        self.addEventListener('message', _handleMessageFromRainbow);
     }
-}) ();
+}) (this);

From 7167bd03b6b6141173d0f35cf1a6c12e3edbf2b9 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Thu, 2 Oct 2014 23:56:05 -0400
Subject: [PATCH 012/153] Get things pretty much working

---
 js/rainbow.js | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 45e5a285..88b3432e 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -40,11 +40,6 @@
          */
         DEFAULT_LANGUAGE = 0,
 
-        /**
-         * @type {number}
-         */
-        replacementCounter = 0,
-
         /**
          * @type {null|string}
          */
@@ -313,15 +308,10 @@
          * @param {string} code
          * @returns void
          */
-        function _processPattern(pattern, code, callback) {
+        function _processPattern(pattern, code) {
             var regex = pattern.pattern;
-
-            if (typeof regex === 'undefined' || regex === null) {
-                //console.warn("undefined regular expression")
-                return;
-            }
-
             var match = regex.exec(code);
+
             if (!match) {
                 return;
             }
@@ -339,6 +329,7 @@
             // if this is not a child match and it falls inside of another
             // match that already happened we should skip it and continue processing
             if (_matchIsInsideOtherMatch(startPos, endPos)) {
+                _processPattern(pattern, code);
                 return;
             }
 
@@ -354,7 +345,7 @@
                     replacement = _wrapCodeInSpan(pattern['name'], replacement);
                 }
 
-                // console.log('LEVEL', currentLevel, 'replace', match[0], 'with', replacement, 'at position', startPos, 'to', endPos);
+                // console.log('LEVEL ' + currentLevel + ' replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos);
 
                 // store what needs to be replaced with what at this position
                 if (!replacements[currentLevel]) {
@@ -370,6 +361,8 @@
                 // store the range of this match so we can use it for comparisons
                 // with other matches later
                 replacementPositions[currentLevel][startPos] = endPos;
+
+                _processPattern(pattern, code);
             }
 
             /**
@@ -425,30 +418,30 @@
                  * @param {string|null} matchName
                  */
                 var _getReplacement = function(block, replaceBlock, matchName) {
-                    return _replaceAtPosition(_indexOfGroup(match, groupKeys[i]), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
+                    replacement = _replaceAtPosition(_indexOfGroup(match, groupKey), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
+                    return replacement;
                 };
 
+                var localCode;
+
                 // if this is a sublanguage go and process the block using that language
                 if (language) {
-                    var code = _highlightBlockForLanguage(block, language);
-                    replacement = _getReplacement(block, code);
-                    onMatchSuccess(replacement);
+                    localCode = _highlightBlockForLanguage(block, language);
+                    _getReplacement(block, localCode);
                     return;
                 }
 
                 // if this is a string then this match is directly mapped to selector
                 // so all we have to do is wrap it in a span and continue
                 if (typeof group === 'string') {
-                    replacement = _getReplacement(block, block, group);
-                    onMatchSuccess(replacement);
+                    _getReplacement(block, block, group);
                     return;
                 }
 
-                    // the process group can be a single pattern or an array of patterns
-                    // _processCodeWithPatterns always expects an array so we convert it here
-                var code = _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess]);
-                replacement = _getReplacement(block, code, group['matches'] ? group['name'] : 0);
-                onMatchSuccess(replacement);
+                // the process group can be a single pattern or an array of patterns
+                // _processCodeWithPatterns always expects an array so we convert it here
+                localCode = _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess]);
+                _getReplacement(block, localCode, group['matches'] ? group['name'] : 0);
             }
 
             // if this pattern has sub matches for different groups in the regex
@@ -462,6 +455,8 @@
             for (var i = 0; i < groupKeys.length; i++) {
                 _processGroup(groupKeys[i]);
             }
+
+            onMatchSuccess(replacement);
         }
 
         /**

From 3c5acf53f1af41488cb787e820afe8a20002f066 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 00:08:44 -0400
Subject: [PATCH 013/153] Make all the tests pass

---
 js/rainbow.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 88b3432e..c9d820c3 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -86,7 +86,9 @@
             }
         }
 
-        return language.toLowerCase();
+        if (language) {
+            return language.toLowerCase();
+        }
     }
 
     /**
@@ -310,6 +312,11 @@
          */
         function _processPattern(pattern, code) {
             var regex = pattern.pattern;
+
+            if (!regex) {
+                return;
+            }
+
             var match = regex.exec(code);
 
             if (!match) {
@@ -656,7 +663,11 @@
         // if you want to straight up highlight a string you can pass the string of code,
         // the language, and a callback function
         if (typeof arguments[0] == 'string') {
-            return _highlightBlockForLanguage(arguments[0], arguments[1], arguments[2]);
+            var drop = new Raindrop();
+            var result = drop.refract(arguments[0], arguments[1]);
+            if (arguments[2]) {
+                arguments[2](result);
+            }
         }
 
         // if you pass a callback function then we rerun the color function

From 570da3ecf443e8afb4bc816006f5bd466adf7309 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 00:22:30 -0400
Subject: [PATCH 014/153] Remove console log

---
 js/rainbow.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index c9d820c3..4ec66933 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -530,7 +530,6 @@
         if (element) {
             element.innerHTML = message.data.result;
         }
-        console.log(message.data);
     }
 
     function _highlightCodeBlocks(codeBlocks, onComplete) {

From 9d0b04d8456f84df761434807b947ddf871412d2 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 00:31:31 -0400
Subject: [PATCH 015/153] Simplify support checks

---
 js/rainbow.js | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 4ec66933..edd8b1ba 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -15,7 +15,7 @@
  *
  * Rainbow is a simple code syntax highlighter
  *
- * @preserve @version 1.2
+ * @version 1.2
  * @url rainbowco.de
  */
 (function(global) {
@@ -690,22 +690,20 @@
         color: _color
     };
 
+    var isSupported = !isWorker && typeof Worker !== 'undefined';
+
+    /**
+     * adds event listener to start highlighting
+     */
     // @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file
-    if (!isWorker && typeof Worker !== 'undefined') {
+    if (isSupported) {
         var id = Date.now();
         document.write('');
         var src = document.getElementById('wts' + id).previousSibling.src;
         worker = new Worker(src);
         worker.addEventListener('message', _handleResponseFromWorker, false);
-    }
-
-    global.Rainbow = _rainbow;
-
-    /**
-     * adds event listener to start highlighting
-     */
-    if (!isWorker && document.addEventListener) {
-        return document.addEventListener('DOMContentLoaded', _rainbow.color, false);
+        global.Rainbow = _rainbow;
+        document.addEventListener('DOMContentLoaded', _rainbow.color, false);
     }
 
     if (isWorker) {

From 19a4c6c1eb01cffd7f5c03802d74fcef8c78ed90 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 20:12:50 -0400
Subject: [PATCH 016/153] Make sure onHighlight still works

---
 js/rainbow.js | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index edd8b1ba..748ffabb 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -519,20 +519,26 @@
         bypassDefaults = message.data.bypassDefaults;
         var drop = new Raindrop();
         var result = drop.refract(message.data.code, message.data.lang);
-        postMessage({
+        self.postMessage({
             id: message.data.id,
+            start: message.data.time,
+            lang: message.data.lang,
             result: result
         });
     }
 
     function _handleResponseFromWorker(message) {
+        console.log('_handleResponseFromWorker', performance.now() - message.data.start);
         var element = document.querySelector('.' + message.data.id);
         if (element) {
             element.innerHTML = message.data.result;
+            element.classList.remove(message.data.id);
+            element.classList.add('rainbow');
+            Rainbow.onHighlight(element, message.data.lang);
         }
     }
 
-    function _highlightCodeBlocks(codeBlocks, onComplete) {
+    function _highlightCodeBlocks(codeBlocks) {
         for (var i = 0; i < codeBlocks.length; i++) {
             var block = codeBlocks[i];
             var language = _getLanguageForBlock(block);
@@ -546,6 +552,7 @@
             block.classList.add(uniqueId);
 
             worker.postMessage({
+                time: performance.now(),
                 id: uniqueId,
                 lang: language,
                 code: block.innerHTML,
@@ -685,7 +692,7 @@
      */
     var _rainbow = {
         extend: _extend,
-        onHighlight: _onHighlight,
+        onHighlight: _onHighlight || function() {},
         addClass: _addGlobalClass,
         color: _color
     };

From b456ef90a75b5b1d3432d3f046f2c48ef605c061 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 21:28:36 -0400
Subject: [PATCH 017/153] Clean up documentation

- Use capital letters and full sentences
- Fix jsdoc statements that were incorrect
- Add documentation for things missing it
- Clarify/expand on existing docs
---
 js/rainbow.js | 303 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 185 insertions(+), 118 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 748ffabb..b88cf41f 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -19,63 +19,75 @@
  * @url rainbowco.de
  */
 (function(global) {
+
     /**
-     * an array of the language patterns specified for each language
+     * An array of the language patterns specified for each language
      *
      * @type {Object}
      */
     var languagePatterns = {},
 
         /**
-         * an array of languages and whether they should bypass the default patterns
+         * An array of languages and whether they should bypass the
+         * default patterns
          *
          * @type {Object}
          */
         bypassDefaults = {},
 
         /**
-         * constant used to refer to the default language
+         * Constant used to refer to the default language
          *
          * @type {number}
          */
         DEFAULT_LANGUAGE = 0,
 
         /**
+         * Global class added to each span in the highlighted code
+         *
          * @type {null|string}
          */
         globalClass,
 
         /**
+         * Callback to fire after each block is highlighted
+         *
          * @type {null|Function}
          */
         onHighlight,
 
         /**
+         * Reference to web worker for doing the heavy lifting
+         *
          * @type Worker
          */
         worker,
 
         /**
+         * Flag for if this is the web worker or not
+         *
          * @type {Boolean}
          */
         isWorker = typeof document === 'undefined';
 
     /**
-     * gets the language for this block of code
+     * Browser Only - Gets the language for this block of code
      *
      * @param {Element} block
      * @returns {string|null}
      */
     function _getLanguageForBlock(block) {
 
-        // if this doesn't have a language but the parent does then use that
-        // this means if for example you have: 
+        // If this doesn't have a language but the parent does then use that.
+        //
+        // This means if for example you have: 
         // with a bunch of  blocks inside then you do not have
-        // to specify the language for each block
+        // to specify the language for each block.
         var language = block.getAttribute('data-language') || block.parentNode.getAttribute('data-language');
 
-        // this adds support for specifying language via a css class
-        // you can use the Google Code Prettify style: 
+        // This adds support for specifying language via a CSS class.
+        //
+        // You can use the Google Code Prettify style: 
         // or the HTML5 style: 

         if (!language) {
             var pattern = /\blang(?:uage)?-(\w+)/,
@@ -92,7 +104,7 @@
     }
 
     /**
-     * makes sure html entities are always used for tags
+     * Encodes < and > as html entities
      *
      * @param {string} code
      * @returns {string}
@@ -102,7 +114,7 @@
     }
 
     /**
-     * determines if a new match intersects with an existing one
+     * Determines if a new match intersects with an existing one
      *
      * @param {number} start1    start position of existing match
      * @param {number} end1      end position of existing match
@@ -119,7 +131,7 @@
     }
 
     /**
-     * determines if two different matches have complete overlap with each other
+     * Determines if two different matches have complete overlap with each other
      *
      * @param {number} start1   start position of existing match
      * @param {number} end1     end position of existing match
@@ -129,8 +141,8 @@
      */
     function _hasCompleteOverlap(start1, end1, start2, end2) {
 
-        // if the starting and end positions are exactly the same
-        // then the first one should stay and this one should be ignored
+        // If the starting and end positions are exactly the same
+        // then the first one should stay and this one should be ignored.
         if (start2 == start1 && end2 == end1) {
             return false;
         }
@@ -139,7 +151,7 @@
     }
 
     /**
-     * takes a string of code and wraps it in a span tag based on the name
+     * Takes a string of code and wraps it in a span tag based on the name
      *
      * @param {string} name     name of the pattern (ie keyword.regex)
      * @param {string} code     block of code to wrap
@@ -150,10 +162,9 @@
     }
 
     /**
-     * finds out the position of group match for a regular expression
+     * Finds out the position of group match for a regular expression
      *
      * @see http://stackoverflow.com/questions/1985594/how-to-find-index-of-groups-in-match
-     *
      * @param {Object} match
      * @param {number} groupNumber
      * @returns {number}
@@ -172,10 +183,13 @@
     }
 
     /**
-     * should a language bypass the default patterns?
+     * Determines if a language should bypass the default patterns
+     *
+     * If you create a language and call Rainbow.extend() with `true` as the
+     * third argument it will bypass the defaults.
      *
-     * if you call Rainbow.extend() and pass true as the third argument
-     * it will bypass the defaults
+     * @param {string} language
+     * @returns {boolean}
      */
     function _bypassDefaultPatterns(language)
     {
@@ -183,7 +197,7 @@
     }
 
     /**
-     * returns a list of regex patterns for this language
+     * Returns a list of regex patterns for this language
      *
      * @param {string} language
      * @returns {Array}
@@ -196,9 +210,10 @@
     }
 
     /**
-     * substring replace call to replace part of a string at a certain position
+     * Substring replace call to replace part of a string at a certain position
      *
-     * @param {number} position         the position where the replacement should happen
+     * @param {number} position         the position where the replacement
+     *                                  should happen
      * @param {string} replace          the text we want to replace
      * @param {string} replaceWith      the text we want to replace it with
      * @param {string} code             the code we are doing the replacing in
@@ -210,7 +225,7 @@
     }
 
    /**
-     * sorts an object by index descending
+     * Sorts an objects keys by index descending
      *
      * @param {Object} object
      * @return {Array}
@@ -230,45 +245,55 @@
         });
     }
 
+    /**
+     * Raindrop is a class used to highlight individual blocks of code
+     *
+     * @class
+     */
     function Raindrop() {
+
         /**
-         * array of replacements to process at the end
+         * Object of replacements to process at the end of the processing
          *
          * @type {Object}
          */
         var replacements = {};
 
         /**
-         * an array of start and end positions of blocks to be replaced
+         * Object of start and end positions of blocks to be replaced
          *
          * @type {Object}
          */
         var replacementPositions = {};
 
         /**
-         * processing level
+         * Processing level
          *
-         * replacements are stored at this level so if there is a sub block of code
-         * (for example php inside of html) it runs at a different level
+         * Replacements are stored at this level so if there is a sub block of
+         * code (for example PHP inside of HTML) it runs at a different level.
          *
          * @type {number}
          */
         var currentLevel = 0;
 
         /**
-         * determines if the match passed in falls inside of an existing match
-         * this prevents a regex pattern from matching inside of a bigger pattern
+         * Determines if the match passed in falls inside of an existing match.
+         * This prevents a regex pattern from matching inside of another pattern
+         * that matches a larger amount of code.
+         *
+         * For example this prevents a keyword from matching `function` if there
+         * is already a match for `function (.*)`.
          *
-         * @param {number} start - start position of new match
-         * @param {number} end - end position of new match
+         * @param {number} start    start position of new match
+         * @param {number} end      end position of new match
          * @returns {boolean}
          */
         function _matchIsInsideOtherMatch(start, end) {
             for (var key in replacementPositions[currentLevel]) {
                 key = parseInt(key, 10);
 
-                // if this block completely overlaps with another block
-                // then we should remove the other block and return false
+                // If this block completely overlaps with another block
+                // then we should remove the other block and return `false`.
                 if (_hasCompleteOverlap(key, replacementPositions[currentLevel][key], start, end)) {
                     delete replacementPositions[currentLevel][key];
                     delete replacements[currentLevel][key];
@@ -283,7 +308,8 @@
         }
 
         /**
-         * process replacements in the string of code to actually update the markup
+         * Process replacements in the string of code to actually update
+         * the markup
          *
          * @param {string} code         the code to process replacements in
          * @returns void
@@ -299,12 +325,12 @@
         }
 
         /**
-         * matches a regex pattern against a block of code
-         * finds all matches that should be processed and stores the positions
-         * of where they should be replaced within the string
+         * Matches a regex pattern against a block of code, finds all matches
+         * that should be processed, and stores the positions of where they
+         * should be replaced within the string.
          *
-         * this is where pretty much all the work is done but it should not
-         * be called directly
+         * This is where pretty much all the work is done but it should not
+         * be called directly.
          *
          * @param {Object} pattern
          * @param {string} code
@@ -323,7 +349,7 @@
                 return;
             }
 
-            // treat match 0 the same way as name
+            // Treat match 0 the same way as name
             if (!pattern['name'] && typeof pattern['matches'][0] == 'string') {
                 pattern['name'] = pattern['matches'][0];
                 delete pattern['matches'][0];
@@ -333,28 +359,31 @@
             var startPos = match.index;
             var endPos = match[0].length + startPos;
 
-            // if this is not a child match and it falls inside of another
-            // match that already happened we should skip it and continue processing
+            // If this is not a child match and it falls inside of another
+            // match that already happened we should skip it and continue
+            // processing.
             if (_matchIsInsideOtherMatch(startPos, endPos)) {
                 _processPattern(pattern, code);
                 return;
             }
 
             /**
-             * callback for when a match was successfully processed
+             * Callback for when a match was successfully processed
              *
              * @param {string} replacement
              * @returns void
              */
             function onMatchSuccess(replacement) {
-                // if this match has a name then wrap it in a span tag
+
+                // If this match has a name then wrap it in a span tag
                 if (pattern['name']) {
                     replacement = _wrapCodeInSpan(pattern['name'], replacement);
                 }
 
+                // For debugging
                 // console.log('LEVEL ' + currentLevel + ' replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos);
 
-                // store what needs to be replaced with what at this position
+                // Store what needs to be replaced with what at this position
                 if (!replacements[currentLevel]) {
                     replacements[currentLevel] = {};
                     replacementPositions[currentLevel] = {};
@@ -365,24 +394,23 @@
                     'with': replacement
                 };
 
-                // store the range of this match so we can use it for comparisons
-                // with other matches later
+                // Store the range of this match so we can use it for
+                // comparisons with other matches later.
                 replacementPositions[currentLevel][startPos] = endPos;
 
                 _processPattern(pattern, code);
             }
 
             /**
-             * callback for processing a sub group
+             * Helper function for processing a sub group
              *
-             * @param {number} i
-             * @param {Array} groupKeys
-             * @param {Function} callback
+             * @param {number} groupKey      index of group
+             * @returns void
              */
             function _processGroup(groupKey) {
                 var block = match[groupKey];
 
-                // if there is no match here then move on
+                // If there is no match here then move on
                 if (!block) {
                     return;
                 }
@@ -391,16 +419,17 @@
                 var language = group['language'];
 
                 /**
-                 * process group is what group we should use to actually process
-                 * this match group
+                 * Process group is what group we should use to actually process
+                 * this match group.
+                 *
+                 * For example if the subgroup pattern looks like this:
                  *
-                 * for example if the subgroup pattern looks like this
                  * 2: {
                  *     'name': 'keyword',
                  *     'pattern': /true/g
                  * }
                  *
-                 * then we use that as is, but if it looks like this
+                 * then we use that as is, but if it looks like this:
                  *
                  * 2: {
                  *     'name': 'keyword',
@@ -416,7 +445,7 @@
                 var groupToProcess = group['name'] && group['matches'] ? group['matches'] : group;
 
                 /**
-                 * takes the code block matched at this group, replaces it
+                 * Takes the code block matched at this group, replaces it
                  * with the highlighted block, and optionally wraps it with
                  * a span with a name
                  *
@@ -426,52 +455,56 @@
                  */
                 var _getReplacement = function(block, replaceBlock, matchName) {
                     replacement = _replaceAtPosition(_indexOfGroup(match, groupKey), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
-                    return replacement;
+                    return;
                 };
 
                 var localCode;
 
-                // if this is a sublanguage go and process the block using that language
+                // If this is a sublanguage go and process the block using
+                // that language
                 if (language) {
                     localCode = _highlightBlockForLanguage(block, language);
                     _getReplacement(block, localCode);
                     return;
                 }
 
-                // if this is a string then this match is directly mapped to selector
-                // so all we have to do is wrap it in a span and continue
+                // If this is a string then this match is directly mapped
+                // to selector so all we have to do is wrap it in a span
+                // and continue.
                 if (typeof group === 'string') {
                     _getReplacement(block, block, group);
                     return;
                 }
 
-                // the process group can be a single pattern or an array of patterns
-                // _processCodeWithPatterns always expects an array so we convert it here
+                // The process group can be a single pattern or an array of
+                // patterns. `_processCodeWithPatterns` always expects an array
+                // so we convert it here.
                 localCode = _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess]);
                 _getReplacement(block, localCode, group['matches'] ? group['name'] : 0);
             }
 
-            // if this pattern has sub matches for different groups in the regex
-            // then we should process them one at a time by rerunning them through
-            // this function to generate the new replacement
+            // If this pattern has sub matches for different groups in the regex
+            // then we should process them one at a time by running them through
+            // the _processGroup function to generate the new replacement.
             //
-            // we run through them backwards because the match position of earlier
-            // matches will not change depending on what gets replaced in later
-            // matches
+            // We use the `keys` function to run through them backwards because
+            // the match position of earlier matches will not change depending
+            // on what gets replaced in later matches.
             var groupKeys = keys(pattern['matches']);
             for (var i = 0; i < groupKeys.length; i++) {
                 _processGroup(groupKeys[i]);
             }
 
+            // Finally, call `onMatchSuccess` with the replacement
             onMatchSuccess(replacement);
         }
 
         /**
-         * takes a string of code and highlights it according to the language specified
+         * Takes a string of code and highlights it according to the language
+         * specified
          *
          * @param {string} code
          * @param {string} language
-         * @param {Function} onComplete
          * @returns void
          */
         function _highlightBlockForLanguage(code, language) {
@@ -480,28 +513,27 @@
         }
 
         /**
-         * processes a block of code using specified patterns
+         * Processes a block of code using specified patterns
          *
          * @param {string} code
          * @param {Array} patterns
          * @returns void
          */
         function _processCodeWithPatterns(code, patterns) {
-            // we have to increase the level here so that the
-            // replacements will not conflict with each other when
-            // processing sub blocks of code
+            // We have to increase the level here so that the replacements will
+            // not conflict with each other when processing sub blocks of code.
             ++currentLevel;
 
             for (var i = 0; i < patterns.length; i++) {
                 _processPattern(patterns[i], code);
             }
 
-            // we are done processing the patterns
-            // process the replacements and update the DOM
+            // We are done processing the patterns so we should actually replace
+            // what needs to be replaced in the code.
             code = _processReplacements(code);
 
-            // when we are done processing replacements
-            // we are done at this level so we can go back down
+            // When we are done processing replacements we can move back down to
+            // the previous level.
             delete replacements[currentLevel];
             delete replacementPositions[currentLevel];
             --currentLevel;
@@ -514,6 +546,13 @@
         };
     }
 
+    /**
+     * Web Worker Only - Handles message from main script giving commands about
+     * what to highlight
+     *
+     * @param {object} message      message received from worker.postMessage
+     * @returns void
+     */
     function _handleMessageFromRainbow(message) {
         languagePatterns = message.data.languagePatterns;
         bypassDefaults = message.data.bypassDefaults;
@@ -527,6 +566,13 @@
         });
     }
 
+    /**
+     * Browser Only - Handles response from web worker, updates DOM with
+     * resulting code, and fires callback
+     *
+     * @param {object} message      message received from self.postMessage
+     * @returns void
+     */
     function _handleResponseFromWorker(message) {
         console.log('_handleResponseFromWorker', performance.now() - message.data.start);
         var element = document.querySelector('.' + message.data.id);
@@ -538,6 +584,13 @@
         }
     }
 
+    /**
+     * Browser Only - Sends messages to web worker to highlight elements passed
+     * in
+     *
+     * @param {Array} codeBlocks
+     * @returns void
+     */
     function _highlightCodeBlocks(codeBlocks) {
         for (var i = 0; i < codeBlocks.length; i++) {
             var block = codeBlocks[i];
@@ -563,18 +616,19 @@
     }
 
     /**
-     * start highlighting all the code blocks
+     * Browser Only - Start highlighting all the code blocks
      *
+     * @param {Element} node       HTMLElement to search within
      * @returns void
      */
-    function _highlight(node, onComplete) {
+    function _highlight(node) {
 
-        // the first argument can be an Event or a DOM Element
-        // I was originally checking instanceof Event but that makes it break
-        // when using mootools
+        // The first argument can be an Event or a DOM Element.
         //
-        // @see https://github.com/ccampbell/rainbow/issues/32
+        // I was originally checking instanceof Event but that made it break
+        // when using mootools.
         //
+        // @see https://github.com/ccampbell/rainbow/issues/32
         node = node && typeof node.getElementsByTagName == 'function' ? node : document;
 
         var preBlocks = node.getElementsByTagName('pre'),
@@ -583,55 +637,59 @@
             finalPreBlocks = [],
             finalCodeBlocks = [];
 
-        // first loop through all pre blocks to find which ones to highlight
-        // also strip whitespace
+        // First loop through all pre blocks to find which ones to highlight
         for (i = 0; i < preBlocks.length; ++i) {
 
-            // strip whitespace around code tags when they are inside of a pre tag
-            // this makes the themes look better because you can't accidentally
-            // add extra linebreaks at the start and end
+            // Strip whitespace around code tags when they are inside of a pre
+            // tag.  This makes the themes look better because you can't
+            // accidentally add extra linebreaks at the start and end.
+            //
+            // When the pre tag contains a code tag then strip any extra
+            // whitespace.
+            //
+            // For example:
             //
-            // when the pre tag contains a code tag then strip any extra whitespace
-            // for example
             // 
             //      var foo = true;
             // 
// - // will become + // will become: + // //
var foo = true;
// - // if you want to preserve whitespace you can use a pre tag on its own - // without a code tag inside of it + // If you want to preserve whitespace you can use a pre tag on + // its own without a code tag inside of it. if (preBlocks[i].getElementsByTagName('code').length) { preBlocks[i].innerHTML = preBlocks[i].innerHTML.replace(/^\s+/, '').replace(/\s+$/, ''); continue; } - // if the pre block has no code blocks then we are going to want to - // process it directly + // If the pre block has no code blocks then we are going to want to + // process it directly. finalPreBlocks.push(preBlocks[i]); } // @see http://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript - // we are going to process all blocks + // We are going to process all blocks for (i = 0; i < codeBlocks.length; ++i) { finalCodeBlocks.push(codeBlocks[i]); } - _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks), onComplete); + _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks)); } /** - * extends the language pattern matches + * Extends the language pattern matches * - * @param {*} language name of language - * @param {*} patterns array of patterns to add on - * @param {boolean|null} bypass if true this will bypass the default language patterns + * @param {string} language name of language + * @param {object} patterns object of patterns to add on + * @param {boolean|null} bypass if `true` this will not inherit the + * default language patterns */ function _extend(language, patterns, bypass) { - // if there is only one argument then we assume that we want to - // extend the default language rules + // If there is only one argument then we assume that we want to + // extend the default language rules. if (arguments.length == 1) { patterns = language; language = DEFAULT_LANGUAGE; @@ -642,7 +700,8 @@ } /** - * call back to let you do stuff in your app after a piece of code has been highlighted + * Callback to let you do stuff in your app after a piece of code has + * been highlighted * * @param {Function} callback */ @@ -651,23 +710,30 @@ } /** - * method to set a global class that will be applied to all spans + * Method to set a global class that will be applied to all spans. + * + * This is realy only useful for the effect on rainbowco.de where you can + * force all blocks to not be highlighted and remove this class to + * transition them to being highlighted. * * @param {string} className + * @returns void */ function _addGlobalClass(className) { globalClass = className; } /** - * starts the magic rainbow + * Starts the magic rainbow * * @returns void */ function _color() { - // if you want to straight up highlight a string you can pass the string of code, - // the language, and a callback function + // If you want to straight up highlight a string you can pass the + // string of code, the language, and a callback function. + // + // @todo make this async in the browser if (typeof arguments[0] == 'string') { var drop = new Raindrop(); var result = drop.refract(arguments[0], arguments[1]); @@ -676,14 +742,14 @@ } } - // if you pass a callback function then we rerun the color function - // on all the code and call the callback function on complete + // If you pass a callback function then we rerun the color function + // on all the code and call the callback function on complete. if (typeof arguments[0] == 'function') { return _highlight(0, arguments[0]); } - // otherwise we use whatever node you passed in with an optional - // callback function as the second parameter + // Otherwise we use whatever node you passed in with an optional + // callback function as the second parameter. _highlight(arguments[0], arguments[1]); } @@ -700,9 +766,10 @@ var isSupported = !isWorker && typeof Worker !== 'undefined'; /** - * adds event listener to start highlighting + * Set up web worker and add event listener to start highlighting + * + * @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file */ - // @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file if (isSupported) { var id = Date.now(); document.write(''); From 75f9e08660391af00b234d285aba37e085f4621b Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Fri, 3 Oct 2014 21:33:13 -0400 Subject: [PATCH 018/153] Use individual var declarations This avoids having to use commas and messing up indentation. Closure Compiler will deal with it anyway when it minimizes. --- js/rainbow.js | 101 +++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/js/rainbow.js b/js/rainbow.js index b88cf41f..fe07b7e8 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -19,56 +19,57 @@ * @url rainbowco.de */ (function(global) { + "use strict"; /** * An array of the language patterns specified for each language * * @type {Object} */ - var languagePatterns = {}, + var languagePatterns = {}; - /** - * An array of languages and whether they should bypass the - * default patterns - * - * @type {Object} - */ - bypassDefaults = {}, + /** + * An array of languages and whether they should bypass the + * default patterns + * + * @type {Object} + */ + var bypassDefaults = {}; - /** - * Constant used to refer to the default language - * - * @type {number} - */ - DEFAULT_LANGUAGE = 0, + /** + * Constant used to refer to the default language + * + * @type {number} + */ + var DEFAULT_LANGUAGE = 0; - /** - * Global class added to each span in the highlighted code - * - * @type {null|string} - */ - globalClass, + /** + * Global class added to each span in the highlighted code + * + * @type {null|string} + */ + var globalClass; - /** - * Callback to fire after each block is highlighted - * - * @type {null|Function} - */ - onHighlight, + /** + * Callback to fire after each block is highlighted + * + * @type {null|Function} + */ + var onHighlight; - /** - * Reference to web worker for doing the heavy lifting - * - * @type Worker - */ - worker, + /** + * Reference to web worker for doing the heavy lifting + * + * @type Worker + */ + var worker; - /** - * Flag for if this is the web worker or not - * - * @type {Boolean} - */ - isWorker = typeof document === 'undefined'; + /** + * Flag for if this is the web worker or not + * + * @type {Boolean} + */ + var isWorker = typeof document === 'undefined'; /** * Browser Only - Gets the language for this block of code @@ -90,8 +91,8 @@ // You can use the Google Code Prettify style:
         // or the HTML5 style: 

         if (!language) {
-            var pattern = /\blang(?:uage)?-(\w+)/,
-                match = block.className.match(pattern) || block.parentNode.className.match(pattern);
+            var pattern = /\blang(?:uage)?-(\w+)/;
+            var match = block.className.match(pattern) || block.parentNode.className.match(pattern);
 
             if (match) {
                 language = match[1];
@@ -170,8 +171,8 @@
      * @returns {number}
      */
     function _indexOfGroup(match, groupNumber) {
-        var index = 0,
-            i;
+        var index = 0;
+        var i;
 
         for (i = 1; i < groupNumber; ++i) {
             if (match[i]) {
@@ -203,8 +204,8 @@
      * @returns {Array}
      */
     function _getPatternsForLanguage(language) {
-        var patterns = languagePatterns[language] || [],
-            defaultPatterns = languagePatterns[DEFAULT_LANGUAGE] || [];
+        var patterns = languagePatterns[language] || [];
+        var defaultPatterns = languagePatterns[DEFAULT_LANGUAGE] || [];
 
         return _bypassDefaultPatterns(language) ? patterns : patterns.concat(defaultPatterns);
     }
@@ -580,7 +581,7 @@
             element.innerHTML = message.data.result;
             element.classList.remove(message.data.id);
             element.classList.add('rainbow');
-            Rainbow.onHighlight(element, message.data.lang);
+            _onHighlight(element, message.data.lang);
         }
     }
 
@@ -631,11 +632,11 @@
         // @see https://github.com/ccampbell/rainbow/issues/32
         node = node && typeof node.getElementsByTagName == 'function' ? node : document;
 
-        var preBlocks = node.getElementsByTagName('pre'),
-            codeBlocks = node.getElementsByTagName('code'),
-            i,
-            finalPreBlocks = [],
-            finalCodeBlocks = [];
+        var preBlocks = node.getElementsByTagName('pre');
+        var codeBlocks = node.getElementsByTagName('code');
+        var i;
+        var finalPreBlocks = [];
+        var finalCodeBlocks = [];
 
         // First loop through all pre blocks to find which ones to highlight
         for (i = 0; i < preBlocks.length; ++i) {

From bcc017b01a29b2faade5406f771ed5d4ef746488 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 22:01:54 -0400
Subject: [PATCH 019/153] Simplify web worker callbacks

---
 js/rainbow.js | 48 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index fe07b7e8..d794e79d 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -560,13 +560,33 @@
         var drop = new Raindrop();
         var result = drop.refract(message.data.code, message.data.lang);
         self.postMessage({
-            id: message.data.id,
             start: message.data.time,
             lang: message.data.lang,
             result: result
         });
     }
 
+    /**
+     * Browser Only - Helper for matching up callbacks directly with the
+     * post message requests to a web worker.
+     *
+     * @see http://stackoverflow.com/questions/18056637/html5-web-worker-communication
+     * @param {object} message      data to send to web worker
+     * @param {Function} callback   callback function for worker to reply to
+     * @return void
+     */
+    function _messageWorker(message, callback) {
+        function _listen(e){
+            if (e.data.funcName === message.funcName){
+                worker.removeEventListener('message', _listen);
+                callback(e.data);
+            }
+        }
+
+        worker.addEventListener('message', _listen);
+        worker.postMessage(message);
+    }
+
     /**
      * Browser Only - Handles response from web worker, updates DOM with
      * resulting code, and fires callback
@@ -574,15 +594,13 @@
      * @param {object} message      message received from self.postMessage
      * @returns void
      */
-    function _handleResponseFromWorker(message) {
-        console.log('_handleResponseFromWorker', performance.now() - message.data.start);
-        var element = document.querySelector('.' + message.data.id);
-        if (element) {
-            element.innerHTML = message.data.result;
-            element.classList.remove(message.data.id);
+    function _generateHandler(element) {
+        return function _handleResponseFromWorker(data) {
+            console.log('_handleResponseFromWorker', performance.now() - data.start);
+            element.innerHTML = data.result;
             element.classList.add('rainbow');
-            _onHighlight(element, message.data.lang);
-        }
+            _onHighlight(element, data.lang);
+        };
     }
 
     /**
@@ -601,18 +619,15 @@
                 continue;
             }
 
-            var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
-            var uniqueId = randLetter.toLowerCase() + Date.now();
-            block.classList.add(uniqueId);
-
-            worker.postMessage({
+            var workerData = {
                 time: performance.now(),
-                id: uniqueId,
                 lang: language,
                 code: block.innerHTML,
                 languagePatterns: languagePatterns,
                 bypassDefaults: bypassDefaults
-            });
+            };
+
+            _messageWorker(workerData, _generateHandler(block));
         }
     }
 
@@ -776,7 +791,6 @@
         document.write('');
         var src = document.getElementById('wts' + id).previousSibling.src;
         worker = new Worker(src);
-        worker.addEventListener('message', _handleResponseFromWorker, false);
         global.Rainbow = _rainbow;
         document.addEventListener('DOMContentLoaded', _rainbow.color, false);
     }

From bea6e7714189b452d3a2a9bc59a9536bd68aa036 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 22:56:06 -0400
Subject: [PATCH 020/153] Make all the callback stuff work correctly

---
 js/rainbow.js | 60 ++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 17 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index d794e79d..50b33e3f 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -594,13 +594,34 @@
      * @param {object} message      message received from self.postMessage
      * @returns void
      */
-    function _generateHandler(element) {
+    function _generateHandler(element, waitingOn, callback) {
         return function _handleResponseFromWorker(data) {
             console.log('_handleResponseFromWorker', performance.now() - data.start);
             element.innerHTML = data.result;
             element.classList.add('rainbow');
             _onHighlight(element, data.lang);
+            if (--waitingOn.c === 0) {
+                callback();
+            }
+        };
+    }
+
+    /**
+     * Browser Only - Gets data to send to webworker
+     * @param  {string} code
+     * @param  {string} lang
+     * @return {object}
+     */
+    function _getWorkerData(code, lang) {
+        var workerData = {
+            time: performance.now(),
+            code: code,
+            lang: lang,
+            languagePatterns: languagePatterns,
+            bypassDefaults: bypassDefaults
         };
+
+        return workerData;
     }
 
     /**
@@ -610,7 +631,8 @@
      * @param {Array} codeBlocks
      * @returns void
      */
-    function _highlightCodeBlocks(codeBlocks) {
+    function _highlightCodeBlocks(codeBlocks, callback) {
+        var waitingOn = {c: 0};
         for (var i = 0; i < codeBlocks.length; i++) {
             var block = codeBlocks[i];
             var language = _getLanguageForBlock(block);
@@ -619,15 +641,13 @@
                 continue;
             }
 
-            var workerData = {
-                time: performance.now(),
-                lang: language,
-                code: block.innerHTML,
-                languagePatterns: languagePatterns,
-                bypassDefaults: bypassDefaults
-            };
+            ++waitingOn.c;
+            _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback));
+        }
 
-            _messageWorker(workerData, _generateHandler(block));
+        if (waitingOn.c === 0) {
+            console.log(codeBlocks, callback);
+            callback();
         }
     }
 
@@ -637,7 +657,8 @@
      * @param {Element} node       HTMLElement to search within
      * @returns void
      */
-    function _highlight(node) {
+    function _highlight(node, callback) {
+        callback = callback || function() {};
 
         // The first argument can be an Event or a DOM Element.
         //
@@ -691,7 +712,7 @@
             finalCodeBlocks.push(codeBlocks[i]);
         }
 
-        _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks));
+        _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks), callback);
     }
 
     /**
@@ -751,16 +772,21 @@
         //
         // @todo make this async in the browser
         if (typeof arguments[0] == 'string') {
-            var drop = new Raindrop();
-            var result = drop.refract(arguments[0], arguments[1]);
-            if (arguments[2]) {
-                arguments[2](result);
-            }
+            var workerData = _getWorkerData(arguments[0], arguments[1]);
+            _messageWorker(workerData, (function(cb) {
+                return function(data) {
+                    if (cb) {
+                        cb(data.result, data.lang);
+                    }
+                };
+            } (arguments[2])));
+            return;
         }
 
         // If you pass a callback function then we rerun the color function
         // on all the code and call the callback function on complete.
         if (typeof arguments[0] == 'function') {
+            console.log('this one');
             return _highlight(0, arguments[0]);
         }
 

From 594114f48b54e321924e54055cea24b16163d2ca Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Fri, 3 Oct 2014 22:56:25 -0400
Subject: [PATCH 021/153] Remove @todo

---
 js/rainbow.js | 2 --
 1 file changed, 2 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 50b33e3f..fee7e6f7 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -769,8 +769,6 @@
 
         // If you want to straight up highlight a string you can pass the
         // string of code, the language, and a callback function.
-        //
-        // @todo make this async in the browser
         if (typeof arguments[0] == 'string') {
             var workerData = _getWorkerData(arguments[0], arguments[1]);
             _messageWorker(workerData, (function(cb) {

From ea8b5e00c8dbcb9fddebd91827a820a1d85a994d Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 02:12:48 -0400
Subject: [PATCH 022/153] Add node support

---
 js/rainbow.js | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index fee7e6f7..5332a8c6 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -64,12 +64,16 @@
      */
     var worker;
 
+    var isNode = typeof module !== 'undefined' && typeof module.exports === 'object';
     /**
      * Flag for if this is the web worker or not
      *
      * @type {Boolean}
      */
-    var isWorker = typeof document === 'undefined';
+    var isWorker = !isNode && typeof document === 'undefined';
+    if (isNode) {
+        global.Worker = require('webworker-threads').Worker;
+    }
 
     /**
      * Browser Only - Gets the language for this block of code
@@ -576,10 +580,10 @@
      * @return void
      */
     function _messageWorker(message, callback) {
-        function _listen(e){
-            if (e.data.funcName === message.funcName){
-                worker.removeEventListener('message', _listen);
+        function _listen(e) {
+            if (e.data.funcName === message.funcName) {
                 callback(e.data);
+                worker.removeEventListener('message', _listen);
             }
         }
 
@@ -596,7 +600,6 @@
      */
     function _generateHandler(element, waitingOn, callback) {
         return function _handleResponseFromWorker(data) {
-            console.log('_handleResponseFromWorker', performance.now() - data.start);
             element.innerHTML = data.result;
             element.classList.add('rainbow');
             _onHighlight(element, data.lang);
@@ -614,7 +617,7 @@
      */
     function _getWorkerData(code, lang) {
         var workerData = {
-            time: performance.now(),
+            // time: performance.now(),
             code: code,
             lang: lang,
             languagePatterns: languagePatterns,
@@ -646,7 +649,6 @@
         }
 
         if (waitingOn.c === 0) {
-            console.log(codeBlocks, callback);
             callback();
         }
     }
@@ -766,7 +768,6 @@
      * @returns void
      */
     function _color() {
-
         // If you want to straight up highlight a string you can pass the
         // string of code, the language, and a callback function.
         if (typeof arguments[0] == 'string') {
@@ -784,7 +785,6 @@
         // If you pass a callback function then we rerun the color function
         // on all the code and call the callback function on complete.
         if (typeof arguments[0] == 'function') {
-            console.log('this one');
             return _highlight(0, arguments[0]);
         }
 
@@ -803,20 +803,31 @@
         color: _color
     };
 
-    var isSupported = !isWorker && typeof Worker !== 'undefined';
+    var setUpWorker = !isWorker && typeof global.Worker !== 'undefined';
 
     /**
      * Set up web worker and add event listener to start highlighting
      *
      * @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file
      */
-    if (isSupported) {
-        var id = Date.now();
-        document.write('');
-        var src = document.getElementById('wts' + id).previousSibling.src;
-        worker = new Worker(src);
-        global.Rainbow = _rainbow;
-        document.addEventListener('DOMContentLoaded', _rainbow.color, false);
+    global.Rainbow = _rainbow;
+    if (setUpWorker) {
+        var src;
+        if (!isNode) {
+            var id = Date.now();
+            document.write('');
+            src = document.getElementById('wts' + id).previousSibling.src;
+        }
+
+        worker = new global.Worker(isNode ? __filename : src);
+
+        if (!isNode) {
+            document.addEventListener('DOMContentLoaded', _rainbow.color, false);
+        }
+    }
+
+    if (isNode) {
+        module.exports = _rainbow;
     }
 
     if (isWorker) {

From 6fef758ebf4e3cd75ac1ca5ecd6dd63e0e81355a Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 02:14:02 -0400
Subject: [PATCH 023/153] Update package.json

---
 package.json | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 612e4fde..a093dcac 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
 {
-  "name": "Rainbow",
+  "name": "rainbow",
   "version": "1.2.0",
   "description": "Simple library for code syntax highlighting",
-  "main": "Gruntfile.js",
+  "main": "./js/rainbow.js",
   "directories": {
     "test": "tests"
   },
@@ -26,5 +26,8 @@
     "grunt": "~0.4.1",
     "grunt-complexity": "~0.1.2",
     "grunt-mocha": "~0.3.1"
+  },
+  "dependencies": {
+    "webworker-threads": "^0.5.1"
   }
 }

From b47b109b5f4048aa729fc11454d80f2d71d0cae4 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 03:07:58 -0400
Subject: [PATCH 024/153] Use unique identifiers for web worker calls

---
 js/rainbow.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 5332a8c6..997ead63 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -563,25 +563,25 @@
         bypassDefaults = message.data.bypassDefaults;
         var drop = new Raindrop();
         var result = drop.refract(message.data.code, message.data.lang);
-        self.postMessage({
-            start: message.data.time,
+        var data = {
+            id: message.data.id,
             lang: message.data.lang,
             result: result
-        });
+        };
+        self.postMessage(data);
     }
 
     /**
      * Browser Only - Helper for matching up callbacks directly with the
      * post message requests to a web worker.
      *
-     * @see http://stackoverflow.com/questions/18056637/html5-web-worker-communication
      * @param {object} message      data to send to web worker
      * @param {Function} callback   callback function for worker to reply to
      * @return void
      */
     function _messageWorker(message, callback) {
         function _listen(e) {
-            if (e.data.funcName === message.funcName) {
+            if (e.data.id === message.id) {
                 callback(e.data);
                 worker.removeEventListener('message', _listen);
             }
@@ -617,7 +617,7 @@
      */
     function _getWorkerData(code, lang) {
         var workerData = {
-            // time: performance.now(),
+            id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(),
             code: code,
             lang: lang,
             languagePatterns: languagePatterns,

From 79ba305809f3d7df15c22d1982c433fca480d951 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 03:08:28 -0400
Subject: [PATCH 025/153] Add colorSync method for node.js

---
 js/rainbow.js | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/js/rainbow.js b/js/rainbow.js
index 997ead63..6e90c81e 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -803,6 +803,13 @@
         color: _color
     };
 
+    if (isNode) {
+        _rainbow.colorSync = function(code, lang) {
+            var drop = new Raindrop();
+            return drop.refract(code, lang);
+        };
+    }
+
     var setUpWorker = !isWorker && typeof global.Worker !== 'undefined';
 
     /**

From 0631f8e97bb090d7a6c7c8cd0df3027a2fdf51ad Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 14:37:50 -0400
Subject: [PATCH 026/153] Use String.trim()

---
 js/rainbow.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 6e90c81e..0d079eea 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -699,7 +699,7 @@
             // If you want to preserve whitespace you can use a pre tag on
             // its own without a code tag inside of it.
             if (preBlocks[i].getElementsByTagName('code').length) {
-                preBlocks[i].innerHTML = preBlocks[i].innerHTML.replace(/^\s+/, '').replace(/\s+$/, '');
+                preBlocks[i].innerHTML = preBlocks[i].innerHTML.trim();
                 continue;
             }
 

From 249380a614680de214fb50eb8e13a32e95254c4f Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 14:50:08 -0400
Subject: [PATCH 027/153] Fix Javascript regex patterns

- Make regex pattern lazy
- Add .replace as a support function
---
 js/language/javascript.js         |  6 +++---
 tests/language/test.javascript.js | 10 ++++++++++
 util/builder.py                   |  2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/js/language/javascript.js b/js/language/javascript.js
index fc881f82..7a1a2260 100644
--- a/js/language/javascript.js
+++ b/js/language/javascript.js
@@ -2,7 +2,7 @@
  * Javascript patterns
  *
  * @author Craig Campbell
- * @version 1.0.9
+ * @version 1.0.10
  */
 Rainbow.extend('javascript', [
 
@@ -34,7 +34,7 @@ Rainbow.extend('javascript', [
         'matches': {
             1: 'support.method'
         },
-        'pattern': /\.(getAttribute|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g
+        'pattern': /\.(getAttribute|replace|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g
     },
 
     /**
@@ -58,7 +58,7 @@ Rainbow.extend('javascript', [
             3: 'string.regexp.close',
             4: 'string.regexp.modifier'
         },
-        'pattern': /(\/)(?!\*)(.+)(\/)([igm]{0,3})/g
+        'pattern': /(\/)(?!\*)(.+?)(\/)([igm]{0,3})/g
     },
 
     /**
diff --git a/tests/language/test.javascript.js b/tests/language/test.javascript.js
index 9d621b1e..5e09bc54 100644
--- a/tests/language/test.javascript.js
+++ b/tests/language/test.javascript.js
@@ -209,4 +209,14 @@ describe(language, function() {
         'var parseAndHighlight = function() {};\n' +
         'var parseAndHighlight2 = function() {};'
     );
+
+    run(
+        language,
+
+        'multiple regex same line',
+
+        "code.replace(//g, '>')",
+
+        'code.replace(/</g, \'<\').replace(/>/g, \'>\')'
+    );
 });
diff --git a/util/builder.py b/util/builder.py
index 87ad37e3..e1797d5c 100644
--- a/util/builder.py
+++ b/util/builder.py
@@ -23,7 +23,7 @@ def __init__(self, js_path, closure_path, theme_path=None):
             'haskell': '1.0.1',
             'html': '1.0.9',
             'java': '1.0',
-            'javascript': '1.0.9',
+            'javascript': '1.0.10',
             'lua': '1.0.1',
             'php': '1.0.8',
             'python': '1.0.9',

From 46ae813570e6adef95180e273af349e728330c24 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 15:08:36 -0400
Subject: [PATCH 028/153] Update build script

---
 util/builder.py | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/util/builder.py b/util/builder.py
index e1797d5c..e39c715c 100644
--- a/util/builder.py
+++ b/util/builder.py
@@ -4,6 +4,7 @@
 import hashlib
 import re
 import glob
+import json
 from zipfile import ZipFile
 from StringIO import StringIO
 
@@ -90,10 +91,9 @@ def writeFile(self, path, content):
         file.write(content)
         file.close()
 
-    def getVersion(self):
-        contents = self.openFile(self.getRainbowPath())
-        match = re.search(r'@version\s(.*)\s+?', contents)
-        return match.group(1)
+    def getPackageJSON(self):
+        contents = self.openFile(os.path.join(self.js_path, '../package.json'))
+        return json.loads(contents)
 
     def getLanguageVersions(self, languages):
         groups = []
@@ -126,7 +126,7 @@ def getFileForLanguages(self, languages, cache=None):
             if cached_version:
                 return cached_version
 
-        command = ['java', '-jar', self.closure_path, '--compilation_level', 'ADVANCED_OPTIMIZATIONS'] + self.js_files_to_include
+        command = ['java', '-jar', self.closure_path, '--compilation_level', 'SIMPLE_OPTIMIZATIONS'] + self.js_files_to_include
         proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         output, err = proc.communicate()
 
@@ -134,17 +134,18 @@ def getFileForLanguages(self, languages, cache=None):
             print err
 
         lines = output.splitlines()
-        comments = lines[0:4]
-        version = comments[1].replace(' @version ', '')
-        url = comments[2].replace(' @url ', '')
-        new_comment = '/* Rainbow v' + version + ' ' + url
 
-        if len(languages):
-            new_comment += ' | included languages: ' + ', '.join(languages)
+        data = self.getPackageJSON()
 
-        new_comment += ' */'
+        new_comment = "/* Rainbow v%s %s | included languages: %s */" % (
+            data['version'],
+            data['homepage'].replace('http://', ''),
+            ', '.join(languages)
+        )
 
-        output = new_comment + '\n' + '\n'.join(lines[4:])
+        lines.insert(0, new_comment)
+
+        output = '\n'.join(lines)
 
         if cache is not None:
             cache.set(cache_key, output, 14400)  # 4 hours

From 1a69f7f969d83384e0b6bd861f9b77d2b62f31bc Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 15:08:56 -0400
Subject: [PATCH 029/153] Remove version from main js file

---
 js/rainbow.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 0d079eea..dcaf41ee 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -15,8 +15,7 @@
  *
  * Rainbow is a simple code syntax highlighter
  *
- * @version 1.2
- * @url rainbowco.de
+ * @see rainbowco.de
  */
 (function(global) {
     "use strict";

From ca1293c0fd7c08306f34086bc7ac68dd2b0b44af Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 16:59:16 -0400
Subject: [PATCH 030/153] Get rid of processing level

Use separate Raindrop instances for processing submatches so we do
not have to keep a hacky level incrementing and decrementing.
---
 js/rainbow.js | 84 ++++++++++++++++++++-------------------------------
 1 file changed, 33 insertions(+), 51 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index dcaf41ee..87259478 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -264,21 +264,18 @@
         var replacements = {};
 
         /**
-         * Object of start and end positions of blocks to be replaced
+         * Language associated with this Raindrop object
          *
-         * @type {Object}
+         * @type {string}
          */
-        var replacementPositions = {};
+        var currentLanguage;
 
         /**
-         * Processing level
-         *
-         * Replacements are stored at this level so if there is a sub block of
-         * code (for example PHP inside of HTML) it runs at a different level.
+         * Object of start and end positions of blocks to be replaced
          *
-         * @type {number}
+         * @type {Object}
          */
-        var currentLevel = 0;
+        var replacementPositions = {};
 
         /**
          * Determines if the match passed in falls inside of an existing match.
@@ -293,17 +290,17 @@
          * @returns {boolean}
          */
         function _matchIsInsideOtherMatch(start, end) {
-            for (var key in replacementPositions[currentLevel]) {
+            for (var key in replacementPositions) {
                 key = parseInt(key, 10);
 
                 // If this block completely overlaps with another block
                 // then we should remove the other block and return `false`.
-                if (_hasCompleteOverlap(key, replacementPositions[currentLevel][key], start, end)) {
-                    delete replacementPositions[currentLevel][key];
-                    delete replacements[currentLevel][key];
+                if (_hasCompleteOverlap(key, replacementPositions[key], start, end)) {
+                    delete replacementPositions[key];
+                    delete replacements[key];
                 }
 
-                if (_intersects(key, replacementPositions[currentLevel][key], start, end)) {
+                if (_intersects(key, replacementPositions[key], start, end)) {
                     return true;
                 }
             }
@@ -319,10 +316,10 @@
          * @returns void
          */
         function _processReplacements(code) {
-            var positions = keys(replacements[currentLevel]);
+            var positions = keys(replacements);
             for (var i = 0; i < positions.length; i++) {
                 var pos = positions[i];
-                var replacement = replacements[currentLevel][pos];
+                var replacement = replacements[pos];
                 code = _replaceAtPosition(pos, replacement['replace'], replacement['with'], code);
             }
             return code;
@@ -385,22 +382,17 @@
                 }
 
                 // For debugging
-                // console.log('LEVEL ' + currentLevel + ' replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos);
+                // console.log('Replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos);
 
                 // Store what needs to be replaced with what at this position
-                if (!replacements[currentLevel]) {
-                    replacements[currentLevel] = {};
-                    replacementPositions[currentLevel] = {};
-                }
-
-                replacements[currentLevel][startPos] = {
+                replacements[startPos] = {
                     'replace': match[0],
                     'with': replacement
                 };
 
                 // Store the range of this match so we can use it for
                 // comparisons with other matches later.
-                replacementPositions[currentLevel][startPos] = endPos;
+                replacementPositions[startPos] = endPos;
 
                 _processPattern(pattern, code);
             }
@@ -462,28 +454,29 @@
                     return;
                 };
 
+                // If this is a string then this match is directly mapped
+                // to selector so all we have to do is wrap it in a span
+                // and continue.
+                if (typeof group === 'string') {
+                    _getReplacement(block, block, group);
+                    return;
+                }
+
                 var localCode;
+                var drop = new Raindrop();
 
                 // If this is a sublanguage go and process the block using
                 // that language
                 if (language) {
-                    localCode = _highlightBlockForLanguage(block, language);
+                    localCode = drop.refract(block, language);
                     _getReplacement(block, localCode);
                     return;
                 }
 
-                // If this is a string then this match is directly mapped
-                // to selector so all we have to do is wrap it in a span
-                // and continue.
-                if (typeof group === 'string') {
-                    _getReplacement(block, block, group);
-                    return;
-                }
-
                 // The process group can be a single pattern or an array of
                 // patterns. `_processCodeWithPatterns` always expects an array
                 // so we convert it here.
-                localCode = _processCodeWithPatterns(block, groupToProcess.length ? groupToProcess : [groupToProcess]);
+                localCode = drop.refract(block, currentLanguage, groupToProcess.length ? groupToProcess : [groupToProcess]);
                 _getReplacement(block, localCode, group['matches'] ? group['name'] : 0);
             }
 
@@ -511,8 +504,9 @@
          * @param {string} language
          * @returns void
          */
-        function _highlightBlockForLanguage(code, language) {
-            var patterns = _getPatternsForLanguage(language);
+        function _highlightBlockForLanguage(code, language, patterns) {
+            currentLanguage = language;
+            patterns = patterns || _getPatternsForLanguage(language);
             return _processCodeWithPatterns(_htmlEntities(code), patterns);
         }
 
@@ -524,25 +518,13 @@
          * @returns void
          */
         function _processCodeWithPatterns(code, patterns) {
-            // We have to increase the level here so that the replacements will
-            // not conflict with each other when processing sub blocks of code.
-            ++currentLevel;
-
             for (var i = 0; i < patterns.length; i++) {
                 _processPattern(patterns[i], code);
             }
 
             // We are done processing the patterns so we should actually replace
             // what needs to be replaced in the code.
-            code = _processReplacements(code);
-
-            // When we are done processing replacements we can move back down to
-            // the previous level.
-            delete replacements[currentLevel];
-            delete replacementPositions[currentLevel];
-            --currentLevel;
-
-            return code;
+            return _processReplacements(code);
         }
 
         return {
@@ -821,8 +803,8 @@
         var src;
         if (!isNode) {
             var id = Date.now();
-            document.write('');
-            src = document.getElementById('wts' + id).previousSibling.src;
+            document.write('');
+            src = document.getElementById('w' + id).previousSibling.src;
         }
 
         worker = new global.Worker(isNode ? __filename : src);

From c12341889c14760177662b035d83fed498bb4d07 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 17:06:46 -0400
Subject: [PATCH 031/153] Make sure web worker has knowledge of global class

---
 js/rainbow.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 87259478..604430c7 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -542,6 +542,7 @@
     function _handleMessageFromRainbow(message) {
         languagePatterns = message.data.languagePatterns;
         bypassDefaults = message.data.bypassDefaults;
+        globalClass = message.data.globalClass;
         var drop = new Raindrop();
         var result = drop.refract(message.data.code, message.data.lang);
         var data = {
@@ -602,7 +603,8 @@
             code: code,
             lang: lang,
             languagePatterns: languagePatterns,
-            bypassDefaults: bypassDefaults
+            bypassDefaults: bypassDefaults,
+            globalClass: globalClass
         };
 
         return workerData;

From 45f08c9b05171eb98de60ebb58cd1ac3a26e9b8c Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 17:15:16 -0400
Subject: [PATCH 032/153] Fix onHighlight callback

---
 js/rainbow.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index 604430c7..c7c64fcf 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -584,7 +584,11 @@
         return function _handleResponseFromWorker(data) {
             element.innerHTML = data.result;
             element.classList.add('rainbow');
-            _onHighlight(element, data.lang);
+
+            if (onHighlight) {
+                onHighlight(element, data.lang);
+            }
+
             if (--waitingOn.c === 0) {
                 callback();
             }
@@ -781,7 +785,7 @@
      */
     var _rainbow = {
         extend: _extend,
-        onHighlight: _onHighlight || function() {},
+        onHighlight: _onHighlight,
         addClass: _addGlobalClass,
         color: _color
     };

From 8d4ac649e3259da415af9b59e282efb7bd6bfb0e Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 21:11:52 -0400
Subject: [PATCH 033/153] Add homepage url to package.json

---
 package.json | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package.json b/package.json
index a093dcac..99a24e2a 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
   "version": "1.2.0",
   "description": "Simple library for code syntax highlighting",
   "main": "./js/rainbow.js",
+  "homepage": "http://rainbowco.de",
   "directories": {
     "test": "tests"
   },

From 0768c547010bada8dfc69cebc60364a7213564df Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 21:27:59 -0400
Subject: [PATCH 034/153] Simplify method to find current script URL

---
 js/rainbow.js | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/js/rainbow.js b/js/rainbow.js
index c7c64fcf..04c528ef 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -806,14 +806,15 @@
      */
     global.Rainbow = _rainbow;
     if (setUpWorker) {
-        var src;
+        var currentSrc;
         if (!isNode) {
-            var id = Date.now();
-            document.write('');
-            src = document.getElementById('w' + id).previousSibling.src;
+
+            // @see http://stackoverflow.com/questions/2255689/how-to-get-the-file-path-of-the-currently-executing-javascript-code
+            var scripts = document.getElementsByTagName('script');
+            currentSrc = scripts[scripts.length - 1].src;
         }
 
-        worker = new global.Worker(isNode ? __filename : src);
+        worker = new global.Worker(isNode ? __filename : currentSrc);
 
         if (!isNode) {
             document.addEventListener('DOMContentLoaded', _rainbow.color, false);

From 8f40174dbbbb2815a3923352eab9f6906f7dc46c Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sat, 4 Oct 2014 21:54:47 -0400
Subject: [PATCH 035/153] Do not process Rainbow.extend from worker context

---
 js/rainbow.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/js/rainbow.js b/js/rainbow.js
index 04c528ef..17b13a34 100644
--- a/js/rainbow.js
+++ b/js/rainbow.js
@@ -713,6 +713,9 @@
      *                                  default language patterns
      */
     function _extend(language, patterns, bypass) {
+        if (isWorker) {
+            return;
+        }
 
         // If there is only one argument then we assume that we want to
         // extend the default language rules.

From 508755935bca8e6c65932e8dddb6e23786c24fb3 Mon Sep 17 00:00:00 2001
From: Craig Campbell 
Date: Sun, 5 Oct 2014 09:58:42 -0400
Subject: [PATCH 036/153] Add another example to api test page

---
 tests/api.html | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tests/api.html b/tests/api.html
index 74e0e037..a4e4d641 100644
--- a/tests/api.html
+++ b/tests/api.html
@@ -6,7 +6,7 @@
     

API Test Page

code on page to begin with

-
var foo = false;
+
var foo = false;
@@ -15,6 +15,12 @@

API Test Page

From de680887e9a40fe852c067aacd4f3c0508645443 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 10:14:14 -0400 Subject: [PATCH 037/153] Fix white flash when .js class is added to --- js/rainbow.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/js/rainbow.js b/js/rainbow.js index 17b13a34..50be1ae7 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -1,5 +1,5 @@ /** - * Copyright 2014 Craig Campbell + * Copyright 2012-2014 Craig Campbell * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -584,6 +584,7 @@ return function _handleResponseFromWorker(data) { element.innerHTML = data.result; element.classList.add('rainbow'); + element.style.opacity = 1; if (onHighlight) { onHighlight(element, data.lang); @@ -631,6 +632,8 @@ continue; } + block.style.transition = Rainbow.transition; + ++waitingOn.c; _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback)); } @@ -790,6 +793,7 @@ extend: _extend, onHighlight: _onHighlight, addClass: _addGlobalClass, + transition: 'opacity 50ms ease-in-out', color: _color }; @@ -800,6 +804,11 @@ }; } + global.Rainbow = _rainbow; + if (isNode) { + module.exports = _rainbow; + } + var setUpWorker = !isWorker && typeof global.Worker !== 'undefined'; /** @@ -807,7 +816,6 @@ * * @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file */ - global.Rainbow = _rainbow; if (setUpWorker) { var currentSrc; if (!isNode) { @@ -822,13 +830,16 @@ if (!isNode) { document.addEventListener('DOMContentLoaded', _rainbow.color, false); } - } - if (isNode) { - module.exports = _rainbow; + return; } - if (isWorker) { - self.addEventListener('message', _handleMessageFromRainbow); + // this is for older browsers where they don't have webworker support + // but we still want to show the code + if (!isWorker) { + document.write(''); + return; } + + self.addEventListener('message', _handleMessageFromRainbow); }) (this); From afe7a530dabce9b2cb4c04f12d8de639b0dab093 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 10:23:47 -0400 Subject: [PATCH 038/153] Add examples/documentation for Rainbow.color --- js/rainbow.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/js/rainbow.js b/js/rainbow.js index 50be1ae7..2880a593 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -761,8 +761,15 @@ * @returns void */ function _color() { + // If you want to straight up highlight a string you can pass the // string of code, the language, and a callback function. + // + // Example: + // + // Rainbow.color(code, language, function(highlightedCode, language) { + // // this code block is now highlighted + // }); if (typeof arguments[0] == 'string') { var workerData = _getWorkerData(arguments[0], arguments[1]); _messageWorker(workerData, (function(cb) { @@ -777,12 +784,31 @@ // If you pass a callback function then we rerun the color function // on all the code and call the callback function on complete. + // + // Example: + // + // Rainbow.color(function() { + // console.log('All matching tags on the page are now highlighted'); + // }); if (typeof arguments[0] == 'function') { return _highlight(0, arguments[0]); } // Otherwise we use whatever node you passed in with an optional // callback function as the second parameter. + // + // Example: + // + // var preElement = document.createElement('pre'); + // var codeElement = document.createElement('code'); + // codeElement.setAttribute('data-language', 'javascript'); + // codeElement.innerHTML = '// Here is some JavaScript'; + // preElement.appendChild(codeElement); + // Rainbow.color(preElement, function() { + // // New element is now highlighted + // }); + // + // If you don't pass an element it will default to `document` _highlight(arguments[0], arguments[1]); } From 5c3504a4011153c51d2308f8eaaea610b82ef4b2 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 10:54:04 -0400 Subject: [PATCH 039/153] Add JSON language --- demos/json.html | 25 +++++++++++++++++++++++++ js/language/json.js | 29 +++++++++++++++++++++++++++++ tests/language/test.json.js | 28 ++++++++++++++++++++++++++++ tests/rainbow.html | 2 ++ 4 files changed, 84 insertions(+) create mode 100644 demos/json.html create mode 100644 js/language/json.js create mode 100644 tests/language/test.json.js diff --git a/demos/json.html b/demos/json.html new file mode 100644 index 00000000..5ae69b26 --- /dev/null +++ b/demos/json.html @@ -0,0 +1,25 @@ + + +Syntax Highlighting + + + +
{
+    "id": 23,
+    "name": "Something",
+    "description": "He said, \"Double quotes inside of other double quotes.\"",
+    "tags": [
+        "one",
+        "two",
+        "three"
+    ],
+    "image": {
+        "url": "http://example.com/image.jpg",
+        "width": 100,
+        "height": 100
+    }
+}
+ + + + diff --git a/js/language/json.js b/js/language/json.js new file mode 100644 index 00000000..bb8f06a0 --- /dev/null +++ b/js/language/json.js @@ -0,0 +1,29 @@ +/** + * JSON patterns + * + * @author Nijiko Yonskai + * @author Craig Campbell + * @version 1.0 + */ +Rainbow.extend('json', [ + { + 'matches': { + 0: { + 'name': 'string', + 'matches': { + 'name': 'constant.character.escape', + 'pattern': /\\('|"){1}/g + } + } + }, + 'pattern': /(\"|\')(\\?.)*?\1/g + }, + { + 'name': 'constant.numeric', + 'pattern': /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/gi + }, + { + 'name': 'constant.language', + 'pattern': /\b(true|false|null)\b/g + } +], true); diff --git a/tests/language/test.json.js b/tests/language/test.json.js new file mode 100644 index 00000000..2524c73f --- /dev/null +++ b/tests/language/test.json.js @@ -0,0 +1,28 @@ +/* global describe, run */ +var language = 'json'; + +describe(language, function() { + run( + language, + + 'json string', + + '{\n' + + ' "id": 23,\n' + + ' "name": "Something",\n' + + ' "description": "He said, \"Double quotes inside of other double quotes.\"",\n' + + ' "tags": [\n' + + ' "one",\n' + + ' "two",\n' + + ' "three"\n' + + ' ],\n' + + ' "image": {\n' + + ' "url": "http://example.com/image.jpg",\n' + + ' "width": 100,\n' + + ' "height": 100\n' + + ' }\n' + + '}', + + '{\n "id": 23,\n "name": "Something",\n "description": "He said, "Double quotes inside of other double quotes."",\n "tags": [\n "one",\n "two",\n "three"\n ],\n "image": {\n "url": "http://example.com/image.jpg",\n "width": 100,\n "height": 100\n }\n}' + ); +}); diff --git a/tests/rainbow.html b/tests/rainbow.html index 2ac44d7d..f79dc926 100644 --- a/tests/rainbow.html +++ b/tests/rainbow.html @@ -23,6 +23,7 @@ + @@ -53,6 +54,7 @@ + From d84217764e02bc4383f90750a55915db2fc75c3d Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 11:04:35 -0400 Subject: [PATCH 040/153] Add ability to specify language aliases --- js/rainbow.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/rainbow.js b/js/rainbow.js index 2880a593..8e12aa41 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -35,6 +35,13 @@ */ var bypassDefaults = {}; + /** + * A mapping of language aliases + * + * @type {Object} + */ + var aliases = {}; + /** * Constant used to refer to the default language * @@ -603,6 +610,10 @@ * @return {object} */ function _getWorkerData(code, lang) { + if (aliases[lang]) { + lang = aliases[lang]; + } + var workerData = { id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(), code: code, @@ -755,6 +766,17 @@ globalClass = className; } + /** + * Method to add an alias for an existing language. + * + * For example if you want to have "coffee" map to "coffeescript" + * + * @see https://github.com/ccampbell/rainbow/issues/154 + */ + function _addAlias(alias, originalLanguage) { + aliases[alias] = originalLanguage; + } + /** * Starts the magic rainbow * @@ -819,6 +841,7 @@ extend: _extend, onHighlight: _onHighlight, addClass: _addGlobalClass, + addAlias: _addAlias, transition: 'opacity 50ms ease-in-out', color: _color }; From 6ba7d682746c08e78f28e1c40830f757678f51ac Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 11:07:38 -0400 Subject: [PATCH 041/153] Make sure aliases work with Rainbow.colorSync too --- js/rainbow.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/rainbow.js b/js/rainbow.js index 8e12aa41..40c737c8 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -610,9 +610,7 @@ * @return {object} */ function _getWorkerData(code, lang) { - if (aliases[lang]) { - lang = aliases[lang]; - } + lang = aliases[lang] || lang; var workerData = { id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(), @@ -849,7 +847,7 @@ if (isNode) { _rainbow.colorSync = function(code, lang) { var drop = new Raindrop(); - return drop.refract(code, lang); + return drop.refract(code, aliases[lang] || lang); }; } From 4298415e71ee735902b4312661c46e8e08ebb46c Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 5 Oct 2014 11:09:34 -0400 Subject: [PATCH 042/153] Add aliases for existing languages --- js/language/coffeescript.js | 3 +++ js/language/css.js | 2 ++ js/language/html.js | 2 ++ js/language/javascript.js | 3 +++ 4 files changed, 10 insertions(+) diff --git a/js/language/coffeescript.js b/js/language/coffeescript.js index ecf082e0..a0404976 100644 --- a/js/language/coffeescript.js +++ b/js/language/coffeescript.js @@ -123,3 +123,6 @@ Rainbow.extend('coffeescript', [ 'pattern': /\b(new)\s(.*?)(?=\s)/g } ]); + +Rainbow.addAlias('coffee', 'coffeescript'); + diff --git a/js/language/css.js b/js/language/css.js index e3bc6f53..766ea0ba 100644 --- a/js/language/css.js +++ b/js/language/css.js @@ -70,3 +70,5 @@ Rainbow.extend('css', [ 'pattern': /(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g } ], true); + +Rainbow.addAlias('scss', 'css'); diff --git a/js/language/html.js b/js/language/html.js index 31c80f4b..095497ad 100644 --- a/js/language/html.js +++ b/js/language/html.js @@ -130,3 +130,5 @@ Rainbow.extend('html', [ 'pattern': /\s(\w+)(?=\s|>)(?![\s\S]*<)/g } ], true); + +Rainbow.addAlias('xml', 'html'); diff --git a/js/language/javascript.js b/js/language/javascript.js index 7a1a2260..6caae39f 100644 --- a/js/language/javascript.js +++ b/js/language/javascript.js @@ -91,3 +91,6 @@ Rainbow.extend('javascript', [ 'pattern': /(\w+)(?=:\s{0,}function)/g } ]); + +Rainbow.addAlias('js', 'javascript'); + From c0606aeaf8ea897e206eb8810b6c4d3a1f8df06a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 6 Oct 2014 20:48:06 -0400 Subject: [PATCH 043/153] Add loading class for large code blocks --- js/rainbow.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/rainbow.js b/js/rainbow.js index 40c737c8..7951945d 100644 --- a/js/rainbow.js +++ b/js/rainbow.js @@ -591,6 +591,7 @@ return function _handleResponseFromWorker(data) { element.innerHTML = data.result; element.classList.add('rainbow'); + element.classList.remove('loading'); element.style.opacity = 1; if (onHighlight) { @@ -643,6 +644,11 @@ block.style.transition = Rainbow.transition; + // for long files show a spinner + if (block.innerHTML.length > 20000) { + block.classList.add('loading'); + } + ++waitingOn.c; _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback)); } From 96fab8225927583d41fe21bad5f7a4dac006a21b Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 6 Oct 2014 21:21:15 -0400 Subject: [PATCH 044/153] Move all themes into SASS --- Gruntfile.js | 16 ++++++ package.json | 3 +- themes/css/all-hallows-eve.css | 1 + themes/css/blackboard.css | 1 + themes/css/dreamweaver.css | 1 + themes/css/espresso-libre.css | 1 + themes/css/github.css | 1 + themes/css/kimbie-dark.css | 1 + themes/css/kimbie-light.css | 1 + themes/css/monokai.css | 1 + themes/css/obsidian.css | 1 + themes/css/paraiso-dark.css | 1 + themes/css/paraiso-light.css | 1 + themes/css/pastie.css | 1 + themes/css/solarized-dark.css | 1 + themes/css/solarized-light.css | 1 + themes/css/sunburst.css | 1 + themes/css/tomorrow-night.css | 1 + themes/css/tricolore.css | 1 + themes/css/twilight.css | 1 + themes/css/zenburnesque.css | 1 + themes/sass/_base.sass | 13 +++++ themes/sass/_init.sass | 8 +++ themes/sass/all-hallows-eve.sass | 31 ++++++++++++ themes/sass/blackboard.sass | 46 +++++++++++++++++ themes/sass/dreamweaver.sass | 85 ++++++++++++++++++++++++++++++++ themes/sass/espresso-libre.sass | 48 ++++++++++++++++++ themes/sass/github.sass | 71 ++++++++++++++++++++++++++ themes/sass/kimbie-dark.sass | 33 +++++++++++++ themes/sass/kimbie-light.sass | 33 +++++++++++++ themes/sass/monokai.sass | 58 ++++++++++++++++++++++ themes/sass/obsidian.sass | 51 +++++++++++++++++++ themes/sass/paraiso-dark.sass | 33 +++++++++++++ themes/sass/paraiso-light.sass | 33 +++++++++++++ themes/sass/pastie.sass | 81 ++++++++++++++++++++++++++++++ themes/sass/solarized-dark.sass | 62 +++++++++++++++++++++++ themes/sass/solarized-light.sass | 62 +++++++++++++++++++++++ themes/sass/sunburst.sass | 64 ++++++++++++++++++++++++ themes/sass/tomorrow-night.sass | 33 +++++++++++++ themes/sass/tricolore.sass | 43 ++++++++++++++++ themes/sass/twilight.sass | 59 ++++++++++++++++++++++ themes/sass/zenburnesque.sass | 42 ++++++++++++++++ 42 files changed, 1026 insertions(+), 1 deletion(-) create mode 100644 themes/css/all-hallows-eve.css create mode 100644 themes/css/blackboard.css create mode 100644 themes/css/dreamweaver.css create mode 100644 themes/css/espresso-libre.css create mode 100644 themes/css/github.css create mode 100644 themes/css/kimbie-dark.css create mode 100644 themes/css/kimbie-light.css create mode 100644 themes/css/monokai.css create mode 100644 themes/css/obsidian.css create mode 100644 themes/css/paraiso-dark.css create mode 100644 themes/css/paraiso-light.css create mode 100644 themes/css/pastie.css create mode 100644 themes/css/solarized-dark.css create mode 100644 themes/css/solarized-light.css create mode 100644 themes/css/sunburst.css create mode 100644 themes/css/tomorrow-night.css create mode 100644 themes/css/tricolore.css create mode 100644 themes/css/twilight.css create mode 100644 themes/css/zenburnesque.css create mode 100644 themes/sass/_base.sass create mode 100644 themes/sass/_init.sass create mode 100644 themes/sass/all-hallows-eve.sass create mode 100644 themes/sass/blackboard.sass create mode 100644 themes/sass/dreamweaver.sass create mode 100644 themes/sass/espresso-libre.sass create mode 100644 themes/sass/github.sass create mode 100644 themes/sass/kimbie-dark.sass create mode 100644 themes/sass/kimbie-light.sass create mode 100644 themes/sass/monokai.sass create mode 100644 themes/sass/obsidian.sass create mode 100644 themes/sass/paraiso-dark.sass create mode 100644 themes/sass/paraiso-light.sass create mode 100644 themes/sass/pastie.sass create mode 100644 themes/sass/solarized-dark.sass create mode 100644 themes/sass/solarized-light.sass create mode 100644 themes/sass/sunburst.sass create mode 100644 themes/sass/tomorrow-night.sass create mode 100644 themes/sass/tricolore.sass create mode 100644 themes/sass/twilight.sass create mode 100644 themes/sass/zenburnesque.sass diff --git a/Gruntfile.js b/Gruntfile.js index a19a792e..98288fe4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,6 +15,21 @@ module.exports = function(grunt) { } }, + sass: { + dist: { + options: { + style: 'compressed' + }, + files: [{ + expand: true, + src: ['themes/sass/*.sass'], + dest: 'themes/css', + flatten: true, + ext: '.css' + }] + } + }, + complexity: { options: { errorsOnly: false, @@ -32,6 +47,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-complexity'); grunt.loadNpmTasks('grunt-mocha'); + grunt.loadNpmTasks('grunt-contrib-sass'); grunt.registerTask('default', [ 'complexity', diff --git a/package.json b/package.json index 99a24e2a..a9766065 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "devDependencies": { "grunt": "~0.4.1", "grunt-complexity": "~0.1.2", - "grunt-mocha": "~0.3.1" + "grunt-mocha": "~0.3.1", + "grunt-contrib-sass": "^0.8.1" }, "dependencies": { "webworker-threads": "^0.5.1" diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css new file mode 100644 index 00000000..49d707a9 --- /dev/null +++ b/themes/css/all-hallows-eve.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre .comment{color:#93c}pre .constant{color:#3387cc}pre .storage{color:#cc7833}pre .string{color:#6c3}pre .keyword,pre .selector{color:#cc7833}pre .inherited-class{font-style:italic}pre .support{color:#c83730} diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css new file mode 100644 index 00000000..37427f17 --- /dev/null +++ b/themes/css/blackboard.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#0b1022}pre .comment{color:#727272}pre .constant{color:#d8fa3c}pre .storage{color:#fbde2d}pre .string,pre .comment.docstring{color:#61ce3c}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#fbde2d}pre .inherited-class{font-style:italic}pre .entity{color:#ff6400}pre .support{color:#8da6ce}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ff6400}*[data-language="c"] .function.call{color:#8da6ce} diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css new file mode 100644 index 00000000..b3c85ac2 --- /dev/null +++ b/themes/css/dreamweaver.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css new file mode 100644 index 00000000..0efdef61 --- /dev/null +++ b/themes/css/espresso-libre.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#06f;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} diff --git a/themes/css/github.css b/themes/css/github.css new file mode 100644 index 00000000..e614ba0c --- /dev/null +++ b/themes/css/github.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0px;padding:0px;margin:0px;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas,"Liberation Mono",Courier,monospace;color:#333;background:#f8f8f8;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086b3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css new file mode 100644 index 00000000..0f374055 --- /dev/null +++ b/themes/css/kimbie-dark.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css new file mode 100644 index 00000000..127da369 --- /dev/null +++ b/themes/css/kimbie-light.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/monokai.css b/themes/css/monokai.css new file mode 100644 index 00000000..be77a4bb --- /dev/null +++ b/themes/css/monokai.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#272822}pre .comment{color:#75715e}pre .constant{color:#ae81ff}pre .storage{color:#66d9ef}pre .string,pre .comment.docstring{color:#e6db74}pre .support.tag{color:#fff}pre .keyword{color:#f92672}pre .selector{color:#f92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#f92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#a6e22e}pre .support,pre *[data-language="c"] .function.call{color:#66d9ef}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#a6e22e}*[data-language="html"] .support.operator{color:#fff} diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css new file mode 100644 index 00000000..52ef1f06 --- /dev/null +++ b/themes/css/obsidian.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#22282a;color:#f1f2f3}pre .comment{color:#66747b}pre .constant{color:#ec7600}pre .storage{color:#ec7600}pre .string,pre .comment.docstring{color:#ec7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93c763}pre .inherited-class{font-style:italic}pre .entity{color:#93c763}pre .integer{color:#ffcd22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ccc}pre .preprocessor{color:#66747b}pre .support,*[data-language="csharp"] .function.call{color:#facd22} diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css new file mode 100644 index 00000000..4b6580d3 --- /dev/null +++ b/themes/css/paraiso-dark.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css new file mode 100644 index 00000000..8fbdc18a --- /dev/null +++ b/themes/css/paraiso-light.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/pastie.css b/themes/css/pastie.css new file mode 100644 index 00000000..06cc9bb9 --- /dev/null +++ b/themes/css/pastie.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#f8f8ff;border:1px solid #dedede;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#b06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00d;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#d20;background-color:#fff0f0}pre .string.regexp,code .string.regexp{background-color:#fff0ff;color:#808}pre .variable.instance,code .variable.instance{color:#33b}pre .entity.name.function,code .entity.name.function{color:#06b;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#c00;font-weight:bold} diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css new file mode 100644 index 00000000..9543530e --- /dev/null +++ b/themes/css/solarized-dark.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css new file mode 100644 index 00000000..f6872684 --- /dev/null +++ b/themes/css/solarized-light.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css new file mode 100644 index 00000000..924c77ee --- /dev/null +++ b/themes/css/sunburst.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre .comment{color:#aeaeae;font-style:italic}pre .constant{color:#3387cc}pre .storage{color:#99cf50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65b042}pre .string.regexp{color:#e9c062}pre .string.constant{color:#ddf2a4}pre .constant.hex-color{color:#dd7b3b}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#c5af75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#e28964}pre .keyword.namespace{color:#3387cc;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89bdff}pre .entity.name.id{color:#8693a5}pre .variable,pre .variable.global{color:#3e87e3}*[data-language="c"] .function.call{color:#8da6ce} diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css new file mode 100644 index 00000000..5bc727c6 --- /dev/null +++ b/themes/css/tomorrow-night.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css new file mode 100644 index 00000000..2a8f1b04 --- /dev/null +++ b/themes/css/tricolore.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#fff;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7e7e7e;font-style:italic}pre .constant{color:#18838a;font-weight:bold}pre .storage{color:#0000a1}pre .string{color:#8e0022}pre .keyword,pre .selector{color:#0000a1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3e853f}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3e853f} diff --git a/themes/css/twilight.css b/themes/css/twilight.css new file mode 100644 index 00000000..6cb7c146 --- /dev/null +++ b/themes/css/twilight.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#141414;color:#f8f8f8}pre .comment{color:#5f5a60}pre .constant.numeric{color:#d87d50}pre .constant{color:#889ab4}pre .constant.symbol,pre .constant.language{color:#d87d50}pre .storage{color:#f9ee98}pre .string{color:#8f9d6a}pre .string.regexp{color:#e9c062}pre .keyword,pre .selector,pre .storage{color:#cda869}pre .inherited-class{color:#9b5c2e}pre .entity{color:#ff6400}pre .support{color:#9b859d}pre .support.magic{color:#dad69a}pre .variable{color:#7587a6}pre .function,pre .entity.class{color:#9b703f}pre .support.class-name,pre .support.type{color:#ab99ac} diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css new file mode 100644 index 00000000..edc1b1e6 --- /dev/null +++ b/themes/css/zenburnesque.css @@ -0,0 +1 @@ +.js [data-language] code,.js pre [data-language]{opacity:0}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22c0ff}pre .storage{color:#6080ff}pre .string{color:#ff2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#f09040}pre .support{color:#c83730}pre .variable.class{color:#ff8000} diff --git a/themes/sass/_base.sass b/themes/sass/_base.sass new file mode 100644 index 00000000..d34867ef --- /dev/null +++ b/themes/sass/_base.sass @@ -0,0 +1,13 @@ +@import "_init.sass" + +pre + background-color: #000 + word-wrap: break-word + margin: 0px + padding: 10px + color: #fff + font-size: 14px + margin-bottom: 20px + +pre, code + font-family: 'Monaco', courier, monospace diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass new file mode 100644 index 00000000..74dce539 --- /dev/null +++ b/themes/sass/_init.sass @@ -0,0 +1,8 @@ +.js [data-language] code, .js pre [data-language] + opacity: 0 + +@mixin border-radius($args) + border-radius: $args + -moz-border-radius: $args + -webkit-border-radius: $args + diff --git a/themes/sass/all-hallows-eve.sass b/themes/sass/all-hallows-eve.sass new file mode 100644 index 00000000..9732384d --- /dev/null +++ b/themes/sass/all-hallows-eve.sass @@ -0,0 +1,31 @@ +/** + * All Hallows Eve theme + * + * Adapted from Ultraviolet RubyGem + * + * @author Flinn Mueller + * @version 1.0.1 + */ +@import "_base.sass" + +pre + .comment + color: #9933CC + + .constant + color: #3387CC + + .storage + color: #CC7833 + + .string + color: #66CC33 + + .keyword, .selector + color: #CC7833 + + .inherited-class + font-style: italic + + .support + color: #C83730 diff --git a/themes/sass/blackboard.sass b/themes/sass/blackboard.sass new file mode 100644 index 00000000..1b79696b --- /dev/null +++ b/themes/sass/blackboard.sass @@ -0,0 +1,46 @@ +/** + * Blackboard theme + * + * Adapted from Domenico Carbotta's TextMate theme of the same name + * + * @author Domenico Carbotta + * @author Craig Campbell + * @version 1.0.2 + */ +@import "_base.sass" + +pre + background: #0B1022 + + .comment + color: #727272 + + .constant + color: #D8FA3C + + .storage + color: #FBDE2D + + .string, .comment.docstring + color: #61CE3C + + .string.regexp, .support.tag.script, .support.tag.style + color: #fff + + .keyword, .selector + color: #FBDE2D + + .inherited-class + font-style: italic + + .entity + color: #FF6400 + + .support + color: #8DA6CE + + .variable.global, .variable.class, .variable.instance + color: #FF6400 + +*[data-language="c"] .function.call + color: #8DA6CE diff --git a/themes/sass/dreamweaver.sass b/themes/sass/dreamweaver.sass new file mode 100644 index 00000000..c67a2b38 --- /dev/null +++ b/themes/sass/dreamweaver.sass @@ -0,0 +1,85 @@ +/** + * Dreamweaver theme + * + * @author Sean Coker + * @url http://seancoker.com + * @version 1.0 + */ +@import "_base.sass" + +pre, code + font-family: monospace + +pre + /* original is white background with no border */ + background-color: #fff + color: #000 + font-size: 13px + line-height: 16px + + .comment + color: #888 + + .support + color: #cd57d5 + + .constant.numeric, .php.embedded + color: #fa0002 + font-weight: bold + + .keyword, .constant.language + color: #000789 + font-weight: bold + + .selector, .support.property, .entity.name.function + color: #000 + + .storage.function, .variable.self, .support.function, .constant.language + color: #000 + font-weight: bold + + .string + color: #0d43fa + font-weight: normal + + .css-property + span, .keyword.unit, .support.css-value + color: #0d43fa !important + font-weight: normal !important + + .entity.tag.style + .string, .php.embedded .constant.language, .php.embedded .keyword + color: #37a348 !important + + .support.method + color: #2bd5bb + + .entity.name + color: #fd74e0 + + .support.css-property, .support.tag-name, .support.tag, .support.attribute, .support.attribute + .operator + color: #000789 + + .storage.module, .storage.class + color: #122573 + font-weight: bold + + .css.embedded .support.tag, .css.embedded .style.tag + color: #cd57d5 + + .keyword.operator + color: #2852eb + font-weight: normal + + .php.embedded .variable, .php.embedded .storage.function + color: #0d43fa + font-weight: normal + + .php.embedded .string, .js.embedded .tag.script + color: #c4001e + + .php.embedded .comment + color: #f4b441 + font-weight: normal + + .php.embedded .function.name + color: #000 + font-weight: normal diff --git a/themes/sass/espresso-libre.sass b/themes/sass/espresso-libre.sass new file mode 100644 index 00000000..216da009 --- /dev/null +++ b/themes/sass/espresso-libre.sass @@ -0,0 +1,48 @@ +/** + * Espresso Libre theme + * + * Adapted from Ultraviolet RubyGem + * + * @author Flinn Mueller + * @version 1.0 + */ +@import "_base.sass" + +pre + background-color: #2a211c + color: #bdae9d + + .support.class, .support.type + color: #6d79de + + .support.constant + color: #00af0e + + .constant.language + color: #585cf6 + + .support.function + font-weight: bold + color: #7290d9 + + .string + color: #049b0a + + .constant.numeric + color: #44aa43 + + .keyword, .storage + color: #43a8ed + + .entity.function + color: #ff9358 + + .comment + color: #0066ff + font-style: italic + + .constant.symbol + color: #c5656b + + .variable.instance, .variable.language, .constant + color: #318495 diff --git a/themes/sass/github.sass b/themes/sass/github.sass new file mode 100644 index 00000000..a7814f5e --- /dev/null +++ b/themes/sass/github.sass @@ -0,0 +1,71 @@ +/** + * GitHub theme + * + * @author Craig Campbell + * @version 1.0.4 + */ +@import "_init.sass" + +pre + border: 1px solid #ccc + word-wrap: break-word + padding: 6px 10px + line-height: 19px + margin-bottom: 20px + + code + border: 0px + padding: 0px + margin: 0px + @include border-radius(0px) + +code + border: 1px solid #eaeaea + margin: 0px 2px + padding: 0px 5px + font-size: 12px + +pre, code + font-family: Consolas, 'Liberation Mono', Courier, monospace + color: #333 + background: #f8f8f8 + @include border-radius(3px) + +pre, pre code + font-size: 13px + +pre + .comment + color: #998 + + .support + color: #0086B3 + + .tag, .tag-name + color: navy + + .keyword, .css-property, .vendor-fix, .sass, .class, .id, .css-value, .entity.function, .storage.function + font-weight: bold + + .css-property, .css-value, .vendor-fix, .support.namespace + color: #333 + + .constant.numeric, .keyword.unit, .hex-color + font-weight: normal + color: #099 + + .entity.class + color: #458 + + .entity.id, .entity.function + color: #900 + + .attribute, .variable + color: teal + + .string, .support.value + font-weight: normal + color: #d14 + + .regexp + color: #009926 diff --git a/themes/sass/kimbie-dark.sass b/themes/sass/kimbie-dark.sass new file mode 100644 index 00000000..0726cc94 --- /dev/null +++ b/themes/sass/kimbie-dark.sass @@ -0,0 +1,33 @@ +/** + * Kimbie (Dark) + * + * @author Jan T. Sott + * @version 1.0.0 + * @url http://github.com/idleberg/Kimbie-Rainbow + */ +@import "_base.sass" + +pre + background-color: #221a0f + color: #fbebd4 + + .comment + color: #a57a4c + + .variable.global, .variable.class, .variable.instance + color: #dc3958 /* red */ + + .constant.numeric, .constant.language, .constant.hex-color, .keyword.unit + color: #f79a32 /* orange */ + + .constant, .entity, .entity.class, .support + color: #f06431 /* yellow */ + + .constant.symbol, .string + color: #889b4a /* green */ + + .entity.function, .support.css-property, .selector + color: #8ab1b0 /* blue */ + + .keyword, .storage + color: #98676a /* purple */ diff --git a/themes/sass/kimbie-light.sass b/themes/sass/kimbie-light.sass new file mode 100644 index 00000000..c4abb73b --- /dev/null +++ b/themes/sass/kimbie-light.sass @@ -0,0 +1,33 @@ +/** + * Kimbie (Light) + * + * @author Jan T. Sott + * @version 1.0.0 + * @url http://github.com/idleberg/Kimbie-Rainbow + */ +@import "_base.sass" + +pre + background-color: #fbebd4 + color: #221a0f + + .comment + color: #d6baad + + .variable.global, .variable.class, .variable.instance + color: #dc3958 /* red */ + + .constant.numeric, .constant.language, .constant.hex-color, .keyword.unit + color: #f79a32 /* orange */ + + .constant, .entity, .entity.class, .support + color: #f06431 /* yellow */ + + .constant.symbol, .string + color: #889b4a /* green */ + + .entity.function, .support.css-property, .selector + color: #8ab1b0 /* blue */ + + .keyword, .storage + color: #98676a /* purple */ diff --git a/themes/sass/monokai.sass b/themes/sass/monokai.sass new file mode 100644 index 00000000..744e4d8b --- /dev/null +++ b/themes/sass/monokai.sass @@ -0,0 +1,58 @@ +/** + * Monokai theme + * + * Adapted from Wimer Hazenberg's TextMate theme of the same name + * + * @author Wimer Hazenberg + * @author Michael Fasani + * @author Craig Campbell + * @version 1.0.0 + */ +@import "_base.sass" + +pre + background: #272822 + + .comment + color: #75715E + + .constant + color: #AE81FF + + .storage + color: #66D9EF + + .string, .comment.docstring + color: #E6DB74 + + .support.tag + color: #fff + + .keyword + /* @todo some keywords use this light blue, most use the pink */ + /*color: #66D9EF*/ + color: #F92672 + + .selector + color: #F92672 + + .inherited-class + font-style: italic + + .operator, .support.tag-name, .entity.tag + color: #F92672 + + .entity, .support.attribute, .entity.attribute + color: #A6E22E + + .support, *[data-language="c"] .function.call + color: #66D9EF + + .css-property, .storage.function + font-style: italic + + .variable.global, .variable.class, .variable.instance + color: #A6E22E + +*[data-language="html"] .support.operator + color: #fff diff --git a/themes/sass/obsidian.sass b/themes/sass/obsidian.sass new file mode 100644 index 00000000..2c67e253 --- /dev/null +++ b/themes/sass/obsidian.sass @@ -0,0 +1,51 @@ +/** + * Obsidian theme + * + * Adapted from a theme based on: + * http://studiostyl.es/schemes/son-of-obsidian + * + * @author Dan Stewart + * @version 1.0 + */ +@import "_base.sass" + +pre + background: #22282A + color: #F1F2F3 + + .comment + color: #66747B + + .constant + color: #EC7600 + + .storage + color: #EC7600 + + .string, .comment.docstring + color: #EC7600 + + .string.regexp, .support.tag.script, .support.tag.style + color: #fff + + .keyword, .selector + color: #93C763 + + .inherited-class + font-style: italic + + .entity + color: #93C763 + + .integer + color: #FFCD22 + + .variable.global, .variable.class, .variable.instance + color: #CCC + + /* C# specific rule */ + .preprocessor + color: #66747B + +pre .support, *[data-language="csharp"] .function.call + color: #FACD22 diff --git a/themes/sass/paraiso-dark.sass b/themes/sass/paraiso-dark.sass new file mode 100644 index 00000000..2add959d --- /dev/null +++ b/themes/sass/paraiso-dark.sass @@ -0,0 +1,33 @@ +/** + * Paraíso (Dark) + * + * @author Jan T. Sott + * @version 1.0.0 + * @url http://github.com/idleberg/Paraiso-Rainbow + */ +@import "_base.sass" + +pre + background-color: #2f1e2e + color: #e7e9db + + .comment + color: #776e71 + + .variable.global, .variable.class, .variable.instance + color: #ef6155 /* red */ + + .constant.numeric, .constant.language, .constant.hex-color, .keyword.unit + color: #f99b15 /* orange */ + + .constant, .entity, .entity.class, .support + color: #fec418 /* yellow */ + + .constant.symbol, .string + color: #48b685 /* green */ + + .entity.function, .support.css-property, .selector + color: #06b6ef /* blue */ + + .keyword, .storage + color: #815ba4 /* purple */ diff --git a/themes/sass/paraiso-light.sass b/themes/sass/paraiso-light.sass new file mode 100644 index 00000000..645241f1 --- /dev/null +++ b/themes/sass/paraiso-light.sass @@ -0,0 +1,33 @@ +/** + * Paraíso (Light) + * + * @author Jan T. Sott + * @version 1.0.0 + * @url http://github.com/idleberg/Paraiso-Rainbow + */ +@import "_base.sass" + +pre + background-color: #e7e9db + color: #2f1e2e + + .comment + color: #8d8687 + + .variable.global, .variable.class, .variable.instance + color: #ef6155 /* red */ + + .constant.numeric, .constant.language, .constant.hex-color, .keyword.unit + color: #f99b15 /* orange */ + + .constant, .entity, .entity.class, .support + color: #fec418 /* yellow */ + + .constant.symbol, .string + color: #48b685 /* green */ + + .entity.function, .support.css-property, .selector + color: #06b6ef /* blue */ + + .keyword, .storage + color: #815ba4 /* purple */ diff --git a/themes/sass/pastie.sass b/themes/sass/pastie.sass new file mode 100644 index 00000000..b2dabdd2 --- /dev/null +++ b/themes/sass/pastie.sass @@ -0,0 +1,81 @@ +/** + * Pastie theme + * + * @author pygments.org + * @author pastie.org + * @author Simon Potter + * @version 1.0 + */ +@import "_base.sass" + +pre + /* original is white background with no border */ + background-color: #F8F8FF + border: 1px solid #DEDEDE + color: #000 + font-size: 13px + line-height: 16px + +pre, code + font-family: monospace + + .comment + color: #888 + + .keyword, .selector, .storage.module, .storage.class, .storage.function + color: #080 + font-weight: bold + + .keyword.operator + color: #000 + font-weight: normal + + .constant.language + color: #038 + font-weight: bold + + .constant.symbol, .class, .constant + color: #036 + font-weight: bold + + .keyword.namespace, .entity.name.class + color: #B06 + font-weight: bold + + .constant.numeric + color: #00D + font-weight: bold + + .string, .comment.docstring + color: #D20 + background-color: #FFF0F0 + + .string.regexp + background-color: #FFF0FF + color: #808 + + .variable.instance + color: #33B + + .entity.name.function + color: #06B + font-weight: bold + + .support.tag-name, .entity.tag.script, .entity.tag.style + color: #070 + + .support.attribute + color: #007 + font-style: italic + + .entity.name.tag, .storage.type + color: #070 + font-weight: bold + + .variable.self, .support.function + color: #038 + font-weight: bold + + .entity.function, .support.magic, &.support.method + color: #C00 + font-weight: bold diff --git a/themes/sass/solarized-dark.sass b/themes/sass/solarized-dark.sass new file mode 100644 index 00000000..ddc7afa5 --- /dev/null +++ b/themes/sass/solarized-dark.sass @@ -0,0 +1,62 @@ +/** + * Solarized Dark theme + * + * Adaptation of Solarized Dark from ethanschoonover.com/solarized + * + * @author Ethan Schoonover + * @author David Litmark + * @version 1.0.0 + */ +@import "_base.sass" + +pre + background: #002b36 /* base03 */ + color: #839496 /* base0 */ + + .comment + color: #586e75 /* base01 */ + + .constant + color: #839496 /* base0 */ + + .constant.language + color: #268bd2 /* blue */ + + .constant.regexp + color: #2aa198 /* cyan */ + + .storage + color: #268bd2 /* blue */ + + .string, .comment.docstring + color: #2aa198 /* cyan */ + + .support.tag.script, .support.tag.style + color: #2aa198 /* cyan */ + + .string.regexp + color: #2aa198 /* cyan */ + + .string.regexp.open, .string.regexp.close + color: #2aa198 /* cyan */ + + .keyword, .selector + color: #859900 /* green */ + + .inherited-class + font-style: italic + + .entity + color: #b58900 /* yellow */ + + .support.method + color: #839496 /* base0 */ + + .support.property + color: #839496 /* base0 */ + + .variable.global, .variable.class, .variable.instance + color: #839496 /* base0 */ + +pre .support, *[data-language="c"] .function.call + color: #859900 /* green */ diff --git a/themes/sass/solarized-light.sass b/themes/sass/solarized-light.sass new file mode 100644 index 00000000..655d1f3a --- /dev/null +++ b/themes/sass/solarized-light.sass @@ -0,0 +1,62 @@ +/** + * Solarized Light theme + * + * Adaptation of Solarized Light from ethanschoonover.com/solarized + * + * @author Ethan Schoonover + * @author David Litmark + * @version 1.0.0 + */ +@import "_base.sass" + +pre + background: #fdf6e3 /* base3 */ + color: #657b83 /* base00 */ + + .comment + color: #93a1a1 /* base1 */ + + .constant + color: #657b83 /* base00 */ + + .constant.language + color: #268bd2 /* blue */ + + .constant.regexp + color: #2aa198 /* cyan */ + + .storage + color: #268bd2 /* blue */ + + .string, .comment.docstring + color: #2aa198 /* cyan */ + + .support.tag.script, .support.tag.style + color: #2aa198 /* cyan */ + + .string.regexp + color: #2aa198 /* cyan */ + + .string.regexp.open, .string.regexp.close + color: #2aa198 /* cyan */ + + .keyword, .selector + color: #859900 /* green */ + + .inherited-class + font-style: italic + + .entity + color: #b58900 /* yellow */ + + .support.method + color: #657b83 /* base00 */ + + .support.property + color: #657b83 /* base00 */ + + .variable.global, .variable.class, .variable.instance + color: #657b83 /* base00 */ + +pre .support, *[data-language="c"] .function.call + color: #859900 /* green */ diff --git a/themes/sass/sunburst.sass b/themes/sass/sunburst.sass new file mode 100644 index 00000000..1285e9f8 --- /dev/null +++ b/themes/sass/sunburst.sass @@ -0,0 +1,64 @@ +/** + * Sunburst theme + * + * Adapted from the Textmate Sunburst theme by Stanley Rost + * + * @author Stanley Rost + * @author Rachel Baker + * @version 1.0.0 + */ +@import "_base.sass" + +pre + .comment + color: #AEAEAE + font-style: italic + + .constant + color: #3387CC + + .storage + color: #99CF50 + + .string, .entity.name.class, .comment.docstring + color: #65B042 /* green */ + + .string.regexp + color: #E9C062 + + .string.constant + color: #DDF2A4 + + .constant.hex-color + color: #DD7B3B /* orange */ + + .support, .tag.script, .function.call + color: #dad085 + + .support.css-property + color: #C5AF75 + + .support.tag.style + color: #fff + + .keyword, .selector + color: #E28964 /* dark pink */ + + .keyword.namespace + color: #3387CC + font-weight: bold + + .inherited-class + font-style: italic + + .entity, .variable.instance, .support.namespace, .support.tag, .support.tag-name + color: #89BDFF + + .entity.name.id + color: #8693A5 + + .variable, .variable.global + color: #3E87E3 + +*[data-language="c"] .function.call + color: #8DA6CE diff --git a/themes/sass/tomorrow-night.sass b/themes/sass/tomorrow-night.sass new file mode 100644 index 00000000..8de78a7d --- /dev/null +++ b/themes/sass/tomorrow-night.sass @@ -0,0 +1,33 @@ +/** + * Tomorrow Night theme + * + * @author Chris Kempson + * @author skim + * @version 1.0.0 + */ +@import "_base.sass" + +pre + background-color: #1d1f21 + color: #c5c8c6 + + .comment + color: #969896 + + .variable.global, .variable.class, .variable.instance + color: #cc6666 /* red */ + + .constant.numeric, .constant.language, .constant.hex-color, .keyword.unit + color: #de935f /* orange */ + + .constant, .entity, .entity.class, .support + color: #f0c674 /* yellow */ + + .constant.symbol, .string + color: #b5bd68 /* green */ + + .entity.function, .support.css-property, .selector + color: #81a2be /* blue */ + + .keyword, .storage + color: #b294bb /* purple */ diff --git a/themes/sass/tricolore.sass b/themes/sass/tricolore.sass new file mode 100644 index 00000000..203db7ce --- /dev/null +++ b/themes/sass/tricolore.sass @@ -0,0 +1,43 @@ +/** + * Tricolore theme + * + * @author Jean Nicolas + * @version 1.0.1 + */ +@import "_base.sass" + +pre + background: #FFF + color: #000 + font-size: 12px + line-height: 16px + + .comment + color: #7E7E7E + font-style: italic + + .constant + color: #18838A + font-weight: bold + + .storage + color: #0000A1 + + .string + color: #8E0022 + + .keyword, .selector + color: #0000A1 + font-weight: bold + + .inherited-class + font-style: italic + + .entity + color: #3E853F + + .support + color: #192140 + + .variable.global, .variable.class, .variable.instance + color: #3E853F diff --git a/themes/sass/twilight.sass b/themes/sass/twilight.sass new file mode 100644 index 00000000..192d9c8c --- /dev/null +++ b/themes/sass/twilight.sass @@ -0,0 +1,59 @@ +/** + * Twilight theme + * + * Adapted from Michael Sheets' TextMate theme of the same name + * + * @author Michael Sheets + * @author Jesse Farmer + * @version 1.0.1 + */ +@import "_base.sass" + +pre + background: #141414 + color: #F8F8F8 + + .comment + color: #5F5A60 + + .constant.numeric + color: #D87D50 + + .constant + color: #889AB4 + + .constant.symbol, .constant.language + color: #D87D50 + + .storage + color: #F9EE98 + + .string + color: #8F9D6A + + .string.regexp + color: #E9C062 + + .keyword, .selector, .storage + color: #CDA869 + + .inherited-class + color: #9B5C2E + + .entity + color: #FF6400 + + .support + color: #9B859D + + .support.magic + color: #DAD69A + + .variable + color: #7587A6 + + .function, .entity.class + color: #9B703F + + .support.class-name, .support.type + color: #AB99AC diff --git a/themes/sass/zenburnesque.sass b/themes/sass/zenburnesque.sass new file mode 100644 index 00000000..9cb7f291 --- /dev/null +++ b/themes/sass/zenburnesque.sass @@ -0,0 +1,42 @@ +/** + * Zenburnesque theme + * + * Adapted from Ultraviolet RubyGem + * + * @author Flinn Mueller + * @version 1.0 + */ +@import "_base.sass" + +pre + background: #404040 + color: #dedede + + .comment + color: #709070 + font-style: italic + + .integer + color: #22C0FF + + .storage + color: #6080FF + + /* This includes regexes */ + .string + color: #FF2020 + + .keyword, .selector + color: #ffffa0 + + .inherited-class + font-style: italic + + .entity + color: #F09040 + + .support + color: #C83730 + + .variable.class + color: #FF8000 From 839e42e1b8c37e016de4bf6cee3b522768dd171a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 6 Oct 2014 21:21:58 -0400 Subject: [PATCH 045/153] Remove older css themes --- themes/all-hallows-eve.css | 49 ----------------- themes/blackboard.css | 62 --------------------- themes/dreamweaver.css | 109 ------------------------------------- themes/espresso-libre.css | 67 ----------------------- themes/github.css | 88 ------------------------------ themes/kimbie-dark.css | 48 ---------------- themes/kimbie-light.css | 48 ---------------- themes/monokai.css | 81 --------------------------- themes/obsidian.css | 72 ------------------------ themes/paraiso-dark.css | 48 ---------------- themes/paraiso-light.css | 48 ---------------- themes/pastie.css | 102 ---------------------------------- themes/solarized-dark.css | 86 ----------------------------- themes/solarized-light.css | 86 ----------------------------- themes/sunburst.css | 94 -------------------------------- themes/tomorrow-night.css | 48 ---------------- themes/tricolore.css | 59 -------------------- themes/twilight.css | 82 ---------------------------- themes/zenburnesque.css | 59 -------------------- 19 files changed, 1336 deletions(-) delete mode 100644 themes/all-hallows-eve.css delete mode 100644 themes/blackboard.css delete mode 100644 themes/dreamweaver.css delete mode 100644 themes/espresso-libre.css delete mode 100644 themes/github.css delete mode 100644 themes/kimbie-dark.css delete mode 100644 themes/kimbie-light.css delete mode 100644 themes/monokai.css delete mode 100644 themes/obsidian.css delete mode 100644 themes/paraiso-dark.css delete mode 100644 themes/paraiso-light.css delete mode 100644 themes/pastie.css delete mode 100644 themes/solarized-dark.css delete mode 100644 themes/solarized-light.css delete mode 100644 themes/sunburst.css delete mode 100644 themes/tomorrow-night.css delete mode 100644 themes/tricolore.css delete mode 100644 themes/twilight.css delete mode 100644 themes/zenburnesque.css diff --git a/themes/all-hallows-eve.css b/themes/all-hallows-eve.css deleted file mode 100644 index f06a33f3..00000000 --- a/themes/all-hallows-eve.css +++ /dev/null @@ -1,49 +0,0 @@ -/** - * All Hallows Eve theme - * - * Adapted from Ultraviolet RubyGem - * - * @author Flinn Mueller - * @version 1.0.1 - */ -pre { - background: #000; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #fff; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #9933CC; -} - -pre .constant { - color: #3387CC; -} - -pre .storage { - color: #CC7833; -} - -pre .string { - color: #66CC33; -} - -pre .keyword, pre .selector { - color: #CC7833; -} - -pre .inherited-class { - font-style: italic; -} - -pre .support { - color: #C83730; -} diff --git a/themes/blackboard.css b/themes/blackboard.css deleted file mode 100644 index 68fe5158..00000000 --- a/themes/blackboard.css +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Blackboard theme - * - * Adapted from Domenico Carbotta's TextMate theme of the same name - * - * @author Domenico Carbotta - * @author Craig Campbell - * @version 1.0.2 - */ -pre { - background: #0B1022; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #fff; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #727272; -} - -pre .constant { - color: #D8FA3C; -} - -pre .storage { - color: #FBDE2D; -} - -pre .string, pre .comment.docstring { - color: #61CE3C; -} - -pre .string.regexp, pre .support.tag.script, pre .support.tag.style { - color: #fff; -} - -pre .keyword, pre .selector { - color: #FBDE2D; -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #FF6400; -} - -pre .support, *[data-language="c"] .function.call { - color: #8DA6CE; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #FF6400; -} diff --git a/themes/dreamweaver.css b/themes/dreamweaver.css deleted file mode 100644 index 16081639..00000000 --- a/themes/dreamweaver.css +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Dreamweaver theme - * - * @author Sean Coker - * @url http://seancoker.com - * @version 1.0 - */ - -pre { - /* original is white background with no border */ - background-color: #fff; - word-wrap: break-word; - margin: 0; - padding: 10px; - color: #000; - font-size: 13px; - line-height: 16px; - margin-bottom: 20px -} - -pre, code { - font-family: monospace; -} - -pre .comment { - color: #888; -} - -pre .support { - color: #cd57d5; -} - -pre .constant.numeric, pre .php.embedded { - color: #fa0002; - font-weight: bold; -} - -pre .keyword, pre .constant.language { - color: #000789; - font-weight: bold; -} - -pre .selector, pre .support.property, pre .entity.name.function { - color: #000; -} - -pre .storage.function, pre .variable.self, pre .support.function, pre .constant.language { - color: #000; - font-weight: bold; -} - -pre .string { - color: #0d43fa; - font-weight: normal; -} - -pre .css-property + span, pre .keyword.unit, pre .support.css-value { - color: #0d43fa !important; - font-weight: normal !important; -} - -pre .entity.tag.style + .string, pre .php.embedded .constant.language, pre .php.embedded .keyword { - color: #37a348 !important; -} - -pre .support.method { - color: #2bd5bb; -} - -pre .entity.name { - color: #fd74e0; -} - -pre .support.css-property, pre .support.tag-name, pre .support.tag, pre .support.attribute, pre .support.attribute + .operator { - color: #000789; -} - -pre .storage.module, pre .storage.class { - color: #122573; - font-weight: bold; -} - -pre .css.embedded .support.tag, pre .css.embedded .style.tag { - color: #cd57d5; -} - -pre .keyword.operator { - color: #2852eb; - font-weight: normal; -} - -pre .php.embedded .variable, pre .php.embedded .storage.function { - color: #0d43fa; - font-weight: normal; -} - -pre .php.embedded .string, pre .js.embedded .tag.script { - color: #c4001e; -} - -pre .php.embedded .comment { - color: #f4b441; - font-weight: normal; -} - -pre .php.embedded .function.name { - color: #000; - font-weight: normal; -} diff --git a/themes/espresso-libre.css b/themes/espresso-libre.css deleted file mode 100644 index a9ee2d9a..00000000 --- a/themes/espresso-libre.css +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Espresso Libre theme - * - * Adapted from Ultraviolet RubyGem - * - * @author Flinn Mueller - * @version 1.0 - */ -pre { - background-color: #2a211c; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #bdae9d; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .support.class, pre .support.type { - color: #6d79de; -} - -pre .support.constant { - color: #00af0e; -} - -pre .constant.language { - color: #585cf6; -} - -pre .support.function { - font-weight: bold; - color: #7290d9; -} - -pre .string { - color: #049b0a; -} - -pre .constant.numeric { - color: #44aa43; -} - -pre .keyword, pre .storage { - color: #43a8ed; -} - -pre .entity.function { - color: #ff9358; -} - -pre .comment { - color: #0066ff; - font-style: italic; -} - -pre .constant.symbol { - color:#c5656b; -} - -pre .variable.instance, pre .variable.language, pre .constant { - color: #318495; -} diff --git a/themes/github.css b/themes/github.css deleted file mode 100644 index 088f0657..00000000 --- a/themes/github.css +++ /dev/null @@ -1,88 +0,0 @@ -/** - * GitHub theme - * - * @author Craig Campbell - * @version 1.0.4 - */ -pre { - border: 1px solid #ccc; - word-wrap: break-word; - padding: 6px 10px; - line-height: 19px; - margin-bottom: 20px; -} - -code { - border: 1px solid #eaeaea; - margin: 0px 2px; - padding: 0px 5px; - font-size: 12px; -} - -pre code { - border: 0px; - padding: 0px; - margin: 0px; - -moz-border-radius: 0px; - -webkit-border-radius: 0px; - border-radius: 0px; -} - -pre, code { - font-family: Consolas, 'Liberation Mono', Courier, monospace; - color: #333; - background: #f8f8f8; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} - -pre, pre code { - font-size: 13px; -} - -pre .comment { - color: #998; -} - -pre .support { - color: #0086B3; -} - -pre .tag, pre .tag-name { - color: navy; -} - -pre .keyword, pre .css-property, pre .vendor-prefix, pre .sass, pre .class, pre .id, pre .css-value, pre .entity.function, pre .storage.function { - font-weight: bold; -} - -pre .css-property, pre .css-value, pre .vendor-prefix, pre .support.namespace { - color: #333; -} - -pre .constant.numeric, pre .keyword.unit, pre .hex-color { - font-weight: normal; - color: #099; -} - -pre .entity.class { - color: #458; -} - -pre .entity.id, pre .entity.function { - color: #900; -} - -pre .attribute, pre .variable { - color: teal; -} - -pre .string, pre .support.value { - font-weight: normal; - color: #d14; -} - -pre .regexp { - color: #009926; -} diff --git a/themes/kimbie-dark.css b/themes/kimbie-dark.css deleted file mode 100644 index f3d7140f..00000000 --- a/themes/kimbie-dark.css +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Kimbie (Dark) - * - * @author Jan T. Sott - * @version 1.0.0 - * @url http://github.com/idleberg/Kimbie-Rainbow - */ -pre { - background-color: #221a0f; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #fbebd4; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #a57a4c; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #dc3958; /* red */ -} - -pre .constant.numeric, pre .constant.language, pre .constant.hex-color, pre .keyword.unit { - color: #f79a32; /* orange */ -} - -pre .constant, pre .entity, pre .entity.class, pre .support { - color: #f06431; /* yellow */ -} - -pre .constant.symbol, pre .string { - color: #889b4a; /* green */ -} - -pre .entity.function, pre .support.css-property, pre .selector { - color: #8ab1b0; /* blue */ -} - -pre .keyword, pre .storage { - color: #98676a; /* purple */ -} diff --git a/themes/kimbie-light.css b/themes/kimbie-light.css deleted file mode 100644 index 77df45cb..00000000 --- a/themes/kimbie-light.css +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Kimbie (Light) - * - * @author Jan T. Sott - * @version 1.0.0 - * @url http://github.com/idleberg/Kimbie-Rainbow - */ -pre { - background-color: #fbebd4; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #221a0f; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #d6baad; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #dc3958; /* red */ -} - -pre .constant.numeric, pre .constant.language, pre .constant.hex-color, pre .keyword.unit { - color: #f79a32; /* orange */ -} - -pre .constant, pre .entity, pre .entity.class, pre .support { - color: #f06431; /* yellow */ -} - -pre .constant.symbol, pre .string { - color: #889b4a; /* green */ -} - -pre .entity.function, pre .support.css-property, pre .selector { - color: #8ab1b0; /* blue */ -} - -pre .keyword, pre .storage { - color: #98676a; /* purple */ -} diff --git a/themes/monokai.css b/themes/monokai.css deleted file mode 100644 index 1205c780..00000000 --- a/themes/monokai.css +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Monokai theme - * - * Adapted from Wimer Hazenberg's TextMate theme of the same name - * - * @author Wimer Hazenberg - * @author Michael Fasani - * @author Craig Campbell - * @version 1.0.0 - */ -pre { - background: #272822; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #fff; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #75715E; -} - -pre .constant { - color: #AE81FF; -} - -pre .storage { - color: #66D9EF; -} - -pre .string, pre .comment.docstring { - color: #E6DB74; -} - -pre .support.tag { - color: #fff; -} - -pre .keyword { - /* @todo some keywords use this light blue, most use the pink */ - /*color: #66D9EF;*/ - color: #F92672; -} - -pre .selector { - color: #F92672; -} - -pre .inherited-class { - font-style: italic; -} - -pre .operator, pre .support.tag-name , pre .entity.tag { - color: #F92672; -} - -pre .entity, pre .support.attribute, pre .entity.attribute { - color: #A6E22E; -} - -pre .support, *[data-language="c"] .function.call { - color: #66D9EF; -} - -*[data-language="html"] .support.operator { - color: #fff; -} - -pre .css-property, pre .storage.function { - font-style: italic; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #A6E22E; -} diff --git a/themes/obsidian.css b/themes/obsidian.css deleted file mode 100644 index 7b79b81d..00000000 --- a/themes/obsidian.css +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Obsidian theme - * - * Adapted from a theme based on: - * http://studiostyl.es/schemes/son-of-obsidian - * - * @author Dan Stewart - * @version 1.0 - */ -pre { - background: #22282A; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #F1F2F3; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #66747B; -} - -pre .constant { - color: #EC7600; -} - -pre .storage { - color: #EC7600; -} - -pre .string, pre .comment.docstring { - color: #EC7600; -} - -pre .string.regexp, pre .support.tag.script, pre .support.tag.style { - color: #fff; -} - - -pre .keyword, pre .selector { - color: #93C763; -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #93C763; -} - -pre .integer { - color: #FFCD22; -} - -pre .support, *[data-language="csharp"] .function.call { - color: #FACD22; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #CCC; -} - -/* C# specific rule */ -pre .preprocessor { - color: #66747B; -} diff --git a/themes/paraiso-dark.css b/themes/paraiso-dark.css deleted file mode 100644 index 9b9a0e9a..00000000 --- a/themes/paraiso-dark.css +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Paraíso (Dark) - * - * @author Jan T. Sott - * @version 1.0.0 - * @url http://github.com/idleberg/Paraiso-Rainbow - */ -pre { - background-color: #2f1e2e; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #e7e9db; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #776e71; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #ef6155; /* red */ -} - -pre .constant.numeric, pre .constant.language, pre .constant.hex-color, pre .keyword.unit { - color: #f99b15; /* orange */ -} - -pre .constant, pre .entity, pre .entity.class, pre .support { - color: #fec418; /* yellow */ -} - -pre .constant.symbol, pre .string { - color: #48b685; /* green */ -} - -pre .entity.function, pre .support.css-property, pre .selector { - color: #06b6ef; /* blue */ -} - -pre .keyword, pre .storage { - color: #815ba4; /* purple */ -} diff --git a/themes/paraiso-light.css b/themes/paraiso-light.css deleted file mode 100644 index ba48055b..00000000 --- a/themes/paraiso-light.css +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Paraíso (Light) - * - * @author Jan T. Sott - * @version 1.0.0 - * @url http://github.com/idleberg/Paraiso-Rainbow - */ -pre { - background-color: #e7e9db; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #2f1e2e; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #8d8687; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #ef6155; /* red */ -} - -pre .constant.numeric, pre .constant.language, pre .constant.hex-color, pre .keyword.unit { - color: #f99b15; /* orange */ -} - -pre .constant, pre .entity, pre .entity.class, pre .support { - color: #fec418; /* yellow */ -} - -pre .constant.symbol, pre .string { - color: #48b685; /* green */ -} - -pre .entity.function, pre .support.css-property, pre .selector { - color: #06b6ef; /* blue */ -} - -pre .keyword, pre .storage { - color: #815ba4; /* purple */ -} diff --git a/themes/pastie.css b/themes/pastie.css deleted file mode 100644 index bc3032f1..00000000 --- a/themes/pastie.css +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Pastie theme - * - * @author pygments.org - * @author pastie.org - * @author Simon Potter - * @version 1.0 - */ - -pre { - /* original is white background with no border */ - background-color: #F8F8FF; - border: 1px solid #DEDEDE; - word-wrap: break-word; - margin: 0; - padding: 10px; - color: #000; - font-size: 13px; - line-height: 16px; - margin-bottom: 20px -} - -pre, code { - font-family: monospace; -} - -pre .comment { - color: #888; -} - -pre .keyword, pre .selector, pre .storage.module, pre .storage.class, pre .storage.function { - color: #080; - font-weight: bold; -} - -pre .keyword.operator { - color: #000; - font-weight: normal; -} - -pre .constant.language { - color: #038; - font-weight:bold; -} - -pre .constant.symbol, pre .class, pre .constant { - color: #036; - font-weight: bold; -} - -pre .keyword.namespace, pre .entity.name.class { - color: #B06; - font-weight: bold; -} - -pre .constant.numeric { - color: #00D; - font-weight: bold; -} - -pre .string, pre .comment.docstring { - color: #D20; - background-color: #FFF0F0; -} - -pre .string.regexp { - background-color: #FFF0FF; - color: #808; -} - -pre .variable.instance { - color: #33B; -} - -pre .entity.name.function { - color: #06B; - font-weight: bold; -} - -pre .support.tag-name, pre .entity.tag.script, pre .entity.tag.style { - color: #070; -} - -pre .support.attribute { - color: #007; - font-style: italic; -} - -pre .entity.name.tag, pre .storage.type { - color: #070; - font-weight: bold; -} - -pre .variable.self, pre .support.function { - color: #038; - font-weight: bold; -} - -pre .entity.function, pre .support.magic, pre.support.method { - color: #C00; - font-weight: bold; -} diff --git a/themes/solarized-dark.css b/themes/solarized-dark.css deleted file mode 100644 index 7f77841e..00000000 --- a/themes/solarized-dark.css +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Solarized Dark theme - * - * Adaptation of Solarized Dark from ethanschoonover.com/solarized - * - * @author Ethan Schoonover - * @author David Litmark - * @version 1.0.0 - */ -pre { - background: #002b36; /* base03 */ - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #839496; /* base0 */ - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #586e75; /* base01 */ -} - -pre .constant { - color: #839496; /* base0 */ -} - -pre .constant.language { - color: #268bd2; /* blue */ -} - -pre .constant.regexp { - color: #2aa198; /* cyan */ -} - -pre .storage { - color: #268bd2; /* blue */ -} - -pre .string, pre .comment.docstring { - color: #2aa198; /* cyan */ -} - -pre .support.tag.script, pre .support.tag.style { - color: #2aa198; /* cyan */ -} - -pre .string.regexp { - color: #2aa198; /* cyan */ -} - -pre .string.regexp.open, pre .string.regexp.close { - color: #2aa198; /* cyan */ -} - -pre .keyword, pre .selector { - color: #859900; /* green */ -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #b58900; /* yellow */ -} - -pre .support, *[data-language="c"] .function.call { - color: #859900; /* green */ -} - -pre .support.method { - color: #839496; /* base0 */ -} - -pre .support.property { - color: #839496; /* base0 */ -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #839496; /* base0 */ -} diff --git a/themes/solarized-light.css b/themes/solarized-light.css deleted file mode 100644 index 01e39e85..00000000 --- a/themes/solarized-light.css +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Solarized Light theme - * - * Adaptation of Solarized Light from ethanschoonover.com/solarized - * - * @author Ethan Schoonover - * @author David Litmark - * @version 1.0.0 - */ -pre { - background: #fdf6e3; /* base3 */ - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #657b83; /* base00 */ - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #93a1a1; /* base1 */ -} - -pre .constant { - color: #657b83; /* base00 */ -} - -pre .constant.language { - color: #268bd2; /* blue */ -} - -pre .constant.regexp { - color: #2aa198; /* cyan */ -} - -pre .storage { - color: #268bd2; /* blue */ -} - -pre .string, pre .comment.docstring { - color: #2aa198; /* cyan */ -} - -pre .support.tag.script, pre .support.tag.style { - color: #2aa198; /* cyan */ -} - -pre .string.regexp { - color: #2aa198; /* cyan */ -} - -pre .string.regexp.open, pre .string.regexp.close { - color: #2aa198; /* cyan */ -} - -pre .keyword, pre .selector { - color: #859900; /* green */ -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #b58900; /* yellow */ -} - -pre .support, *[data-language="c"] .function.call { - color: #859900; /* green */ -} - -pre .support.method { - color: #657b83; /* base00 */ -} - -pre .support.property { - color: #657b83; /* base00 */ -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #657b83; /* base00 */ -} diff --git a/themes/sunburst.css b/themes/sunburst.css deleted file mode 100644 index 9ff5eae6..00000000 --- a/themes/sunburst.css +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Sunburst theme - * - * Adapted from the Textmate Sunburst theme by Stanley Rost - * - * @author Stanley Rost - * @author Rachel Baker - * @version 1.0.0 - */ -pre { - background-color: #000; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #fff; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #AEAEAE; font-style: italic; -} - -pre .constant { - color: #3387CC; -} - -pre .storage { - color: #99CF50; -} - -pre .string, pre .entity.name.class, pre .comment.docstring { -color: #65B042; -/* green */ -} - -pre .string.regexp { - color: #E9C062; - } - -pre .string.constant { - color: #DDF2A4; -} - -pre .constant.hex-color { - color: #DD7B3B; - /* orange */ -} -pre .support, pre .tag.script, pre .function.call { - color: #dad085; -} -pre .support.css-property { - color: #C5AF75; -} -pre .support.tag.style { - color: #fff; -} -pre .keyword, pre .selector { - color: #E28964; - /* dark pink */ -} - -pre .keyword.namespace { - color: #3387CC; - font-weight: bold; -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity, pre .variable.instance, pre .support.namespace, pre .support.tag, pre .support.tag-name { - color: #89BDFF; -} - -pre .entity.name.id { - color: #8693A5; -} - -*[data-language="c"] .function.call { - color: #8DA6CE; -} - -pre .variable, pre .variable.global { - color: #3E87E3; - } -pre .variable.class { - - } - diff --git a/themes/tomorrow-night.css b/themes/tomorrow-night.css deleted file mode 100644 index 8832b04e..00000000 --- a/themes/tomorrow-night.css +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Tomorrow Night theme - * - * @author Chris Kempson - * @author skim - * @version 1.0.0 - */ -pre { - background-color: #1d1f21; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #c5c8c6; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #969896; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #cc6666; /* red */ -} - -pre .constant.numeric, pre .constant.language, pre .constant.hex-color, pre .keyword.unit { - color: #de935f; /* orange */ -} - -pre .constant, pre .entity, pre .entity.class, pre .support { - color: #f0c674; /* yellow */ -} - -pre .constant.symbol, pre .string { - color: #b5bd68; /* green */ -} - -pre .entity.function, pre .support.css-property, pre .selector { - color: #81a2be; /* blue */ -} - -pre .keyword, pre .storage { - color: #b294bb; /* purple */ -} diff --git a/themes/tricolore.css b/themes/tricolore.css deleted file mode 100644 index bc16ea91..00000000 --- a/themes/tricolore.css +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Tricolore theme - * - * @author Jean Nicolas - * @version 1.0.1 - */ -pre { - background: #FFF; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #000; - font-size: 12px; - margin-bottom: 20px; - line-height: 16px; -} - -pre, code { - font-family: 'Monaco', 'Consolas', monospace; -} - -pre .comment { - color: #7E7E7E; - font-style: italic; -} - -pre .constant { - color: #18838A; - font-weight: bold; -} - -pre .storage { - color: #0000A1; -} - -pre .string { - color: #8E0022; -} - -pre .keyword, pre .selector { - color: #0000A1; - font-weight: bold; -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #3E853F; -} - -pre .support { - color: #192140; -} - -pre .variable.global, pre .variable.class, pre .variable.instance { - color: #3E853F; -} diff --git a/themes/twilight.css b/themes/twilight.css deleted file mode 100644 index 315bc47d..00000000 --- a/themes/twilight.css +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Twilight theme - * - * Adapted from Michael Sheets' TextMate theme of the same name - * - * @author Michael Sheets - * @author Jesse Farmer - * @version 1.0.1 - */ -pre { - background: #141414; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #F8F8F8; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #5F5A60; -} - -pre .constant.numeric { - color: #D87D50; -} - -pre .constant { - color: #889AB4; -} - -pre .constant.symbol, pre .constant.language { - color: #D87D50; -} - -pre .storage { - color: #F9EE98; -} - -pre .string { - color: #8F9D6A; -} - -pre .string.regexp { - color: #E9C062; -} - -pre .keyword, pre .selector, pre .storage { - color: #CDA869; -} - -pre .inherited-class { - color: #9B5C2E; -} - -pre .entity { - color: #FF6400; -} - -pre .support { - color: #9B859D; -} - -pre .support.magic { - color: #DAD69A; -} - -pre .variable { - color: #7587A6; -} - -pre .function, pre .entity.class { - color: #9B703F; -} - -pre .support.class-name, pre .support.type { - color: #AB99AC; -} diff --git a/themes/zenburnesque.css b/themes/zenburnesque.css deleted file mode 100644 index fdbe9650..00000000 --- a/themes/zenburnesque.css +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Zenburnesque theme - * - * Adapted from Ultraviolet RubyGem - * - * @author Flinn Mueller - * @version 1.0 - */ -pre { - background: #404040; - word-wrap: break-word; - margin: 0px; - padding: 10px; - color: #dedede; - font-size: 14px; - margin-bottom: 20px; -} - -pre, code { - font-family: 'Monaco', courier, monospace; -} - -pre .comment { - color: #709070; - font-style: italic; -} - -pre .integer { - color: #22C0FF; -} - -pre .storage { - color: #6080FF; -} - -/* This includes regexes */ -pre .string { - color: #FF2020; -} - -pre .keyword, pre .selector { - color: #ffffa0; -} - -pre .inherited-class { - font-style: italic; -} - -pre .entity { - color: #F09040; -} - -pre .support { - color: #C83730; -} - -pre .variable.class { - color: #FF8000; -} From d0ed7c4899882ef13f06c7ca77d562d218571e33 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 6 Oct 2014 21:24:21 -0400 Subject: [PATCH 046/153] Update theme paths --- demos/c.html | 24 ++++++++++++------------ demos/coffeescript.html | 4 ++-- demos/csharp.html | 2 +- demos/css.html | 2 +- demos/d.html | 2 +- demos/go.html | 2 +- demos/haskell.html | 6 +++--- demos/html.html | 2 +- demos/js.html | 10 +++++----- demos/json.html | 2 +- demos/lua.html | 2 +- demos/php-long.html | 3 ++- demos/php.html | 2 +- demos/python.html | 2 +- demos/r.html | 10 +++++----- demos/ruby-test.html | 2 +- demos/ruby.html | 10 +++++----- demos/scheme.html | 2 +- demos/shell.html | 2 +- 19 files changed, 46 insertions(+), 45 deletions(-) diff --git a/demos/c.html b/demos/c.html index 4c6c245c..795c4f24 100644 --- a/demos/c.html +++ b/demos/c.html @@ -1,7 +1,7 @@ Syntax Highlighting - +
@@ -56,7 +56,7 @@
 
     while ((opt = getopt(argc, argv, ":a")) != -1) {
 	switch (opt) {
-	case 'a': 
+	case 'a':
 	    openFlags |= O_APPEND;
 	default:
 	    die("Unrecognized option");
@@ -115,25 +115,25 @@
 
 /* Dynamically enter types into table */
 int type_find(const char* type) {
-  
+
   if (strlen(type) >= MAX_TYPE_LEN) {
     error("Type name %s is too long to index into type table.", type);
   }
   if (type_index >= MAX_NUM_TYPES) {
     error("Too many types in type table already. Cannot add %s.", type);
   }
-  
+
   for (int i = 0; i < type_index; i++) {
     // Return type index if found
     if (strcmp(type, type_table[i]) == 0) {
       return i;
     }
   }
-  
+
   // If not found add to table and return
   strcpy(type_table[type_index], type);
   type_index++;
-  
+
   return type_index-1;
 }
 
@@ -177,24 +177,24 @@
 }
 
 sound* wav_load_file(char* filename) {
-  
+
   sound* s = malloc(sizeof(sound));
-  
+
   SDL_AudioSpec spec;
-  
+
   if( SDL_LoadWAV(filename, &spec, (Uint8**)&s->data, (Uint32*)&s->length) == NULL) {
     error("Unable to load sound file %s", filename);
   }
-  
+
   if ((spec.format != AUDIO_S16LSB) &&
       (spec.format != AUDIO_S16MSB)) {
     error("Unsupported sound format for file %s, id %i.", filename, spec.format);
   }
-  
+
   if (spec.format != AUDIO_S16SYS) {
     flip_endian(s->data, s->length);
   }
-  
+
   return s;
 }
 
diff --git a/demos/coffeescript.html b/demos/coffeescript.html
index f4e72853..28af3bae 100644
--- a/demos/coffeescript.html
+++ b/demos/coffeescript.html
@@ -1,10 +1,10 @@
 
 
 Syntax Highlighting
-
+
 
 
-    
# Assignment:
+    
# Assignment:
 number   = 42
 opposite = true
 
diff --git a/demos/csharp.html b/demos/csharp.html
index b8fd85b9..cb0c0504 100644
--- a/demos/csharp.html
+++ b/demos/csharp.html
@@ -1,7 +1,7 @@
 
 
 Syntax Highlighting
-
+
 
 
 
diff --git a/demos/css.html b/demos/css.html
index 0b19bd43..a1eb0aa0 100644
--- a/demos/css.html
+++ b/demos/css.html
@@ -1,7 +1,7 @@
 
 
 Syntax Highlighting
-
+
 
 
 
diff --git a/demos/d.html b/demos/d.html
index 21b68c9e..f40404e6 100644
--- a/demos/d.html
+++ b/demos/d.html
@@ -1,7 +1,7 @@
 
 
 Syntax Highlighting
-
+
 
 
 
diff --git a/demos/go.html b/demos/go.html
index c6b75945..b5281629 100644
--- a/demos/go.html
+++ b/demos/go.html
@@ -4,7 +4,7 @@
 -->
 
 Syntax Highlighting
-
+
 
 

GO language

First example:

diff --git a/demos/haskell.html b/demos/haskell.html index 7ba7ad86..19f8570e 100644 --- a/demos/haskell.html +++ b/demos/haskell.html @@ -1,7 +1,7 @@ Syntax Highlighting - +
@@ -14,7 +14,7 @@
 -- Module      :  System.Exit
 -- Copyright   :  (c) The University of Glasgow 2001
 -- License     :  BSD-style (see the file libraries/base/LICENSE)
--- 
+--
 -- Maintainer  :  libraries@haskell.org
 -- Stability   :  provisional
 -- Portability :  portable
@@ -106,4 +106,4 @@
 
     
     
-
\ No newline at end of file
+
diff --git a/demos/html.html b/demos/html.html
index 96ac4643..99762fcf 100644
--- a/demos/html.html
+++ b/demos/html.html
@@ -1,7 +1,7 @@
 
 
 Syntax Highlighting
-
+
 
 
diff --git a/demos/js.html b/demos/js.html
index 01a61c5d..4d919e9b 100644
--- a/demos/js.html
+++ b/demos/js.html
@@ -1,10 +1,11 @@
 
 
 Syntax Highlighting
-
+
+
 
-    
-/**
+    
+/**
  * test function
  *
  * @param string
@@ -27,8 +28,7 @@
         console.log('td click');
     });
 });
-
-
+
 window.Rainbow = {
diff --git a/demos/json.html b/demos/json.html
index 5ae69b26..6c8ca077 100644
--- a/demos/json.html
+++ b/demos/json.html
@@ -1,7 +1,7 @@
 
 
 Syntax Highlighting
-
+
 
 
 
{
diff --git a/demos/lua.html b/demos/lua.html
index a238cb4a..2de08b30 100644
--- a/demos/lua.html
+++ b/demos/lua.html
@@ -4,7 +4,7 @@
 -->
 
 Syntax Highlighting
-
+
 
 
 
diff --git a/demos/php-long.html b/demos/php-long.html
index fb853c1a..644b25cf 100644
--- a/demos/php-long.html
+++ b/demos/php-long.html
@@ -1,7 +1,8 @@
 
 
 Syntax Highlighting
-
+
+
 
 
 Last modified: Wed Jan 25 22:04:37 CET 2012 
 
-
-
+
+
  
diff --git a/demos/shell.html b/demos/shell.html
index 59155de8..be4a1bea 100644
--- a/demos/shell.html
+++ b/demos/shell.html
@@ -426,8 +426,8 @@
 rm -fr "$TEMP_PATH"
 trap - ERR
 
- - - + + + From 8616f00de07e821fd0ebfeb10e06937602822794 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 08:40:14 -0400 Subject: [PATCH 059/153] Add sass and autoprefixer to gulp --- gulpfile.js | 13 +++++++++++-- package.json | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 64d4765a..164e6f4d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,6 +14,8 @@ var inject = require('gulp-inject-string'); var git = require('gulp-git'); var bump = require('gulp-bump'); var semver = require('semver'); +var sass = require('gulp-sass'); +var autoprefixer = require('gulp-autoprefixer'); var version = require('./package.json').version; var appName = 'Rainbow'; @@ -38,10 +40,9 @@ gulp.task('pack', function() { } var dest = 'dist/' + lowercaseAppName + '.js'; - var format = 'iife'; + var format = 'umd'; if (argv.release) { dest = 'dist/' + lowercaseAppName + '.min.js'; - format = 'umd'; } return rollup({ @@ -120,8 +121,16 @@ gulp.task('release', function(callback) { runSequence('test', 'pack', 'update-version', callback); }); +gulp.task('sass', function() { + return gulp.src('./themes/sass/*.sass') + .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) + .pipe(autoprefixer({browsers: ['last 2 versions']})) + .pipe(gulp.dest('./themes/css')); +}); + gulp.task('watch', function() { gulp.watch('src/**/*.js', ['pack']); + gulp.watch('themes/sass/*.sass', ['sass']); }); gulp.task('default', ['lint', 'test', 'pack']); diff --git a/package.json b/package.json index 7b8fa043..283c5cdf 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,12 @@ "chai-as-promised": "5.3.0", "del": "2.2.0", "gulp": "3.9.1", + "gulp-autoprefixer": "3.1.0", "gulp-bump": "2.1.0", "gulp-eslint": "2.0.0", "gulp-git": "1.7.2", "gulp-inject-string": "1.1.0", + "gulp-sass": "2.3.2", "karma": "0.13.22", "karma-chai": "0.1.0", "karma-chai-as-promised": "0.1.2", @@ -56,6 +58,6 @@ "yargs": "4.7.1" }, "dependencies": { - "webworker-threads": "0.7.5" + "webworker-threads": "0.7.5" } } From 6ce63f7fc4d87c2c18b627c70eac3af9b8108a79 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 09:35:56 -0400 Subject: [PATCH 060/153] Update some packages --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 283c5cdf..e50ccaa4 100644 --- a/package.json +++ b/package.json @@ -41,14 +41,14 @@ "karma-chrome-launcher": "1.0.1", "karma-coverage": "1.0.0", "karma-mocha": "1.0.1", - "karma-mocha-reporter": "2.0.3", - "karma-phantomjs-launcher": "1.0.0", + "karma-mocha-reporter": "2.0.4", + "karma-phantomjs-launcher": "1.0.1", "karma-rollup-preprocessor": "2.0.2", "karma-sourcemap-loader": "0.3.7", "mocha": "2.5.3", "phantomjs-prebuilt": "2.1.7", - "rollup": "0.26.6", - "rollup-plugin-buble": "0.10.0", + "rollup": "0.33.0", + "rollup-plugin-buble": "0.12.1", "rollup-plugin-istanbul": "1.0.0", "rollup-plugin-uglify": "0.3.1", "run-sequence": "1.2.1", From a40ec49dfce517820b15a558fb3e0f4aa00bcc9b Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:10:24 -0400 Subject: [PATCH 061/153] Update all themes --- themes/css/all-hallows-eve.css | 2 +- themes/css/blackboard.css | 2 +- themes/css/dreamweaver.css | 2 +- themes/css/espresso-libre.css | 2 +- themes/css/github.css | 2 +- themes/css/kimbie-dark.css | 2 +- themes/css/kimbie-light.css | 2 +- themes/css/monokai.css | 2 +- themes/css/obsidian.css | 2 +- themes/css/paraiso-dark.css | 2 +- themes/css/paraiso-light.css | 2 +- themes/css/pastie.css | 2 +- themes/css/solarized-dark.css | 2 +- themes/css/solarized-light.css | 2 +- themes/css/sunburst.css | 2 +- themes/css/tomorrow-night.css | 2 +- themes/css/tricolore.css | 2 +- themes/css/twilight.css | 2 +- themes/css/zenburnesque.css | 2 +- themes/sass/_init.sass | 44 +++++++++------------------------- themes/sass/github.sass | 10 ++++---- 21 files changed, 35 insertions(+), 57 deletions(-) diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css index adc84ba0..d42ce481 100644 --- a/themes/css/all-hallows-eve.css +++ b/themes/css/all-hallows-eve.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre .comment{color:#93c}pre .constant{color:#3387cc}pre .storage{color:#cc7833}pre .string{color:#6c3}pre .keyword,pre .selector{color:#cc7833}pre .inherited-class{font-style:italic}pre .support{color:#c83730} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css index 49091938..69d9b924 100644 --- a/themes/css/blackboard.css +++ b/themes/css/blackboard.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#0b1022}pre .comment{color:#727272}pre .constant{color:#d8fa3c}pre .storage{color:#fbde2d}pre .string,pre .comment.docstring{color:#61ce3c}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#fbde2d}pre .inherited-class{font-style:italic}pre .entity{color:#ff6400}pre .support{color:#8da6ce}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ff6400}*[data-language="c"] .function.call{color:#8da6ce} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css index fc9b3ff0..f493fd08 100644 --- a/themes/css/dreamweaver.css +++ b/themes/css/dreamweaver.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css index a02b603a..b0553031 100644 --- a/themes/css/espresso-libre.css +++ b/themes/css/espresso-libre.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#06f;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} diff --git a/themes/css/github.css b/themes/css/github.css index 4894d64a..1fa6e4f5 100644 --- a/themes/css/github.css +++ b/themes/css/github.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0px;padding:0px;margin:0px;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas,"Liberation Mono",Courier,monospace;color:#333;background:#f8f8f8;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086b3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css index c1664c64..ee77a553 100644 --- a/themes/css/kimbie-dark.css +++ b/themes/css/kimbie-dark.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css index 8dcb6099..252dcfba 100644 --- a/themes/css/kimbie-light.css +++ b/themes/css/kimbie-light.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/monokai.css b/themes/css/monokai.css index e3960614..0aa03cde 100644 --- a/themes/css/monokai.css +++ b/themes/css/monokai.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#272822}pre .comment{color:#75715e}pre .constant{color:#ae81ff}pre .storage{color:#66d9ef}pre .string,pre .comment.docstring{color:#e6db74}pre .support.tag{color:#fff}pre .keyword{color:#f92672}pre .selector{color:#f92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#f92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#a6e22e}pre .support,pre *[data-language="c"] .function.call{color:#66d9ef}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#a6e22e}*[data-language="html"] .support.operator{color:#fff} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css index cbeeafe9..0667ddb3 100644 --- a/themes/css/obsidian.css +++ b/themes/css/obsidian.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#22282a;color:#f1f2f3}pre .comment{color:#66747b}pre .constant{color:#ec7600}pre .storage{color:#ec7600}pre .string,pre .comment.docstring{color:#ec7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93c763}pre .inherited-class{font-style:italic}pre .entity{color:#93c763}pre .integer{color:#ffcd22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ccc}pre .preprocessor{color:#66747b}pre .support,*[data-language="csharp"] .function.call{color:#facd22} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css index 740157fa..18abb0e1 100644 --- a/themes/css/paraiso-dark.css +++ b/themes/css/paraiso-dark.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css index bd43252d..e3c57a47 100644 --- a/themes/css/paraiso-light.css +++ b/themes/css/paraiso-light.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/pastie.css b/themes/css/pastie.css index f421b53e..1ccb161b 100644 --- a/themes/css/pastie.css +++ b/themes/css/pastie.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#f8f8ff;border:1px solid #dedede;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#b06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00d;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#d20;background-color:#fff0f0}pre .string.regexp,code .string.regexp{background-color:#fff0ff;color:#808}pre .variable.instance,code .variable.instance{color:#33b}pre .entity.name.function,code .entity.name.function{color:#06b;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#c00;font-weight:bold} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css index 4aa2d03f..41d35dd4 100644 --- a/themes/css/solarized-dark.css +++ b/themes/css/solarized-dark.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css index 70f934d2..5b504bd0 100644 --- a/themes/css/solarized-light.css +++ b/themes/css/solarized-light.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css index c3e8e719..da353c9b 100644 --- a/themes/css/sunburst.css +++ b/themes/css/sunburst.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre .comment{color:#aeaeae;font-style:italic}pre .constant{color:#3387cc}pre .storage{color:#99cf50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65b042}pre .string.regexp{color:#e9c062}pre .string.constant{color:#ddf2a4}pre .constant.hex-color{color:#dd7b3b}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#c5af75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#e28964}pre .keyword.namespace{color:#3387cc;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89bdff}pre .entity.name.id{color:#8693a5}pre .variable,pre .variable.global{color:#3e87e3}*[data-language="c"] .function.call{color:#8da6ce} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css index 290663b7..a2d2b896 100644 --- a/themes/css/tomorrow-night.css +++ b/themes/css/tomorrow-night.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css index 37b4e77a..4ba92274 100644 --- a/themes/css/tricolore.css +++ b/themes/css/tricolore.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#fff;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7e7e7e;font-style:italic}pre .constant{color:#18838a;font-weight:bold}pre .storage{color:#0000a1}pre .string{color:#8e0022}pre .keyword,pre .selector{color:#0000a1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3e853f}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3e853f} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} diff --git a/themes/css/twilight.css b/themes/css/twilight.css index 77b2b667..a1a02a45 100644 --- a/themes/css/twilight.css +++ b/themes/css/twilight.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#141414;color:#f8f8f8}pre .comment{color:#5f5a60}pre .constant.numeric{color:#d87d50}pre .constant{color:#889ab4}pre .constant.symbol,pre .constant.language{color:#d87d50}pre .storage{color:#f9ee98}pre .string{color:#8f9d6a}pre .string.regexp{color:#e9c062}pre .keyword,pre .selector,pre .storage{color:#cda869}pre .inherited-class{color:#9b5c2e}pre .entity{color:#ff6400}pre .support{color:#9b859d}pre .support.magic{color:#dad69a}pre .variable{color:#7587a6}pre .function,pre .entity.class{color:#9b703f}pre .support.class-name,pre .support.type{color:#ab99ac} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css index 78b60768..8962d9af 100644 --- a/themes/css/zenburnesque.css +++ b/themes/css/zenburnesque.css @@ -1 +1 @@ -@-webkit-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-moz-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@-o-keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";-webkit-animation:fade-in 50ms 100ms forwards ease-in-out;animation:fade-in 50ms 100ms forwards ease-in-out}[data-language] code.stop-animation,pre [data-language].stop-animation{-webkit-animation-play-state:paused;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:"Monaco",courier,monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22c0ff}pre .storage{color:#6080ff}pre .string{color:#ff2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#f09040}pre .support{color:#c83730}pre .variable.class{color:#ff8000} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index 4c56e449..b7ffc261 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -1,37 +1,10 @@ - -@mixin animation($animation) - -webkit-animation: $animation - animation: $animation - -@mixin animation-play-state($state) - -webkit-animation-play-state: $state - animation-play-state: $state - -/** - * @todo not sure we need all the prefixed keyframes - */ -@mixin keyframes($animationName) - @-webkit-keyframes #{$animationName} - @content - - @-moz-keyframes #{$animationName} - @content - - @-o-keyframes #{$animationName} - @content - - @keyframes #{$animationName} - @content - -@mixin border-radius($args) - border-radius: $args - -moz-border-radius: $args - -webkit-border-radius: $args - -@include keyframes(fade-in) +@keyframes #{fade-in} 0% opacity: 0 + 5% + opacity: 0 + 100% opacity: 1 @@ -45,7 +18,12 @@ // IE 10+ and all modern browsers support CSS animations -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)" - @include animation((fade-in 50ms 100ms forwards ease-in-out)) + animation: 50ms ease-in-out 1000ms forwards fade-in + + &.decrease-delay + animation-delay: 75ms &.stop-animation - @include animation-play-state(paused) + opacity: 0 + // background: red + animation-play-state: paused diff --git a/themes/sass/github.sass b/themes/sass/github.sass index a7814f5e..c6a119b4 100644 --- a/themes/sass/github.sass +++ b/themes/sass/github.sass @@ -14,10 +14,10 @@ pre margin-bottom: 20px code - border: 0px - padding: 0px - margin: 0px - @include border-radius(0px) + border: 0 + padding: 0 + margin: 0 + border-radius: 0 code border: 1px solid #eaeaea @@ -29,7 +29,7 @@ pre, code font-family: Consolas, 'Liberation Mono', Courier, monospace color: #333 background: #f8f8f8 - @include border-radius(3px) + border-radius: 3px pre, pre code font-size: 13px From af79ec858617c65a2e02c60e496db9232799e880 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:10:35 -0400 Subject: [PATCH 062/153] Move api.html to test directory --- {tests => test}/api.html | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {tests => test}/api.html (100%) diff --git a/tests/api.html b/test/api.html similarity index 100% rename from tests/api.html rename to test/api.html From 9951f78840e8d96287392cf0aad34bff239447d1 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:11:26 -0400 Subject: [PATCH 063/153] Add more to coffeescript demo --- demos/coffeescript.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/demos/coffeescript.html b/demos/coffeescript.html index e3553241..5fcb1f28 100644 --- a/demos/coffeescript.html +++ b/demos/coffeescript.html @@ -73,3 +73,14 @@ + +
OPERATOR = /// ^ (
+           ?: [-=]>            # function
+           | [-+*/%<>&|^!?=]=  # compound assign / compare
+           | >>>=?             # zero-fill right shift
+           | ([-+:])\\1        # doubles
+           | ([&|<>])\\2=?     # logic / shift
+           | \\?\\.            # soak access
+           | \\.{2,3}          # range or splat
+        ) ///
+ From 8163f763a000630ff034acd4d16522f2137ad723 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:11:34 -0400 Subject: [PATCH 064/153] Switch golang demo to use monokai --- demos/go.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/go.html b/demos/go.html index c02b0f2f..4907b1e0 100644 --- a/demos/go.html +++ b/demos/go.html @@ -4,7 +4,7 @@ --> Syntax Highlighting - +

GO language

First example:

From fdff693985b8d9d9f207b18ea3f62cb6e728b7e9 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:11:45 -0400 Subject: [PATCH 065/153] Add karma conf --- karma.conf.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 karma.conf.js diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 00000000..c10b7ef1 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,52 @@ +/* eslint-env node */ +/* eslint no-var: false */ + +module.exports = function(config) { + config.set({ + basePath: './', + + plugins: [ + 'karma-rollup-preprocessor', + 'karma-mocha-reporter', + 'karma-chrome-launcher', + 'karma-phantomjs-launcher', + 'karma-sourcemap-loader', + 'karma-mocha', + 'karma-chai', + 'karma-chai-sinon', + 'karma-chai-as-promised' + ], + + frameworks: ['mocha', 'chai-sinon', 'chai-as-promised', 'chai'], + + files: [ + 'node_modules/babel-polyfill/dist/polyfill.js', + 'dist/rainbow.js', + {pattern: 'test/**/*-test.js'} + ], + + logLevel: config.LOG_INFO, + + preprocessors: { + 'test/**/*-test.js': ['rollup', 'sourcemap'] + }, + + rollupPreprocessor: { + rollup: { + plugins: [ + require('rollup-plugin-buble')({ + transforms: { + dangerousForOf: true + } + }) + ] + }, + bundle: { + sourceMap: 'inline' + } + }, + + reporters: ['mocha'], + colors: true + }); +}; From ba150082bb6e3a26bce010f029544fa116f99a84 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:11:51 -0400 Subject: [PATCH 066/153] Remove unused packages --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index e50ccaa4..4da185f9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "karma-chai-as-promised": "0.1.2", "karma-chai-sinon": "0.1.5", "karma-chrome-launcher": "1.0.1", - "karma-coverage": "1.0.0", "karma-mocha": "1.0.1", "karma-mocha-reporter": "2.0.4", "karma-phantomjs-launcher": "1.0.1", @@ -49,7 +48,6 @@ "phantomjs-prebuilt": "2.1.7", "rollup": "0.33.0", "rollup-plugin-buble": "0.12.1", - "rollup-plugin-istanbul": "1.0.0", "rollup-plugin-uglify": "0.3.1", "run-sequence": "1.2.1", "semver": "5.1.0", From 82150da3d9d81aef118b3d729b455776c60fcef8 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:12:40 -0400 Subject: [PATCH 067/153] Make sure coffeescript regex comments end at new line --- src/language/coffeescript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/language/coffeescript.js b/src/language/coffeescript.js index a0404976..876a6240 100644 --- a/src/language/coffeescript.js +++ b/src/language/coffeescript.js @@ -2,7 +2,7 @@ * Coffeescript patterns * * @author Craig Campbell - * @version 1.0 + * @version 1.0.1 */ Rainbow.extend('coffeescript', [ { @@ -22,7 +22,7 @@ Rainbow.extend('coffeescript', [ 'matches': { 2: { 'name': 'comment', - 'pattern': /\#(.*?)\n/g + 'pattern': /\#(.*?)(?=\n)/g } }, 'pattern': /(\/{3})([\s\S]*)\1/gm From 3efff371f2b90b9d6199c67044fcdea3873eff27 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:13:25 -0400 Subject: [PATCH 068/153] Update api test to match new project structure --- test/api.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/api.html b/test/api.html index a4e4d641..41b9f173 100644 --- a/test/api.html +++ b/test/api.html @@ -1,7 +1,7 @@ Syntax Highlighting - +

API Test Page

@@ -9,10 +9,10 @@

API Test Page

var foo = false;
- - - - + + + + ', + + '<script type="text/javascript">\n' + + ' function prettyCool() {\n' + + ' doSomeJQueryOrWhatever();\n' + + ' }\n' + + '</script>' + ); + + + run( + language, + + 'inline js 2', + + '', + + '<script>\n' + + ' function prettyCool() {\n' + + ' doSomeJQueryOrWhatever();\n' + + ' }\n' + + '</script>' + ); + + + run( + language, + + 'js include', + + '', + + '<script src="http://somewebsite.com/some-script.js" type="text/javascript"></script>' + ); + + run( + language, + + 'attribute no quotes', + + '

test

', + + '<p class=test>test</p>' + ); + + run( + language, + + 'attribute alone', + + '', + + '<input type="checkbox" name="whatever" checked>' + ); + + run( + language, + + 'attribute middle', + + '', + + '<input checked type="checkbox">' + ); + + run( + language, + + 'attribute alone self close', + + '', + + '<input type="checkbox" name="whatever" checked />' + ); + + run( + language, + + 'attribute camel case', + + '', + + '<button onClick="test()">Click me</button>' + ); + + run( + language, + + 'string inside tags', + + '
def openFile(path):\n' +
+        'file = open(path, "r")\n' +
+        'content = file.read()\n' +
+        'file.close()\n' +
+        'return content
', + + '<pre><code data-language="python">def openFile(path):\n' + + 'file = open(path, "r")\n' + + 'content = file.read()\n' + + 'file.close()\n' + + 'return content</code></pre>' + ); +}); diff --git a/test/language/java-test.js b/test/language/java-test.js new file mode 100644 index 00000000..73c2a988 --- /dev/null +++ b/test/language/java-test.js @@ -0,0 +1,114 @@ +import '../../src/language/java'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'java'; + +describe(language, () => { + run( + language, + "package declaration", + 'package com.example.rainbow;', + 'package com.example.rainbow;' + ); + + run( + language, + "import statement", + 'import com.example.rainbow.util.RainbowUtil;', + 'import com.example.rainbow.util.RainbowUtil;' + ); + + run( + language, + "multi-line comment", + '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */', + '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */' + ); + + run( + language, + "single-line comment", + '// This is a good comment.', + '// This is a good comment.' + ); + + run( + language, + "complicated class declaration", + 'public class Rainbow> extends Spectrum implements HasColors, IsPretty {', + 'public class Rainbow<T, List<? extends T>> extends Spectrum implements HasColors, IsPretty {' + ); + + run( + language, + "simple class declaration", + 'public class Rainbow {', + 'public class Rainbow {' + ); + + run( + language, + "constant declaration", + 'private static final int RESOLUTION = 7;', + 'private static final int RESOLUTION = 7;' + ); + + run( + language, + "field declaration", + 'private final String name;', + 'private final String name;' + ); + + run( + language, + "method declaration", + 'public void shine() {', + 'public void shine() {' + ); + + run( + language, + "simple annotation", + '@Override', + '@Override' + ); + + run( + language, + "complex annotation", + '@RequestMapping( value = "/rainbow", method = Method.POST )', + '@RequestMapping( value = "/rainbow", method = Method.POST )' + ); + + run( + language, + "string concatenation", + '"I found " + numberOfTurtles + " turtles."', + '"I found " + numberOfTurtles + " turtles."' + ); + + run( + language, + "local method invocation", + 'wait(1000L)', + 'wait(1000L)' + ); + + run( + language, + "static method invocation", + 'System.out.println("Hello, world!");', + 'System.out.println("Hello, world!");' + ); + + run( + language, + "variable assignment", + 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );', + 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );' + ); +}); diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js new file mode 100644 index 00000000..fd6bf284 --- /dev/null +++ b/test/language/javascript-test.js @@ -0,0 +1,228 @@ +import '../../src/language/javascript'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'javascript'; + +describe(language, () => { + run( + language, + + 'selector 1', + + '$.get()', + + '$.get()' + ); + + run( + language, + + 'selector 2', + + ' $(\'.some_class\').show()', + + ' $(\'.some_class\').show()' + ); + + run( + language, + + 'window', + + 'console.log(window.scrollX)', + + 'console.log(window.scrollX)' + ); + + run( + language, + + 'document', + + 'document.getElementById(\'#some_id\')', + + 'document.getElementById(\'#some_id\')' + ); + + run( + language, + + 'regex', + + 'var pattern = /\\((.*?)\\)/g', + + 'var pattern = /\\((.*?)\\)/g' + ); + + run( + language, + + 'regex 2', + + 'var pattern = /true/', + + 'var pattern = /true/' + ); + + run( + language, + + 'string no regex', + + 'var test = "http://website.com/could/match/regex/i";', + + 'var test = "http://website.com/could/match/regex/i";' + ); + + run( + language, + + 'single line comment vs. regex', + + 'var Animal = function() { /* some comment */ };', + + 'var Animal = function() { /* some comment */ };' + ); + + run( + language, + + 'class instantiation', + + 'var animal = new Animal();', + + 'var animal = new Animal();' + ); + + run( + language, + + 'inline function', + + 'var foo = true,\n' + + ' something = function() {\n' + + ' // do something\n' + + ' };', + + 'var foo = true,\n' + + ' something = function() {\n' + + ' // do something\n' + + ' };' + ); + + run( + language, + + 'inline function beginning of line', + + 'something = function() {\n' + + ' // do something\n' + + '};', + + 'something = function() {\n' + + ' // do something\n' + + '};' + ); + + run( + language, + + 'functions in object', + + 'window.Rainbow = {\n' + + ' color: function() {\n' + + ' // do something\n' + + ' },\n' + + '\n' + + ' other: function() {}\n' + + '};', + + 'window.Rainbow = {\n' + + ' color: function() {\n' + + ' // do something\n' + + ' },\n' + + '\n' + + ' other: function() {}\n' + + '};' + ); + + run( + language, + + 'JSON 1', + + '{\n' + + ' "generated_in": "0.0423",\n' + + ' "stat": "fail"\n' + + ' "err": {\n' + + ' "code": "1",\n' + + ' "expl": "The user id or name was either not valid or not provided.",\n' + + ' "msg": "User not found"\n' + + ' }\n' + + '}', + + '{\n' + + ' "generated_in": "0.0423",\n' + + ' "stat": "fail"\n' + + ' "err": {\n' + + ' "code": "1",\n' + + ' "expl": "The user id or name was either not valid or not provided.",\n' + + ' "msg": "User not found"\n' + + ' }\n' + + '}' + ); + + run( + language, + + 'JSON 2', + + '{\n' + + ' "generated_in":"0.0423",\n' + + ' "stat":"fail"\n' + + ' "err":{\n' + + ' "code":"1",\n' + + ' "expl":"The user id or name was either not valid or not provided.",\n' + + ' "msg":"User not found"\n' + + ' }\n' + + '}', + + '{\n' + + ' "generated_in":"0.0423",\n' + + ' "stat":"fail"\n' + + ' "err":{\n' + + ' "code":"1",\n' + + ' "expl":"The user id or name was either not valid or not provided.",\n' + + ' "msg":"User not found"\n' + + ' }\n' + + '}' + ); + + run( + language, + + 'multiple var declarations', + + 'var language = getLanguage(source);\n' + + 'var parseAndHighlight = function() {};\n' + + 'var parseAndHighlight2 = function() {};', + + 'var language = getLanguage(source);\n' + + 'var parseAndHighlight = function() {};\n' + + 'var parseAndHighlight2 = function() {};' + ); + + run( + language, + + 'multiple regex same line', + + "code.replace(//g, '>')", + + 'code.replace(/</g, \'<\').replace(/>/g, \'>\')' + ); +}); + diff --git a/test/language/json-test.js b/test/language/json-test.js new file mode 100644 index 00000000..145d6a04 --- /dev/null +++ b/test/language/json-test.js @@ -0,0 +1,33 @@ +import '../../src/language/json'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'json'; + +describe(language, () => { + run( + language, + + 'json string', + + '{\n' + + ' "id": 23,\n' + + ' "name": "Something",\n' + + ' "description": "He said, \"Double quotes inside of other double quotes.\"",\n' + + ' "tags": [\n' + + ' "one",\n' + + ' "two",\n' + + ' "three"\n' + + ' ],\n' + + ' "image": {\n' + + ' "url": "http://example.com/image.jpg",\n' + + ' "width": 100,\n' + + ' "height": 100\n' + + ' }\n' + + '}', + + '{\n "id": 23,\n "name": "Something",\n "description": "He said, "Double quotes inside of other double quotes."",\n "tags": [\n "one",\n "two",\n "three"\n ],\n "image": {\n "url": "http://example.com/image.jpg",\n "width": 100,\n "height": 100\n }\n}' + ); +}); diff --git a/test/language/php-test.js b/test/language/php-test.js new file mode 100644 index 00000000..5069ae70 --- /dev/null +++ b/test/language/php-test.js @@ -0,0 +1,412 @@ +import '../../src/language/php'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'php'; + +describe(language, () => { + run( + language, + + 'echo', + + 'echo \'hello world\';', + + 'echo \'hello world\';' + ); + + run( + language, + + 'variable', + + '$foo = true;', + + '$foo = true;' + ); + + skip( + language, + + 'variable variable', + + '$$foo = true;', + + '$$foo = true;' + ); + + run( + language, + + 'string concatenation', + + "$foo = 'test' . 'string' . 'concatenation';", + + '$foo = \'test\' . \'string\' . \'concatenation\';' + ); + + run( + language, + + 'include 1', + + "include 'App.php';", + + 'include \'App.php\';' + ); + + run( + language, + + 'include 2', + + "include_once('App.php');", + + 'include_once(\'App.php\');' + ); + + run( + language, + + 'instanceof', + + "$is_array_object = $collection instanceof ArrayObject;", + + '$is_array_object = $collection instanceof ArrayObject;' + ); + + run( + language, + + 'instanceof namespace class', + + "$is_user = $object instanceof App\\User;", + + '$is_user = $object instanceof App\\User;' + ); + + run( + language, + + 'array stuff', + + '$turtles = array(\n' + + ' \'leonardo\',\n' + + ' \'michaelangelo\',\n' + + ' \'donatello\',\n' + + ' \'raphael\'\n' + + ');\n' + + '\n' + + '$exists = array_key_exists(0, $turtles);', + + '$turtles = array(\n' + + ' \'leonardo\',\n' + + ' \'michaelangelo\',\n' + + ' \'donatello\',\n' + + ' \'raphael\'\n' + + ');\n' + + '\n' + + '$exists = array_key_exists(0, $turtles);' + ); + + run( + language, + + 'php tag', + + '<?php echo $foo; ?>', + + '<?php echo $foo; ?>' + ); + + run( + language, + + 'php tag 2', + + '<?php echo \'?>\'; ?>', + + '<?php echo \'?>\'; ?>' + ); + + run( + language, + + 'namespace declaration', + + 'namespace Sonic\\Database;', + + 'namespace Sonic\\Database;' + ); + + run( + language, + + 'use declaration', + + 'use Sonic;', + + 'use Sonic;' + ); + + run( + language, + + 'class declaration', + + 'class MyClass {}', + + 'class MyClass {}' + ); + + run( + language, + + 'trait declaration', + + 'trait MyClass {}', + + 'trait MyClass {}' + ); + + run( + language, + + 'interface declaration', + + 'interface IMyClass {}', + + 'interface IMyClass {}' + ); + + run( + language, + + 'abstract class declaration', + + 'abstract class MyClass {}', + + 'abstract class MyClass {}' + ); + + run( + language, + + 'final class declaration', + + 'final class TestClass\n' + + '{\n' + + '}', + + 'final class TestClass\n' + + '{\n' + + '}' + ); + + run( + language, + + 'class with an implementation declaration', + + 'class Collection implements IList {}', + + 'class Collection implements IList {}' + ); + + run( + language, + + 'child class declaration', + + 'class Collection extends ArrayObject {}', + + 'class Collection extends ArrayObject {}' + ); + + run( + language, + + 'child class with an implementation declaration', + + 'class Collection extends ArrayObject implements IList {}', + + 'class Collection extends ArrayObject implements IList {}' + ); + + run( + language, + + 'final child class declaration', + + 'final class TestClass extends \\Some\\Other\\Class {}', + + 'final class TestClass extends \\Some\\Other\\Class {}' + ); + + run( + language, + + 'test static', + + 'self::_doSomething();\n' + + 'static::_doSomethingElse();', + + 'self::_doSomething();\n' + + 'static::_doSomethingElse();' + ); + + run( + language, + + 'test magic function', + + 'function __autoload($class)\n' + + '{\n' + + ' // do whatever\n' + + '}', + + 'function __autoload($class)\n' + + '{\n' + + ' // do whatever\n' + + '}' + ); + + run( + language, + + 'test magic method', + + 'class SomeThing\n' + + '{\n' + + ' protected $_foo;\n' + + '\n' + + ' public function __construct($foo)\n' + + ' {\n' + + ' $this->_foo = $foo;\n' + + ' }\n' + + '}', + + 'class SomeThing\n' + + '{\n' + + ' protected $_foo;\n' + + '\n' + + ' public function __construct($foo)\n' + + ' {\n' + + ' $this->_foo = $foo;\n' + + ' }\n' + + '}' + ); + + run( + language, + + 'test new class', + + 'new SomeClass();', + + 'new SomeClass();' + ); + + run( + language, + + 'test new namespace class', + + 'new Sonic\\Database\\Query();', + + 'new Sonic\\Database\\Query();' + ); + + run( + language, + + 'test new class without parenthesis', + + 'new Sonic\\Controller;', + + 'new Sonic\\Controller;' + ); + + run( + language, + + 'test static class call', + + '$path = Sonic\\App::getInstance()->getPath();', + + '$path = Sonic\\App::getInstance()->getPath();' + ); + + run( + language, + + 'constant language', + + 'true; TRUE;', + + 'true; TRUE;' + ); + + run( + language, + + 'constant', + + 'TEST_CONSTANT', + + 'TEST_CONSTANT' + ); + + run( + language, + + 'constant 2', + + '(TEST_CONSTANT_2)', + + '(TEST_CONSTANT_2)' + ); + + run( + language, + + 'class constant', + + '$version = Sonic\\App::VERSION', + + '$version = Sonic\\App::VERSION' + ); + + run( + language, + + 'static variable access', + + '$foo = Sonic\\App::$static_property;', + + '$foo = Sonic\\App::$static_property;' + ); + + run( + language, + + 'type hint', + + 'public static function getForUser(User $user, Sort $sort) {}', + + 'public static function getForUser(User $user, Sort $sort) {}' + ); + + + run( + language, + + 'type hint with namespace', + + 'public static function getForUser(\\SomeApp\\User $user) {}', + + 'public static function getForUser(\\SomeApp\\User $user) {}' + ); +}); diff --git a/test/language/python-test.js b/test/language/python-test.js new file mode 100644 index 00000000..b5ec7cbc --- /dev/null +++ b/test/language/python-test.js @@ -0,0 +1,215 @@ +import '../../src/language/python'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'python'; + +describe(language, () => { + run( + language, + + 'no self', + + 'print self.something', + + 'print self.something' + ); + + run( + language, + + 'comment', + + '# this is a comment', + + '# this is a comment' + ); + + run( + language, + + 'language constants', + + 'var1 = None\n' + + 'var2 = True\n' + + 'someFunction(var3=False)', + + 'var1 = None\n' + + 'var2 = True\n' + + 'someFunction(var3=False)' + ); + + run( + language, + + 'object', + + 'object', + + 'object' + ); + + run( + language, + + 'import', + + 'from SomePackage import SomeThing', + + 'from SomePackage import SomeThing' + ); + + run( + language, + + 'class', + + 'class Something(object):\n' + + ' pass', + + 'class Something(object):\n' + + ' pass' + ); + + run( + language, + + 'special method', + + 'def __init__(self, some_var):\n' + + ' pass', + + 'def __init__(self, some_var):\n' + + ' pass' + ); + + run( + language, + + 'function', + + 'def openFile(path):\n' + + ' file = open(path, "r")\n' + + ' content = file.read()\n' + + ' file.close()\n' + + ' return content', + + 'def openFile(path):\n' + + ' file = open(path, "r")\n' + + ' content = file.read()\n' + + ' file.close()\n' + + ' return content' + ); + + run( + language, + + 'decorator', + + '@makebold\n' + + '@makeitalic\n' + + 'def hello():\n' + + ' return "hello world"', + + '@makebold\n' + + '@makeitalic\n' + + 'def hello():\n' + + ' return "hello world"' + ); + + run( + language, + + '__main__', + + 'if __name__ == \'__main__\':\n' + + ' pass', + + 'if __name__ == \'__main__\':\n' + + ' pass' + ); + + run( + language, + + 'try catch', + + 'try:\n' + + ' import cPickle as pickle\n' + + 'except ImportError:\n' + + ' import pickle', + + 'try:\n' + + ' import cPickle as pickle\n' + + 'except ImportError:\n' + + ' import pickle' + ); + + run( + language, + + 'docstring single line double quotes', + + '"""docstring test"""', + + '"""docstring test"""' + ); + + run( + language, + + 'docstring single line single quotes', + + "'''docstring test'''", + + '\'\'\'docstring test\'\'\'' + ); + + run( + language, + + 'docstring multiline', + + '"""test\n' + + 'multiline\n' + + 'yes"""', + + '"""test\n' + + 'multiline\n' + + 'yes"""' + ); + + run( + language, + + 'decorator with dot', + + '@tornado.web.asynchronous', + + '@tornado.web.asynchronous' + ); + + run( + language, + + 'multiple docstrings', + + '"""\n' + + 'x\n' + + '"""\n' + + '2 + 2\n' + + '"""\n' + + 'y\n' + + '"""', + + '"""\n' + + 'x\n' + + '"""\n' + + '2 + 2\n' + + '"""\n' + + 'y\n' + + '"""' + ); +}); diff --git a/test/language/r-test.js b/test/language/r-test.js new file mode 100644 index 00000000..8f021f32 --- /dev/null +++ b/test/language/r-test.js @@ -0,0 +1,131 @@ +import '../../src/language/r'; +import { run, skip } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'r'; + +describe(language, () => { + run( + language, + + 'comments', + + '# A comment\n' + + 'a <- "b" # Another comment', + + '# A comment\n' + + 'a <- "b" # Another comment' + ); + + run( + language, + + 'assignment', + + 'foo.bar <- "foo"\n' + + 'baz1 = 1.62e-4', + + 'foo.bar <- "foo"\n' + + 'baz1 = 1.62e-4' + ); + + run( + language, + + 'constants', + + 'baz <- NA\n' + + 'my.pi <- pi\n' + + 'all.letters <- c(LETTERS, letters)\n' + + 'xrange <- c(-Inf, TRUE)', + + 'baz <- NA\n' + + 'my.pi <- pi\n' + + 'all.letters <- c(LETTERS, letters)\n' + + 'xrange <- c(-Inf, TRUE)' + ); + + run( + language, + + 'operators', + + 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + + 'bound.rect <- grid::rectGrob()\n' + + 'my_seq <- 1:10\n' + + 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + + 'plot(y ~ x, type = "l")', + + 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + + 'bound.rect <- grid::rectGrob()\n' + + 'my_seq <- 1:10\n' + + 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + + 'plot(y ~ x, type = "l")' + ); + + /** + * Note that the second function is intentionally not a function call, + * just testing that the regex is matching only 'function' and not .+function + */ + run( + language, + + 'function creation', + + 'square <- function(x) x * x\n' + + 'square2 <- testfunction(x) x * x\n' + + 'area <- function (r) {\n' + + ' pi * r^2\n' + + '}', + + 'square <- function(x) x * x\n' + + 'square2 <- testfunction(x) x * x\n' + + 'area <- function (r) {\n' + + ' pi * r^2\n' + + '}' + ); + + skip( + language, + + 'variable', + + 'tmp <- 1\n' + + 'another.tmp <- 2\n' + + 'this.is.a.var <- 3', + + 'tmp <- 1\n' + + 'another.tmp <- 2\n' + + 'this.is.a.var <- 3' + ); + + skip( + language, + + 'subsetting', + + 'tmp[1]\n' + + 'tmp[["test"]]', + + 'tmp[1]\n' + + 'tmp[["test"]]' + ); + + skip( + language, + + 'support functions', + + 'logical(10)\n' + + 'test.logical(10)\n' + + 'data.frame(a = 1:10, b = 15:24)\n' + + 'complex(real = 1, imaginary = 0.5)', + + 'logical(10)\n' + + 'test.logical(10)\n' + + 'data.frame(a = 1:10, b = 15:24)\n' + + 'complex(real = 1, imaginary = 0.5)' + ); +}); diff --git a/test/language/ruby-test.js b/test/language/ruby-test.js new file mode 100644 index 00000000..0fa8290c --- /dev/null +++ b/test/language/ruby-test.js @@ -0,0 +1,61 @@ +import '../../src/language/ruby'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'ruby'; + +describe(language, () => { + run( + language, + + 'multiple (non-greedy) strings', + + '"me" && "you"\n', + + '"me"' + + ' && ' + + '"you"\n' + ); + + run( + language, + + 'interpolated strings', + + '"chapter #{x+5}"\n', + + '"chapter ' + + '#{' + + 'x+' + + '5}' + + '"\n' + ); + + run( + language, + + 'string in brackets', + + 'foo = ["one", "two", "three"];', + + 'foo = ['+ + '"one", '+ + '"two", ' + + '"three"];' + ); + + run( + language, + + '__END__', + + 'class Test;end;\n__END__\nthis is just text\ntrue\n', + + 'class Test;' + + 'end;\n__END__\n' + + 'this is just text\ntrue\n' + ); + +}); diff --git a/test/language/smalltalk-test.js b/test/language/smalltalk-test.js new file mode 100644 index 00000000..b1dc3ecb --- /dev/null +++ b/test/language/smalltalk-test.js @@ -0,0 +1,309 @@ +import '../../src/language/smalltalk'; +import { run } from '../helper'; + +//////////////// +// Test suite // +//////////////// +const language = 'smalltalk'; + +describe(language, () => { + run( + language, + + 'constant true', + + 'true', + + 'true' + ); + + run( + language, + + 'constant false', + + 'false', + + 'false' + ); + + run( + language, + + 'constant nil', + + 'nil', + + 'nil' + ); + + run( + language, + + 'self pseudovariable', + + 'self', + + 'self' + ); + + run( + language, + + 'thisContext pseudovariable', + + 'thisContext', + + 'thisContext' + ); + + run( + language, + + 'two-character operator !!', + + '!!', + + '!!' + ); + + run( + language, + + 'two-character operator //', + + '//', + + '//' + ); + + run( + language, + + '| delimiter', + + '|', + + '|' + ); + + run( + language, + + '|| binary selector', + + '||', + + '||' + ); + + run( + language, + + 'HTML-unfriendly operator', + + '&', + + '&' + ); + + run( + language, + + 'three-character operator', + + '>>=', + + '>>=' + ); + + run( + language, + + 'String-like Symbol', + + "#'this is a symbol'", + + "#'this is a symbol'" + ); + + run( + language, + + 'Symbol', + + "#thisIsaSymbol0", + + "#thisIsaSymbol0" + ); + + run( + language, + + 'String', + + "'This is a string'", + + '\'This is a string\'' + ); + + run( + language, + + 'Comment', + + '"This is a comment"', + + '"This is a comment"' + ); + + run( + language, + + 'Comment in between message sends', + + 'self "this is a comment" foo', + + 'self "this is a comment" foo' + ); + + run( + language, + + 'Integer', + + '987654321', + + '987654321' + ); + + run( + language, + + 'Negative integer', + + '-987654321', + + '-987654321' + ); + + run( + language, + + 'Exponent integer', + + '987654321e10', + + '987654321e10' + ); + + run( + language, + + 'Negative exponent integer', + + '-987654321e10', + + '-987654321e10' + ); + + run( + language, + + 'Radix Integer', + + '16r987654321deadbeef', + + '16r987654321deadbeef' + ); + + run( + language, + + 'Negative radix Integer', + + '16r-987654321deadbeef', + + '16r-987654321deadbeef' + ); + + run( + language, + + 'Float', + + '987654321.0', + + '987654321.0' + ); + + run( + language, + + 'Negative float', + + '-987654321.0', + + '-987654321.0' + ); + + run( + language, + + 'Exponent float', + + '1.0e10', + + '1.0e10' + ); + + run( + language, + + 'Negative exponent float', + + '1.0e-10', + + '1.0e-10' + ); + + run( + language, + + 'Negative exponent negative float', + + '-1.0e-10', + + '-1.0e-10' + ); + + run( + language, + + 'Scaled decimal', + + '1.0s10', + + '1.0s10' + ); + + run( + language, + + 'Class name, normal', + + 'Class', + + 'Class' + ); + + run( + language, + + 'Class name, with digits', + + 'Class0zero', + + 'Class0zero' + ); +}); From c2f8c9f076f6a1e95e06c82950ceded3baa09113 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 10:15:38 -0400 Subject: [PATCH 073/153] Remove old tests directory --- tests/language/test.coffeescript.js | 260 -- tests/language/test.csharp.js | 198 - tests/language/test.css.js | 222 -- tests/language/test.d.js | 168 - tests/language/test.generic.js | 348 -- tests/language/test.haskell.js | 157 - tests/language/test.html.js | 240 -- tests/language/test.java.js | 109 - tests/language/test.javascript.js | 222 -- tests/language/test.json.js | 28 - tests/language/test.php.js | 407 -- tests/language/test.python.js | 210 -- tests/language/test.r.js | 126 - tests/language/test.ruby.js | 57 - tests/language/test.smalltalk.js | 304 -- tests/libs/chai-1.6.0.js | 4251 --------------------- tests/libs/mocha-1.9.0.css | 246 -- tests/libs/mocha-1.9.0.js | 5338 --------------------------- tests/libs/sinon-1.7.1.js | 4299 --------------------- tests/libs/sinon-chai-2.4.0.js | 109 - tests/libs/sinon-ie-1.7.1.js | 82 - tests/rainbow.html | 74 - 22 files changed, 17455 deletions(-) delete mode 100644 tests/language/test.coffeescript.js delete mode 100644 tests/language/test.csharp.js delete mode 100644 tests/language/test.css.js delete mode 100644 tests/language/test.d.js delete mode 100644 tests/language/test.generic.js delete mode 100644 tests/language/test.haskell.js delete mode 100644 tests/language/test.html.js delete mode 100644 tests/language/test.java.js delete mode 100644 tests/language/test.javascript.js delete mode 100644 tests/language/test.json.js delete mode 100644 tests/language/test.php.js delete mode 100644 tests/language/test.python.js delete mode 100644 tests/language/test.r.js delete mode 100644 tests/language/test.ruby.js delete mode 100644 tests/language/test.smalltalk.js delete mode 100644 tests/libs/chai-1.6.0.js delete mode 100644 tests/libs/mocha-1.9.0.css delete mode 100644 tests/libs/mocha-1.9.0.js delete mode 100644 tests/libs/sinon-1.7.1.js delete mode 100644 tests/libs/sinon-chai-2.4.0.js delete mode 100644 tests/libs/sinon-ie-1.7.1.js delete mode 100644 tests/rainbow.html diff --git a/tests/language/test.coffeescript.js b/tests/language/test.coffeescript.js deleted file mode 100644 index 98ccdb03..00000000 --- a/tests/language/test.coffeescript.js +++ /dev/null @@ -1,260 +0,0 @@ -/* global describe, run */ -var language = 'coffeescript'; - -describe(language, function() { - run( - language, - - 'comment', - - '# this is a comment', - - '# this is a comment' - ); - - run( - language, - - 'block comment', - - '###\n' + - 'CoffeeScript Compiler v1.3.3\n' + - 'Released under the MIT License\n' + - '###', - - '###\n' + - 'CoffeeScript Compiler v1.3.3\n' + - 'Released under the MIT License\n' + - '###' - ); - - run( - language, - - 'string', - - 'test = "this is a string"', - - 'test = "this is a string"' - ); - - run( - language, - - 'block string', - - 'html = """\n' + - ' \n' + - ' cup of coffeescript\n' + - ' \n' + - ' """', - - 'html = """\n' + - ' <strong>\n' + - ' cup of coffeescript\n' + - ' </strong>\n' + - ' """' - ); - - run( - language, - - 'function call', - - 'square = (x) -> x * x', - - 'square = (x) -> x * x' - ); - - run( - language, - - 'function call inside object', - - 'math =\n' + - ' root: Math.sqrt\n' + - ' square: square\n' + - ' cube: (x) -> x * square x', - - 'math =\n' + - ' root: Math.sqrt\n' + - ' square: square\n' + - ' cube: (x) -> x * square x' - ); - - run( - language, - - 'function call multiple arguments', - - 'race = (winner, runners...) ->\n' + - ' print winner, runners', - - 'race = (winner, runners...) ->\n' + - ' print winner, runners' - ); - - run( - language, - - 'switch statement', - - 'switch day\n' + - ' when "Mon" then go work\n' + - ' when "Tue" then go relax\n' + - ' when "Thu" then go iceFishing\n' + - ' when "Fri", "Sat"\n' + - ' if day is bingoDay\n' + - ' go bingo\n' + - ' go dancing\n' + - ' when "Sun" then go church\n' + - 'else go work', - - 'switch day\n' + - ' when "Mon" then go work\n' + - ' when "Tue" then go relax\n' + - ' when "Thu" then go iceFishing\n' + - ' when "Fri", "Sat"\n' + - ' if day is bingoDay\n' + - ' go bingo\n' + - ' go dancing\n' + - ' when "Sun" then go church\n' + - 'else go work' - ); - - run( - language, - - 'multiline regex', - - 'OPERATOR = /// ^ (\n' + - ' ?: [-=]> # function\n' + - ' | [-+*/%<>&|^!?=]= # compound assign / compare\n' + - ' | >>>=? # zero-fill right shift\n' + - ' | ([-+:])\\1 # doubles\n' + - ' | ([&|<>])\\2=? # logic / shift\n' + - ' | \\?\\. # soak access\n' + - ' | \\.{2,3} # range or splat\n' + - ') ///', - - 'OPERATOR = /// ^ (\n' + - ' ?: [-=]> # function\n' + - ' | [-+*/%<>&|^!?=]= # compound assign / compare\n' + - ' | >>>=? # zero-fill right shift\n' + - ' | ([-+:])\\1 # doubles\n' + - ' | ([&|<>])\\2=? # logic / shift\n' + - ' | \\?\\. # soak access\n' + - ' | \\.{2,3} # range or splat\n' + - ') ///' - ); - - run( - language, - - 'function inside function call', - - "task 'build:parser', 'rebuild the Jison parser', (options) ->\n" + - " require 'jison'\n" + - " code = require('./lib/grammar').parser.generate()\n" + - " dir = options.output or 'lib'\n" + - " fs.writeFile \"#{dir}/parser.js\", code", - - 'task \'build:parser\', \'rebuild the Jison parser\', (options) ->\n' + - ' require \'jison\'\n' + - ' code = require(\'./lib/grammar\').parser.generate()\n' + - ' dir = options.output or \'lib\'\n' + - ' fs.writeFile "#{dir}/parser.js", code' - ); - - run( - language, - - 'multiline function', - - 'weatherReport = (location) ->\n' + - ' # Make an Ajax request to fetch the weather...\n' + - ' [location, 72, "Mostly Sunny"]\n' + - '\n' + - ' [city, temp, forecast] = weatherReport "Berkeley, CA"', - - 'weatherReport = (location) ->\n' + - ' # Make an Ajax request to fetch the weather...\n' + - ' [location, 72, "Mostly Sunny"]\n' + - '\n' + - ' [city, temp, forecast] = weatherReport "Berkeley, CA"' - ); - - run( - language, - - 'function binding', - - 'Account = (customer, cart) ->\n' + - ' @customer = customer\n' + - ' @cart = cart\n' + - '\n' + - ' $(\'.shopping_cart\').bind \'click\', (event) =>\n' + - ' @customer.purchase @cart', - - 'Account = (customer, cart) ->\n' + - ' @customer = customer\n' + - ' @cart = cart\n' + - '\n' + - ' $(\'.shopping_cart\').bind \'click\', (event) =>\n' + - ' @customer.purchase @cart' - ); - - run( - language, - - 'direct function call', - - 'move: ->\n' + - ' alert "Galloping..."\n' + - ' super 45', - - 'move: ->\n' + - ' alert "Galloping..."\n' + - ' super 45' - ); - - run( - language, - - '@ keyword', - - 'alert @name + " moved #{meters}m."', - - 'alert @name + " moved #{meters}m."' - ); - - run( - language, - - 'class definition', - - 'class Animal', - - 'class Animal' - ); - - run( - language, - - 'child class definition', - - 'class Snake extends Animal', - - 'class Snake extends Animal' - ); - - run( - language, - - 'class instantiation', - - 'sam = new Snake "Sammy the Python"', - - 'sam = new Snake "Sammy the Python"' - ); -}); diff --git a/tests/language/test.csharp.js b/tests/language/test.csharp.js deleted file mode 100644 index 25c57f01..00000000 --- a/tests/language/test.csharp.js +++ /dev/null @@ -1,198 +0,0 @@ -/* global describe, run */ -var language = 'csharp'; - -describe(language, function() { - run( - language, - - 'echo', - - 'Console.WriteLine("hello world");', - - 'Console.WriteLine("hello world");' - ); - - run( - language, - - 'variable', - - 'var foo = true;', - - 'var foo = true;' - ); - - run( - language, - - 'string concatenation', - - 'string foo = "test " + "string " + "concatenation";', - - 'string foo = "test " + "string " + "concatenation";' - ); - - run( - language, - - 'typeof', - - "var is_array_object = typeof(System.Array);", - - 'var is_array_object = typeof(System.Array);' - ); - - run( - language, - - 'array stuff', - - 'string[] turtles = new string[] {\n' + - ' "leonardo",\n' + - ' "michaelangelo",\n' + - ' "donatello",\n' + - ' "raphael"\n' + - '};\n' + - '\n' + - 'bool exists = turtles[0] == "leonardo";', - - 'string[] turtles = new string[] {\n' + - ' "leonardo",\n' + - ' "michaelangelo",\n' + - ' "donatello",\n' + - ' "raphael"\n' + - '};\n' + - '\n' + - 'bool exists = turtles[0] == "leonardo";' - ); - - run( - language, - - 'namespace declaration', - - 'namespace Sonic.Database {', - - 'namespace Sonic.Database {' - ); - - run( - language, - - 'class declaration', - - 'class MyClass {}', - - 'class MyClass {}' - ); - - run( - language, - - 'abstract class declaration', - - 'abstract class MyClass {}', - - 'abstract class MyClass {}' - ); - - run( - language, - - 'sealed class declaration', - - 'sealed class TestClass\n' + - '{\n' + - '}', - - 'sealed class TestClass\n' + - '{\n' + - '}' - ); - - run( - language, - - 'child class declaration', - - 'class MyCollection : ICollection {}', - - 'class MyCollection : ICollection {}' - ); - - run( - language, - - 'test static', - - 'static void doSomethingElse() {}', - - 'static void doSomethingElse() {}' - ); - - run( - language, - - 'test magic function', - - 'protected void Page_Load(object sender, EventArgs e)\n' + - '{\n' + - ' // do whatever\n' + - '}', - - 'protected void Page_Load(object sender, EventArgs e)\n' + - '{\n' + - ' // do whatever\n' + - '}' - ); - - run( - language, - - 'test new class', - - 'new SomeClass();', - - 'new SomeClass();' - ); - - run( - language, - - 'test new namespace class', - - 'var s = new Sonic.Database.Query();', - - 'var s = new Sonic.Database.Query();' - ); - - run( - language, - - 'test static class call', - - 'var path = Sonic.App.getInstance();', - - 'var path = Sonic.App.getInstance();' - ); - - run( - language, - - 'type hint', - - 'public static string getForUser(User user, Sort sort) {}', - - 'public static string getForUser(User user, Sort sort) {}' - ); - - run( - language, - - 'generics', - - 'public IList<string> firstNames = new List<string>()', - - 'public IList<string> firstNames = new List<string>()' - ); -}); diff --git a/tests/language/test.css.js b/tests/language/test.css.js deleted file mode 100644 index a7d473ad..00000000 --- a/tests/language/test.css.js +++ /dev/null @@ -1,222 +0,0 @@ -/* global describe, run */ -var language = 'css'; - -describe(language, function() { - run( - language, - - 'comment', - - '/* comment */', - - '/* comment */' - ); - - run( - language, - - 'multi-line comment', - - '/**\n' + - ' * comment\n' + - ' */', - - '/**\n' + - ' * comment\n' + - ' */' - ); - - run( - language, - - 'pixels', - - 'margin:10px 20px 5px 30px;', - - 'margin:10px 20px 5px 30px;' - ); - - run( - language, - - 'cm', - - 'margin: 1cm 2cm 1.3cm 4cm;', - - 'margin: 1cm 2cm 1.3cm 4cm;' - ); - - run( - language, - - 'em', - - 'font-size: 1.2em;', - - 'font-size: 1.2em;' - ); - - run( - language, - - 'percentage', - - 'width: 100%\n' + - 'height: 100%', - - 'width: 100%\n' + - 'height: 100%' - ); - - run( - language, - - 'string single quote', - - '\'test string\'', - - '\'test string\'' - ); - - run( - language, - - 'string double quote', - - '"test string"', - - '"test string"' - ); - - run( - language, - - 'transition - vendor prefix', - - 'code span {\n' + - ' -moz-transition: color .8s ease-in;\n' + - ' -o-transition: color .8s ease-in;\n' + - ' -webkit-transition: color .8s ease-in;\n' + - ' transition: color .8s ease-in;\n' + - '}', - - 'code span {\n' + - ' -moz-transition: color .8s ease-in;\n' + - ' -o-transition: color .8s ease-in;\n' + - ' -webkit-transition: color .8s ease-in;\n' + - ' transition: color .8s ease-in;\n' + - '}' - ); - - run( - language, - - 'tag', - - 'p {', - - 'p {' - ); - - run( - language, - - 'class', - - 'p.intro {', - - 'p.intro {' - ); - - run( - language, - - 'id', - - 'p#intro {', - - 'p#intro {' - ); - - run( - language, - - 'direct descendant', - - 'p > span {', - - 'p > span {' - ); - - run( - language, - - 'scss', - - 'article {\n' + - ' &.cool {\n' + - ' p {\n' + - ' margin-top: 20px;\n' + - ' }\n' + - ' }\n' + - '}', - - 'article {\n' + - ' &.cool {\n' + - ' p {\n' + - ' margin-top: 20px;\n' + - ' }\n' + - ' }\n' + - '}' - ); - - run( - language, - - 'one line', - - 'p { color: #fff; margin-top: 10px; }', - - 'p { color: #fff; margin-top: 10px; }' - ); - - run( - language, - - 'linear gradients', - - '.gradient {\n' + - ' background: -webkit-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: -moz-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: -o-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: linear-gradient(#f7f7f7, #e8e8e8);\n' + - '}', - - '.gradient {\n' + - ' background: -webkit-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: -moz-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: -o-linear-gradient(#f7f7f7, #e8e8e8);\n' + - ' background: linear-gradient(#f7f7f7, #e8e8e8);\n' + - '}' - ); - - run( - language, - - 'multi line selectors', - - '.maps-headline,\n' + - '.maps-subline,\n' + - '.chart-headline,\n' + - '.chart-subline {\n' + - ' font-weight: bold;\n' + - '}', - - '.maps-headline,\n' + - '.maps-subline,\n' + - '.chart-headline,\n' + - '.chart-subline {\n' + - ' font-weight: bold;\n' + - '}' - ); -}); diff --git a/tests/language/test.d.js b/tests/language/test.d.js deleted file mode 100644 index fef642a1..00000000 --- a/tests/language/test.d.js +++ /dev/null @@ -1,168 +0,0 @@ -/* global describe, run */ -var language = 'd'; - -describe(language, function() { - run( - language, - - 'echo', - - 'writeln("hello world");', - - 'writeln("hello world");' - ); - - run( - language, - - 'variable', - - 'bool foo = true;', - - 'bool foo = true;' - ); - - run( - language, - - 'string concatenation', - - 'string foo = "test " ~ "string " ~ "concatenation";', - - 'string foo = "test " ~ "string " ~ "concatenation";' - ); - - run( - language, - - 'typeof', - - "auto is_array_object = typeof(System.Array);", - - 'auto is_array_object = typeof(System.Array);' - ); - - run( - language, - - 'array stuff', - - 'string[] turtles = new string[] {\n' + - ' "leonardo",\n' + - ' "michaelangelo",\n' + - ' "donatello",\n' + - ' "raphael"\n' + - '};\n' + - '\n' + - 'bool exists = turtles[0] == "leonardo";', - - 'string[] turtles = new string[] {\n' + - ' "leonardo",\n' + - ' "michaelangelo",\n' + - ' "donatello",\n' + - ' "raphael"\n' + - '};\n' + - '\n' + - 'bool exists = turtles[0] == "leonardo";' - ); - - run( - language, - - 'module declaration', - - 'module SonicDatabase;', - - 'module SonicDatabase;' - ); - - run( - language, - - 'class declaration', - - 'class MyClass {}', - - 'class MyClass {}' - ); - - run( - language, - - 'abstract class declaration', - - 'abstract class MyClass {}', - - 'abstract class MyClass {}' - ); - - run( - language, - - 'child class declaration', - - 'class MyCollection : ICollection {}', - - 'class MyCollection : ICollection {}' - ); - - run( - language, - - 'test static', - - 'static void doSomethingElse() {}', - - 'static void doSomethingElse() {}' - ); - - run( - language, - - 'test new class', - - 'new SomeClass();', - - 'new SomeClass();' - ); - - run( - language, - - 'test new namespace class', - - 'auto s = new Sonic.Database.Query();', - - 'auto s = new Sonic.Database.Query();' - ); - - run( - language, - - 'test static class call', - - 'auto path = Sonic.App.getInstance();', - - 'auto path = Sonic.App.getInstance();' - ); - - run( - language, - - 'type hint', - - 'public static string getForUser(User user, Sort sort) {}', - - 'public static string getForUser(User user, Sort sort) {}' - ); - - run( - language, - - 'template', - - 'public List!string firstNames = new List!(string)()', - - 'public List!string firstNames = new List!(string)()' - ); -}); diff --git a/tests/language/test.generic.js b/tests/language/test.generic.js deleted file mode 100644 index 073b1a97..00000000 --- a/tests/language/test.generic.js +++ /dev/null @@ -1,348 +0,0 @@ -/* global describe, run */ -var language = 'generic'; - -describe(language, function() { - run( - language, - - 'string alone', - - 'foo = "this is a string"', - - 'foo = "this is a string"' - ); - - run( - language, - - 'string after equal sign', - - 'foo=\'this is a string\'', - - 'foo=\'this is a string\'' - ); - - run( - language, - - 'string in brackets', - - 'foo = ["one", "two", "three"];', - - 'foo = ["one", "two", "three"];' - ); - - run( - language, - - 'string in function call', - - "someFunction('some string', true);", - - 'someFunction(\'some string\', true);' - ); - - run( - language, - - 'concatenated string', - - "foo = 'string1' + 'string2';", - - 'foo = \'string1\' + \'string2\';' - ); - - run( - language, - - 'quoted comment with string', - - '# someone\'s comment\n' + - 'doSomething(\'js\')\n' + - 'doSomethingElse()\n' + - 'test = \'other string\'', - - '# someone\'s comment\n' + - 'doSomething(\'js\')\n' + - 'doSomethingElse()\n' + - 'test = \'other string\'' - ); - - run( - language, - - 'quoted comment with multi-line string', - - '/* someone\'s comment */\n' + - 'doSomething(\'js\')\n' + - 'doSomethingElse()\n' + - 'test = \'other string\n' + - 'string is still going\'', - - '/* someone\'s comment */\n' + - 'doSomething(\'js\')\n' + - 'doSomethingElse()\n' + - 'test = \'other string\n' + - 'string is still going\'' - ); - - run( - language, - - 'quoted comment with multi-line directly after', - - '// someone\'s comment\n' + - 'test = \'blah blah\n' + - 'blah blah blah\'', - - '// someone\'s comment\n' + - 'test = \'blah blah\n' + - 'blah blah blah\'' - ); - - run( - language, - - 'comment inline 1', - - '// this is a comment', - - '// this is a comment' - ); - - run( - language, - - 'comment inline 2', - - '// this is a comment\n' + - '//\n' + - '// other comment', - - '// this is a comment\n' + - '//\n' + - '// other comment' - ); - - run( - language, - - 'comment inline 3', - - '# this is a comment', - - '# this is a comment' - ); - - run( - language, - - 'comment inline 4', - - '/* this is a comment */', - - '/* this is a comment */' - ); - - run( - language, - - 'comment block', - - '/**\n' + - ' * test comment\n' + - ' */', - - '/**\n' + - ' * test comment\n' + - ' */' - ); - - run( - language, - - 'integer', - - '23', - - '23' - ); - - run( - language, - - 'decimal', - - '3.21', - - '3.21' - ); - - run( - language, - - 'float', - - '23.5f', - - '23.5f' - ); - - run( - language, - - 'exponential', - - '121.22e-10', - - '121.22e-10' - ); - - run( - language, - - 'hex', - - '0x0A', - - '0x0A' - ); - - run( - language, - - 'language constants', - - 'if (thing == true) {\n' + - ' thing = false;\n' + - '}\n' + - 'other_thing = null;' , - - 'if (thing == true) {\n' + - ' thing = false;\n' + - '}\n' + - 'other_thing = null;' - ); - - run( - language, - - 'comment after string', - - 'var test = "some string" // comment after string', - - 'var test = "some string" // comment after string' - ); - - run( - language, - - 'operator math', - - 'value = (25 * 2) + (14 / 2) - 10', - - 'value = (25 * 2) + (14 / 2) - 10' - ); - - run( - language, - - 'operator comparison not escaped', - - 'if ((test > 0 && test < 25) || test == 50) {\n' + - ' print "nice";\n' + - '}', - - 'if ((test > 0 && test < 25) || test == 50) {\n' + - ' print "nice";\n' + - '}' - ); - - run( - language, - - 'operator comparison escaped', - - 'if ((test > 0 && test < 25) || test == 50) {\n' + - ' print "nice";\n' + - '}', - - 'if ((test > 0 && test < 25) || test == 50) {\n' + - ' print "nice";\n' + - '}' - ); - - run( - language, - - 'function call', - - 'someFunction(arg);', - - 'someFunction(arg);' - ); - - run( - language, - - 'function definition', - - 'function someFunction(arg) {\n' + - ' return strtolower(arg);\n' + - '}', - - 'function someFunction(arg) {\n' + - ' return strtolower(arg);\n' + - '}' - ); - - skip( - language, - - 'comment after website string', - - 'var test = "http://website.com/index.html"; // sweet website', - - 'var test = "http://website.com/index.html"; // sweet website' - ); - - run( - language, - - 'escaped string single quote', - - 'var test = \'someone\\\'s string\'', - - 'var test = \'someone\\\'s string\'' - ); - - run( - language, - - 'escaped string double quote', - - 'var test = \"someone\\\"s string\"', - - 'var test = "someone\\\"s string"' - ); - - run( - language, - - 'string concatenation with +', - - 'time=h+":"+m+":"+s;', - - 'time=h+":"+m+":"+s;' - ); - - run( - language, - - 'string concatenation with .', - - 'NV_CSS.\'/app.css\'', - - 'NV_CSS.\'/app.css\'' - ); -}); diff --git a/tests/language/test.haskell.js b/tests/language/test.haskell.js deleted file mode 100644 index b98c83c4..00000000 --- a/tests/language/test.haskell.js +++ /dev/null @@ -1,157 +0,0 @@ -/* global describe, run */ -var language = 'haskell'; - -describe(language, function() { - run( - language, - '-- comments', - '-- fn2 :: String -> [String]', - '-- fn2 :: String -> [String]' - ); - - run( - language, - '{-- comments --}', - '{-- this is a comment --}', - '{-- this is a comment --}' - ); - - run( - language, - '{-- comments with multiple lines --}', - '{--\n' + - ' this is a comment\n' + - '--}', - '{--\n this is a comment\n--}' - ); - - run( - language, - 'module declaration', - 'module A where', - 'module A where' - ); - - run( - language, - 'module with exported functions and comments', - 'module A (\n' + - ' B,\n' + - ' C(..),\n' + - ' fn1,\n' + - ' fn2, -- fn2 :: String -> [String]\n' + - ' fn3\n' + - ') where', - 'module A (\n B,\n C(..),\n fn1,\n fn2, -- fn2 :: String -> [String]\n fn3\n) where' - ); - - run( - language, - 'import', - 'import Data.List qualified DL\n' + - 'import Prelude hiding ((*))', - 'import Data.List qualified DL\nimport Prelude hiding ((*))' - ); - - run( - language, - 'function declaration', - 'fn :: String -> [(String,Int)]', - 'fn :: String -> [(String,Int)]' - ); - - run( - language, - 'IO function declaration', - 'getLine :: IO String\n' + - 'getLine = do c <- getChar\n' + - ' if c == \'\\n\' then return ""\n' + - ' else do s <- getLine\n' + - ' return (c:s)', - 'getLine :: IO String\ngetLine = do c <- getChar\n if c == \'\\n\' then return ""\n else do s <- getLine\n return (c:s)' - ); - - run( - language, - 'infix declaration', - 'infix 4 >*', - 'infix 4 >*' - ); - - run( - language, - 'let declaration', - 'let a\' = s :: String\n' + - 'in a\' \"some string\"', - 'let a\' = s :: String\nin a\' "some string"' - ); - - run( - language, - 'if declaration', - 'if a == 0\n' + - 'then A\n' + - 'else B', - 'if a == 0\nthen A\nelse B' - ); - - run( - language, - 'data types decaration', - 'data S = S1 { x :: Int }\n' + - ' | S2 { x :: Int }\n' + - ' deriving (Show, Eq)\n\n' + - 'newtype NString = [String]\n\n' + - 'type String = [Char]', - 'data S = S1 { x :: Int }\n | S2 { x :: Int }\n deriving (Show, Eq)\n\nnewtype NString = [String]\n\ntype String = [Char]' - ); - - run( - language, - 'classes', - 'class Eq a where\n' + - ' (==), (/=) :: a -> a -> Bool\n\n' + - ' x /= y = not (x == y)\n' + - ' x == y = not (x /= y)', - 'class Eq a where\n (==), (/=) :: a -> a -> Bool\n\n x /= y = not (x == y)\n x == y = not (x /= y)' - ); - - run( - language, - 'instances', - 'instance Monad IO where\n' + - ' fail s = ioError (userError s)', - 'instance Monad IO where\n fail s = ioError (userError s)' - ); - - run( - language, - 'list comprehensions', - '[ x | x <- x, x <- x ]', - '[ x | x <- x, x <- x ]' - ); - - run( - language, - 'case statement', - 'case e of\n' + - ' A -> Just a\n' + - ' _ -> Nothing', - 'case e of\n A -> Just a\n _ -> Nothing' - ); - - run( - language, - 'C Preprocessors', - '#ifndef __NHC__\n' + - 'exitWith :: ExitCode -> IO a\n' + - 'exitWith ExitSuccess = throwIO ExitSuccess\n' + - 'exitWith code@(ExitFailure n)\n' + - ' | n /= 0 = throwIO code\n' + - '#ifdef __GLASGOW_HASKELL__\n' + - ' | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)\n' + - '#endif\n' + - '#endif /* ! __NHC__ */', - '#ifndef __NHC__\nexitWith :: ExitCode -> IO a\nexitWith ExitSuccess = throwIO ExitSuccess\nexitWith code@(ExitFailure n)\n | n /= 0 = throwIO code\n#ifdef __GLASGOW_HASKELL__\n | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)\n#endif\n#endif /* ! __NHC__ */' - ); -}); diff --git a/tests/language/test.html.js b/tests/language/test.html.js deleted file mode 100644 index 5df646f3..00000000 --- a/tests/language/test.html.js +++ /dev/null @@ -1,240 +0,0 @@ -/* global describe, run */ -var language = 'html'; - -describe(language, function() { - run( - language, - - 'comment', - - '', - - '<!-- this is a comment -->' - ); - - - run( - language, - - 'multi-line comment', - - '', - - '<!-- this is a comment\n' + - 'on two lines -->' - ); - - - run( - language, - - 'paragraph', - - '

this is a paragraph

', - - '<p class="test">this is a paragraph</p>' - ); - - - run( - language, - - 'inline php', - - '
    \n' + - ' \n' + - '
  • title; ?>
  • \n' + - ' \n' + - '
', - - '<ul class="articles">\n' + - ' <?php foreach ($articles as $article): ?>\n' + - ' <li><?php echo $article->title; ?></li>\n' + - ' <?php endforeach; ?>\n' + - '</ul>' - ); - - run( - language, - - 'php short tag', - - '<? foreach ($users as $key => $user): ?>\n' + - '

<?= $user->getBio() ?>

\n' + - '<? endforeach ?>', - - '<? foreach ($users as $key => $user): ?>\n' + - ' <p><?= $user->getBio() ?></p>\n' + - '<? endforeach ?>' - ); - - run( - language, - - 'xml declaration', - - '', - - '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' - ); - - - run( - language, - - 'inline css 1', - - '', - - '<style type="text/css">\n' + - ' body span.blah {\n' + - ' background: #000;\n' + - ' color: #fff;\n' + - ' }\n' + - '</style>' - ); - - - run( - language, - - 'inline css 2', - - '', - - '<style>\n' + - ' body span.blah {\n' + - ' background: #000;\n' + - ' color: #fff;\n' + - ' }\n' + - '</style>' - ); - - - run( - language, - - 'inline js 1', - - '', - - '<script type="text/javascript">\n' + - ' function prettyCool() {\n' + - ' doSomeJQueryOrWhatever();\n' + - ' }\n' + - '</script>' - ); - - - run( - language, - - 'inline js 2', - - '', - - '<script>\n' + - ' function prettyCool() {\n' + - ' doSomeJQueryOrWhatever();\n' + - ' }\n' + - '</script>' - ); - - - run( - language, - - 'js include', - - '', - - '<script src="http://somewebsite.com/some-script.js" type="text/javascript"></script>' - ); - - run( - language, - - 'attribute no quotes', - - '

test

', - - '<p class=test>test</p>' - ); - - run( - language, - - 'attribute alone', - - '', - - '<input type="checkbox" name="whatever" checked>' - ); - - run( - language, - - 'attribute middle', - - '', - - '<input checked type="checkbox">' - ); - - run( - language, - - 'attribute alone self close', - - '', - - '<input type="checkbox" name="whatever" checked />' - ); - - run( - language, - - 'attribute camel case', - - '', - - '<button onClick="test()">Click me</button>' - ); - - run( - language, - - 'string inside tags', - - '
def openFile(path):\n' +
-        'file = open(path, "r")\n' +
-        'content = file.read()\n' +
-        'file.close()\n' +
-        'return content
', - - '<pre><code data-language="python">def openFile(path):\n' + - 'file = open(path, "r")\n' + - 'content = file.read()\n' + - 'file.close()\n' + - 'return content</code></pre>' - ); -}); diff --git a/tests/language/test.java.js b/tests/language/test.java.js deleted file mode 100644 index 6b149209..00000000 --- a/tests/language/test.java.js +++ /dev/null @@ -1,109 +0,0 @@ -/* global describe, run */ -var language = 'java'; - -describe(language, function() { - run( - language, - "package declaration", - 'package com.example.rainbow;', - 'package com.example.rainbow;' - ); - - run( - language, - "import statement", - 'import com.example.rainbow.util.RainbowUtil;', - 'import com.example.rainbow.util.RainbowUtil;' - ); - - run( - language, - "multi-line comment", - '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */', - '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */' - ); - - run( - language, - "single-line comment", - '// This is a good comment.', - '// This is a good comment.' - ); - - run( - language, - "complicated class declaration", - 'public class Rainbow> extends Spectrum implements HasColors, IsPretty {', - 'public class Rainbow<T, List<? extends T>> extends Spectrum implements HasColors, IsPretty {' - ); - - run( - language, - "simple class declaration", - 'public class Rainbow {', - 'public class Rainbow {' - ); - - run( - language, - "constant declaration", - 'private static final int RESOLUTION = 7;', - 'private static final int RESOLUTION = 7;' - ); - - run( - language, - "field declaration", - 'private final String name;', - 'private final String name;' - ); - - run( - language, - "method declaration", - 'public void shine() {', - 'public void shine() {' - ); - - run( - language, - "simple annotation", - '@Override', - '@Override' - ); - - run( - language, - "complex annotation", - '@RequestMapping( value = "/rainbow", method = Method.POST )', - '@RequestMapping( value = "/rainbow", method = Method.POST )' - ); - - run( - language, - "string concatenation", - '"I found " + numberOfTurtles + " turtles."', - '"I found " + numberOfTurtles + " turtles."' - ); - - run( - language, - "local method invocation", - 'wait(1000L)', - 'wait(1000L)' - ); - - run( - language, - "static method invocation", - 'System.out.println("Hello, world!");', - 'System.out.println("Hello, world!");' - ); - - run( - language, - "variable assignment", - 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );', - 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );' - ); -}); diff --git a/tests/language/test.javascript.js b/tests/language/test.javascript.js deleted file mode 100644 index 5e09bc54..00000000 --- a/tests/language/test.javascript.js +++ /dev/null @@ -1,222 +0,0 @@ -/* global describe, run */ -var language = 'javascript'; - -describe(language, function() { - run( - language, - - 'selector 1', - - '$.get()', - - '$.get()' - ); - - run( - language, - - 'selector 2', - - ' $(\'.some_class\').show()', - - ' $(\'.some_class\').show()' - ); - - run( - language, - - 'window', - - 'console.log(window.scrollX)', - - 'console.log(window.scrollX)' - ); - - run( - language, - - 'document', - - 'document.getElementById(\'#some_id\')', - - 'document.getElementById(\'#some_id\')' - ); - - run( - language, - - 'regex', - - 'var pattern = /\\((.*?)\\)/g', - - 'var pattern = /\\((.*?)\\)/g' - ); - - run( - language, - - 'regex 2', - - 'var pattern = /true/', - - 'var pattern = /true/' - ); - - run( - language, - - 'string no regex', - - 'var test = "http://website.com/could/match/regex/i";', - - 'var test = "http://website.com/could/match/regex/i";' - ); - - run( - language, - - 'single line comment vs. regex', - - 'var Animal = function() { /* some comment */ };', - - 'var Animal = function() { /* some comment */ };' - ); - - run( - language, - - 'class instantiation', - - 'var animal = new Animal();', - - 'var animal = new Animal();' - ); - - run( - language, - - 'inline function', - - 'var foo = true,\n' + - ' something = function() {\n' + - ' // do something\n' + - ' };', - - 'var foo = true,\n' + - ' something = function() {\n' + - ' // do something\n' + - ' };' - ); - - run( - language, - - 'inline function beginning of line', - - 'something = function() {\n' + - ' // do something\n' + - '};', - - 'something = function() {\n' + - ' // do something\n' + - '};' - ); - - run( - language, - - 'functions in object', - - 'window.Rainbow = {\n' + - ' color: function() {\n' + - ' // do something\n' + - ' },\n' + - '\n' + - ' other: function() {}\n' + - '};', - - 'window.Rainbow = {\n' + - ' color: function() {\n' + - ' // do something\n' + - ' },\n' + - '\n' + - ' other: function() {}\n' + - '};' - ); - - run( - language, - - 'JSON 1', - - '{\n' + - ' "generated_in": "0.0423",\n' + - ' "stat": "fail"\n' + - ' "err": {\n' + - ' "code": "1",\n' + - ' "expl": "The user id or name was either not valid or not provided.",\n' + - ' "msg": "User not found"\n' + - ' }\n' + - '}', - - '{\n' + - ' "generated_in": "0.0423",\n' + - ' "stat": "fail"\n' + - ' "err": {\n' + - ' "code": "1",\n' + - ' "expl": "The user id or name was either not valid or not provided.",\n' + - ' "msg": "User not found"\n' + - ' }\n' + - '}' - ); - - run( - language, - - 'JSON 2', - - '{\n' + - ' "generated_in":"0.0423",\n' + - ' "stat":"fail"\n' + - ' "err":{\n' + - ' "code":"1",\n' + - ' "expl":"The user id or name was either not valid or not provided.",\n' + - ' "msg":"User not found"\n' + - ' }\n' + - '}', - - '{\n' + - ' "generated_in":"0.0423",\n' + - ' "stat":"fail"\n' + - ' "err":{\n' + - ' "code":"1",\n' + - ' "expl":"The user id or name was either not valid or not provided.",\n' + - ' "msg":"User not found"\n' + - ' }\n' + - '}' - ); - - run( - language, - - 'multiple var declarations', - - 'var language = getLanguage(source);\n' + - 'var parseAndHighlight = function() {};\n' + - 'var parseAndHighlight2 = function() {};', - - 'var language = getLanguage(source);\n' + - 'var parseAndHighlight = function() {};\n' + - 'var parseAndHighlight2 = function() {};' - ); - - run( - language, - - 'multiple regex same line', - - "code.replace(//g, '>')", - - 'code.replace(/</g, \'<\').replace(/>/g, \'>\')' - ); -}); diff --git a/tests/language/test.json.js b/tests/language/test.json.js deleted file mode 100644 index 2524c73f..00000000 --- a/tests/language/test.json.js +++ /dev/null @@ -1,28 +0,0 @@ -/* global describe, run */ -var language = 'json'; - -describe(language, function() { - run( - language, - - 'json string', - - '{\n' + - ' "id": 23,\n' + - ' "name": "Something",\n' + - ' "description": "He said, \"Double quotes inside of other double quotes.\"",\n' + - ' "tags": [\n' + - ' "one",\n' + - ' "two",\n' + - ' "three"\n' + - ' ],\n' + - ' "image": {\n' + - ' "url": "http://example.com/image.jpg",\n' + - ' "width": 100,\n' + - ' "height": 100\n' + - ' }\n' + - '}', - - '{\n "id": 23,\n "name": "Something",\n "description": "He said, "Double quotes inside of other double quotes."",\n "tags": [\n "one",\n "two",\n "three"\n ],\n "image": {\n "url": "http://example.com/image.jpg",\n "width": 100,\n "height": 100\n }\n}' - ); -}); diff --git a/tests/language/test.php.js b/tests/language/test.php.js deleted file mode 100644 index 93c859ca..00000000 --- a/tests/language/test.php.js +++ /dev/null @@ -1,407 +0,0 @@ -/* global describe, run */ -var language = 'php'; - -describe(language, function() { - run( - language, - - 'echo', - - 'echo \'hello world\';', - - 'echo \'hello world\';' - ); - - run( - language, - - 'variable', - - '$foo = true;', - - '$foo = true;' - ); - - skip( - language, - - 'variable variable', - - '$$foo = true;', - - '$$foo = true;' - ); - - run( - language, - - 'string concatenation', - - "$foo = 'test' . 'string' . 'concatenation';", - - '$foo = \'test\' . \'string\' . \'concatenation\';' - ); - - run( - language, - - 'include 1', - - "include 'App.php';", - - 'include \'App.php\';' - ); - - run( - language, - - 'include 2', - - "include_once('App.php');", - - 'include_once(\'App.php\');' - ); - - run( - language, - - 'instanceof', - - "$is_array_object = $collection instanceof ArrayObject;", - - '$is_array_object = $collection instanceof ArrayObject;' - ); - - run( - language, - - 'instanceof namespace class', - - "$is_user = $object instanceof App\\User;", - - '$is_user = $object instanceof App\\User;' - ); - - run( - language, - - 'array stuff', - - '$turtles = array(\n' + - ' \'leonardo\',\n' + - ' \'michaelangelo\',\n' + - ' \'donatello\',\n' + - ' \'raphael\'\n' + - ');\n' + - '\n' + - '$exists = array_key_exists(0, $turtles);', - - '$turtles = array(\n' + - ' \'leonardo\',\n' + - ' \'michaelangelo\',\n' + - ' \'donatello\',\n' + - ' \'raphael\'\n' + - ');\n' + - '\n' + - '$exists = array_key_exists(0, $turtles);' - ); - - run( - language, - - 'php tag', - - '<?php echo $foo; ?>', - - '<?php echo $foo; ?>' - ); - - run( - language, - - 'php tag 2', - - '<?php echo \'?>\'; ?>', - - '<?php echo \'?>\'; ?>' - ); - - run( - language, - - 'namespace declaration', - - 'namespace Sonic\\Database;', - - 'namespace Sonic\\Database;' - ); - - run( - language, - - 'use declaration', - - 'use Sonic;', - - 'use Sonic;' - ); - - run( - language, - - 'class declaration', - - 'class MyClass {}', - - 'class MyClass {}' - ); - - run( - language, - - 'trait declaration', - - 'trait MyClass {}', - - 'trait MyClass {}' - ); - - run( - language, - - 'interface declaration', - - 'interface IMyClass {}', - - 'interface IMyClass {}' - ); - - run( - language, - - 'abstract class declaration', - - 'abstract class MyClass {}', - - 'abstract class MyClass {}' - ); - - run( - language, - - 'final class declaration', - - 'final class TestClass\n' + - '{\n' + - '}', - - 'final class TestClass\n' + - '{\n' + - '}' - ); - - run( - language, - - 'class with an implementation declaration', - - 'class Collection implements IList {}', - - 'class Collection implements IList {}' - ); - - run( - language, - - 'child class declaration', - - 'class Collection extends ArrayObject {}', - - 'class Collection extends ArrayObject {}' - ); - - run( - language, - - 'child class with an implementation declaration', - - 'class Collection extends ArrayObject implements IList {}', - - 'class Collection extends ArrayObject implements IList {}' - ); - - run( - language, - - 'final child class declaration', - - 'final class TestClass extends \\Some\\Other\\Class {}', - - 'final class TestClass extends \\Some\\Other\\Class {}' - ); - - run( - language, - - 'test static', - - 'self::_doSomething();\n' + - 'static::_doSomethingElse();', - - 'self::_doSomething();\n' + - 'static::_doSomethingElse();' - ); - - run( - language, - - 'test magic function', - - 'function __autoload($class)\n' + - '{\n' + - ' // do whatever\n' + - '}', - - 'function __autoload($class)\n' + - '{\n' + - ' // do whatever\n' + - '}' - ); - - run( - language, - - 'test magic method', - - 'class SomeThing\n' + - '{\n' + - ' protected $_foo;\n' + - '\n' + - ' public function __construct($foo)\n' + - ' {\n' + - ' $this->_foo = $foo;\n' + - ' }\n' + - '}', - - 'class SomeThing\n' + - '{\n' + - ' protected $_foo;\n' + - '\n' + - ' public function __construct($foo)\n' + - ' {\n' + - ' $this->_foo = $foo;\n' + - ' }\n' + - '}' - ); - - run( - language, - - 'test new class', - - 'new SomeClass();', - - 'new SomeClass();' - ); - - run( - language, - - 'test new namespace class', - - 'new Sonic\\Database\\Query();', - - 'new Sonic\\Database\\Query();' - ); - - run( - language, - - 'test new class without parenthesis', - - 'new Sonic\\Controller;', - - 'new Sonic\\Controller;' - ); - - run( - language, - - 'test static class call', - - '$path = Sonic\\App::getInstance()->getPath();', - - '$path = Sonic\\App::getInstance()->getPath();' - ); - - run( - language, - - 'constant language', - - 'true; TRUE;', - - 'true; TRUE;' - ); - - run( - language, - - 'constant', - - 'TEST_CONSTANT', - - 'TEST_CONSTANT' - ); - - run( - language, - - 'constant 2', - - '(TEST_CONSTANT_2)', - - '(TEST_CONSTANT_2)' - ); - - run( - language, - - 'class constant', - - '$version = Sonic\\App::VERSION', - - '$version = Sonic\\App::VERSION' - ); - - run( - language, - - 'static variable access', - - '$foo = Sonic\\App::$static_property;', - - '$foo = Sonic\\App::$static_property;' - ); - - run( - language, - - 'type hint', - - 'public static function getForUser(User $user, Sort $sort) {}', - - 'public static function getForUser(User $user, Sort $sort) {}' - ); - - - run( - language, - - 'type hint with namespace', - - 'public static function getForUser(\\SomeApp\\User $user) {}', - - 'public static function getForUser(\\SomeApp\\User $user) {}' - ); -}); diff --git a/tests/language/test.python.js b/tests/language/test.python.js deleted file mode 100644 index 468a9bbe..00000000 --- a/tests/language/test.python.js +++ /dev/null @@ -1,210 +0,0 @@ -/* global describe, run */ -var language = 'python'; - -describe(language, function() { - run( - language, - - 'no self', - - 'print self.something', - - 'print self.something' - ); - - run( - language, - - 'comment', - - '# this is a comment', - - '# this is a comment' - ); - - run( - language, - - 'language constants', - - 'var1 = None\n' + - 'var2 = True\n' + - 'someFunction(var3=False)', - - 'var1 = None\n' + - 'var2 = True\n' + - 'someFunction(var3=False)' - ); - - run( - language, - - 'object', - - 'object', - - 'object' - ); - - run( - language, - - 'import', - - 'from SomePackage import SomeThing', - - 'from SomePackage import SomeThing' - ); - - run( - language, - - 'class', - - 'class Something(object):\n' + - ' pass', - - 'class Something(object):\n' + - ' pass' - ); - - run( - language, - - 'special method', - - 'def __init__(self, some_var):\n' + - ' pass', - - 'def __init__(self, some_var):\n' + - ' pass' - ); - - run( - language, - - 'function', - - 'def openFile(path):\n' + - ' file = open(path, "r")\n' + - ' content = file.read()\n' + - ' file.close()\n' + - ' return content', - - 'def openFile(path):\n' + - ' file = open(path, "r")\n' + - ' content = file.read()\n' + - ' file.close()\n' + - ' return content' - ); - - run( - language, - - 'decorator', - - '@makebold\n' + - '@makeitalic\n' + - 'def hello():\n' + - ' return "hello world"', - - '@makebold\n' + - '@makeitalic\n' + - 'def hello():\n' + - ' return "hello world"' - ); - - run( - language, - - '__main__', - - 'if __name__ == \'__main__\':\n' + - ' pass', - - 'if __name__ == \'__main__\':\n' + - ' pass' - ); - - run( - language, - - 'try catch', - - 'try:\n' + - ' import cPickle as pickle\n' + - 'except ImportError:\n' + - ' import pickle', - - 'try:\n' + - ' import cPickle as pickle\n' + - 'except ImportError:\n' + - ' import pickle' - ); - - run( - language, - - 'docstring single line double quotes', - - '"""docstring test"""', - - '"""docstring test"""' - ); - - run( - language, - - 'docstring single line single quotes', - - "'''docstring test'''", - - '\'\'\'docstring test\'\'\'' - ); - - run( - language, - - 'docstring multiline', - - '"""test\n' + - 'multiline\n' + - 'yes"""', - - '"""test\n' + - 'multiline\n' + - 'yes"""' - ); - - run( - language, - - 'decorator with dot', - - '@tornado.web.asynchronous', - - '@tornado.web.asynchronous' - ); - - run( - language, - - 'multiple docstrings', - - '"""\n' + - 'x\n' + - '"""\n' + - '2 + 2\n' + - '"""\n' + - 'y\n' + - '"""', - - '"""\n' + - 'x\n' + - '"""\n' + - '2 + 2\n' + - '"""\n' + - 'y\n' + - '"""' - ); -}); diff --git a/tests/language/test.r.js b/tests/language/test.r.js deleted file mode 100644 index ae47c66f..00000000 --- a/tests/language/test.r.js +++ /dev/null @@ -1,126 +0,0 @@ -/* global describe, run */ -var language = 'r'; - -describe(language, function() { - run( - language, - - 'comments', - - '# A comment\n' + - 'a <- "b" # Another comment', - - '# A comment\n' + - 'a <- "b" # Another comment' - ); - - run( - language, - - 'assignment', - - 'foo.bar <- "foo"\n' + - 'baz1 = 1.62e-4', - - 'foo.bar <- "foo"\n' + - 'baz1 = 1.62e-4' - ); - - run( - language, - - 'constants', - - 'baz <- NA\n' + - 'my.pi <- pi\n' + - 'all.letters <- c(LETTERS, letters)\n' + - 'xrange <- c(-Inf, TRUE)', - - 'baz <- NA\n' + - 'my.pi <- pi\n' + - 'all.letters <- c(LETTERS, letters)\n' + - 'xrange <- c(-Inf, TRUE)' - ); - - run( - language, - - 'operators', - - 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + - 'bound.rect <- grid::rectGrob()\n' + - 'my_seq <- 1:10\n' + - 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + - 'plot(y ~ x, type = "l")', - - 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + - 'bound.rect <- grid::rectGrob()\n' + - 'my_seq <- 1:10\n' + - 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + - 'plot(y ~ x, type = "l")' - ); - - /** - * Note that the second function is intentionally not a function call, - * just testing that the regex is matching only 'function' and not .+function - */ - run( - language, - - 'function creation', - - 'square <- function(x) x * x\n' + - 'square2 <- testfunction(x) x * x\n' + - 'area <- function (r) {\n' + - ' pi * r^2\n' + - '}', - - 'square <- function(x) x * x\n' + - 'square2 <- testfunction(x) x * x\n' + - 'area <- function (r) {\n' + - ' pi * r^2\n' + - '}' - ); - - skip( - language, - - 'variable', - - 'tmp <- 1\n' + - 'another.tmp <- 2\n' + - 'this.is.a.var <- 3', - - 'tmp <- 1\n' + - 'another.tmp <- 2\n' + - 'this.is.a.var <- 3' - ); - - skip( - language, - - 'subsetting', - - 'tmp[1]\n' + - 'tmp[["test"]]', - - 'tmp[1]\n' + - 'tmp[["test"]]' - ); - - skip( - language, - - 'support functions', - - 'logical(10)\n' + - 'test.logical(10)\n' + - 'data.frame(a = 1:10, b = 15:24)\n' + - 'complex(real = 1, imaginary = 0.5)', - - 'logical(10)\n' + - 'test.logical(10)\n' + - 'data.frame(a = 1:10, b = 15:24)\n' + - 'complex(real = 1, imaginary = 0.5)' - ); -}); diff --git a/tests/language/test.ruby.js b/tests/language/test.ruby.js deleted file mode 100644 index 3582cb42..00000000 --- a/tests/language/test.ruby.js +++ /dev/null @@ -1,57 +0,0 @@ -/* global describe, run */ -var language = 'ruby'; - -describe(language, function() { - - run( - language, - - 'multiple (non-greedy) strings', - - '"me" && "you"\n', - - '"me"' + - ' && ' + - '"you"\n' - ); - - run( - language, - - 'interpolated strings', - - '"chapter #{x+5}"\n', - - '"chapter ' + - '#{' + - 'x+' + - '5}' + - '"\n' - ); - - run( - language, - - 'string in brackets', - - 'foo = ["one", "two", "three"];', - - 'foo = ['+ - '"one", '+ - '"two", ' + - '"three"];' - ); - - run( - language, - - '__END__', - - 'class Test;end;\n__END__\nthis is just text\ntrue\n', - - 'class Test;' + - 'end;\n__END__\n' + - 'this is just text\ntrue\n' - ); - -}); diff --git a/tests/language/test.smalltalk.js b/tests/language/test.smalltalk.js deleted file mode 100644 index 383ce495..00000000 --- a/tests/language/test.smalltalk.js +++ /dev/null @@ -1,304 +0,0 @@ -/* global describe, run */ -var language = 'smalltalk'; - -describe(language, function() { - run( - language, - - 'constant true', - - 'true', - - 'true' - ); - - run( - language, - - 'constant false', - - 'false', - - 'false' - ); - - run( - language, - - 'constant nil', - - 'nil', - - 'nil' - ); - - run( - language, - - 'self pseudovariable', - - 'self', - - 'self' - ); - - run( - language, - - 'thisContext pseudovariable', - - 'thisContext', - - 'thisContext' - ); - - run( - language, - - 'two-character operator !!', - - '!!', - - '!!' - ); - - run( - language, - - 'two-character operator //', - - '//', - - '//' - ); - - run( - language, - - '| delimiter', - - '|', - - '|' - ); - - run( - language, - - '|| binary selector', - - '||', - - '||' - ); - - run( - language, - - 'HTML-unfriendly operator', - - '&', - - '&' - ); - - run( - language, - - 'three-character operator', - - '>>=', - - '>>=' - ); - - run( - language, - - 'String-like Symbol', - - "#'this is a symbol'", - - "#'this is a symbol'" - ); - - run( - language, - - 'Symbol', - - "#thisIsaSymbol0", - - "#thisIsaSymbol0" - ); - - run( - language, - - 'String', - - "'This is a string'", - - '\'This is a string\'' - ); - - run( - language, - - 'Comment', - - '"This is a comment"', - - '"This is a comment"' - ); - - run( - language, - - 'Comment in between message sends', - - 'self "this is a comment" foo', - - 'self "this is a comment" foo' - ); - - run( - language, - - 'Integer', - - '987654321', - - '987654321' - ); - - run( - language, - - 'Negative integer', - - '-987654321', - - '-987654321' - ); - - run( - language, - - 'Exponent integer', - - '987654321e10', - - '987654321e10' - ); - - run( - language, - - 'Negative exponent integer', - - '-987654321e10', - - '-987654321e10' - ); - - run( - language, - - 'Radix Integer', - - '16r987654321deadbeef', - - '16r987654321deadbeef' - ); - - run( - language, - - 'Negative radix Integer', - - '16r-987654321deadbeef', - - '16r-987654321deadbeef' - ); - - run( - language, - - 'Float', - - '987654321.0', - - '987654321.0' - ); - - run( - language, - - 'Negative float', - - '-987654321.0', - - '-987654321.0' - ); - - run( - language, - - 'Exponent float', - - '1.0e10', - - '1.0e10' - ); - - run( - language, - - 'Negative exponent float', - - '1.0e-10', - - '1.0e-10' - ); - - run( - language, - - 'Negative exponent negative float', - - '-1.0e-10', - - '-1.0e-10' - ); - - run( - language, - - 'Scaled decimal', - - '1.0s10', - - '1.0s10' - ); - - run( - language, - - 'Class name, normal', - - 'Class', - - 'Class' - ); - - run( - language, - - 'Class name, with digits', - - 'Class0zero', - - 'Class0zero' - ); -}); diff --git a/tests/libs/chai-1.6.0.js b/tests/libs/chai-1.6.0.js deleted file mode 100644 index 629e199b..00000000 --- a/tests/libs/chai-1.6.0.js +++ /dev/null @@ -1,4251 +0,0 @@ -;(function(){ - -/** - * Require the given path. - * - * @param {String} path - * @return {Object} exports - * @api public - */ - -function require(path, parent, orig) { - var resolved = require.resolve(path); - - // lookup failed - if (null == resolved) { - orig = orig || path; - parent = parent || 'root'; - var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); - err.path = orig; - err.parent = parent; - err.require = true; - throw err; - } - - var module = require.modules[resolved]; - - // perform real require() - // by invoking the module's - // registered function - if (!module.exports) { - module.exports = {}; - module.client = module.component = true; - module.call(this, module.exports, require.relative(resolved), module); - } - - return module.exports; -} - -/** - * Registered modules. - */ - -require.modules = {}; - -/** - * Registered aliases. - */ - -require.aliases = {}; - -/** - * Resolve `path`. - * - * Lookup: - * - * - PATH/index.js - * - PATH.js - * - PATH - * - * @param {String} path - * @return {String} path or null - * @api private - */ - -require.resolve = function(path) { - if (path.charAt(0) === '/') path = path.slice(1); - var index = path + '/index.js'; - - var paths = [ - path, - path + '.js', - path + '.json', - path + '/index.js', - path + '/index.json' - ]; - - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - if (require.modules.hasOwnProperty(path)) return path; - } - - if (require.aliases.hasOwnProperty(index)) { - return require.aliases[index]; - } -}; - -/** - * Normalize `path` relative to the current path. - * - * @param {String} curr - * @param {String} path - * @return {String} - * @api private - */ - -require.normalize = function(curr, path) { - var segs = []; - - if ('.' != path.charAt(0)) return path; - - curr = curr.split('/'); - path = path.split('/'); - - for (var i = 0; i < path.length; ++i) { - if ('..' == path[i]) { - curr.pop(); - } else if ('.' != path[i] && '' != path[i]) { - segs.push(path[i]); - } - } - - return curr.concat(segs).join('/'); -}; - -/** - * Register module at `path` with callback `definition`. - * - * @param {String} path - * @param {Function} definition - * @api private - */ - -require.register = function(path, definition) { - require.modules[path] = definition; -}; - -/** - * Alias a module definition. - * - * @param {String} from - * @param {String} to - * @api private - */ - -require.alias = function(from, to) { - if (!require.modules.hasOwnProperty(from)) { - throw new Error('Failed to alias "' + from + '", it does not exist'); - } - require.aliases[to] = from; -}; - -/** - * Return a require function relative to the `parent` path. - * - * @param {String} parent - * @return {Function} - * @api private - */ - -require.relative = function(parent) { - var p = require.normalize(parent, '..'); - - /** - * lastIndexOf helper. - */ - - function lastIndexOf(arr, obj) { - var i = arr.length; - while (i--) { - if (arr[i] === obj) return i; - } - return -1; - } - - /** - * The relative require() itself. - */ - - function localRequire(path) { - var resolved = localRequire.resolve(path); - return require(resolved, parent, path); - } - - /** - * Resolve relative to the parent. - */ - - localRequire.resolve = function(path) { - var c = path.charAt(0); - if ('/' == c) return path.slice(1); - if ('.' == c) return require.normalize(p, path); - - // resolve deps by returning - // the dep in the nearest "deps" - // directory - var segs = parent.split('/'); - var i = lastIndexOf(segs, 'deps') + 1; - if (!i) i = 0; - path = segs.slice(0, i + 1).join('/') + '/deps/' + path; - return path; - }; - - /** - * Check if module is defined at `path`. - */ - - localRequire.exists = function(path) { - return require.modules.hasOwnProperty(localRequire.resolve(path)); - }; - - return localRequire; -}; -require.register("chai/index.js", function(exports, require, module){ -module.exports = require('./lib/chai'); - -}); -require.register("chai/lib/chai.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -var used = [] - , exports = module.exports = {}; - -/*! - * Chai version - */ - -exports.version = '1.6.0'; - -/*! - * Primary `Assertion` prototype - */ - -exports.Assertion = require('./chai/assertion'); - -/*! - * Assertion Error - */ - -exports.AssertionError = require('./chai/error'); - -/*! - * Utils for plugins (not exported) - */ - -var util = require('./chai/utils'); - -/** - * # .use(function) - * - * Provides a way to extend the internals of Chai - * - * @param {Function} - * @returns {this} for chaining - * @api public - */ - -exports.use = function (fn) { - if (!~used.indexOf(fn)) { - fn(this, util); - used.push(fn); - } - - return this; -}; - -/*! - * Core Assertions - */ - -var core = require('./chai/core/assertions'); -exports.use(core); - -/*! - * Expect interface - */ - -var expect = require('./chai/interface/expect'); -exports.use(expect); - -/*! - * Should interface - */ - -var should = require('./chai/interface/should'); -exports.use(should); - -/*! - * Assert interface - */ - -var assert = require('./chai/interface/assert'); -exports.use(assert); - -}); -require.register("chai/lib/chai/assertion.js", function(exports, require, module){ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies. - */ - -var AssertionError = require('./error') - , util = require('./utils') - , flag = util.flag; - -/*! - * Module export. - */ - -module.exports = Assertion; - - -/*! - * Assertion Constructor - * - * Creates object for chaining. - * - * @api private - */ - -function Assertion (obj, msg, stack) { - flag(this, 'ssfi', stack || arguments.callee); - flag(this, 'object', obj); - flag(this, 'message', msg); -} - -/*! - * ### Assertion.includeStack - * - * User configurable property, influences whether stack trace - * is included in Assertion error message. Default of false - * suppresses stack trace in the error message - * - * Assertion.includeStack = true; // enable stack on error - * - * @api public - */ - -Assertion.includeStack = false; - -/*! - * ### Assertion.showDiff - * - * User configurable property, influences whether or not - * the `showDiff` flag should be included in the thrown - * AssertionErrors. `false` will always be `false`; `true` - * will be true when the assertion has requested a diff - * be shown. - * - * @api public - */ - -Assertion.showDiff = true; - -Assertion.addProperty = function (name, fn) { - util.addProperty(this.prototype, name, fn); -}; - -Assertion.addMethod = function (name, fn) { - util.addMethod(this.prototype, name, fn); -}; - -Assertion.addChainableMethod = function (name, fn, chainingBehavior) { - util.addChainableMethod(this.prototype, name, fn, chainingBehavior); -}; - -Assertion.overwriteProperty = function (name, fn) { - util.overwriteProperty(this.prototype, name, fn); -}; - -Assertion.overwriteMethod = function (name, fn) { - util.overwriteMethod(this.prototype, name, fn); -}; - -/*! - * ### .assert(expression, message, negateMessage, expected, actual) - * - * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass. - * - * @name assert - * @param {Philosophical} expression to be tested - * @param {String} message to display if fails - * @param {String} negatedMessage to display if negated expression fails - * @param {Mixed} expected value (remember to check for negation) - * @param {Mixed} actual (optional) will default to `this.obj` - * @api private - */ - -Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) { - var ok = util.test(this, arguments); - if (true !== showDiff) showDiff = false; - if (true !== Assertion.showDiff) showDiff = false; - - if (!ok) { - var msg = util.getMessage(this, arguments) - , actual = util.getActual(this, arguments); - throw new AssertionError({ - message: msg - , actual: actual - , expected: expected - , stackStartFunction: (Assertion.includeStack) ? this.assert : flag(this, 'ssfi') - , showDiff: showDiff - }); - } -}; - -/*! - * ### ._obj - * - * Quick reference to stored `actual` value for plugin developers. - * - * @api private - */ - -Object.defineProperty(Assertion.prototype, '_obj', - { get: function () { - return flag(this, 'object'); - } - , set: function (val) { - flag(this, 'object', val); - } -}); - -}); -require.register("chai/lib/chai/error.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Main export - */ - -module.exports = AssertionError; - -/** - * # AssertionError (constructor) - * - * Create a new assertion error based on the Javascript - * `Error` prototype. - * - * **Options** - * - message - * - actual - * - expected - * - operator - * - startStackFunction - * - * @param {Object} options - * @api public - */ - -function AssertionError (options) { - options = options || {}; - this.message = options.message; - this.actual = options.actual; - this.expected = options.expected; - this.operator = options.operator; - this.showDiff = options.showDiff; - - if (options.stackStartFunction && Error.captureStackTrace) { - var stackStartFunction = options.stackStartFunction; - Error.captureStackTrace(this, stackStartFunction); - } -} - -/*! - * Inherit from Error - */ - -AssertionError.prototype = Object.create(Error.prototype); -AssertionError.prototype.name = 'AssertionError'; -AssertionError.prototype.constructor = AssertionError; - -/** - * # toString() - * - * Override default to string method - */ - -AssertionError.prototype.toString = function() { - return this.message; -}; - -}); -require.register("chai/lib/chai/core/assertions.js", function(exports, require, module){ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, _) { - var Assertion = chai.Assertion - , toString = Object.prototype.toString - , flag = _.flag; - - /** - * ### Language Chains - * - * The following are provide as chainable getters to - * improve the readability of your assertions. They - * do not provide an testing capability unless they - * have been overwritten by a plugin. - * - * **Chains** - * - * - to - * - be - * - been - * - is - * - that - * - and - * - have - * - with - * - at - * - of - * - same - * - * @name language chains - * @api public - */ - - [ 'to', 'be', 'been' - , 'is', 'and', 'have' - , 'with', 'that', 'at' - , 'of', 'same' ].forEach(function (chain) { - Assertion.addProperty(chain, function () { - return this; - }); - }); - - /** - * ### .not - * - * Negates any of assertions following in the chain. - * - * expect(foo).to.not.equal('bar'); - * expect(goodFn).to.not.throw(Error); - * expect({ foo: 'baz' }).to.have.property('foo') - * .and.not.equal('bar'); - * - * @name not - * @api public - */ - - Assertion.addProperty('not', function () { - flag(this, 'negate', true); - }); - - /** - * ### .deep - * - * Sets the `deep` flag, later used by the `equal` and - * `property` assertions. - * - * expect(foo).to.deep.equal({ bar: 'baz' }); - * expect({ foo: { bar: { baz: 'quux' } } }) - * .to.have.deep.property('foo.bar.baz', 'quux'); - * - * @name deep - * @api public - */ - - Assertion.addProperty('deep', function () { - flag(this, 'deep', true); - }); - - /** - * ### .a(type) - * - * The `a` and `an` assertions are aliases that can be - * used either as language chains or to assert a value's - * type. - * - * // typeof - * expect('test').to.be.a('string'); - * expect({ foo: 'bar' }).to.be.an('object'); - * expect(null).to.be.a('null'); - * expect(undefined).to.be.an('undefined'); - * - * // language chain - * expect(foo).to.be.an.instanceof(Foo); - * - * @name a - * @alias an - * @param {String} type - * @param {String} message _optional_ - * @api public - */ - - function an (type, msg) { - if (msg) flag(this, 'message', msg); - type = type.toLowerCase(); - var obj = flag(this, 'object') - , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a '; - - this.assert( - type === _.type(obj) - , 'expected #{this} to be ' + article + type - , 'expected #{this} not to be ' + article + type - ); - } - - Assertion.addChainableMethod('an', an); - Assertion.addChainableMethod('a', an); - - /** - * ### .include(value) - * - * The `include` and `contain` assertions can be used as either property - * based language chains or as methods to assert the inclusion of an object - * in an array or a substring in a string. When used as language chains, - * they toggle the `contain` flag for the `keys` assertion. - * - * expect([1,2,3]).to.include(2); - * expect('foobar').to.contain('foo'); - * expect({ foo: 'bar', hello: 'universe' }).to.include.keys('foo'); - * - * @name include - * @alias contain - * @param {Object|String|Number} obj - * @param {String} message _optional_ - * @api public - */ - - function includeChainingBehavior () { - flag(this, 'contains', true); - } - - function include (val, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - this.assert( - ~obj.indexOf(val) - , 'expected #{this} to include ' + _.inspect(val) - , 'expected #{this} to not include ' + _.inspect(val)); - } - - Assertion.addChainableMethod('include', include, includeChainingBehavior); - Assertion.addChainableMethod('contain', include, includeChainingBehavior); - - /** - * ### .ok - * - * Asserts that the target is truthy. - * - * expect('everthing').to.be.ok; - * expect(1).to.be.ok; - * expect(false).to.not.be.ok; - * expect(undefined).to.not.be.ok; - * expect(null).to.not.be.ok; - * - * @name ok - * @api public - */ - - Assertion.addProperty('ok', function () { - this.assert( - flag(this, 'object') - , 'expected #{this} to be truthy' - , 'expected #{this} to be falsy'); - }); - - /** - * ### .true - * - * Asserts that the target is `true`. - * - * expect(true).to.be.true; - * expect(1).to.not.be.true; - * - * @name true - * @api public - */ - - Assertion.addProperty('true', function () { - this.assert( - true === flag(this, 'object') - , 'expected #{this} to be true' - , 'expected #{this} to be false' - , this.negate ? false : true - ); - }); - - /** - * ### .false - * - * Asserts that the target is `false`. - * - * expect(false).to.be.false; - * expect(0).to.not.be.false; - * - * @name false - * @api public - */ - - Assertion.addProperty('false', function () { - this.assert( - false === flag(this, 'object') - , 'expected #{this} to be false' - , 'expected #{this} to be true' - , this.negate ? true : false - ); - }); - - /** - * ### .null - * - * Asserts that the target is `null`. - * - * expect(null).to.be.null; - * expect(undefined).not.to.be.null; - * - * @name null - * @api public - */ - - Assertion.addProperty('null', function () { - this.assert( - null === flag(this, 'object') - , 'expected #{this} to be null' - , 'expected #{this} not to be null' - ); - }); - - /** - * ### .undefined - * - * Asserts that the target is `undefined`. - * - * expect(undefined).to.be.undefined; - * expect(null).to.not.be.undefined; - * - * @name undefined - * @api public - */ - - Assertion.addProperty('undefined', function () { - this.assert( - undefined === flag(this, 'object') - , 'expected #{this} to be undefined' - , 'expected #{this} not to be undefined' - ); - }); - - /** - * ### .exist - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var foo = 'hi' - * , bar = null - * , baz; - * - * expect(foo).to.exist; - * expect(bar).to.not.exist; - * expect(baz).to.not.exist; - * - * @name exist - * @api public - */ - - Assertion.addProperty('exist', function () { - this.assert( - null != flag(this, 'object') - , 'expected #{this} to exist' - , 'expected #{this} to not exist' - ); - }); - - - /** - * ### .empty - * - * Asserts that the target's length is `0`. For arrays, it checks - * the `length` property. For objects, it gets the count of - * enumerable keys. - * - * expect([]).to.be.empty; - * expect('').to.be.empty; - * expect({}).to.be.empty; - * - * @name empty - * @api public - */ - - Assertion.addProperty('empty', function () { - var obj = flag(this, 'object') - , expected = obj; - - if (Array.isArray(obj) || 'string' === typeof object) { - expected = obj.length; - } else if (typeof obj === 'object') { - expected = Object.keys(obj).length; - } - - this.assert( - !expected - , 'expected #{this} to be empty' - , 'expected #{this} not to be empty' - ); - }); - - /** - * ### .arguments - * - * Asserts that the target is an arguments object. - * - * function test () { - * expect(arguments).to.be.arguments; - * } - * - * @name arguments - * @alias Arguments - * @api public - */ - - function checkArguments () { - var obj = flag(this, 'object') - , type = Object.prototype.toString.call(obj); - this.assert( - '[object Arguments]' === type - , 'expected #{this} to be arguments but got ' + type - , 'expected #{this} to not be arguments' - ); - } - - Assertion.addProperty('arguments', checkArguments); - Assertion.addProperty('Arguments', checkArguments); - - /** - * ### .equal(value) - * - * Asserts that the target is strictly equal (`===`) to `value`. - * Alternately, if the `deep` flag is set, asserts that - * the target is deeply equal to `value`. - * - * expect('hello').to.equal('hello'); - * expect(42).to.equal(42); - * expect(1).to.not.equal(true); - * expect({ foo: 'bar' }).to.not.equal({ foo: 'bar' }); - * expect({ foo: 'bar' }).to.deep.equal({ foo: 'bar' }); - * - * @name equal - * @alias equals - * @alias eq - * @alias deep.equal - * @param {Mixed} value - * @param {String} message _optional_ - * @api public - */ - - function assertEqual (val, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'deep')) { - return this.eql(val); - } else { - this.assert( - val === obj - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{exp}' - , val - , this._obj - , true - ); - } - } - - Assertion.addMethod('equal', assertEqual); - Assertion.addMethod('equals', assertEqual); - Assertion.addMethod('eq', assertEqual); - - /** - * ### .eql(value) - * - * Asserts that the target is deeply equal to `value`. - * - * expect({ foo: 'bar' }).to.eql({ foo: 'bar' }); - * expect([ 1, 2, 3 ]).to.eql([ 1, 2, 3 ]); - * - * @name eql - * @alias eqls - * @param {Mixed} value - * @param {String} message _optional_ - * @api public - */ - - function assertEql(obj, msg) { - if (msg) flag(this, 'message', msg); - this.assert( - _.eql(obj, flag(this, 'object')) - , 'expected #{this} to deeply equal #{exp}' - , 'expected #{this} to not deeply equal #{exp}' - , obj - , this._obj - , true - ); - } - - Assertion.addMethod('eql', assertEql); - Assertion.addMethod('eqls', assertEql); - - /** - * ### .above(value) - * - * Asserts that the target is greater than `value`. - * - * expect(10).to.be.above(5); - * - * Can also be used in conjunction with `length` to - * assert a minimum length. The benefit being a - * more informative error message than if the length - * was supplied directly. - * - * expect('foo').to.have.length.above(2); - * expect([ 1, 2, 3 ]).to.have.length.above(2); - * - * @name above - * @alias gt - * @alias greaterThan - * @param {Number} value - * @param {String} message _optional_ - * @api public - */ - - function assertAbove (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'doLength')) { - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - this.assert( - len > n - , 'expected #{this} to have a length above #{exp} but got #{act}' - , 'expected #{this} to not have a length above #{exp}' - , n - , len - ); - } else { - this.assert( - obj > n - , 'expected #{this} to be above ' + n - , 'expected #{this} to be at most ' + n - ); - } - } - - Assertion.addMethod('above', assertAbove); - Assertion.addMethod('gt', assertAbove); - Assertion.addMethod('greaterThan', assertAbove); - - /** - * ### .least(value) - * - * Asserts that the target is greater than or equal to `value`. - * - * expect(10).to.be.at.least(10); - * - * Can also be used in conjunction with `length` to - * assert a minimum length. The benefit being a - * more informative error message than if the length - * was supplied directly. - * - * expect('foo').to.have.length.of.at.least(2); - * expect([ 1, 2, 3 ]).to.have.length.of.at.least(3); - * - * @name least - * @alias gte - * @param {Number} value - * @param {String} message _optional_ - * @api public - */ - - function assertLeast (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'doLength')) { - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - this.assert( - len >= n - , 'expected #{this} to have a length at least #{exp} but got #{act}' - , 'expected #{this} to have a length below #{exp}' - , n - , len - ); - } else { - this.assert( - obj >= n - , 'expected #{this} to be at least ' + n - , 'expected #{this} to be below ' + n - ); - } - } - - Assertion.addMethod('least', assertLeast); - Assertion.addMethod('gte', assertLeast); - - /** - * ### .below(value) - * - * Asserts that the target is less than `value`. - * - * expect(5).to.be.below(10); - * - * Can also be used in conjunction with `length` to - * assert a maximum length. The benefit being a - * more informative error message than if the length - * was supplied directly. - * - * expect('foo').to.have.length.below(4); - * expect([ 1, 2, 3 ]).to.have.length.below(4); - * - * @name below - * @alias lt - * @alias lessThan - * @param {Number} value - * @param {String} message _optional_ - * @api public - */ - - function assertBelow (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'doLength')) { - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - this.assert( - len < n - , 'expected #{this} to have a length below #{exp} but got #{act}' - , 'expected #{this} to not have a length below #{exp}' - , n - , len - ); - } else { - this.assert( - obj < n - , 'expected #{this} to be below ' + n - , 'expected #{this} to be at least ' + n - ); - } - } - - Assertion.addMethod('below', assertBelow); - Assertion.addMethod('lt', assertBelow); - Assertion.addMethod('lessThan', assertBelow); - - /** - * ### .most(value) - * - * Asserts that the target is less than or equal to `value`. - * - * expect(5).to.be.at.most(5); - * - * Can also be used in conjunction with `length` to - * assert a maximum length. The benefit being a - * more informative error message than if the length - * was supplied directly. - * - * expect('foo').to.have.length.of.at.most(4); - * expect([ 1, 2, 3 ]).to.have.length.of.at.most(3); - * - * @name most - * @alias lte - * @param {Number} value - * @param {String} message _optional_ - * @api public - */ - - function assertMost (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'doLength')) { - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - this.assert( - len <= n - , 'expected #{this} to have a length at most #{exp} but got #{act}' - , 'expected #{this} to have a length above #{exp}' - , n - , len - ); - } else { - this.assert( - obj <= n - , 'expected #{this} to be at most ' + n - , 'expected #{this} to be above ' + n - ); - } - } - - Assertion.addMethod('most', assertMost); - Assertion.addMethod('lte', assertMost); - - /** - * ### .within(start, finish) - * - * Asserts that the target is within a range. - * - * expect(7).to.be.within(5,10); - * - * Can also be used in conjunction with `length` to - * assert a length range. The benefit being a - * more informative error message than if the length - * was supplied directly. - * - * expect('foo').to.have.length.within(2,4); - * expect([ 1, 2, 3 ]).to.have.length.within(2,4); - * - * @name within - * @param {Number} start lowerbound inclusive - * @param {Number} finish upperbound inclusive - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('within', function (start, finish, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , range = start + '..' + finish; - if (flag(this, 'doLength')) { - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - this.assert( - len >= start && len <= finish - , 'expected #{this} to have a length within ' + range - , 'expected #{this} to not have a length within ' + range - ); - } else { - this.assert( - obj >= start && obj <= finish - , 'expected #{this} to be within ' + range - , 'expected #{this} to not be within ' + range - ); - } - }); - - /** - * ### .instanceof(constructor) - * - * Asserts that the target is an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , Chai = new Tea('chai'); - * - * expect(Chai).to.be.an.instanceof(Tea); - * expect([ 1, 2, 3 ]).to.be.instanceof(Array); - * - * @name instanceof - * @param {Constructor} constructor - * @param {String} message _optional_ - * @alias instanceOf - * @api public - */ - - function assertInstanceOf (constructor, msg) { - if (msg) flag(this, 'message', msg); - var name = _.getName(constructor); - this.assert( - flag(this, 'object') instanceof constructor - , 'expected #{this} to be an instance of ' + name - , 'expected #{this} to not be an instance of ' + name - ); - }; - - Assertion.addMethod('instanceof', assertInstanceOf); - Assertion.addMethod('instanceOf', assertInstanceOf); - - /** - * ### .property(name, [value]) - * - * Asserts that the target has a property `name`, optionally asserting that - * the value of that property is strictly equal to `value`. - * If the `deep` flag is set, you can use dot- and bracket-notation for deep - * references into objects and arrays. - * - * // simple referencing - * var obj = { foo: 'bar' }; - * expect(obj).to.have.property('foo'); - * expect(obj).to.have.property('foo', 'bar'); - * - * // deep referencing - * var deepObj = { - * green: { tea: 'matcha' } - * , teas: [ 'chai', 'matcha', { tea: 'konacha' } ] - * }; - - * expect(deepObj).to.have.deep.property('green.tea', 'matcha'); - * expect(deepObj).to.have.deep.property('teas[1]', 'matcha'); - * expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha'); - * - * You can also use an array as the starting point of a `deep.property` - * assertion, or traverse nested arrays. - * - * var arr = [ - * [ 'chai', 'matcha', 'konacha' ] - * , [ { tea: 'chai' } - * , { tea: 'matcha' } - * , { tea: 'konacha' } ] - * ]; - * - * expect(arr).to.have.deep.property('[0][1]', 'matcha'); - * expect(arr).to.have.deep.property('[1][2].tea', 'konacha'); - * - * Furthermore, `property` changes the subject of the assertion - * to be the value of that property from the original object. This - * permits for further chainable assertions on that property. - * - * expect(obj).to.have.property('foo') - * .that.is.a('string'); - * expect(deepObj).to.have.property('green') - * .that.is.an('object') - * .that.deep.equals({ tea: 'matcha' }); - * expect(deepObj).to.have.property('teas') - * .that.is.an('array') - * .with.deep.property('[2]') - * .that.deep.equals({ tea: 'konacha' }); - * - * @name property - * @alias deep.property - * @param {String} name - * @param {Mixed} value (optional) - * @param {String} message _optional_ - * @returns value of property for chaining - * @api public - */ - - Assertion.addMethod('property', function (name, val, msg) { - if (msg) flag(this, 'message', msg); - - var descriptor = flag(this, 'deep') ? 'deep property ' : 'property ' - , negate = flag(this, 'negate') - , obj = flag(this, 'object') - , value = flag(this, 'deep') - ? _.getPathValue(name, obj) - : obj[name]; - - if (negate && undefined !== val) { - if (undefined === value) { - msg = (msg != null) ? msg + ': ' : ''; - throw new Error(msg + _.inspect(obj) + ' has no ' + descriptor + _.inspect(name)); - } - } else { - this.assert( - undefined !== value - , 'expected #{this} to have a ' + descriptor + _.inspect(name) - , 'expected #{this} to not have ' + descriptor + _.inspect(name)); - } - - if (undefined !== val) { - this.assert( - val === value - , 'expected #{this} to have a ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}' - , 'expected #{this} to not have a ' + descriptor + _.inspect(name) + ' of #{act}' - , val - , value - ); - } - - flag(this, 'object', value); - }); - - - /** - * ### .ownProperty(name) - * - * Asserts that the target has an own property `name`. - * - * expect('test').to.have.ownProperty('length'); - * - * @name ownProperty - * @alias haveOwnProperty - * @param {String} name - * @param {String} message _optional_ - * @api public - */ - - function assertOwnProperty (name, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - obj.hasOwnProperty(name) - , 'expected #{this} to have own property ' + _.inspect(name) - , 'expected #{this} to not have own property ' + _.inspect(name) - ); - } - - Assertion.addMethod('ownProperty', assertOwnProperty); - Assertion.addMethod('haveOwnProperty', assertOwnProperty); - - /** - * ### .length(value) - * - * Asserts that the target's `length` property has - * the expected value. - * - * expect([ 1, 2, 3]).to.have.length(3); - * expect('foobar').to.have.length(6); - * - * Can also be used as a chain precursor to a value - * comparison for the length property. - * - * expect('foo').to.have.length.above(2); - * expect([ 1, 2, 3 ]).to.have.length.above(2); - * expect('foo').to.have.length.below(4); - * expect([ 1, 2, 3 ]).to.have.length.below(4); - * expect('foo').to.have.length.within(2,4); - * expect([ 1, 2, 3 ]).to.have.length.within(2,4); - * - * @name length - * @alias lengthOf - * @param {Number} length - * @param {String} message _optional_ - * @api public - */ - - function assertLengthChain () { - flag(this, 'doLength', true); - } - - function assertLength (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - new Assertion(obj, msg).to.have.property('length'); - var len = obj.length; - - this.assert( - len == n - , 'expected #{this} to have a length of #{exp} but got #{act}' - , 'expected #{this} to not have a length of #{act}' - , n - , len - ); - } - - Assertion.addChainableMethod('length', assertLength, assertLengthChain); - Assertion.addMethod('lengthOf', assertLength, assertLengthChain); - - /** - * ### .match(regexp) - * - * Asserts that the target matches a regular expression. - * - * expect('foobar').to.match(/^foo/); - * - * @name match - * @param {RegExp} RegularExpression - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('match', function (re, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - re.exec(obj) - , 'expected #{this} to match ' + re - , 'expected #{this} not to match ' + re - ); - }); - - /** - * ### .string(string) - * - * Asserts that the string target contains another string. - * - * expect('foobar').to.have.string('bar'); - * - * @name string - * @param {String} string - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('string', function (str, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - new Assertion(obj, msg).is.a('string'); - - this.assert( - ~obj.indexOf(str) - , 'expected #{this} to contain ' + _.inspect(str) - , 'expected #{this} to not contain ' + _.inspect(str) - ); - }); - - - /** - * ### .keys(key1, [key2], [...]) - * - * Asserts that the target has exactly the given keys, or - * asserts the inclusion of some keys when using the - * `include` or `contain` modifiers. - * - * expect({ foo: 1, bar: 2 }).to.have.keys(['foo', 'bar']); - * expect({ foo: 1, bar: 2, baz: 3 }).to.contain.keys('foo', 'bar'); - * - * @name keys - * @alias key - * @param {String...|Array} keys - * @api public - */ - - function assertKeys (keys) { - var obj = flag(this, 'object') - , str - , ok = true; - - keys = keys instanceof Array - ? keys - : Array.prototype.slice.call(arguments); - - if (!keys.length) throw new Error('keys required'); - - var actual = Object.keys(obj) - , len = keys.length; - - // Inclusion - ok = keys.every(function(key){ - return ~actual.indexOf(key); - }); - - // Strict - if (!flag(this, 'negate') && !flag(this, 'contains')) { - ok = ok && keys.length == actual.length; - } - - // Key string - if (len > 1) { - keys = keys.map(function(key){ - return _.inspect(key); - }); - var last = keys.pop(); - str = keys.join(', ') + ', and ' + last; - } else { - str = _.inspect(keys[0]); - } - - // Form - str = (len > 1 ? 'keys ' : 'key ') + str; - - // Have / include - str = (flag(this, 'contains') ? 'contain ' : 'have ') + str; - - // Assertion - this.assert( - ok - , 'expected #{this} to ' + str - , 'expected #{this} to not ' + str - ); - } - - Assertion.addMethod('keys', assertKeys); - Assertion.addMethod('key', assertKeys); - - /** - * ### .throw(constructor) - * - * Asserts that the function target will throw a specific error, or specific type of error - * (as determined using `instanceof`), optionally with a RegExp or string inclusion test - * for the error's message. - * - * var err = new ReferenceError('This is a bad function.'); - * var fn = function () { throw err; } - * expect(fn).to.throw(ReferenceError); - * expect(fn).to.throw(Error); - * expect(fn).to.throw(/bad function/); - * expect(fn).to.not.throw('good function'); - * expect(fn).to.throw(ReferenceError, /bad function/); - * expect(fn).to.throw(err); - * expect(fn).to.not.throw(new RangeError('Out of range.')); - * - * Please note that when a throw expectation is negated, it will check each - * parameter independently, starting with error constructor type. The appropriate way - * to check for the existence of a type of error but for a message that does not match - * is to use `and`. - * - * expect(fn).to.throw(ReferenceError) - * .and.not.throw(/good function/); - * - * @name throw - * @alias throws - * @alias Throw - * @param {ErrorConstructor} constructor - * @param {String|RegExp} expected error message - * @param {String} message _optional_ - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @api public - */ - - function assertThrows (constructor, errMsg, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - new Assertion(obj, msg).is.a('function'); - - var thrown = false - , desiredError = null - , name = null - , thrownError = null; - - if (arguments.length === 0) { - errMsg = null; - constructor = null; - } else if (constructor && (constructor instanceof RegExp || 'string' === typeof constructor)) { - errMsg = constructor; - constructor = null; - } else if (constructor && constructor instanceof Error) { - desiredError = constructor; - constructor = null; - errMsg = null; - } else if (typeof constructor === 'function') { - name = (new constructor()).name; - } else { - constructor = null; - } - - try { - obj(); - } catch (err) { - // first, check desired error - if (desiredError) { - this.assert( - err === desiredError - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' - , desiredError - , err - ); - - return this; - } - // next, check constructor - if (constructor) { - this.assert( - err instanceof constructor - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp} but #{act} was thrown' - , name - , err - ); - - if (!errMsg) return this; - } - // next, check message - var message = 'object' === _.type(err) && "message" in err - ? err.message - : '' + err; - - if ((message != null) && errMsg && errMsg instanceof RegExp) { - this.assert( - errMsg.exec(message) - , 'expected #{this} to throw error matching #{exp} but got #{act}' - , 'expected #{this} to throw error not matching #{exp}' - , errMsg - , message - ); - - return this; - } else if ((message != null) && errMsg && 'string' === typeof errMsg) { - this.assert( - ~message.indexOf(errMsg) - , 'expected #{this} to throw error including #{exp} but got #{act}' - , 'expected #{this} to throw error not including #{act}' - , errMsg - , message - ); - - return this; - } else { - thrown = true; - thrownError = err; - } - } - - var actuallyGot = '' - , expectedThrown = name !== null - ? name - : desiredError - ? '#{exp}' //_.inspect(desiredError) - : 'an error'; - - if (thrown) { - actuallyGot = ' but #{act} was thrown' - } - - this.assert( - thrown === true - , 'expected #{this} to throw ' + expectedThrown + actuallyGot - , 'expected #{this} to not throw ' + expectedThrown + actuallyGot - , desiredError - , thrownError - ); - }; - - Assertion.addMethod('throw', assertThrows); - Assertion.addMethod('throws', assertThrows); - Assertion.addMethod('Throw', assertThrows); - - /** - * ### .respondTo(method) - * - * Asserts that the object or class target will respond to a method. - * - * Klass.prototype.bar = function(){}; - * expect(Klass).to.respondTo('bar'); - * expect(obj).to.respondTo('bar'); - * - * To check if a constructor will respond to a static function, - * set the `itself` flag. - * - * Klass.baz = function(){}; - * expect(Klass).itself.to.respondTo('baz'); - * - * @name respondTo - * @param {String} method - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('respondTo', function (method, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , itself = flag(this, 'itself') - , context = ('function' === _.type(obj) && !itself) - ? obj.prototype[method] - : obj[method]; - - this.assert( - 'function' === typeof context - , 'expected #{this} to respond to ' + _.inspect(method) - , 'expected #{this} to not respond to ' + _.inspect(method) - ); - }); - - /** - * ### .itself - * - * Sets the `itself` flag, later used by the `respondTo` assertion. - * - * function Foo() {} - * Foo.bar = function() {} - * Foo.prototype.baz = function() {} - * - * expect(Foo).itself.to.respondTo('bar'); - * expect(Foo).itself.not.to.respondTo('baz'); - * - * @name itself - * @api public - */ - - Assertion.addProperty('itself', function () { - flag(this, 'itself', true); - }); - - /** - * ### .satisfy(method) - * - * Asserts that the target passes a given truth test. - * - * expect(1).to.satisfy(function(num) { return num > 0; }); - * - * @name satisfy - * @param {Function} matcher - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('satisfy', function (matcher, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - matcher(obj) - , 'expected #{this} to satisfy ' + _.objDisplay(matcher) - , 'expected #{this} to not satisfy' + _.objDisplay(matcher) - , this.negate ? false : true - , matcher(obj) - ); - }); - - /** - * ### .closeTo(expected, delta) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * expect(1.5).to.be.closeTo(1, 0.5); - * - * @name closeTo - * @param {Number} expected - * @param {Number} delta - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('closeTo', function (expected, delta, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - Math.abs(obj - expected) <= delta - , 'expected #{this} to be close to ' + expected + ' +/- ' + delta - , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta - ); - }); - - function isSubsetOf(subset, superset) { - return subset.every(function(elem) { - return superset.indexOf(elem) !== -1; - }) - } - - /** - * ### .members - * - * Asserts that the target is a superset of `set`, - * or that the target and `set` have the same members. - * - * expect([1, 2, 3]).to.include.members([3, 2]); - * expect([1, 2, 3]).to.not.include.members([3, 2, 8]); - * - * expect([4, 2]).to.have.members([2, 4]); - * expect([5, 2]).to.not.have.members([5, 2, 1]); - * - * @name members - * @param {Array} set - * @param {String} message _optional_ - * @api public - */ - - Assertion.addMethod('members', function (subset, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - - new Assertion(obj).to.be.an('array'); - new Assertion(subset).to.be.an('array'); - - if (flag(this, 'contains')) { - return this.assert( - isSubsetOf(subset, obj) - , 'expected #{this} to be a superset of #{act}' - , 'expected #{this} to not be a superset of #{act}' - , obj - , subset - ); - } - - this.assert( - isSubsetOf(obj, subset) && isSubsetOf(subset, obj) - , 'expected #{this} to have the same members as #{act}' - , 'expected #{this} to not have the same members as #{act}' - , obj - , subset - ); - }); -}; - -}); -require.register("chai/lib/chai/interface/assert.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - - -module.exports = function (chai, util) { - - /*! - * Chai dependencies. - */ - - var Assertion = chai.Assertion - , flag = util.flag; - - /*! - * Module export. - */ - - /** - * ### assert(expression, message) - * - * Write your own test expressions. - * - * assert('foo' !== 'bar', 'foo is not bar'); - * assert(Array.isArray([]), 'empty arrays are arrays'); - * - * @param {Mixed} expression to test for truthiness - * @param {String} message to display on error - * @name assert - * @api public - */ - - var assert = chai.assert = function (express, errmsg) { - var test = new Assertion(null); - test.assert( - express - , errmsg - , '[ negation message unavailable ]' - ); - }; - - /** - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. Node.js `assert` module-compatible. - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @api public - */ - - assert.fail = function (actual, expected, message, operator) { - throw new chai.AssertionError({ - actual: actual - , expected: expected - , message: message - , operator: operator - , stackStartFunction: assert.fail - }); - }; - - /** - * ### .ok(object, [message]) - * - * Asserts that `object` is truthy. - * - * assert.ok('everything', 'everything is ok'); - * assert.ok(false, 'this will fail'); - * - * @name ok - * @param {Mixed} object to test - * @param {String} message - * @api public - */ - - assert.ok = function (val, msg) { - new Assertion(val, msg).is.ok; - }; - - /** - * ### .equal(actual, expected, [message]) - * - * Asserts non-strict equality (`==`) of `actual` and `expected`. - * - * assert.equal(3, '3', '== coerces values to strings'); - * - * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.equal = function (act, exp, msg) { - var test = new Assertion(act, msg); - - test.assert( - exp == flag(test, 'object') - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{act}' - , exp - , act - ); - }; - - /** - * ### .notEqual(actual, expected, [message]) - * - * Asserts non-strict inequality (`!=`) of `actual` and `expected`. - * - * assert.notEqual(3, 4, 'these numbers are not equal'); - * - * @name notEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.notEqual = function (act, exp, msg) { - var test = new Assertion(act, msg); - - test.assert( - exp != flag(test, 'object') - , 'expected #{this} to not equal #{exp}' - , 'expected #{this} to equal #{act}' - , exp - , act - ); - }; - - /** - * ### .strictEqual(actual, expected, [message]) - * - * Asserts strict equality (`===`) of `actual` and `expected`. - * - * assert.strictEqual(true, true, 'these booleans are strictly equal'); - * - * @name strictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.strictEqual = function (act, exp, msg) { - new Assertion(act, msg).to.equal(exp); - }; - - /** - * ### .notStrictEqual(actual, expected, [message]) - * - * Asserts strict inequality (`!==`) of `actual` and `expected`. - * - * assert.notStrictEqual(3, '3', 'no coercion for strict equality'); - * - * @name notStrictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.notStrictEqual = function (act, exp, msg) { - new Assertion(act, msg).to.not.equal(exp); - }; - - /** - * ### .deepEqual(actual, expected, [message]) - * - * Asserts that `actual` is deeply equal to `expected`. - * - * assert.deepEqual({ tea: 'green' }, { tea: 'green' }); - * - * @name deepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.deepEqual = function (act, exp, msg) { - new Assertion(act, msg).to.eql(exp); - }; - - /** - * ### .notDeepEqual(actual, expected, [message]) - * - * Assert that `actual` is not deeply equal to `expected`. - * - * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' }); - * - * @name notDeepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @api public - */ - - assert.notDeepEqual = function (act, exp, msg) { - new Assertion(act, msg).to.not.eql(exp); - }; - - /** - * ### .isTrue(value, [message]) - * - * Asserts that `value` is true. - * - * var teaServed = true; - * assert.isTrue(teaServed, 'the tea has been served'); - * - * @name isTrue - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isTrue = function (val, msg) { - new Assertion(val, msg).is['true']; - }; - - /** - * ### .isFalse(value, [message]) - * - * Asserts that `value` is false. - * - * var teaServed = false; - * assert.isFalse(teaServed, 'no tea yet? hmm...'); - * - * @name isFalse - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isFalse = function (val, msg) { - new Assertion(val, msg).is['false']; - }; - - /** - * ### .isNull(value, [message]) - * - * Asserts that `value` is null. - * - * assert.isNull(err, 'there was no error'); - * - * @name isNull - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNull = function (val, msg) { - new Assertion(val, msg).to.equal(null); - }; - - /** - * ### .isNotNull(value, [message]) - * - * Asserts that `value` is not null. - * - * var tea = 'tasty chai'; - * assert.isNotNull(tea, 'great, time for tea!'); - * - * @name isNotNull - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotNull = function (val, msg) { - new Assertion(val, msg).to.not.equal(null); - }; - - /** - * ### .isUndefined(value, [message]) - * - * Asserts that `value` is `undefined`. - * - * var tea; - * assert.isUndefined(tea, 'no tea defined'); - * - * @name isUndefined - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isUndefined = function (val, msg) { - new Assertion(val, msg).to.equal(undefined); - }; - - /** - * ### .isDefined(value, [message]) - * - * Asserts that `value` is not `undefined`. - * - * var tea = 'cup of chai'; - * assert.isDefined(tea, 'tea has been defined'); - * - * @name isUndefined - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isDefined = function (val, msg) { - new Assertion(val, msg).to.not.equal(undefined); - }; - - /** - * ### .isFunction(value, [message]) - * - * Asserts that `value` is a function. - * - * function serveTea() { return 'cup of tea'; }; - * assert.isFunction(serveTea, 'great, we can have tea now'); - * - * @name isFunction - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isFunction = function (val, msg) { - new Assertion(val, msg).to.be.a('function'); - }; - - /** - * ### .isNotFunction(value, [message]) - * - * Asserts that `value` is _not_ a function. - * - * var serveTea = [ 'heat', 'pour', 'sip' ]; - * assert.isNotFunction(serveTea, 'great, we have listed the steps'); - * - * @name isNotFunction - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotFunction = function (val, msg) { - new Assertion(val, msg).to.not.be.a('function'); - }; - - /** - * ### .isObject(value, [message]) - * - * Asserts that `value` is an object (as revealed by - * `Object.prototype.toString`). - * - * var selection = { name: 'Chai', serve: 'with spices' }; - * assert.isObject(selection, 'tea selection is an object'); - * - * @name isObject - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isObject = function (val, msg) { - new Assertion(val, msg).to.be.a('object'); - }; - - /** - * ### .isNotObject(value, [message]) - * - * Asserts that `value` is _not_ an object. - * - * var selection = 'chai' - * assert.isObject(selection, 'tea selection is not an object'); - * assert.isObject(null, 'null is not an object'); - * - * @name isNotObject - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotObject = function (val, msg) { - new Assertion(val, msg).to.not.be.a('object'); - }; - - /** - * ### .isArray(value, [message]) - * - * Asserts that `value` is an array. - * - * var menu = [ 'green', 'chai', 'oolong' ]; - * assert.isArray(menu, 'what kind of tea do we want?'); - * - * @name isArray - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isArray = function (val, msg) { - new Assertion(val, msg).to.be.an('array'); - }; - - /** - * ### .isNotArray(value, [message]) - * - * Asserts that `value` is _not_ an array. - * - * var menu = 'green|chai|oolong'; - * assert.isNotArray(menu, 'what kind of tea do we want?'); - * - * @name isNotArray - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotArray = function (val, msg) { - new Assertion(val, msg).to.not.be.an('array'); - }; - - /** - * ### .isString(value, [message]) - * - * Asserts that `value` is a string. - * - * var teaOrder = 'chai'; - * assert.isString(teaOrder, 'order placed'); - * - * @name isString - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isString = function (val, msg) { - new Assertion(val, msg).to.be.a('string'); - }; - - /** - * ### .isNotString(value, [message]) - * - * Asserts that `value` is _not_ a string. - * - * var teaOrder = 4; - * assert.isNotString(teaOrder, 'order placed'); - * - * @name isNotString - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotString = function (val, msg) { - new Assertion(val, msg).to.not.be.a('string'); - }; - - /** - * ### .isNumber(value, [message]) - * - * Asserts that `value` is a number. - * - * var cups = 2; - * assert.isNumber(cups, 'how many cups'); - * - * @name isNumber - * @param {Number} value - * @param {String} message - * @api public - */ - - assert.isNumber = function (val, msg) { - new Assertion(val, msg).to.be.a('number'); - }; - - /** - * ### .isNotNumber(value, [message]) - * - * Asserts that `value` is _not_ a number. - * - * var cups = '2 cups please'; - * assert.isNotNumber(cups, 'how many cups'); - * - * @name isNotNumber - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotNumber = function (val, msg) { - new Assertion(val, msg).to.not.be.a('number'); - }; - - /** - * ### .isBoolean(value, [message]) - * - * Asserts that `value` is a boolean. - * - * var teaReady = true - * , teaServed = false; - * - * assert.isBoolean(teaReady, 'is the tea ready'); - * assert.isBoolean(teaServed, 'has tea been served'); - * - * @name isBoolean - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isBoolean = function (val, msg) { - new Assertion(val, msg).to.be.a('boolean'); - }; - - /** - * ### .isNotBoolean(value, [message]) - * - * Asserts that `value` is _not_ a boolean. - * - * var teaReady = 'yep' - * , teaServed = 'nope'; - * - * assert.isNotBoolean(teaReady, 'is the tea ready'); - * assert.isNotBoolean(teaServed, 'has tea been served'); - * - * @name isNotBoolean - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.isNotBoolean = function (val, msg) { - new Assertion(val, msg).to.not.be.a('boolean'); - }; - - /** - * ### .typeOf(value, name, [message]) - * - * Asserts that `value`'s type is `name`, as determined by - * `Object.prototype.toString`. - * - * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object'); - * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array'); - * assert.typeOf('tea', 'string', 'we have a string'); - * assert.typeOf(/tea/, 'regexp', 'we have a regular expression'); - * assert.typeOf(null, 'null', 'we have a null'); - * assert.typeOf(undefined, 'undefined', 'we have an undefined'); - * - * @name typeOf - * @param {Mixed} value - * @param {String} name - * @param {String} message - * @api public - */ - - assert.typeOf = function (val, type, msg) { - new Assertion(val, msg).to.be.a(type); - }; - - /** - * ### .notTypeOf(value, name, [message]) - * - * Asserts that `value`'s type is _not_ `name`, as determined by - * `Object.prototype.toString`. - * - * assert.notTypeOf('tea', 'number', 'strings are not numbers'); - * - * @name notTypeOf - * @param {Mixed} value - * @param {String} typeof name - * @param {String} message - * @api public - */ - - assert.notTypeOf = function (val, type, msg) { - new Assertion(val, msg).to.not.be.a(type); - }; - - /** - * ### .instanceOf(object, constructor, [message]) - * - * Asserts that `value` is an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new Tea('chai'); - * - * assert.instanceOf(chai, Tea, 'chai is an instance of tea'); - * - * @name instanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @api public - */ - - assert.instanceOf = function (val, type, msg) { - new Assertion(val, msg).to.be.instanceOf(type); - }; - - /** - * ### .notInstanceOf(object, constructor, [message]) - * - * Asserts `value` is not an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new String('chai'); - * - * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea'); - * - * @name notInstanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @api public - */ - - assert.notInstanceOf = function (val, type, msg) { - new Assertion(val, msg).to.not.be.instanceOf(type); - }; - - /** - * ### .include(haystack, needle, [message]) - * - * Asserts that `haystack` includes `needle`. Works - * for strings and arrays. - * - * assert.include('foobar', 'bar', 'foobar contains string "bar"'); - * assert.include([ 1, 2, 3 ], 3, 'array contains value'); - * - * @name include - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @api public - */ - - assert.include = function (exp, inc, msg) { - var obj = new Assertion(exp, msg); - - if (Array.isArray(exp)) { - obj.to.include(inc); - } else if ('string' === typeof exp) { - obj.to.contain.string(inc); - } else { - throw new chai.AssertionError({ - message: 'expected an array or string' - , stackStartFunction: assert.include - }); - } - }; - - /** - * ### .notInclude(haystack, needle, [message]) - * - * Asserts that `haystack` does not include `needle`. Works - * for strings and arrays. - *i - * assert.notInclude('foobar', 'baz', 'string not include substring'); - * assert.notInclude([ 1, 2, 3 ], 4, 'array not include contain value'); - * - * @name notInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @api public - */ - - assert.notInclude = function (exp, inc, msg) { - var obj = new Assertion(exp, msg); - - if (Array.isArray(exp)) { - obj.to.not.include(inc); - } else if ('string' === typeof exp) { - obj.to.not.contain.string(inc); - } else { - throw new chai.AssertionError({ - message: 'expected an array or string' - , stackStartFunction: assert.include - }); - } - }; - - /** - * ### .match(value, regexp, [message]) - * - * Asserts that `value` matches the regular expression `regexp`. - * - * assert.match('foobar', /^foo/, 'regexp matches'); - * - * @name match - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @api public - */ - - assert.match = function (exp, re, msg) { - new Assertion(exp, msg).to.match(re); - }; - - /** - * ### .notMatch(value, regexp, [message]) - * - * Asserts that `value` does not match the regular expression `regexp`. - * - * assert.notMatch('foobar', /^foo/, 'regexp does not match'); - * - * @name notMatch - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @api public - */ - - assert.notMatch = function (exp, re, msg) { - new Assertion(exp, msg).to.not.match(re); - }; - - /** - * ### .property(object, property, [message]) - * - * Asserts that `object` has a property named by `property`. - * - * assert.property({ tea: { green: 'matcha' }}, 'tea'); - * - * @name property - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.property = function (obj, prop, msg) { - new Assertion(obj, msg).to.have.property(prop); - }; - - /** - * ### .notProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a property named by `property`. - * - * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee'); - * - * @name notProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.notProperty = function (obj, prop, msg) { - new Assertion(obj, msg).to.not.have.property(prop); - }; - - /** - * ### .deepProperty(object, property, [message]) - * - * Asserts that `object` has a property named by `property`, which can be a - * string using dot- and bracket-notation for deep reference. - * - * assert.deepProperty({ tea: { green: 'matcha' }}, 'tea.green'); - * - * @name deepProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.deepProperty = function (obj, prop, msg) { - new Assertion(obj, msg).to.have.deep.property(prop); - }; - - /** - * ### .notDeepProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a property named by `property`, which - * can be a string using dot- and bracket-notation for deep reference. - * - * assert.notDeepProperty({ tea: { green: 'matcha' }}, 'tea.oolong'); - * - * @name notDeepProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.notDeepProperty = function (obj, prop, msg) { - new Assertion(obj, msg).to.not.have.deep.property(prop); - }; - - /** - * ### .propertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with value given - * by `value`. - * - * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good'); - * - * @name propertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.propertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg).to.have.property(prop, val); - }; - - /** - * ### .propertyNotVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property`, but with a value - * different from that given by `value`. - * - * assert.propertyNotVal({ tea: 'is good' }, 'tea', 'is bad'); - * - * @name propertyNotVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.propertyNotVal = function (obj, prop, val, msg) { - new Assertion(obj, msg).to.not.have.property(prop, val); - }; - - /** - * ### .deepPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with value given - * by `value`. `property` can use dot- and bracket-notation for deep - * reference. - * - * assert.deepPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha'); - * - * @name deepPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.deepPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg).to.have.deep.property(prop, val); - }; - - /** - * ### .deepPropertyNotVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property`, but with a value - * different from that given by `value`. `property` can use dot- and - * bracket-notation for deep reference. - * - * assert.deepPropertyNotVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha'); - * - * @name deepPropertyNotVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.deepPropertyNotVal = function (obj, prop, val, msg) { - new Assertion(obj, msg).to.not.have.deep.property(prop, val); - }; - - /** - * ### .lengthOf(object, length, [message]) - * - * Asserts that `object` has a `length` property with the expected value. - * - * assert.lengthOf([1,2,3], 3, 'array has length of 3'); - * assert.lengthOf('foobar', 5, 'string has length of 6'); - * - * @name lengthOf - * @param {Mixed} object - * @param {Number} length - * @param {String} message - * @api public - */ - - assert.lengthOf = function (exp, len, msg) { - new Assertion(exp, msg).to.have.length(len); - }; - - /** - * ### .throws(function, [constructor/string/regexp], [string/regexp], [message]) - * - * Asserts that `function` will throw an error that is an instance of - * `constructor`, or alternately that it will throw an error with message - * matching `regexp`. - * - * assert.throw(fn, 'function throws a reference error'); - * assert.throw(fn, /function throws a reference error/); - * assert.throw(fn, ReferenceError); - * assert.throw(fn, ReferenceError, 'function throws a reference error'); - * assert.throw(fn, ReferenceError, /function throws a reference error/); - * - * @name throws - * @alias throw - * @alias Throw - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @api public - */ - - assert.Throw = function (fn, errt, errs, msg) { - if ('string' === typeof errt || errt instanceof RegExp) { - errs = errt; - errt = null; - } - - new Assertion(fn, msg).to.Throw(errt, errs); - }; - - /** - * ### .doesNotThrow(function, [constructor/regexp], [message]) - * - * Asserts that `function` will _not_ throw an error that is an instance of - * `constructor`, or alternately that it will not throw an error with message - * matching `regexp`. - * - * assert.doesNotThrow(fn, Error, 'function does not throw'); - * - * @name doesNotThrow - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @api public - */ - - assert.doesNotThrow = function (fn, type, msg) { - if ('string' === typeof type) { - msg = type; - type = null; - } - - new Assertion(fn, msg).to.not.Throw(type); - }; - - /** - * ### .operator(val1, operator, val2, [message]) - * - * Compares two values using `operator`. - * - * assert.operator(1, '<', 2, 'everything is ok'); - * assert.operator(1, '>', 2, 'this will fail'); - * - * @name operator - * @param {Mixed} val1 - * @param {String} operator - * @param {Mixed} val2 - * @param {String} message - * @api public - */ - - assert.operator = function (val, operator, val2, msg) { - if (!~['==', '===', '>', '>=', '<', '<=', '!=', '!=='].indexOf(operator)) { - throw new Error('Invalid operator "' + operator + '"'); - } - var test = new Assertion(eval(val + operator + val2), msg); - test.assert( - true === flag(test, 'object') - , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2) - , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) ); - }; - - /** - * ### .closeTo(actual, expected, delta, [message]) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * assert.closeTo(1.5, 1, 0.5, 'numbers are close'); - * - * @name closeTo - * @param {Number} actual - * @param {Number} expected - * @param {Number} delta - * @param {String} message - * @api public - */ - - assert.closeTo = function (act, exp, delta, msg) { - new Assertion(act, msg).to.be.closeTo(exp, delta); - }; - - /** - * ### .sameMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members. - * Order is not taken into account. - * - * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members'); - * - * @name sameMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @api public - */ - - assert.sameMembers = function (set1, set2, msg) { - new Assertion(set1, msg).to.have.same.members(set2); - } - - /** - * ### .includeMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset`. - * Order is not taken into account. - * - * assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members'); - * - * @name includeMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @api public - */ - - assert.includeMembers = function (superset, subset, msg) { - new Assertion(superset, msg).to.include.members(subset); - } - - /*! - * Undocumented / untested - */ - - assert.ifError = function (val, msg) { - new Assertion(val, msg).to.not.be.ok; - }; - - /*! - * Aliases. - */ - - (function alias(name, as){ - assert[as] = assert[name]; - return alias; - }) - ('Throw', 'throw') - ('Throw', 'throws'); -}; - -}); -require.register("chai/lib/chai/interface/expect.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - chai.expect = function (val, message) { - return new chai.Assertion(val, message); - }; -}; - - -}); -require.register("chai/lib/chai/interface/should.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011-2013 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - var Assertion = chai.Assertion; - - function loadShould () { - // modify Object.prototype to have `should` - Object.defineProperty(Object.prototype, 'should', - { - set: function (value) { - // See https://github.com/chaijs/chai/issues/86: this makes - // `whatever.should = someValue` actually set `someValue`, which is - // especially useful for `global.should = require('chai').should()`. - // - // Note that we have to use [[DefineProperty]] instead of [[Put]] - // since otherwise we would trigger this very setter! - Object.defineProperty(this, 'should', { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } - , get: function(){ - if (this instanceof String || this instanceof Number) { - return new Assertion(this.constructor(this)); - } else if (this instanceof Boolean) { - return new Assertion(this == true); - } - return new Assertion(this); - } - , configurable: true - }); - - var should = {}; - - should.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.equal(val2); - }; - - should.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.Throw(errt, errs); - }; - - should.exist = function (val, msg) { - new Assertion(val, msg).to.exist; - } - - // negation - should.not = {} - - should.not.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.not.equal(val2); - }; - - should.not.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.not.Throw(errt, errs); - }; - - should.not.exist = function (val, msg) { - new Assertion(val, msg).to.not.exist; - } - - should['throw'] = should['Throw']; - should.not['throw'] = should.not['Throw']; - - return should; - }; - - chai.should = loadShould; - chai.Should = loadShould; -}; - -}); -require.register("chai/lib/chai/utils/addChainableMethod.js", function(exports, require, module){ -/*! - * Chai - addChainingMethod utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var transferFlags = require('./transferFlags'); - -/*! - * Module variables - */ - -// Check whether `__proto__` is supported -var hasProtoSupport = '__proto__' in Object; - -// Without `__proto__` support, this module will need to add properties to a function. -// However, some Function.prototype methods cannot be overwritten, -// and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69). -var excludeNames = /^(?:length|name|arguments|caller)$/; - -// Cache `Function` properties -var call = Function.prototype.call, - apply = Function.prototype.apply; - -/** - * ### addChainableMethod (ctx, name, method, chainingBehavior) - * - * Adds a method to an object, such that the method can also be chained. - * - * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior); - * - * The result can then be used as both a method assertion, executing both `method` and - * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`. - * - * expect(fooStr).to.be.foo('bar'); - * expect(fooStr).to.be.foo.equal('foo'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for `name`, when called - * @param {Function} chainingBehavior function to be called every time the property is accessed - * @name addChainableMethod - * @api public - */ - -module.exports = function (ctx, name, method, chainingBehavior) { - if (typeof chainingBehavior !== 'function') - chainingBehavior = function () { }; - - Object.defineProperty(ctx, name, - { get: function () { - chainingBehavior.call(this); - - var assert = function () { - var result = method.apply(this, arguments); - return result === undefined ? this : result; - }; - - // Use `__proto__` if available - if (hasProtoSupport) { - // Inherit all properties from the object by replacing the `Function` prototype - var prototype = assert.__proto__ = Object.create(this); - // Restore the `call` and `apply` methods from `Function` - prototype.call = call; - prototype.apply = apply; - } - // Otherwise, redefine all properties (slow!) - else { - var asserterNames = Object.getOwnPropertyNames(ctx); - asserterNames.forEach(function (asserterName) { - if (!excludeNames.test(asserterName)) { - var pd = Object.getOwnPropertyDescriptor(ctx, asserterName); - Object.defineProperty(assert, asserterName, pd); - } - }); - } - - transferFlags(this, assert); - return assert; - } - , configurable: true - }); -}; - -}); -require.register("chai/lib/chai/utils/addMethod.js", function(exports, require, module){ -/*! - * Chai - addMethod utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### .addMethod (ctx, name, method) - * - * Adds a method to the prototype of an object. - * - * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(fooStr).to.be.foo('bar'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for name - * @name addMethod - * @api public - */ - -module.exports = function (ctx, name, method) { - ctx[name] = function () { - var result = method.apply(this, arguments); - return result === undefined ? this : result; - }; -}; - -}); -require.register("chai/lib/chai/utils/addProperty.js", function(exports, require, module){ -/*! - * Chai - addProperty utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### addProperty (ctx, name, getter) - * - * Adds a property to the prototype of an object. - * - * utils.addProperty(chai.Assertion.prototype, 'foo', function () { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.instanceof(Foo); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.foo; - * - * @param {Object} ctx object to which the property is added - * @param {String} name of property to add - * @param {Function} getter function to be used for name - * @name addProperty - * @api public - */ - -module.exports = function (ctx, name, getter) { - Object.defineProperty(ctx, name, - { get: function () { - var result = getter.call(this); - return result === undefined ? this : result; - } - , configurable: true - }); -}; - -}); -require.register("chai/lib/chai/utils/eql.js", function(exports, require, module){ -// This is (almost) directly from Node.js assert -// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js - -module.exports = _deepEqual; - -var getEnumerableProperties = require('./getEnumerableProperties'); - -// for the browser -var Buffer; -try { - Buffer = require('buffer').Buffer; -} catch (ex) { - Buffer = { - isBuffer: function () { return false; } - }; -} - -function _deepEqual(actual, expected, memos) { - - // 7.1. All identical values are equivalent, as determined by ===. - if (actual === expected) { - return true; - - } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - - return true; - - // 7.2. If the expected value is a Date object, the actual value is - // equivalent if it is also a Date object that refers to the same time. - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - // 7.3. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual === expected; - - // 7.4. For all other Object pairs, including Array objects, equivalence is - // determined by having the same number of owned properties (as verified - // with Object.prototype.hasOwnProperty.call), the same set of keys - // (although not necessarily the same order), equivalent values for every - // corresponding key, and an identical 'prototype' property. Note: this - // accounts for both named and indexed properties on Arrays. - } else { - return objEquiv(actual, expected, memos); - } -} - -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -function objEquiv(a, b, memos) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - - // an identical 'prototype' property. - if (a.prototype !== b.prototype) return false; - - // check if we have already compared a and b - var i; - if (memos) { - for(i = 0; i < memos.length; i++) { - if ((memos[i][0] === a && memos[i][1] === b) || - (memos[i][0] === b && memos[i][1] === a)) - return true; - } - } else { - memos = []; - } - - //~~~I've managed to break Object.keys through screwy arguments passing. - // Converting to array solves the problem. - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return _deepEqual(a, b, memos); - } - try { - var ka = getEnumerableProperties(a), - kb = getEnumerableProperties(b), - key; - } catch (e) {//happens when one is a string literal and the other isn't - return false; - } - - // having the same number of owned properties (keys incorporates - // hasOwnProperty) - if (ka.length != kb.length) - return false; - - //the same set of keys (although not necessarily the same order), - ka.sort(); - kb.sort(); - //~~~cheap key test - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - - // remember objects we have compared to guard against circular references - memos.push([ a, b ]); - - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!_deepEqual(a[key], b[key], memos)) return false; - } - - return true; -} - -}); -require.register("chai/lib/chai/utils/flag.js", function(exports, require, module){ -/*! - * Chai - flag utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### flag(object ,key, [value]) - * - * Get or set a flag value on an object. If a - * value is provided it will be set, else it will - * return the currently set value or `undefined` if - * the value is not set. - * - * utils.flag(this, 'foo', 'bar'); // setter - * utils.flag(this, 'foo'); // getter, returns `bar` - * - * @param {Object} object (constructed Assertion - * @param {String} key - * @param {Mixed} value (optional) - * @name flag - * @api private - */ - -module.exports = function (obj, key, value) { - var flags = obj.__flags || (obj.__flags = Object.create(null)); - if (arguments.length === 3) { - flags[key] = value; - } else { - return flags[key]; - } -}; - -}); -require.register("chai/lib/chai/utils/getActual.js", function(exports, require, module){ -/*! - * Chai - getActual utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * # getActual(object, [actual]) - * - * Returns the `actual` value for an Assertion - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - */ - -module.exports = function (obj, args) { - var actual = args[4]; - return 'undefined' !== typeof actual ? actual : obj._obj; -}; - -}); -require.register("chai/lib/chai/utils/getEnumerableProperties.js", function(exports, require, module){ -/*! - * Chai - getEnumerableProperties utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### .getEnumerableProperties(object) - * - * This allows the retrieval of enumerable property names of an object, - * inherited or not. - * - * @param {Object} object - * @returns {Array} - * @name getEnumerableProperties - * @api public - */ - -module.exports = function getEnumerableProperties(object) { - var result = []; - for (var name in object) { - result.push(name); - } - return result; -}; - -}); -require.register("chai/lib/chai/utils/getMessage.js", function(exports, require, module){ -/*! - * Chai - message composition utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependancies - */ - -var flag = require('./flag') - , getActual = require('./getActual') - , inspect = require('./inspect') - , objDisplay = require('./objDisplay'); - -/** - * ### .getMessage(object, message, negateMessage) - * - * Construct the error message based on flags - * and template tags. Template tags will return - * a stringified inspection of the object referenced. - * - * Messsage template tags: - * - `#{this}` current asserted object - * - `#{act}` actual value - * - `#{exp}` expected value - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @name getMessage - * @api public - */ - -module.exports = function (obj, args) { - var negate = flag(obj, 'negate') - , val = flag(obj, 'object') - , expected = args[3] - , actual = getActual(obj, args) - , msg = negate ? args[2] : args[1] - , flagMsg = flag(obj, 'message'); - - msg = msg || ''; - msg = msg - .replace(/#{this}/g, objDisplay(val)) - .replace(/#{act}/g, objDisplay(actual)) - .replace(/#{exp}/g, objDisplay(expected)); - - return flagMsg ? flagMsg + ': ' + msg : msg; -}; - -}); -require.register("chai/lib/chai/utils/getName.js", function(exports, require, module){ -/*! - * Chai - getName utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * # getName(func) - * - * Gets the name of a function, in a cross-browser way. - * - * @param {Function} a function (usually a constructor) - */ - -module.exports = function (func) { - if (func.name) return func.name; - - var match = /^\s?function ([^(]*)\(/.exec(func); - return match && match[1] ? match[1] : ""; -}; - -}); -require.register("chai/lib/chai/utils/getPathValue.js", function(exports, require, module){ -/*! - * Chai - getPathValue utility - * Copyright(c) 2012-2013 Jake Luer - * @see https://github.com/logicalparadox/filtr - * MIT Licensed - */ - -/** - * ### .getPathValue(path, object) - * - * This allows the retrieval of values in an - * object given a string path. - * - * var obj = { - * prop1: { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * , prop2: { - * arr: [ { nested: 'Universe' } ] - * , str: 'Hello again!' - * } - * } - * - * The following would be the results. - * - * getPathValue('prop1.str', obj); // Hello - * getPathValue('prop1.att[2]', obj); // b - * getPathValue('prop2.arr[0].nested', obj); // Universe - * - * @param {String} path - * @param {Object} object - * @returns {Object} value or `undefined` - * @name getPathValue - * @api public - */ - -var getPathValue = module.exports = function (path, obj) { - var parsed = parsePath(path); - return _getPathValue(parsed, obj); -}; - -/*! - * ## parsePath(path) - * - * Helper function used to parse string object - * paths. Use in conjunction with `_getPathValue`. - * - * var parsed = parsePath('myobject.property.subprop'); - * - * ### Paths: - * - * * Can be as near infinitely deep and nested - * * Arrays are also valid using the formal `myobject.document[3].property`. - * - * @param {String} path - * @returns {Object} parsed - * @api private - */ - -function parsePath (path) { - var str = path.replace(/\[/g, '.[') - , parts = str.match(/(\\\.|[^.]+?)+/g); - return parts.map(function (value) { - var re = /\[(\d+)\]$/ - , mArr = re.exec(value) - if (mArr) return { i: parseFloat(mArr[1]) }; - else return { p: value }; - }); -}; - -/*! - * ## _getPathValue(parsed, obj) - * - * Helper companion function for `.parsePath` that returns - * the value located at the parsed address. - * - * var value = getPathValue(parsed, obj); - * - * @param {Object} parsed definition from `parsePath`. - * @param {Object} object to search against - * @returns {Object|Undefined} value - * @api private - */ - -function _getPathValue (parsed, obj) { - var tmp = obj - , res; - for (var i = 0, l = parsed.length; i < l; i++) { - var part = parsed[i]; - if (tmp) { - if ('undefined' !== typeof part.p) - tmp = tmp[part.p]; - else if ('undefined' !== typeof part.i) - tmp = tmp[part.i]; - if (i == (l - 1)) res = tmp; - } else { - res = undefined; - } - } - return res; -}; - -}); -require.register("chai/lib/chai/utils/getProperties.js", function(exports, require, module){ -/*! - * Chai - getProperties utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### .getProperties(object) - * - * This allows the retrieval of property names of an object, enumerable or not, - * inherited or not. - * - * @param {Object} object - * @returns {Array} - * @name getProperties - * @api public - */ - -module.exports = function getProperties(object) { - var result = Object.getOwnPropertyNames(subject); - - function addProperty(property) { - if (result.indexOf(property) === -1) { - result.push(property); - } - } - - var proto = Object.getPrototypeOf(subject); - while (proto !== null) { - Object.getOwnPropertyNames(proto).forEach(addProperty); - proto = Object.getPrototypeOf(proto); - } - - return result; -}; - -}); -require.register("chai/lib/chai/utils/index.js", function(exports, require, module){ -/*! - * chai - * Copyright(c) 2011 Jake Luer - * MIT Licensed - */ - -/*! - * Main exports - */ - -var exports = module.exports = {}; - -/*! - * test utility - */ - -exports.test = require('./test'); - -/*! - * type utility - */ - -exports.type = require('./type'); - -/*! - * message utility - */ - -exports.getMessage = require('./getMessage'); - -/*! - * actual utility - */ - -exports.getActual = require('./getActual'); - -/*! - * Inspect util - */ - -exports.inspect = require('./inspect'); - -/*! - * Object Display util - */ - -exports.objDisplay = require('./objDisplay'); - -/*! - * Flag utility - */ - -exports.flag = require('./flag'); - -/*! - * Flag transferring utility - */ - -exports.transferFlags = require('./transferFlags'); - -/*! - * Deep equal utility - */ - -exports.eql = require('./eql'); - -/*! - * Deep path value - */ - -exports.getPathValue = require('./getPathValue'); - -/*! - * Function name - */ - -exports.getName = require('./getName'); - -/*! - * add Property - */ - -exports.addProperty = require('./addProperty'); - -/*! - * add Method - */ - -exports.addMethod = require('./addMethod'); - -/*! - * overwrite Property - */ - -exports.overwriteProperty = require('./overwriteProperty'); - -/*! - * overwrite Method - */ - -exports.overwriteMethod = require('./overwriteMethod'); - -/*! - * Add a chainable method - */ - -exports.addChainableMethod = require('./addChainableMethod'); - - -}); -require.register("chai/lib/chai/utils/inspect.js", function(exports, require, module){ -// This is (almost) directly from Node.js utils -// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js - -var getName = require('./getName'); -var getProperties = require('./getProperties'); -var getEnumerableProperties = require('./getEnumerableProperties'); - -module.exports = inspect; - -/** - * Echos the value of a value. Trys to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Boolean} showHidden Flag that shows hidden (not enumerable) - * properties of objects. - * @param {Number} depth Depth in which to descend in object. Default is 2. - * @param {Boolean} colors Flag to turn on ANSI escape codes to color the - * output. Default is false (no coloring). - */ -function inspect(obj, showHidden, depth, colors) { - var ctx = { - showHidden: showHidden, - seen: [], - stylize: function (str) { return str; } - }; - return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth)); -} - -// https://gist.github.com/1044128/ -var getOuterHTML = function(element) { - if ('outerHTML' in element) return element.outerHTML; - var ns = "http://www.w3.org/1999/xhtml"; - var container = document.createElementNS(ns, '_'); - var elemProto = (window.HTMLElement || window.Element).prototype; - var xmlSerializer = new XMLSerializer(); - var html; - if (document.xmlVersion) { - return xmlSerializer.serializeToString(element); - } else { - container.appendChild(element.cloneNode(false)); - html = container.innerHTML.replace('><', '>' + element.innerHTML + '<'); - container.innerHTML = ''; - return html; - } -}; - -// Returns true if object is a DOM element. -var isDOMElement = function (object) { - if (typeof HTMLElement === 'object') { - return object instanceof HTMLElement; - } else { - return object && - typeof object === 'object' && - object.nodeType === 1 && - typeof object.nodeName === 'string'; - } -}; - -function formatValue(ctx, value, recurseTimes) { - // Provide a hook for user-specified inspect functions. - // Check that value is an object with an inspect function on it - if (value && typeof value.inspect === 'function' && - // Filter out the util module, it's inspect function is special - value.inspect !== exports.inspect && - // Also filter out any prototype objects using the circular check. - !(value.constructor && value.constructor.prototype === value)) { - return value.inspect(recurseTimes); - } - - // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); - if (primitive) { - return primitive; - } - - // If it's DOM elem, get outer HTML. - if (isDOMElement(value)) { - return getOuterHTML(value); - } - - // Look up the keys of the object. - var visibleKeys = getEnumerableProperties(value); - var keys = ctx.showHidden ? getProperties(value) : visibleKeys; - - // Some type of object without properties can be shortcutted. - // In IE, errors have a single `stack` property, or if they are vanilla `Error`, - // a `stack` plus `description` property; ignore those for consistency. - if (keys.length === 0 || (isError(value) && ( - (keys.length === 1 && keys[0] === 'stack') || - (keys.length === 2 && keys[0] === 'description' && keys[1] === 'stack') - ))) { - if (typeof value === 'function') { - var name = getName(value); - var nameSuffix = name ? ': ' + name : ''; - return ctx.stylize('[Function' + nameSuffix + ']', 'special'); - } - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } - if (isDate(value)) { - return ctx.stylize(Date.prototype.toUTCString.call(value), 'date'); - } - if (isError(value)) { - return formatError(value); - } - } - - var base = '', array = false, braces = ['{', '}']; - - // Make Array say that they are Array - if (isArray(value)) { - array = true; - braces = ['[', ']']; - } - - // Make functions say that they are functions - if (typeof value === 'function') { - var name = getName(value); - var nameSuffix = name ? ': ' + name : ''; - base = ' [Function' + nameSuffix + ']'; - } - - // Make RegExps say that they are RegExps - if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); - } - - // Make dates with properties first say the date - if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); - } - - // Make error with message first say the error - if (isError(value)) { - return formatError(value); - } - - if (keys.length === 0 && (!array || value.length == 0)) { - return braces[0] + base + braces[1]; - } - - if (recurseTimes < 0) { - if (isRegExp(value)) { - return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); - } - } - - ctx.seen.push(value); - - var output; - if (array) { - output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); - } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); - }); - } - - ctx.seen.pop(); - - return reduceToSingleString(output, base, braces); -} - - -function formatPrimitive(ctx, value) { - switch (typeof value) { - case 'undefined': - return ctx.stylize('undefined', 'undefined'); - - case 'string': - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; - return ctx.stylize(simple, 'string'); - - case 'number': - return ctx.stylize('' + value, 'number'); - - case 'boolean': - return ctx.stylize('' + value, 'boolean'); - } - // For some reason typeof null is "object", so special case here. - if (value === null) { - return ctx.stylize('null', 'null'); - } -} - - -function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; -} - - -function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { - if (Object.prototype.hasOwnProperty.call(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); - } else { - output.push(''); - } - } - keys.forEach(function(key) { - if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); - } - }); - return output; -} - - -function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str; - if (value.__lookupGetter__) { - if (value.__lookupGetter__(key)) { - if (value.__lookupSetter__(key)) { - str = ctx.stylize('[Getter/Setter]', 'special'); - } else { - str = ctx.stylize('[Getter]', 'special'); - } - } else { - if (value.__lookupSetter__(key)) { - str = ctx.stylize('[Setter]', 'special'); - } - } - } - if (visibleKeys.indexOf(key) < 0) { - name = '[' + key + ']'; - } - if (!str) { - if (ctx.seen.indexOf(value[key]) < 0) { - if (recurseTimes === null) { - str = formatValue(ctx, value[key], null); - } else { - str = formatValue(ctx, value[key], recurseTimes - 1); - } - if (str.indexOf('\n') > -1) { - if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); - } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); - } - } - } else { - str = ctx.stylize('[Circular]', 'special'); - } - } - if (typeof name === 'undefined') { - if (array && key.match(/^\d+$/)) { - return str; - } - name = JSON.stringify('' + key); - if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { - name = name.substr(1, name.length - 2); - name = ctx.stylize(name, 'name'); - } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); - name = ctx.stylize(name, 'string'); - } - } - - return name + ': ' + str; -} - - -function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { - numLinesEst++; - if (cur.indexOf('\n') >= 0) numLinesEst++; - return prev + cur.length + 1; - }, 0); - - if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; - } - - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; -} - -function isArray(ar) { - return Array.isArray(ar) || - (typeof ar === 'object' && objectToString(ar) === '[object Array]'); -} - -function isRegExp(re) { - return typeof re === 'object' && objectToString(re) === '[object RegExp]'; -} - -function isDate(d) { - return typeof d === 'object' && objectToString(d) === '[object Date]'; -} - -function isError(e) { - return typeof e === 'object' && objectToString(e) === '[object Error]'; -} - -function objectToString(o) { - return Object.prototype.toString.call(o); -} - -}); -require.register("chai/lib/chai/utils/objDisplay.js", function(exports, require, module){ -/*! - * Chai - flag utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependancies - */ - -var inspect = require('./inspect'); - -/** - * ### .objDisplay (object) - * - * Determines if an object or an array matches - * criteria to be inspected in-line for error - * messages or should be truncated. - * - * @param {Mixed} javascript object to inspect - * @name objDisplay - * @api public - */ - -module.exports = function (obj) { - var str = inspect(obj) - , type = Object.prototype.toString.call(obj); - - if (str.length >= 40) { - if (type === '[object Function]') { - return !obj.name || obj.name === '' - ? '[Function]' - : '[Function: ' + obj.name + ']'; - } else if (type === '[object Array]') { - return '[ Array(' + obj.length + ') ]'; - } else if (type === '[object Object]') { - var keys = Object.keys(obj) - , kstr = keys.length > 2 - ? keys.splice(0, 2).join(', ') + ', ...' - : keys.join(', '); - return '{ Object (' + kstr + ') }'; - } else { - return str; - } - } else { - return str; - } -}; - -}); -require.register("chai/lib/chai/utils/overwriteMethod.js", function(exports, require, module){ -/*! - * Chai - overwriteMethod utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### overwriteMethod (ctx, name, fn) - * - * Overwites an already existing method and provides - * access to previous function. Must return function - * to be used for name. - * - * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) { - * return function (str) { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.value).to.equal(str); - * } else { - * _super.apply(this, arguments); - * } - * } - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.equal('bar'); - * - * @param {Object} ctx object whose method is to be overwritten - * @param {String} name of method to overwrite - * @param {Function} method function that returns a function to be used for name - * @name overwriteMethod - * @api public - */ - -module.exports = function (ctx, name, method) { - var _method = ctx[name] - , _super = function () { return this; }; - - if (_method && 'function' === typeof _method) - _super = _method; - - ctx[name] = function () { - var result = method(_super).apply(this, arguments); - return result === undefined ? this : result; - } -}; - -}); -require.register("chai/lib/chai/utils/overwriteProperty.js", function(exports, require, module){ -/*! - * Chai - overwriteProperty utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### overwriteProperty (ctx, name, fn) - * - * Overwites an already existing property getter and provides - * access to previous value. Must return function to use as getter. - * - * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) { - * return function () { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.name).to.equal('bar'); - * } else { - * _super.call(this); - * } - * } - * }); - * - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.ok; - * - * @param {Object} ctx object whose property is to be overwritten - * @param {String} name of property to overwrite - * @param {Function} getter function that returns a getter function to be used for name - * @name overwriteProperty - * @api public - */ - -module.exports = function (ctx, name, getter) { - var _get = Object.getOwnPropertyDescriptor(ctx, name) - , _super = function () {}; - - if (_get && 'function' === typeof _get.get) - _super = _get.get - - Object.defineProperty(ctx, name, - { get: function () { - var result = getter(_super).call(this); - return result === undefined ? this : result; - } - , configurable: true - }); -}; - -}); -require.register("chai/lib/chai/utils/test.js", function(exports, require, module){ -/*! - * Chai - test utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependancies - */ - -var flag = require('./flag'); - -/** - * # test(object, expression) - * - * Test and object for expression. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - */ - -module.exports = function (obj, args) { - var negate = flag(obj, 'negate') - , expr = args[0]; - return negate ? !expr : expr; -}; - -}); -require.register("chai/lib/chai/utils/transferFlags.js", function(exports, require, module){ -/*! - * Chai - transferFlags utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/** - * ### transferFlags(assertion, object, includeAll = true) - * - * Transfer all the flags for `assertion` to `object`. If - * `includeAll` is set to `false`, then the base Chai - * assertion flags (namely `object`, `ssfi`, and `message`) - * will not be transferred. - * - * - * var newAssertion = new Assertion(); - * utils.transferFlags(assertion, newAssertion); - * - * var anotherAsseriton = new Assertion(myObj); - * utils.transferFlags(assertion, anotherAssertion, false); - * - * @param {Assertion} assertion the assertion to transfer the flags from - * @param {Object} object the object to transfer the flags too; usually a new assertion - * @param {Boolean} includeAll - * @name getAllFlags - * @api private - */ - -module.exports = function (assertion, object, includeAll) { - var flags = assertion.__flags || (assertion.__flags = Object.create(null)); - - if (!object.__flags) { - object.__flags = Object.create(null); - } - - includeAll = arguments.length === 3 ? includeAll : true; - - for (var flag in flags) { - if (includeAll || - (flag !== 'object' && flag !== 'ssfi' && flag != 'message')) { - object.__flags[flag] = flags[flag]; - } - } -}; - -}); -require.register("chai/lib/chai/utils/type.js", function(exports, require, module){ -/*! - * Chai - type utility - * Copyright(c) 2012-2013 Jake Luer - * MIT Licensed - */ - -/*! - * Detectable javascript natives - */ - -var natives = { - '[object Arguments]': 'arguments' - , '[object Array]': 'array' - , '[object Date]': 'date' - , '[object Function]': 'function' - , '[object Number]': 'number' - , '[object RegExp]': 'regexp' - , '[object String]': 'string' -}; - -/** - * ### type(object) - * - * Better implementation of `typeof` detection that can - * be used cross-browser. Handles the inconsistencies of - * Array, `null`, and `undefined` detection. - * - * utils.type({}) // 'object' - * utils.type(null) // `null' - * utils.type(undefined) // `undefined` - * utils.type([]) // `array` - * - * @param {Mixed} object to detect type of - * @name type - * @api private - */ - -module.exports = function (obj) { - var str = Object.prototype.toString.call(obj); - if (natives[str]) return natives[str]; - if (obj === null) return 'null'; - if (obj === undefined) return 'undefined'; - if (obj === Object(obj)) return 'object'; - return typeof obj; -}; - -}); -require.alias("chai/index.js", "chai/index.js"); - -if (typeof exports == "object") { - module.exports = require("chai"); -} else if (typeof define == "function" && define.amd) { - define(function(){ return require("chai"); }); -} else { - this["chai"] = require("chai"); -}})(); diff --git a/tests/libs/mocha-1.9.0.css b/tests/libs/mocha-1.9.0.css deleted file mode 100644 index 883d44bb..00000000 --- a/tests/libs/mocha-1.9.0.css +++ /dev/null @@ -1,246 +0,0 @@ -@charset "utf-8"; - -body { - font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; - padding: 60px 50px; -} - -#mocha ul, #mocha li { - margin: 0; - padding: 0; -} - -#mocha ul { - list-style: none; -} - -#mocha h1, #mocha h2 { - margin: 0; -} - -#mocha h1 { - margin-top: 15px; - font-size: 1em; - font-weight: 200; -} - -#mocha h1 a { - text-decoration: none; - color: inherit; -} - -#mocha h1 a:hover { - text-decoration: underline; -} - -#mocha .suite .suite h1 { - margin-top: 0; - font-size: .8em; -} - -.hidden { - display: none; -} - -#mocha h2 { - font-size: 12px; - font-weight: normal; - cursor: pointer; -} - -#mocha .suite { - margin-left: 15px; -} - -#mocha .test { - margin-left: 15px; - overflow: hidden; -} - -#mocha .test.pending:hover h2::after { - content: '(pending)'; - font-family: arial; -} - -#mocha .test.pass.medium .duration { - background: #C09853; -} - -#mocha .test.pass.slow .duration { - background: #B94A48; -} - -#mocha .test.pass::before { - content: '✓'; - font-size: 12px; - display: block; - float: left; - margin-right: 5px; - color: #00d6b2; -} - -#mocha .test.pass .duration { - font-size: 9px; - margin-left: 5px; - padding: 2px 5px; - color: white; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2); - -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2); - box-shadow: inset 0 1px 1px rgba(0,0,0,.2); - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - -ms-border-radius: 5px; - -o-border-radius: 5px; - border-radius: 5px; -} - -#mocha .test.pass.fast .duration { - display: none; -} - -#mocha .test.pending { - color: #0b97c4; -} - -#mocha .test.pending::before { - content: '◦'; - color: #0b97c4; -} - -#mocha .test.fail { - color: #c00; -} - -#mocha .test.fail pre { - color: black; -} - -#mocha .test.fail::before { - content: '✖'; - font-size: 12px; - display: block; - float: left; - margin-right: 5px; - color: #c00; -} - -#mocha .test pre.error { - color: #c00; - max-height: 300px; - overflow: auto; -} - -#mocha .test pre { - display: block; - float: left; - clear: left; - font: 12px/1.5 monaco, monospace; - margin: 5px; - padding: 15px; - border: 1px solid #eee; - border-bottom-color: #ddd; - -webkit-border-radius: 3px; - -webkit-box-shadow: 0 1px 3px #eee; - -moz-border-radius: 3px; - -moz-box-shadow: 0 1px 3px #eee; -} - -#mocha .test h2 { - position: relative; -} - -#mocha .test a.replay { - position: absolute; - top: 3px; - right: 0; - text-decoration: none; - vertical-align: middle; - display: block; - width: 15px; - height: 15px; - line-height: 15px; - text-align: center; - background: #eee; - font-size: 15px; - -moz-border-radius: 15px; - border-radius: 15px; - -webkit-transition: opacity 200ms; - -moz-transition: opacity 200ms; - transition: opacity 200ms; - opacity: 0.3; - color: #888; -} - -#mocha .test:hover a.replay { - opacity: 1; -} - -#mocha-report.pass .test.fail { - display: none; -} - -#mocha-report.fail .test.pass { - display: none; -} - -#mocha-error { - color: #c00; - font-size: 1.5 em; - font-weight: 100; - letter-spacing: 1px; -} - -#mocha-stats { - position: fixed; - top: 15px; - right: 10px; - font-size: 12px; - margin: 0; - color: #888; -} - -#mocha-stats .progress { - float: right; - padding-top: 0; -} - -#mocha-stats em { - color: black; -} - -#mocha-stats a { - text-decoration: none; - color: inherit; -} - -#mocha-stats a:hover { - border-bottom: 1px solid #eee; -} - -#mocha-stats li { - display: inline-block; - margin: 0 5px; - list-style: none; - padding-top: 11px; -} - -#mocha-stats canvas { - width: 40px; - height: 40px; -} - -code .comment { color: #ddd } -code .init { color: #2F6FAD } -code .string { color: #5890AD } -code .keyword { color: #8A6343 } -code .number { color: #2F6FAD } - -@media screen and (max-device-width: 480px) { - body { - padding: 60px 0px; - } - - #stats { - position: absolute; - } -} diff --git a/tests/libs/mocha-1.9.0.js b/tests/libs/mocha-1.9.0.js deleted file mode 100644 index aed04d99..00000000 --- a/tests/libs/mocha-1.9.0.js +++ /dev/null @@ -1,5338 +0,0 @@ -;(function(){ - -// CommonJS require() - -function require(p){ - var path = require.resolve(p) - , mod = require.modules[path]; - if (!mod) throw new Error('failed to require "' + p + '"'); - if (!mod.exports) { - mod.exports = {}; - mod.call(mod.exports, mod, mod.exports, require.relative(path)); - } - return mod.exports; - } - -require.modules = {}; - -require.resolve = function (path){ - var orig = path - , reg = path + '.js' - , index = path + '/index.js'; - return require.modules[reg] && reg - || require.modules[index] && index - || orig; - }; - -require.register = function (path, fn){ - require.modules[path] = fn; - }; - -require.relative = function (parent) { - return function(p){ - if ('.' != p.charAt(0)) return require(p); - - var path = parent.split('/') - , segs = p.split('/'); - path.pop(); - - for (var i = 0; i < segs.length; i++) { - var seg = segs[i]; - if ('..' == seg) path.pop(); - else if ('.' != seg) path.push(seg); - } - - return require(path.join('/')); - }; - }; - - -require.register("browser/debug.js", function(module, exports, require){ - -module.exports = function(type){ - return function(){ - } -}; - -}); // module: browser/debug.js - -require.register("browser/diff.js", function(module, exports, require){ -/* See license.txt for terms of usage */ - -/* - * Text diff implementation. - * - * This library supports the following APIS: - * JsDiff.diffChars: Character by character diff - * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace - * JsDiff.diffLines: Line based diff - * - * JsDiff.diffCss: Diff targeted at CSS content - * - * These methods are based on the implementation proposed in - * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986). - * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 - */ -var JsDiff = (function() { - function clonePath(path) { - return { newPos: path.newPos, components: path.components.slice(0) }; - } - function removeEmpty(array) { - var ret = []; - for (var i = 0; i < array.length; i++) { - if (array[i]) { - ret.push(array[i]); - } - } - return ret; - } - function escapeHTML(s) { - var n = s; - n = n.replace(/&/g, "&"); - n = n.replace(//g, ">"); - n = n.replace(/"/g, """); - - return n; - } - - - var fbDiff = function(ignoreWhitespace) { - this.ignoreWhitespace = ignoreWhitespace; - }; - fbDiff.prototype = { - diff: function(oldString, newString) { - // Handle the identity case (this is due to unrolling editLength == 0 - if (newString == oldString) { - return [{ value: newString }]; - } - if (!newString) { - return [{ value: oldString, removed: true }]; - } - if (!oldString) { - return [{ value: newString, added: true }]; - } - - newString = this.tokenize(newString); - oldString = this.tokenize(oldString); - - var newLen = newString.length, oldLen = oldString.length; - var maxEditLength = newLen + oldLen; - var bestPath = [{ newPos: -1, components: [] }]; - - // Seed editLength = 0 - var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); - if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) { - return bestPath[0].components; - } - - for (var editLength = 1; editLength <= maxEditLength; editLength++) { - for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) { - var basePath; - var addPath = bestPath[diagonalPath-1], - removePath = bestPath[diagonalPath+1]; - oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; - if (addPath) { - // No one else is going to attempt to use this value, clear it - bestPath[diagonalPath-1] = undefined; - } - - var canAdd = addPath && addPath.newPos+1 < newLen; - var canRemove = removePath && 0 <= oldPos && oldPos < oldLen; - if (!canAdd && !canRemove) { - bestPath[diagonalPath] = undefined; - continue; - } - - // Select the diagonal that we want to branch from. We select the prior - // path whose position in the new string is the farthest from the origin - // and does not pass the bounds of the diff graph - if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) { - basePath = clonePath(removePath); - this.pushComponent(basePath.components, oldString[oldPos], undefined, true); - } else { - basePath = clonePath(addPath); - basePath.newPos++; - this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined); - } - - var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath); - - if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) { - return basePath.components; - } else { - bestPath[diagonalPath] = basePath; - } - } - } - }, - - pushComponent: function(components, value, added, removed) { - var last = components[components.length-1]; - if (last && last.added === added && last.removed === removed) { - // We need to clone here as the component clone operation is just - // as shallow array clone - components[components.length-1] = - {value: this.join(last.value, value), added: added, removed: removed }; - } else { - components.push({value: value, added: added, removed: removed }); - } - }, - extractCommon: function(basePath, newString, oldString, diagonalPath) { - var newLen = newString.length, - oldLen = oldString.length, - newPos = basePath.newPos, - oldPos = newPos - diagonalPath; - while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) { - newPos++; - oldPos++; - - this.pushComponent(basePath.components, newString[newPos], undefined, undefined); - } - basePath.newPos = newPos; - return oldPos; - }, - - equals: function(left, right) { - var reWhitespace = /\S/; - if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) { - return true; - } else { - return left == right; - } - }, - join: function(left, right) { - return left + right; - }, - tokenize: function(value) { - return value; - } - }; - - var CharDiff = new fbDiff(); - - var WordDiff = new fbDiff(true); - WordDiff.tokenize = function(value) { - return removeEmpty(value.split(/(\s+|\b)/)); - }; - - var CssDiff = new fbDiff(true); - CssDiff.tokenize = function(value) { - return removeEmpty(value.split(/([{}:;,]|\s+)/)); - }; - - var LineDiff = new fbDiff(); - LineDiff.tokenize = function(value) { - return value.split(/^/m); - }; - - return { - diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); }, - diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); }, - diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); }, - - diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); }, - - createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) { - var ret = []; - - ret.push("Index: " + fileName); - ret.push("==================================================================="); - ret.push("--- " + fileName + (typeof oldHeader === "undefined" ? "" : "\t" + oldHeader)); - ret.push("+++ " + fileName + (typeof newHeader === "undefined" ? "" : "\t" + newHeader)); - - var diff = LineDiff.diff(oldStr, newStr); - if (!diff[diff.length-1].value) { - diff.pop(); // Remove trailing newline add - } - diff.push({value: "", lines: []}); // Append an empty value to make cleanup easier - - function contextLines(lines) { - return lines.map(function(entry) { return ' ' + entry; }); - } - function eofNL(curRange, i, current) { - var last = diff[diff.length-2], - isLast = i === diff.length-2, - isLastOfType = i === diff.length-3 && (current.added === !last.added || current.removed === !last.removed); - - // Figure out if this is the last line for the given file and missing NL - if (!/\n$/.test(current.value) && (isLast || isLastOfType)) { - curRange.push('\\ No newline at end of file'); - } - } - - var oldRangeStart = 0, newRangeStart = 0, curRange = [], - oldLine = 1, newLine = 1; - for (var i = 0; i < diff.length; i++) { - var current = diff[i], - lines = current.lines || current.value.replace(/\n$/, "").split("\n"); - current.lines = lines; - - if (current.added || current.removed) { - if (!oldRangeStart) { - var prev = diff[i-1]; - oldRangeStart = oldLine; - newRangeStart = newLine; - - if (prev) { - curRange = contextLines(prev.lines.slice(-4)); - oldRangeStart -= curRange.length; - newRangeStart -= curRange.length; - } - } - curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?"+":"-") + entry; })); - eofNL(curRange, i, current); - - if (current.added) { - newLine += lines.length; - } else { - oldLine += lines.length; - } - } else { - if (oldRangeStart) { - // Close out any changes that have been output (or join overlapping) - if (lines.length <= 8 && i < diff.length-2) { - // Overlapping - curRange.push.apply(curRange, contextLines(lines)); - } else { - // end the range and output - var contextSize = Math.min(lines.length, 4); - ret.push( - "@@ -" + oldRangeStart + "," + (oldLine-oldRangeStart+contextSize) - + " +" + newRangeStart + "," + (newLine-newRangeStart+contextSize) - + " @@"); - ret.push.apply(ret, curRange); - ret.push.apply(ret, contextLines(lines.slice(0, contextSize))); - if (lines.length <= 4) { - eofNL(ret, i, current); - } - - oldRangeStart = 0; newRangeStart = 0; curRange = []; - } - } - oldLine += lines.length; - newLine += lines.length; - } - } - - return ret.join('\n') + '\n'; - }, - - convertChangesToXML: function(changes){ - var ret = []; - for ( var i = 0; i < changes.length; i++) { - var change = changes[i]; - if (change.added) { - ret.push(""); - } else if (change.removed) { - ret.push(""); - } - - ret.push(escapeHTML(change.value)); - - if (change.added) { - ret.push(""); - } else if (change.removed) { - ret.push(""); - } - } - return ret.join(""); - } - }; -})(); - -if (typeof module !== "undefined") { - module.exports = JsDiff; -} - -}); // module: browser/diff.js - -require.register("browser/events.js", function(module, exports, require){ - -/** - * Module exports. - */ - -exports.EventEmitter = EventEmitter; - -/** - * Check if `obj` is an array. - */ - -function isArray(obj) { - return '[object Array]' == {}.toString.call(obj); -} - -/** - * Event emitter constructor. - * - * @api public - */ - -function EventEmitter(){}; - -/** - * Adds a listener. - * - * @api public - */ - -EventEmitter.prototype.on = function (name, fn) { - if (!this.$events) { - this.$events = {}; - } - - if (!this.$events[name]) { - this.$events[name] = fn; - } else if (isArray(this.$events[name])) { - this.$events[name].push(fn); - } else { - this.$events[name] = [this.$events[name], fn]; - } - - return this; -}; - -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -/** - * Adds a volatile listener. - * - * @api public - */ - -EventEmitter.prototype.once = function (name, fn) { - var self = this; - - function on () { - self.removeListener(name, on); - fn.apply(this, arguments); - }; - - on.listener = fn; - this.on(name, on); - - return this; -}; - -/** - * Removes a listener. - * - * @api public - */ - -EventEmitter.prototype.removeListener = function (name, fn) { - if (this.$events && this.$events[name]) { - var list = this.$events[name]; - - if (isArray(list)) { - var pos = -1; - - for (var i = 0, l = list.length; i < l; i++) { - if (list[i] === fn || (list[i].listener && list[i].listener === fn)) { - pos = i; - break; - } - } - - if (pos < 0) { - return this; - } - - list.splice(pos, 1); - - if (!list.length) { - delete this.$events[name]; - } - } else if (list === fn || (list.listener && list.listener === fn)) { - delete this.$events[name]; - } - } - - return this; -}; - -/** - * Removes all listeners for an event. - * - * @api public - */ - -EventEmitter.prototype.removeAllListeners = function (name) { - if (name === undefined) { - this.$events = {}; - return this; - } - - if (this.$events && this.$events[name]) { - this.$events[name] = null; - } - - return this; -}; - -/** - * Gets all listeners for a certain event. - * - * @api public - */ - -EventEmitter.prototype.listeners = function (name) { - if (!this.$events) { - this.$events = {}; - } - - if (!this.$events[name]) { - this.$events[name] = []; - } - - if (!isArray(this.$events[name])) { - this.$events[name] = [this.$events[name]]; - } - - return this.$events[name]; -}; - -/** - * Emits an event. - * - * @api public - */ - -EventEmitter.prototype.emit = function (name) { - if (!this.$events) { - return false; - } - - var handler = this.$events[name]; - - if (!handler) { - return false; - } - - var args = [].slice.call(arguments, 1); - - if ('function' == typeof handler) { - handler.apply(this, args); - } else if (isArray(handler)) { - var listeners = handler.slice(); - - for (var i = 0, l = listeners.length; i < l; i++) { - listeners[i].apply(this, args); - } - } else { - return false; - } - - return true; -}; -}); // module: browser/events.js - -require.register("browser/fs.js", function(module, exports, require){ - -}); // module: browser/fs.js - -require.register("browser/path.js", function(module, exports, require){ - -}); // module: browser/path.js - -require.register("browser/progress.js", function(module, exports, require){ - -/** - * Expose `Progress`. - */ - -module.exports = Progress; - -/** - * Initialize a new `Progress` indicator. - */ - -function Progress() { - this.percent = 0; - this.size(0); - this.fontSize(11); - this.font('helvetica, arial, sans-serif'); -} - -/** - * Set progress size to `n`. - * - * @param {Number} n - * @return {Progress} for chaining - * @api public - */ - -Progress.prototype.size = function(n){ - this._size = n; - return this; -}; - -/** - * Set text to `str`. - * - * @param {String} str - * @return {Progress} for chaining - * @api public - */ - -Progress.prototype.text = function(str){ - this._text = str; - return this; -}; - -/** - * Set font size to `n`. - * - * @param {Number} n - * @return {Progress} for chaining - * @api public - */ - -Progress.prototype.fontSize = function(n){ - this._fontSize = n; - return this; -}; - -/** - * Set font `family`. - * - * @param {String} family - * @return {Progress} for chaining - */ - -Progress.prototype.font = function(family){ - this._font = family; - return this; -}; - -/** - * Update percentage to `n`. - * - * @param {Number} n - * @return {Progress} for chaining - */ - -Progress.prototype.update = function(n){ - this.percent = n; - return this; -}; - -/** - * Draw on `ctx`. - * - * @param {CanvasRenderingContext2d} ctx - * @return {Progress} for chaining - */ - -Progress.prototype.draw = function(ctx){ - var percent = Math.min(this.percent, 100) - , size = this._size - , half = size / 2 - , x = half - , y = half - , rad = half - 1 - , fontSize = this._fontSize; - - ctx.font = fontSize + 'px ' + this._font; - - var angle = Math.PI * 2 * (percent / 100); - ctx.clearRect(0, 0, size, size); - - // outer circle - ctx.strokeStyle = '#9f9f9f'; - ctx.beginPath(); - ctx.arc(x, y, rad, 0, angle, false); - ctx.stroke(); - - // inner circle - ctx.strokeStyle = '#eee'; - ctx.beginPath(); - ctx.arc(x, y, rad - 1, 0, angle, true); - ctx.stroke(); - - // text - var text = this._text || (percent | 0) + '%' - , w = ctx.measureText(text).width; - - ctx.fillText( - text - , x - w / 2 + 1 - , y + fontSize / 2 - 1); - - return this; -}; - -}); // module: browser/progress.js - -require.register("browser/tty.js", function(module, exports, require){ - -exports.isatty = function(){ - return true; -}; - -exports.getWindowSize = function(){ - return [window.innerHeight, window.innerWidth]; -}; -}); // module: browser/tty.js - -require.register("context.js", function(module, exports, require){ - -/** - * Expose `Context`. - */ - -module.exports = Context; - -/** - * Initialize a new `Context`. - * - * @api private - */ - -function Context(){} - -/** - * Set or get the context `Runnable` to `runnable`. - * - * @param {Runnable} runnable - * @return {Context} - * @api private - */ - -Context.prototype.runnable = function(runnable){ - if (0 == arguments.length) return this._runnable; - this.test = this._runnable = runnable; - return this; -}; - -/** - * Set test timeout `ms`. - * - * @param {Number} ms - * @return {Context} self - * @api private - */ - -Context.prototype.timeout = function(ms){ - this.runnable().timeout(ms); - return this; -}; - -/** - * Set test slowness threshold `ms`. - * - * @param {Number} ms - * @return {Context} self - * @api private - */ - -Context.prototype.slow = function(ms){ - this.runnable().slow(ms); - return this; -}; - -/** - * Inspect the context void of `._runnable`. - * - * @return {String} - * @api private - */ - -Context.prototype.inspect = function(){ - return JSON.stringify(this, function(key, val){ - if ('_runnable' == key) return; - if ('test' == key) return; - return val; - }, 2); -}; - -}); // module: context.js - -require.register("hook.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Runnable = require('./runnable'); - -/** - * Expose `Hook`. - */ - -module.exports = Hook; - -/** - * Initialize a new `Hook` with the given `title` and callback `fn`. - * - * @param {String} title - * @param {Function} fn - * @api private - */ - -function Hook(title, fn) { - Runnable.call(this, title, fn); - this.type = 'hook'; -} - -/** - * Inherit from `Runnable.prototype`. - */ - -function F(){}; -F.prototype = Runnable.prototype; -Hook.prototype = new F; -Hook.prototype.constructor = Hook; - - -/** - * Get or set the test `err`. - * - * @param {Error} err - * @return {Error} - * @api public - */ - -Hook.prototype.error = function(err){ - if (0 == arguments.length) { - var err = this._error; - this._error = null; - return err; - } - - this._error = err; -}; - -}); // module: hook.js - -require.register("interfaces/bdd.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Suite = require('../suite') - , Test = require('../test'); - -/** - * BDD-style interface: - * - * describe('Array', function(){ - * describe('#indexOf()', function(){ - * it('should return -1 when not present', function(){ - * - * }); - * - * it('should return the index when present', function(){ - * - * }); - * }); - * }); - * - */ - -module.exports = function(suite){ - var suites = [suite]; - - suite.on('pre-require', function(context, file, mocha){ - - /** - * Execute before running tests. - */ - - context.before = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after running tests. - */ - - context.after = function(fn){ - suites[0].afterAll(fn); - }; - - /** - * Execute before each test case. - */ - - context.beforeEach = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.afterEach = function(fn){ - suites[0].afterEach(fn); - }; - - /** - * Describe a "suite" with the given `title` - * and callback `fn` containing nested suites - * and/or tests. - */ - - context.describe = context.context = function(title, fn){ - var suite = Suite.create(suites[0], title); - suites.unshift(suite); - fn.call(suite); - suites.shift(); - return suite; - }; - - /** - * Pending describe. - */ - - context.xdescribe = - context.xcontext = - context.describe.skip = function(title, fn){ - var suite = Suite.create(suites[0], title); - suite.pending = true; - suites.unshift(suite); - fn.call(suite); - suites.shift(); - }; - - /** - * Exclusive suite. - */ - - context.describe.only = function(title, fn){ - var suite = context.describe(title, fn); - mocha.grep(suite.fullTitle()); - }; - - /** - * Describe a specification or test-case - * with the given `title` and callback `fn` - * acting as a thunk. - */ - - context.it = context.specify = function(title, fn){ - var suite = suites[0]; - if (suite.pending) var fn = null; - var test = new Test(title, fn); - suite.addTest(test); - return test; - }; - - /** - * Exclusive test-case. - */ - - context.it.only = function(title, fn){ - var test = context.it(title, fn); - mocha.grep(test.fullTitle()); - }; - - /** - * Pending test case. - */ - - context.xit = - context.xspecify = - context.it.skip = function(title){ - context.it(title); - }; - }); -}; - -}); // module: interfaces/bdd.js - -require.register("interfaces/exports.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Suite = require('../suite') - , Test = require('../test'); - -/** - * TDD-style interface: - * - * exports.Array = { - * '#indexOf()': { - * 'should return -1 when the value is not present': function(){ - * - * }, - * - * 'should return the correct index when the value is present': function(){ - * - * } - * } - * }; - * - */ - -module.exports = function(suite){ - var suites = [suite]; - - suite.on('require', visit); - - function visit(obj) { - var suite; - for (var key in obj) { - if ('function' == typeof obj[key]) { - var fn = obj[key]; - switch (key) { - case 'before': - suites[0].beforeAll(fn); - break; - case 'after': - suites[0].afterAll(fn); - break; - case 'beforeEach': - suites[0].beforeEach(fn); - break; - case 'afterEach': - suites[0].afterEach(fn); - break; - default: - suites[0].addTest(new Test(key, fn)); - } - } else { - var suite = Suite.create(suites[0], key); - suites.unshift(suite); - visit(obj[key]); - suites.shift(); - } - } - } -}; - -}); // module: interfaces/exports.js - -require.register("interfaces/index.js", function(module, exports, require){ - -exports.bdd = require('./bdd'); -exports.tdd = require('./tdd'); -exports.qunit = require('./qunit'); -exports.exports = require('./exports'); - -}); // module: interfaces/index.js - -require.register("interfaces/qunit.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Suite = require('../suite') - , Test = require('../test'); - -/** - * QUnit-style interface: - * - * suite('Array'); - * - * test('#length', function(){ - * var arr = [1,2,3]; - * ok(arr.length == 3); - * }); - * - * test('#indexOf()', function(){ - * var arr = [1,2,3]; - * ok(arr.indexOf(1) == 0); - * ok(arr.indexOf(2) == 1); - * ok(arr.indexOf(3) == 2); - * }); - * - * suite('String'); - * - * test('#length', function(){ - * ok('foo'.length == 3); - * }); - * - */ - -module.exports = function(suite){ - var suites = [suite]; - - suite.on('pre-require', function(context){ - - /** - * Execute before running tests. - */ - - context.before = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after running tests. - */ - - context.after = function(fn){ - suites[0].afterAll(fn); - }; - - /** - * Execute before each test case. - */ - - context.beforeEach = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.afterEach = function(fn){ - suites[0].afterEach(fn); - }; - - /** - * Describe a "suite" with the given `title`. - */ - - context.suite = function(title){ - if (suites.length > 1) suites.shift(); - var suite = Suite.create(suites[0], title); - suites.unshift(suite); - }; - - /** - * Describe a specification or test-case - * with the given `title` and callback `fn` - * acting as a thunk. - */ - - context.test = function(title, fn){ - suites[0].addTest(new Test(title, fn)); - }; - }); -}; - -}); // module: interfaces/qunit.js - -require.register("interfaces/tdd.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Suite = require('../suite') - , Test = require('../test'); - -/** - * TDD-style interface: - * - * suite('Array', function(){ - * suite('#indexOf()', function(){ - * suiteSetup(function(){ - * - * }); - * - * test('should return -1 when not present', function(){ - * - * }); - * - * test('should return the index when present', function(){ - * - * }); - * - * suiteTeardown(function(){ - * - * }); - * }); - * }); - * - */ - -module.exports = function(suite){ - var suites = [suite]; - - suite.on('pre-require', function(context, file, mocha){ - - /** - * Execute before each test case. - */ - - context.setup = function(fn){ - suites[0].beforeEach(fn); - }; - - /** - * Execute after each test case. - */ - - context.teardown = function(fn){ - suites[0].afterEach(fn); - }; - - /** - * Execute before the suite. - */ - - context.suiteSetup = function(fn){ - suites[0].beforeAll(fn); - }; - - /** - * Execute after the suite. - */ - - context.suiteTeardown = function(fn){ - suites[0].afterAll(fn); - }; - - /** - * Describe a "suite" with the given `title` - * and callback `fn` containing nested suites - * and/or tests. - */ - - context.suite = function(title, fn){ - var suite = Suite.create(suites[0], title); - suites.unshift(suite); - fn.call(suite); - suites.shift(); - return suite; - }; - - /** - * Exclusive test-case. - */ - - context.suite.only = function(title, fn){ - var suite = context.suite(title, fn); - mocha.grep(suite.fullTitle()); - }; - - /** - * Describe a specification or test-case - * with the given `title` and callback `fn` - * acting as a thunk. - */ - - context.test = function(title, fn){ - var test = new Test(title, fn); - suites[0].addTest(test); - return test; - }; - - /** - * Exclusive test-case. - */ - - context.test.only = function(title, fn){ - var test = context.test(title, fn); - mocha.grep(test.fullTitle()); - }; - - /** - * Pending test case. - */ - - context.test.skip = function(title){ - context.test(title); - }; - }); -}; - -}); // module: interfaces/tdd.js - -require.register("mocha.js", function(module, exports, require){ -/*! - * mocha - * Copyright(c) 2011 TJ Holowaychuk - * MIT Licensed - */ - -/** - * Module dependencies. - */ - -var path = require('browser/path') - , utils = require('./utils'); - -/** - * Expose `Mocha`. - */ - -exports = module.exports = Mocha; - -/** - * Expose internals. - */ - -exports.utils = utils; -exports.interfaces = require('./interfaces'); -exports.reporters = require('./reporters'); -exports.Runnable = require('./runnable'); -exports.Context = require('./context'); -exports.Runner = require('./runner'); -exports.Suite = require('./suite'); -exports.Hook = require('./hook'); -exports.Test = require('./test'); - -/** - * Return image `name` path. - * - * @param {String} name - * @return {String} - * @api private - */ - -function image(name) { - return __dirname + '/../images/' + name + '.png'; -} - -/** - * Setup mocha with `options`. - * - * Options: - * - * - `ui` name "bdd", "tdd", "exports" etc - * - `reporter` reporter instance, defaults to `mocha.reporters.Dot` - * - `globals` array of accepted globals - * - `timeout` timeout in milliseconds - * - `bail` bail on the first test failure - * - `slow` milliseconds to wait before considering a test slow - * - `ignoreLeaks` ignore global leaks - * - `grep` string or regexp to filter tests with - * - * @param {Object} options - * @api public - */ - -function Mocha(options) { - options = options || {}; - this.files = []; - this.options = options; - this.grep(options.grep); - this.suite = new exports.Suite('', new exports.Context); - this.ui(options.ui); - this.bail(options.bail); - this.reporter(options.reporter); - if (options.timeout) this.timeout(options.timeout); - if (options.slow) this.slow(options.slow); -} - -/** - * Enable or disable bailing on the first failure. - * - * @param {Boolean} [bail] - * @api public - */ - -Mocha.prototype.bail = function(bail){ - if (0 == arguments.length) bail = true; - this.suite.bail(bail); - return this; -}; - -/** - * Add test `file`. - * - * @param {String} file - * @api public - */ - -Mocha.prototype.addFile = function(file){ - this.files.push(file); - return this; -}; - -/** - * Set reporter to `reporter`, defaults to "dot". - * - * @param {String|Function} reporter name or constructor - * @api public - */ - -Mocha.prototype.reporter = function(reporter){ - if ('function' == typeof reporter) { - this._reporter = reporter; - } else { - reporter = reporter || 'dot'; - try { - this._reporter = require('./reporters/' + reporter); - } catch (err) { - this._reporter = require(reporter); - } - if (!this._reporter) throw new Error('invalid reporter "' + reporter + '"'); - } - return this; -}; - -/** - * Set test UI `name`, defaults to "bdd". - * - * @param {String} bdd - * @api public - */ - -Mocha.prototype.ui = function(name){ - name = name || 'bdd'; - this._ui = exports.interfaces[name]; - if (!this._ui) throw new Error('invalid interface "' + name + '"'); - this._ui = this._ui(this.suite); - return this; -}; - -/** - * Load registered files. - * - * @api private - */ - -Mocha.prototype.loadFiles = function(fn){ - var self = this; - var suite = this.suite; - var pending = this.files.length; - this.files.forEach(function(file){ - file = path.resolve(file); - suite.emit('pre-require', global, file, self); - suite.emit('require', require(file), file, self); - suite.emit('post-require', global, file, self); - --pending || (fn && fn()); - }); -}; - -/** - * Enable growl support. - * - * @api private - */ - -Mocha.prototype._growl = function(runner, reporter) { - var notify = require('growl'); - - runner.on('end', function(){ - var stats = reporter.stats; - if (stats.failures) { - var msg = stats.failures + ' of ' + runner.total + ' tests failed'; - notify(msg, { name: 'mocha', title: 'Failed', image: image('error') }); - } else { - notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', { - name: 'mocha' - , title: 'Passed' - , image: image('ok') - }); - } - }); -}; - -/** - * Add regexp to grep, if `re` is a string it is escaped. - * - * @param {RegExp|String} re - * @return {Mocha} - * @api public - */ - -Mocha.prototype.grep = function(re){ - this.options.grep = 'string' == typeof re - ? new RegExp(utils.escapeRegexp(re)) - : re; - return this; -}; - -/** - * Invert `.grep()` matches. - * - * @return {Mocha} - * @api public - */ - -Mocha.prototype.invert = function(){ - this.options.invert = true; - return this; -}; - -/** - * Ignore global leaks. - * - * @return {Mocha} - * @api public - */ - -Mocha.prototype.ignoreLeaks = function(){ - this.options.ignoreLeaks = true; - return this; -}; - -/** - * Enable global leak checking. - * - * @return {Mocha} - * @api public - */ - -Mocha.prototype.checkLeaks = function(){ - this.options.ignoreLeaks = false; - return this; -}; - -/** - * Enable growl support. - * - * @return {Mocha} - * @api public - */ - -Mocha.prototype.growl = function(){ - this.options.growl = true; - return this; -}; - -/** - * Ignore `globals` array or string. - * - * @param {Array|String} globals - * @return {Mocha} - * @api public - */ - -Mocha.prototype.globals = function(globals){ - this.options.globals = (this.options.globals || []).concat(globals); - return this; -}; - -/** - * Set the timeout in milliseconds. - * - * @param {Number} timeout - * @return {Mocha} - * @api public - */ - -Mocha.prototype.timeout = function(timeout){ - this.suite.timeout(timeout); - return this; -}; - -/** - * Set slowness threshold in milliseconds. - * - * @param {Number} slow - * @return {Mocha} - * @api public - */ - -Mocha.prototype.slow = function(slow){ - this.suite.slow(slow); - return this; -}; - -/** - * Makes all tests async (accepting a callback) - * - * @return {Mocha} - * @api public - */ - -Mocha.prototype.asyncOnly = function(){ - this.options.asyncOnly = true; - return this; -}; - -/** - * Run tests and invoke `fn()` when complete. - * - * @param {Function} fn - * @return {Runner} - * @api public - */ - -Mocha.prototype.run = function(fn){ - if (this.files.length) this.loadFiles(); - var suite = this.suite; - var options = this.options; - var runner = new exports.Runner(suite); - var reporter = new this._reporter(runner); - runner.ignoreLeaks = false !== options.ignoreLeaks; - runner.asyncOnly = options.asyncOnly; - if (options.grep) runner.grep(options.grep, options.invert); - if (options.globals) runner.globals(options.globals); - if (options.growl) this._growl(runner, reporter); - return runner.run(fn); -}; - -}); // module: mocha.js - -require.register("ms.js", function(module, exports, require){ - -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; - -/** - * Parse or format the given `val`. - * - * @param {String|Number} val - * @return {String|Number} - * @api public - */ - -module.exports = function(val){ - if ('string' == typeof val) return parse(val); - return format(val); -} - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - var m = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str); - if (!m) return; - var n = parseFloat(m[1]); - var type = (m[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'y': - return n * 31557600000; - case 'days': - case 'day': - case 'd': - return n * 86400000; - case 'hours': - case 'hour': - case 'h': - return n * 3600000; - case 'minutes': - case 'minute': - case 'm': - return n * 60000; - case 'seconds': - case 'second': - case 's': - return n * 1000; - case 'ms': - return n; - } -} - -/** - * Format the given `ms`. - * - * @param {Number} ms - * @return {String} - * @api public - */ - -function format(ms) { - if (ms == d) return Math.round(ms / d) + ' day'; - if (ms > d) return Math.round(ms / d) + ' days'; - if (ms == h) return Math.round(ms / h) + ' hour'; - if (ms > h) return Math.round(ms / h) + ' hours'; - if (ms == m) return Math.round(ms / m) + ' minute'; - if (ms > m) return Math.round(ms / m) + ' minutes'; - if (ms == s) return Math.round(ms / s) + ' second'; - if (ms > s) return Math.round(ms / s) + ' seconds'; - return ms + ' ms'; -} -}); // module: ms.js - -require.register("reporters/base.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var tty = require('browser/tty') - , diff = require('browser/diff') - , ms = require('../ms'); - -/** - * Save timer references to avoid Sinon interfering (see GH-237). - */ - -var Date = global.Date - , setTimeout = global.setTimeout - , setInterval = global.setInterval - , clearTimeout = global.clearTimeout - , clearInterval = global.clearInterval; - -/** - * Check if both stdio streams are associated with a tty. - */ - -var isatty = tty.isatty(1) && tty.isatty(2); - -/** - * Expose `Base`. - */ - -exports = module.exports = Base; - -/** - * Enable coloring by default. - */ - -exports.useColors = isatty; - -/** - * Default color map. - */ - -exports.colors = { - 'pass': 90 - , 'fail': 31 - , 'bright pass': 92 - , 'bright fail': 91 - , 'bright yellow': 93 - , 'pending': 36 - , 'suite': 0 - , 'error title': 0 - , 'error message': 31 - , 'error stack': 90 - , 'checkmark': 32 - , 'fast': 90 - , 'medium': 33 - , 'slow': 31 - , 'green': 32 - , 'light': 90 - , 'diff gutter': 90 - , 'diff added': 42 - , 'diff removed': 41 -}; - -/** - * Default symbol map. - */ - -exports.symbols = { - ok: '✓', - err: '✖', - dot: '․' -}; - -// With node.js on Windows: use symbols available in terminal default fonts -if ('win32' == process.platform) { - exports.symbols.ok = '\u221A'; - exports.symbols.err = '\u00D7'; - exports.symbols.dot = '.'; -} - -/** - * Color `str` with the given `type`, - * allowing colors to be disabled, - * as well as user-defined color - * schemes. - * - * @param {String} type - * @param {String} str - * @return {String} - * @api private - */ - -var color = exports.color = function(type, str) { - if (!exports.useColors) return str; - return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m'; -}; - -/** - * Expose term window size, with some - * defaults for when stderr is not a tty. - */ - -exports.window = { - width: isatty - ? process.stdout.getWindowSize - ? process.stdout.getWindowSize(1)[0] - : tty.getWindowSize()[1] - : 75 -}; - -/** - * Expose some basic cursor interactions - * that are common among reporters. - */ - -exports.cursor = { - hide: function(){ - process.stdout.write('\u001b[?25l'); - }, - - show: function(){ - process.stdout.write('\u001b[?25h'); - }, - - deleteLine: function(){ - process.stdout.write('\u001b[2K'); - }, - - beginningOfLine: function(){ - process.stdout.write('\u001b[0G'); - }, - - CR: function(){ - exports.cursor.deleteLine(); - exports.cursor.beginningOfLine(); - } -}; - -/** - * Outut the given `failures` as a list. - * - * @param {Array} failures - * @api public - */ - -exports.list = function(failures){ - console.error(); - failures.forEach(function(test, i){ - // format - var fmt = color('error title', ' %s) %s:\n') - + color('error message', ' %s') - + color('error stack', '\n%s\n'); - - // msg - var err = test.err - , message = err.message || '' - , stack = err.stack || message - , index = stack.indexOf(message) + message.length - , msg = stack.slice(0, index) - , actual = err.actual - , expected = err.expected - , escape = true; - - // explicitly show diff - if (err.showDiff) { - escape = false; - err.actual = actual = JSON.stringify(actual, null, 2); - err.expected = expected = JSON.stringify(expected, null, 2); - } - - // actual / expected diff - if ('string' == typeof actual && 'string' == typeof expected) { - var len = Math.max(actual.length, expected.length); - - if (len < 20) msg = errorDiff(err, 'Chars', escape); - else msg = errorDiff(err, 'Words', escape); - - // linenos - var lines = msg.split('\n'); - if (lines.length > 4) { - var width = String(lines.length).length; - msg = lines.map(function(str, i){ - return pad(++i, width) + ' |' + ' ' + str; - }).join('\n'); - } - - // legend - msg = '\n' - + color('diff removed', 'actual') - + ' ' - + color('diff added', 'expected') - + '\n\n' - + msg - + '\n'; - - // indent - msg = msg.replace(/^/gm, ' '); - - fmt = color('error title', ' %s) %s:\n%s') - + color('error stack', '\n%s\n'); - } - - // indent stack trace without msg - stack = stack.slice(index ? index + 1 : index) - .replace(/^/gm, ' '); - - console.error(fmt, (i + 1), test.fullTitle(), msg, stack); - }); -}; - -/** - * Initialize a new `Base` reporter. - * - * All other reporters generally - * inherit from this reporter, providing - * stats such as test duration, number - * of tests passed / failed etc. - * - * @param {Runner} runner - * @api public - */ - -function Base(runner) { - var self = this - , stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 } - , failures = this.failures = []; - - if (!runner) return; - this.runner = runner; - - runner.stats = stats; - - runner.on('start', function(){ - stats.start = new Date; - }); - - runner.on('suite', function(suite){ - stats.suites = stats.suites || 0; - suite.root || stats.suites++; - }); - - runner.on('test end', function(test){ - stats.tests = stats.tests || 0; - stats.tests++; - }); - - runner.on('pass', function(test){ - stats.passes = stats.passes || 0; - - var medium = test.slow() / 2; - test.speed = test.duration > test.slow() - ? 'slow' - : test.duration > medium - ? 'medium' - : 'fast'; - - stats.passes++; - }); - - runner.on('fail', function(test, err){ - stats.failures = stats.failures || 0; - stats.failures++; - test.err = err; - failures.push(test); - }); - - runner.on('end', function(){ - stats.end = new Date; - stats.duration = new Date - stats.start; - }); - - runner.on('pending', function(){ - stats.pending++; - }); -} - -/** - * Output common epilogue used by many of - * the bundled reporters. - * - * @api public - */ - -Base.prototype.epilogue = function(){ - var stats = this.stats - , fmt - , tests; - - console.log(); - - function pluralize(n) { - return 1 == n ? 'test' : 'tests'; - } - - // failure - if (stats.failures) { - fmt = color('bright fail', ' ' + exports.symbols.err) - + color('fail', ' %d of %d %s failed') - + color('light', ':') - - console.error(fmt, - stats.failures, - this.runner.total, - pluralize(this.runner.total)); - - Base.list(this.failures); - console.error(); - return; - } - - // pass - fmt = color('bright pass', ' ') - + color('green', ' %d %s complete') - + color('light', ' (%s)'); - - console.log(fmt, - stats.tests || 0, - pluralize(stats.tests), - ms(stats.duration)); - - // pending - if (stats.pending) { - fmt = color('pending', ' ') - + color('pending', ' %d %s pending'); - - console.log(fmt, stats.pending, pluralize(stats.pending)); - } - - console.log(); -}; - -/** - * Pad the given `str` to `len`. - * - * @param {String} str - * @param {String} len - * @return {String} - * @api private - */ - -function pad(str, len) { - str = String(str); - return Array(len - str.length + 1).join(' ') + str; -} - -/** - * Return a character diff for `err`. - * - * @param {Error} err - * @return {String} - * @api private - */ - -function errorDiff(err, type, escape) { - return diff['diff' + type](err.actual, err.expected).map(function(str){ - if (escape) { - str.value = str.value - .replace(/\t/g, '') - .replace(/\r/g, '') - .replace(/\n/g, '\n'); - } - if (str.added) return colorLines('diff added', str.value); - if (str.removed) return colorLines('diff removed', str.value); - return str.value; - }).join(''); -} - -/** - * Color lines for `str`, using the color `name`. - * - * @param {String} name - * @param {String} str - * @return {String} - * @api private - */ - -function colorLines(name, str) { - return str.split('\n').map(function(str){ - return color(name, str); - }).join('\n'); -} - -}); // module: reporters/base.js - -require.register("reporters/doc.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , utils = require('../utils'); - -/** - * Expose `Doc`. - */ - -exports = module.exports = Doc; - -/** - * Initialize a new `Doc` reporter. - * - * @param {Runner} runner - * @api public - */ - -function Doc(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , total = runner.total - , indents = 2; - - function indent() { - return Array(indents).join(' '); - } - - runner.on('suite', function(suite){ - if (suite.root) return; - ++indents; - console.log('%s
', indent()); - ++indents; - console.log('%s

%s

', indent(), utils.escape(suite.title)); - console.log('%s
', indent()); - }); - - runner.on('suite end', function(suite){ - if (suite.root) return; - console.log('%s
', indent()); - --indents; - console.log('%s
', indent()); - --indents; - }); - - runner.on('pass', function(test){ - console.log('%s
%s
', indent(), utils.escape(test.title)); - var code = utils.escape(utils.clean(test.fn.toString())); - console.log('%s
%s
', indent(), code); - }); -} - -}); // module: reporters/doc.js - -require.register("reporters/dot.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , color = Base.color; - -/** - * Expose `Dot`. - */ - -exports = module.exports = Dot; - -/** - * Initialize a new `Dot` matrix test reporter. - * - * @param {Runner} runner - * @api public - */ - -function Dot(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , width = Base.window.width * .75 | 0 - , n = 0; - - runner.on('start', function(){ - process.stdout.write('\n '); - }); - - runner.on('pending', function(test){ - process.stdout.write(color('pending', Base.symbols.dot)); - }); - - runner.on('pass', function(test){ - if (++n % width == 0) process.stdout.write('\n '); - if ('slow' == test.speed) { - process.stdout.write(color('bright yellow', Base.symbols.dot)); - } else { - process.stdout.write(color(test.speed, Base.symbols.dot)); - } - }); - - runner.on('fail', function(test, err){ - if (++n % width == 0) process.stdout.write('\n '); - process.stdout.write(color('fail', Base.symbols.dot)); - }); - - runner.on('end', function(){ - console.log(); - self.epilogue(); - }); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -Dot.prototype = new F; -Dot.prototype.constructor = Dot; - -}); // module: reporters/dot.js - -require.register("reporters/html-cov.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var JSONCov = require('./json-cov') - , fs = require('browser/fs'); - -/** - * Expose `HTMLCov`. - */ - -exports = module.exports = HTMLCov; - -/** - * Initialize a new `JsCoverage` reporter. - * - * @param {Runner} runner - * @api public - */ - -function HTMLCov(runner) { - var jade = require('jade') - , file = __dirname + '/templates/coverage.jade' - , str = fs.readFileSync(file, 'utf8') - , fn = jade.compile(str, { filename: file }) - , self = this; - - JSONCov.call(this, runner, false); - - runner.on('end', function(){ - process.stdout.write(fn({ - cov: self.cov - , coverageClass: coverageClass - })); - }); -} - -/** - * Return coverage class for `n`. - * - * @return {String} - * @api private - */ - -function coverageClass(n) { - if (n >= 75) return 'high'; - if (n >= 50) return 'medium'; - if (n >= 25) return 'low'; - return 'terrible'; -} -}); // module: reporters/html-cov.js - -require.register("reporters/html.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , utils = require('../utils') - , Progress = require('../browser/progress') - , escape = utils.escape; - -/** - * Save timer references to avoid Sinon interfering (see GH-237). - */ - -var Date = global.Date - , setTimeout = global.setTimeout - , setInterval = global.setInterval - , clearTimeout = global.clearTimeout - , clearInterval = global.clearInterval; - -/** - * Expose `Doc`. - */ - -exports = module.exports = HTML; - -/** - * Stats template. - */ - -var statsTemplate = ''; - -/** - * Initialize a new `Doc` reporter. - * - * @param {Runner} runner - * @api public - */ - -function HTML(runner, root) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , total = runner.total - , stat = fragment(statsTemplate) - , items = stat.getElementsByTagName('li') - , passes = items[1].getElementsByTagName('em')[0] - , passesLink = items[1].getElementsByTagName('a')[0] - , failures = items[2].getElementsByTagName('em')[0] - , failuresLink = items[2].getElementsByTagName('a')[0] - , duration = items[3].getElementsByTagName('em')[0] - , canvas = stat.getElementsByTagName('canvas')[0] - , report = fragment('
    ') - , stack = [report] - , progress - , ctx - - root = root || document.getElementById('mocha'); - - if (canvas.getContext) { - var ratio = window.devicePixelRatio || 1; - canvas.style.width = canvas.width; - canvas.style.height = canvas.height; - canvas.width *= ratio; - canvas.height *= ratio; - ctx = canvas.getContext('2d'); - ctx.scale(ratio, ratio); - progress = new Progress; - } - - if (!root) return error('#mocha div missing, add it to your document'); - - // pass toggle - on(passesLink, 'click', function(){ - unhide(); - var name = /pass/.test(report.className) ? '' : ' pass'; - report.className = report.className.replace(/fail|pass/g, '') + name; - if (report.className.trim()) hideSuitesWithout('test pass'); - }); - - // failure toggle - on(failuresLink, 'click', function(){ - unhide(); - var name = /fail/.test(report.className) ? '' : ' fail'; - report.className = report.className.replace(/fail|pass/g, '') + name; - if (report.className.trim()) hideSuitesWithout('test fail'); - }); - - root.appendChild(stat); - root.appendChild(report); - - if (progress) progress.size(40); - - runner.on('suite', function(suite){ - if (suite.root) return; - - // suite - var url = '?grep=' + encodeURIComponent(suite.fullTitle()); - var el = fragment('
  • %s

  • ', url, escape(suite.title)); - - // container - stack[0].appendChild(el); - stack.unshift(document.createElement('ul')); - el.appendChild(stack[0]); - }); - - runner.on('suite end', function(suite){ - if (suite.root) return; - stack.shift(); - }); - - runner.on('fail', function(test, err){ - if ('hook' == test.type) runner.emit('test end', test); - }); - - runner.on('test end', function(test){ - // TODO: add to stats - var percent = stats.tests / this.total * 100 | 0; - if (progress) progress.update(percent).draw(ctx); - - // update stats - var ms = new Date - stats.start; - text(passes, stats.passes); - text(failures, stats.failures); - text(duration, (ms / 1000).toFixed(2)); - - // test - if ('passed' == test.state) { - var el = fragment('
  • %e%ems

  • ', test.speed, test.title, test.duration, encodeURIComponent(test.fullTitle())); - } else if (test.pending) { - var el = fragment('
  • %e

  • ', test.title); - } else { - var el = fragment('
  • %e

  • ', test.title, encodeURIComponent(test.fullTitle())); - var str = test.err.stack || test.err.toString(); - - // FF / Opera do not add the message - if (!~str.indexOf(test.err.message)) { - str = test.err.message + '\n' + str; - } - - // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we - // check for the result of the stringifying. - if ('[object Error]' == str) str = test.err.message; - - // Safari doesn't give you a stack. Let's at least provide a source line. - if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) { - str += "\n(" + test.err.sourceURL + ":" + test.err.line + ")"; - } - - el.appendChild(fragment('
    %e
    ', str)); - } - - // toggle code - // TODO: defer - if (!test.pending) { - var h2 = el.getElementsByTagName('h2')[0]; - - on(h2, 'click', function(){ - pre.style.display = 'none' == pre.style.display - ? 'block' - : 'none'; - }); - - var pre = fragment('
    %e
    ', utils.clean(test.fn.toString())); - el.appendChild(pre); - pre.style.display = 'none'; - } - - // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. - if (stack[0]) stack[0].appendChild(el); - }); -} - -/** - * Display error `msg`. - */ - -function error(msg) { - document.body.appendChild(fragment('
    %s
    ', msg)); -} - -/** - * Return a DOM fragment from `html`. - */ - -function fragment(html) { - var args = arguments - , div = document.createElement('div') - , i = 1; - - div.innerHTML = html.replace(/%([se])/g, function(_, type){ - switch (type) { - case 's': return String(args[i++]); - case 'e': return escape(args[i++]); - } - }); - - return div.firstChild; -} - -/** - * Check for suites that do not have elements - * with `classname`, and hide them. - */ - -function hideSuitesWithout(classname) { - var suites = document.getElementsByClassName('suite'); - for (var i = 0; i < suites.length; i++) { - var els = suites[i].getElementsByClassName(classname); - if (0 == els.length) suites[i].className += ' hidden'; - } -} - -/** - * Unhide .hidden suites. - */ - -function unhide() { - var els = document.getElementsByClassName('suite hidden'); - for (var i = 0; i < els.length; ++i) { - els[i].className = els[i].className.replace('suite hidden', 'suite'); - } -} - -/** - * Set `el` text to `str`. - */ - -function text(el, str) { - if (el.textContent) { - el.textContent = str; - } else { - el.innerText = str; - } -} - -/** - * Listen on `event` with callback `fn`. - */ - -function on(el, event, fn) { - if (el.addEventListener) { - el.addEventListener(event, fn, false); - } else { - el.attachEvent('on' + event, fn); - } -} - -}); // module: reporters/html.js - -require.register("reporters/index.js", function(module, exports, require){ - -exports.Base = require('./base'); -exports.Dot = require('./dot'); -exports.Doc = require('./doc'); -exports.TAP = require('./tap'); -exports.JSON = require('./json'); -exports.HTML = require('./html'); -exports.List = require('./list'); -exports.Min = require('./min'); -exports.Spec = require('./spec'); -exports.Nyan = require('./nyan'); -exports.XUnit = require('./xunit'); -exports.Markdown = require('./markdown'); -exports.Progress = require('./progress'); -exports.Landing = require('./landing'); -exports.JSONCov = require('./json-cov'); -exports.HTMLCov = require('./html-cov'); -exports.JSONStream = require('./json-stream'); -exports.Teamcity = require('./teamcity'); - -}); // module: reporters/index.js - -require.register("reporters/json-cov.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base'); - -/** - * Expose `JSONCov`. - */ - -exports = module.exports = JSONCov; - -/** - * Initialize a new `JsCoverage` reporter. - * - * @param {Runner} runner - * @param {Boolean} output - * @api public - */ - -function JSONCov(runner, output) { - var self = this - , output = 1 == arguments.length ? true : output; - - Base.call(this, runner); - - var tests = [] - , failures = [] - , passes = []; - - runner.on('test end', function(test){ - tests.push(test); - }); - - runner.on('pass', function(test){ - passes.push(test); - }); - - runner.on('fail', function(test){ - failures.push(test); - }); - - runner.on('end', function(){ - var cov = global._$jscoverage || {}; - var result = self.cov = map(cov); - result.stats = self.stats; - result.tests = tests.map(clean); - result.failures = failures.map(clean); - result.passes = passes.map(clean); - if (!output) return; - process.stdout.write(JSON.stringify(result, null, 2 )); - }); -} - -/** - * Map jscoverage data to a JSON structure - * suitable for reporting. - * - * @param {Object} cov - * @return {Object} - * @api private - */ - -function map(cov) { - var ret = { - instrumentation: 'node-jscoverage' - , sloc: 0 - , hits: 0 - , misses: 0 - , coverage: 0 - , files: [] - }; - - for (var filename in cov) { - var data = coverage(filename, cov[filename]); - ret.files.push(data); - ret.hits += data.hits; - ret.misses += data.misses; - ret.sloc += data.sloc; - } - - ret.files.sort(function(a, b) { - return a.filename.localeCompare(b.filename); - }); - - if (ret.sloc > 0) { - ret.coverage = (ret.hits / ret.sloc) * 100; - } - - return ret; -}; - -/** - * Map jscoverage data for a single source file - * to a JSON structure suitable for reporting. - * - * @param {String} filename name of the source file - * @param {Object} data jscoverage coverage data - * @return {Object} - * @api private - */ - -function coverage(filename, data) { - var ret = { - filename: filename, - coverage: 0, - hits: 0, - misses: 0, - sloc: 0, - source: {} - }; - - data.source.forEach(function(line, num){ - num++; - - if (data[num] === 0) { - ret.misses++; - ret.sloc++; - } else if (data[num] !== undefined) { - ret.hits++; - ret.sloc++; - } - - ret.source[num] = { - source: line - , coverage: data[num] === undefined - ? '' - : data[num] - }; - }); - - ret.coverage = ret.hits / ret.sloc * 100; - - return ret; -} - -/** - * Return a plain-object representation of `test` - * free of cyclic properties etc. - * - * @param {Object} test - * @return {Object} - * @api private - */ - -function clean(test) { - return { - title: test.title - , fullTitle: test.fullTitle() - , duration: test.duration - } -} - -}); // module: reporters/json-cov.js - -require.register("reporters/json-stream.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , color = Base.color; - -/** - * Expose `List`. - */ - -exports = module.exports = List; - -/** - * Initialize a new `List` test reporter. - * - * @param {Runner} runner - * @api public - */ - -function List(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , total = runner.total; - - runner.on('start', function(){ - console.log(JSON.stringify(['start', { total: total }])); - }); - - runner.on('pass', function(test){ - console.log(JSON.stringify(['pass', clean(test)])); - }); - - runner.on('fail', function(test, err){ - console.log(JSON.stringify(['fail', clean(test)])); - }); - - runner.on('end', function(){ - process.stdout.write(JSON.stringify(['end', self.stats])); - }); -} - -/** - * Return a plain-object representation of `test` - * free of cyclic properties etc. - * - * @param {Object} test - * @return {Object} - * @api private - */ - -function clean(test) { - return { - title: test.title - , fullTitle: test.fullTitle() - , duration: test.duration - } -} -}); // module: reporters/json-stream.js - -require.register("reporters/json.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `JSON`. - */ - -exports = module.exports = JSONReporter; - -/** - * Initialize a new `JSON` reporter. - * - * @param {Runner} runner - * @api public - */ - -function JSONReporter(runner) { - var self = this; - Base.call(this, runner); - - var tests = [] - , failures = [] - , passes = []; - - runner.on('test end', function(test){ - tests.push(test); - }); - - runner.on('pass', function(test){ - passes.push(test); - }); - - runner.on('fail', function(test){ - failures.push(test); - }); - - runner.on('end', function(){ - var obj = { - stats: self.stats - , tests: tests.map(clean) - , failures: failures.map(clean) - , passes: passes.map(clean) - }; - - process.stdout.write(JSON.stringify(obj, null, 2)); - }); -} - -/** - * Return a plain-object representation of `test` - * free of cyclic properties etc. - * - * @param {Object} test - * @return {Object} - * @api private - */ - -function clean(test) { - return { - title: test.title - , fullTitle: test.fullTitle() - , duration: test.duration - } -} -}); // module: reporters/json.js - -require.register("reporters/landing.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `Landing`. - */ - -exports = module.exports = Landing; - -/** - * Airplane color. - */ - -Base.colors.plane = 0; - -/** - * Airplane crash color. - */ - -Base.colors['plane crash'] = 31; - -/** - * Runway color. - */ - -Base.colors.runway = 90; - -/** - * Initialize a new `Landing` reporter. - * - * @param {Runner} runner - * @api public - */ - -function Landing(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , width = Base.window.width * .75 | 0 - , total = runner.total - , stream = process.stdout - , plane = color('plane', '✈') - , crashed = -1 - , n = 0; - - function runway() { - var buf = Array(width).join('-'); - return ' ' + color('runway', buf); - } - - runner.on('start', function(){ - stream.write('\n '); - cursor.hide(); - }); - - runner.on('test end', function(test){ - // check if the plane crashed - var col = -1 == crashed - ? width * ++n / total | 0 - : crashed; - - // show the crash - if ('failed' == test.state) { - plane = color('plane crash', '✈'); - crashed = col; - } - - // render landing strip - stream.write('\u001b[4F\n\n'); - stream.write(runway()); - stream.write('\n '); - stream.write(color('runway', Array(col).join('⋅'))); - stream.write(plane) - stream.write(color('runway', Array(width - col).join('⋅') + '\n')); - stream.write(runway()); - stream.write('\u001b[0m'); - }); - - runner.on('end', function(){ - cursor.show(); - console.log(); - self.epilogue(); - }); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -Landing.prototype = new F; -Landing.prototype.constructor = Landing; - -}); // module: reporters/landing.js - -require.register("reporters/list.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `List`. - */ - -exports = module.exports = List; - -/** - * Initialize a new `List` test reporter. - * - * @param {Runner} runner - * @api public - */ - -function List(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , n = 0; - - runner.on('start', function(){ - console.log(); - }); - - runner.on('test', function(test){ - process.stdout.write(color('pass', ' ' + test.fullTitle() + ': ')); - }); - - runner.on('pending', function(test){ - var fmt = color('checkmark', ' -') - + color('pending', ' %s'); - console.log(fmt, test.fullTitle()); - }); - - runner.on('pass', function(test){ - var fmt = color('checkmark', ' '+Base.symbols.dot) - + color('pass', ' %s: ') - + color(test.speed, '%dms'); - cursor.CR(); - console.log(fmt, test.fullTitle(), test.duration); - }); - - runner.on('fail', function(test, err){ - cursor.CR(); - console.log(color('fail', ' %d) %s'), ++n, test.fullTitle()); - }); - - runner.on('end', self.epilogue.bind(self)); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -List.prototype = new F; -List.prototype.constructor = List; - - -}); // module: reporters/list.js - -require.register("reporters/markdown.js", function(module, exports, require){ -/** - * Module dependencies. - */ - -var Base = require('./base') - , utils = require('../utils'); - -/** - * Expose `Markdown`. - */ - -exports = module.exports = Markdown; - -/** - * Initialize a new `Markdown` reporter. - * - * @param {Runner} runner - * @api public - */ - -function Markdown(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , level = 0 - , buf = ''; - - function title(str) { - return Array(level).join('#') + ' ' + str; - } - - function indent() { - return Array(level).join(' '); - } - - function mapTOC(suite, obj) { - var ret = obj; - obj = obj[suite.title] = obj[suite.title] || { suite: suite }; - suite.suites.forEach(function(suite){ - mapTOC(suite, obj); - }); - return ret; - } - - function stringifyTOC(obj, level) { - ++level; - var buf = ''; - var link; - for (var key in obj) { - if ('suite' == key) continue; - if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\n'; - if (key) buf += Array(level).join(' ') + link; - buf += stringifyTOC(obj[key], level); - } - --level; - return buf; - } - - function generateTOC(suite) { - var obj = mapTOC(suite, {}); - return stringifyTOC(obj, 0); - } - - generateTOC(runner.suite); - - runner.on('suite', function(suite){ - ++level; - var slug = utils.slug(suite.fullTitle()); - buf += '' + '\n'; - buf += title(suite.title) + '\n'; - }); - - runner.on('suite end', function(suite){ - --level; - }); - - runner.on('pass', function(test){ - var code = utils.clean(test.fn.toString()); - buf += test.title + '.\n'; - buf += '\n```js\n'; - buf += code + '\n'; - buf += '```\n\n'; - }); - - runner.on('end', function(){ - process.stdout.write('# TOC\n'); - process.stdout.write(generateTOC(runner.suite)); - process.stdout.write(buf); - }); -} -}); // module: reporters/markdown.js - -require.register("reporters/min.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base'); - -/** - * Expose `Min`. - */ - -exports = module.exports = Min; - -/** - * Initialize a new `Min` minimal test reporter (best used with --watch). - * - * @param {Runner} runner - * @api public - */ - -function Min(runner) { - Base.call(this, runner); - - runner.on('start', function(){ - // clear screen - process.stdout.write('\u001b[2J'); - // set cursor position - process.stdout.write('\u001b[1;3H'); - }); - - runner.on('end', this.epilogue.bind(this)); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -Min.prototype = new F; -Min.prototype.constructor = Min; - - -}); // module: reporters/min.js - -require.register("reporters/nyan.js", function(module, exports, require){ -/** - * Module dependencies. - */ - -var Base = require('./base') - , color = Base.color; - -/** - * Expose `Dot`. - */ - -exports = module.exports = NyanCat; - -/** - * Initialize a new `Dot` matrix test reporter. - * - * @param {Runner} runner - * @api public - */ - -function NyanCat(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , width = Base.window.width * .75 | 0 - , rainbowColors = this.rainbowColors = self.generateColors() - , colorIndex = this.colorIndex = 0 - , numerOfLines = this.numberOfLines = 4 - , trajectories = this.trajectories = [[], [], [], []] - , nyanCatWidth = this.nyanCatWidth = 11 - , trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth) - , scoreboardWidth = this.scoreboardWidth = 5 - , tick = this.tick = 0 - , n = 0; - - runner.on('start', function(){ - Base.cursor.hide(); - self.draw('start'); - }); - - runner.on('pending', function(test){ - self.draw('pending'); - }); - - runner.on('pass', function(test){ - self.draw('pass'); - }); - - runner.on('fail', function(test, err){ - self.draw('fail'); - }); - - runner.on('end', function(){ - Base.cursor.show(); - for (var i = 0; i < self.numberOfLines; i++) write('\n'); - self.epilogue(); - }); -} - -/** - * Draw the nyan cat with runner `status`. - * - * @param {String} status - * @api private - */ - -NyanCat.prototype.draw = function(status){ - this.appendRainbow(); - this.drawScoreboard(); - this.drawRainbow(); - this.drawNyanCat(status); - this.tick = !this.tick; -}; - -/** - * Draw the "scoreboard" showing the number - * of passes, failures and pending tests. - * - * @api private - */ - -NyanCat.prototype.drawScoreboard = function(){ - var stats = this.stats; - var colors = Base.colors; - - function draw(color, n) { - write(' '); - write('\u001b[' + color + 'm' + n + '\u001b[0m'); - write('\n'); - } - - draw(colors.green, stats.passes); - draw(colors.fail, stats.failures); - draw(colors.pending, stats.pending); - write('\n'); - - this.cursorUp(this.numberOfLines); -}; - -/** - * Append the rainbow. - * - * @api private - */ - -NyanCat.prototype.appendRainbow = function(){ - var segment = this.tick ? '_' : '-'; - var rainbowified = this.rainbowify(segment); - - for (var index = 0; index < this.numberOfLines; index++) { - var trajectory = this.trajectories[index]; - if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift(); - trajectory.push(rainbowified); - } -}; - -/** - * Draw the rainbow. - * - * @api private - */ - -NyanCat.prototype.drawRainbow = function(){ - var self = this; - - this.trajectories.forEach(function(line, index) { - write('\u001b[' + self.scoreboardWidth + 'C'); - write(line.join('')); - write('\n'); - }); - - this.cursorUp(this.numberOfLines); -}; - -/** - * Draw the nyan cat with `status`. - * - * @param {String} status - * @api private - */ - -NyanCat.prototype.drawNyanCat = function(status) { - var self = this; - var startWidth = this.scoreboardWidth + this.trajectories[0].length; - var color = '\u001b[' + startWidth + 'C'; - var padding = ''; - - write(color); - write('_,------,'); - write('\n'); - - write(color); - padding = self.tick ? ' ' : ' '; - write('_|' + padding + '/\\_/\\ '); - write('\n'); - - write(color); - padding = self.tick ? '_' : '__'; - var tail = self.tick ? '~' : '^'; - var face; - switch (status) { - case 'pass': - face = '( ^ .^)'; - break; - case 'fail': - face = '( o .o)'; - break; - default: - face = '( - .-)'; - } - write(tail + '|' + padding + face + ' '); - write('\n'); - - write(color); - padding = self.tick ? ' ' : ' '; - write(padding + '"" "" '); - write('\n'); - - this.cursorUp(this.numberOfLines); -}; - -/** - * Move cursor up `n`. - * - * @param {Number} n - * @api private - */ - -NyanCat.prototype.cursorUp = function(n) { - write('\u001b[' + n + 'A'); -}; - -/** - * Move cursor down `n`. - * - * @param {Number} n - * @api private - */ - -NyanCat.prototype.cursorDown = function(n) { - write('\u001b[' + n + 'B'); -}; - -/** - * Generate rainbow colors. - * - * @return {Array} - * @api private - */ - -NyanCat.prototype.generateColors = function(){ - var colors = []; - - for (var i = 0; i < (6 * 7); i++) { - var pi3 = Math.floor(Math.PI / 3); - var n = (i * (1.0 / 6)); - var r = Math.floor(3 * Math.sin(n) + 3); - var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3); - var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3); - colors.push(36 * r + 6 * g + b + 16); - } - - return colors; -}; - -/** - * Apply rainbow to the given `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - -NyanCat.prototype.rainbowify = function(str){ - var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length]; - this.colorIndex += 1; - return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m'; -}; - -/** - * Stdout helper. - */ - -function write(string) { - process.stdout.write(string); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -NyanCat.prototype = new F; -NyanCat.prototype.constructor = NyanCat; - - -}); // module: reporters/nyan.js - -require.register("reporters/progress.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `Progress`. - */ - -exports = module.exports = Progress; - -/** - * General progress bar color. - */ - -Base.colors.progress = 90; - -/** - * Initialize a new `Progress` bar test reporter. - * - * @param {Runner} runner - * @param {Object} options - * @api public - */ - -function Progress(runner, options) { - Base.call(this, runner); - - var self = this - , options = options || {} - , stats = this.stats - , width = Base.window.width * .50 | 0 - , total = runner.total - , complete = 0 - , max = Math.max; - - // default chars - options.open = options.open || '['; - options.complete = options.complete || '▬'; - options.incomplete = options.incomplete || Base.symbols.dot; - options.close = options.close || ']'; - options.verbose = false; - - // tests started - runner.on('start', function(){ - console.log(); - cursor.hide(); - }); - - // tests complete - runner.on('test end', function(){ - complete++; - var incomplete = total - complete - , percent = complete / total - , n = width * percent | 0 - , i = width - n; - - cursor.CR(); - process.stdout.write('\u001b[J'); - process.stdout.write(color('progress', ' ' + options.open)); - process.stdout.write(Array(n).join(options.complete)); - process.stdout.write(Array(i).join(options.incomplete)); - process.stdout.write(color('progress', options.close)); - if (options.verbose) { - process.stdout.write(color('progress', ' ' + complete + ' of ' + total)); - } - }); - - // tests are complete, output some stats - // and the failures if any - runner.on('end', function(){ - cursor.show(); - console.log(); - self.epilogue(); - }); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -Progress.prototype = new F; -Progress.prototype.constructor = Progress; - - -}); // module: reporters/progress.js - -require.register("reporters/spec.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `Spec`. - */ - -exports = module.exports = Spec; - -/** - * Initialize a new `Spec` test reporter. - * - * @param {Runner} runner - * @api public - */ - -function Spec(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , indents = 0 - , n = 0; - - function indent() { - return Array(indents).join(' ') - } - - runner.on('start', function(){ - console.log(); - }); - - runner.on('suite', function(suite){ - ++indents; - console.log(color('suite', '%s%s'), indent(), suite.title); - }); - - runner.on('suite end', function(suite){ - --indents; - if (1 == indents) console.log(); - }); - - runner.on('test', function(test){ - process.stdout.write(indent() + color('pass', ' ◦ ' + test.title + ': ')); - }); - - runner.on('pending', function(test){ - var fmt = indent() + color('pending', ' - %s'); - console.log(fmt, test.title); - }); - - runner.on('pass', function(test){ - if ('fast' == test.speed) { - var fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s '); - cursor.CR(); - console.log(fmt, test.title); - } else { - var fmt = indent() - + color('checkmark', ' ' + Base.symbols.ok) - + color('pass', ' %s ') - + color(test.speed, '(%dms)'); - cursor.CR(); - console.log(fmt, test.title, test.duration); - } - }); - - runner.on('fail', function(test, err){ - cursor.CR(); - console.log(indent() + color('fail', ' %d) %s'), ++n, test.title); - }); - - runner.on('end', self.epilogue.bind(self)); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -Spec.prototype = new F; -Spec.prototype.constructor = Spec; - - -}); // module: reporters/spec.js - -require.register("reporters/tap.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , cursor = Base.cursor - , color = Base.color; - -/** - * Expose `TAP`. - */ - -exports = module.exports = TAP; - -/** - * Initialize a new `TAP` reporter. - * - * @param {Runner} runner - * @api public - */ - -function TAP(runner) { - Base.call(this, runner); - - var self = this - , stats = this.stats - , n = 1 - , passes = 0 - , failures = 0; - - runner.on('start', function(){ - var total = runner.grepTotal(runner.suite); - console.log('%d..%d', 1, total); - }); - - runner.on('test end', function(){ - ++n; - }); - - runner.on('pending', function(test){ - console.log('ok %d %s # SKIP -', n, title(test)); - }); - - runner.on('pass', function(test){ - passes++; - console.log('ok %d %s', n, title(test)); - }); - - runner.on('fail', function(test, err){ - failures++; - console.log('not ok %d %s', n, title(test)); - if (err.stack) console.log(err.stack.replace(/^/gm, ' ')); - }); - - runner.on('end', function(){ - console.log('# tests ' + (passes + failures)); - console.log('# pass ' + passes); - console.log('# fail ' + failures); - }); -} - -/** - * Return a TAP-safe title of `test` - * - * @param {Object} test - * @return {String} - * @api private - */ - -function title(test) { - return test.fullTitle().replace(/#/g, ''); -} - -}); // module: reporters/tap.js - -require.register("reporters/teamcity.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base'); - -/** - * Expose `Teamcity`. - */ - -exports = module.exports = Teamcity; - -/** - * Initialize a new `Teamcity` reporter. - * - * @param {Runner} runner - * @api public - */ - -function Teamcity(runner) { - Base.call(this, runner); - var stats = this.stats; - - runner.on('start', function() { - console.log("##teamcity[testSuiteStarted name='mocha.suite']"); - }); - - runner.on('test', function(test) { - console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']"); - }); - - runner.on('fail', function(test, err) { - console.log("##teamcity[testFailed name='" + escape(test.fullTitle()) + "' message='" + escape(err.message) + "']"); - }); - - runner.on('pending', function(test) { - console.log("##teamcity[testIgnored name='" + escape(test.fullTitle()) + "' message='pending']"); - }); - - runner.on('test end', function(test) { - console.log("##teamcity[testFinished name='" + escape(test.fullTitle()) + "' duration='" + test.duration + "']"); - }); - - runner.on('end', function() { - console.log("##teamcity[testSuiteFinished name='mocha.suite' duration='" + stats.duration + "']"); - }); -} - -/** - * Escape the given `str`. - */ - -function escape(str) { - return str - .replace(/\|/g, "||") - .replace(/\n/g, "|n") - .replace(/\r/g, "|r") - .replace(/\[/g, "|[") - .replace(/\]/g, "|]") - .replace(/\u0085/g, "|x") - .replace(/\u2028/g, "|l") - .replace(/\u2029/g, "|p") - .replace(/'/g, "|'"); -} - -}); // module: reporters/teamcity.js - -require.register("reporters/xunit.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Base = require('./base') - , utils = require('../utils') - , escape = utils.escape; - -/** - * Save timer references to avoid Sinon interfering (see GH-237). - */ - -var Date = global.Date - , setTimeout = global.setTimeout - , setInterval = global.setInterval - , clearTimeout = global.clearTimeout - , clearInterval = global.clearInterval; - -/** - * Expose `XUnit`. - */ - -exports = module.exports = XUnit; - -/** - * Initialize a new `XUnit` reporter. - * - * @param {Runner} runner - * @api public - */ - -function XUnit(runner) { - Base.call(this, runner); - var stats = this.stats - , tests = [] - , self = this; - - runner.on('pass', function(test){ - tests.push(test); - }); - - runner.on('fail', function(test){ - tests.push(test); - }); - - runner.on('end', function(){ - console.log(tag('testsuite', { - name: 'Mocha Tests' - , tests: stats.tests - , failures: stats.failures - , errors: stats.failures - , skip: stats.tests - stats.failures - stats.passes - , timestamp: (new Date).toUTCString() - , time: stats.duration / 1000 - }, false)); - - tests.forEach(test); - console.log(''); - }); -} - -/** - * Inherit from `Base.prototype`. - */ - -function F(){}; -F.prototype = Base.prototype; -XUnit.prototype = new F; -XUnit.prototype.constructor = XUnit; - - -/** - * Output tag for the given `test.` - */ - -function test(test) { - var attrs = { - classname: test.parent.fullTitle() - , name: test.title - , time: test.duration / 1000 - }; - - if ('failed' == test.state) { - var err = test.err; - attrs.message = escape(err.message); - console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack)))); - } else if (test.pending) { - console.log(tag('testcase', attrs, false, tag('skipped', {}, true))); - } else { - console.log(tag('testcase', attrs, true) ); - } -} - -/** - * HTML tag helper. - */ - -function tag(name, attrs, close, content) { - var end = close ? '/>' : '>' - , pairs = [] - , tag; - - for (var key in attrs) { - pairs.push(key + '="' + escape(attrs[key]) + '"'); - } - - tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end; - if (content) tag += content + ''; -} - -}); // module: reporters/xunit.js - -require.register("runnable.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var EventEmitter = require('browser/events').EventEmitter - , debug = require('browser/debug')('mocha:runnable') - , milliseconds = require('./ms'); - -/** - * Save timer references to avoid Sinon interfering (see GH-237). - */ - -var Date = global.Date - , setTimeout = global.setTimeout - , setInterval = global.setInterval - , clearTimeout = global.clearTimeout - , clearInterval = global.clearInterval; - -/** - * Object#toString(). - */ - -var toString = Object.prototype.toString; - -/** - * Expose `Runnable`. - */ - -module.exports = Runnable; - -/** - * Initialize a new `Runnable` with the given `title` and callback `fn`. - * - * @param {String} title - * @param {Function} fn - * @api private - */ - -function Runnable(title, fn) { - this.title = title; - this.fn = fn; - this.async = fn && fn.length; - this.sync = ! this.async; - this._timeout = 2000; - this._slow = 75; - this.timedOut = false; -} - -/** - * Inherit from `EventEmitter.prototype`. - */ - -function F(){}; -F.prototype = EventEmitter.prototype; -Runnable.prototype = new F; -Runnable.prototype.constructor = Runnable; - - -/** - * Set & get timeout `ms`. - * - * @param {Number|String} ms - * @return {Runnable|Number} ms or self - * @api private - */ - -Runnable.prototype.timeout = function(ms){ - if (0 == arguments.length) return this._timeout; - if ('string' == typeof ms) ms = milliseconds(ms); - debug('timeout %d', ms); - this._timeout = ms; - if (this.timer) this.resetTimeout(); - return this; -}; - -/** - * Set & get slow `ms`. - * - * @param {Number|String} ms - * @return {Runnable|Number} ms or self - * @api private - */ - -Runnable.prototype.slow = function(ms){ - if (0 === arguments.length) return this._slow; - if ('string' == typeof ms) ms = milliseconds(ms); - debug('timeout %d', ms); - this._slow = ms; - return this; -}; - -/** - * Return the full title generated by recursively - * concatenating the parent's full title. - * - * @return {String} - * @api public - */ - -Runnable.prototype.fullTitle = function(){ - return this.parent.fullTitle() + ' ' + this.title; -}; - -/** - * Clear the timeout. - * - * @api private - */ - -Runnable.prototype.clearTimeout = function(){ - clearTimeout(this.timer); -}; - -/** - * Inspect the runnable void of private properties. - * - * @return {String} - * @api private - */ - -Runnable.prototype.inspect = function(){ - return JSON.stringify(this, function(key, val){ - if ('_' == key[0]) return; - if ('parent' == key) return '#'; - if ('ctx' == key) return '#'; - return val; - }, 2); -}; - -/** - * Reset the timeout. - * - * @api private - */ - -Runnable.prototype.resetTimeout = function(){ - var self = this - , ms = this.timeout(); - - this.clearTimeout(); - if (ms) { - this.timer = setTimeout(function(){ - self.callback(new Error('timeout of ' + ms + 'ms exceeded')); - self.timedOut = true; - }, ms); - } -}; - -/** - * Run the test and invoke `fn(err)`. - * - * @param {Function} fn - * @api private - */ - -Runnable.prototype.run = function(fn){ - var self = this - , ms = this.timeout() - , start = new Date - , ctx = this.ctx - , finished - , emitted; - - if (ctx) ctx.runnable(this); - - // timeout - if (this.async) { - if (ms) { - this.timer = setTimeout(function(){ - done(new Error('timeout of ' + ms + 'ms exceeded')); - self.timedOut = true; - }, ms); - } - } - - // called multiple times - function multiple(err) { - if (emitted) return; - emitted = true; - self.emit('error', err || new Error('done() called multiple times')); - } - - // finished - function done(err) { - if (self.timedOut) return; - if (finished) return multiple(err); - self.clearTimeout(); - self.duration = new Date - start; - finished = true; - fn(err); - } - - // for .resetTimeout() - this.callback = done; - - // async - if (this.async) { - try { - this.fn.call(ctx, function(err){ - if (err instanceof Error || toString.call(err) === "[object Error]") return done(err); - if (null != err) return done(new Error('done() invoked with non-Error: ' + err)); - done(); - }); - } catch (err) { - done(err); - } - return; - } - - if (this.asyncOnly) { - return done(new Error('--async-only option in use without declaring `done()`')); - } - - // sync - try { - if (!this.pending) this.fn.call(ctx); - this.duration = new Date - start; - fn(); - } catch (err) { - fn(err); - } -}; - -}); // module: runnable.js - -require.register("runner.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var EventEmitter = require('browser/events').EventEmitter - , debug = require('browser/debug')('mocha:runner') - , Test = require('./test') - , utils = require('./utils') - , filter = utils.filter - , keys = utils.keys; - -/** - * Non-enumerable globals. - */ - -var globals = [ - 'setTimeout', - 'clearTimeout', - 'setInterval', - 'clearInterval', - 'XMLHttpRequest', - 'Date' -]; - -/** - * Expose `Runner`. - */ - -module.exports = Runner; - -/** - * Initialize a `Runner` for the given `suite`. - * - * Events: - * - * - `start` execution started - * - `end` execution complete - * - `suite` (suite) test suite execution started - * - `suite end` (suite) all tests (and sub-suites) have finished - * - `test` (test) test execution started - * - `test end` (test) test completed - * - `hook` (hook) hook execution started - * - `hook end` (hook) hook complete - * - `pass` (test) test passed - * - `fail` (test, err) test failed - * - * @api public - */ - -function Runner(suite) { - var self = this; - this._globals = []; - this.suite = suite; - this.total = suite.total(); - this.failures = 0; - this.on('test end', function(test){ self.checkGlobals(test); }); - this.on('hook end', function(hook){ self.checkGlobals(hook); }); - this.grep(/.*/); - this.globals(this.globalProps().concat(['errno'])); -} - -/** - * Wrapper for setImmediate, process.nextTick, or browser polyfill. - * - * @param {Function} fn - * @api private - */ - -Runner.immediately = global.setImmediate || process.nextTick; - -/** - * Inherit from `EventEmitter.prototype`. - */ - -function F(){}; -F.prototype = EventEmitter.prototype; -Runner.prototype = new F; -Runner.prototype.constructor = Runner; - - -/** - * Run tests with full titles matching `re`. Updates runner.total - * with number of tests matched. - * - * @param {RegExp} re - * @param {Boolean} invert - * @return {Runner} for chaining - * @api public - */ - -Runner.prototype.grep = function(re, invert){ - debug('grep %s', re); - this._grep = re; - this._invert = invert; - this.total = this.grepTotal(this.suite); - return this; -}; - -/** - * Returns the number of tests matching the grep search for the - * given suite. - * - * @param {Suite} suite - * @return {Number} - * @api public - */ - -Runner.prototype.grepTotal = function(suite) { - var self = this; - var total = 0; - - suite.eachTest(function(test){ - var match = self._grep.test(test.fullTitle()); - if (self._invert) match = !match; - if (match) total++; - }); - - return total; -}; - -/** - * Return a list of global properties. - * - * @return {Array} - * @api private - */ - -Runner.prototype.globalProps = function() { - var props = utils.keys(global); - - // non-enumerables - for (var i = 0; i < globals.length; ++i) { - if (~utils.indexOf(props, globals[i])) continue; - props.push(globals[i]); - } - - return props; -}; - -/** - * Allow the given `arr` of globals. - * - * @param {Array} arr - * @return {Runner} for chaining - * @api public - */ - -Runner.prototype.globals = function(arr){ - if (0 == arguments.length) return this._globals; - debug('globals %j', arr); - utils.forEach(arr, function(arr){ - this._globals.push(arr); - }, this); - return this; -}; - -/** - * Check for global variable leaks. - * - * @api private - */ - -Runner.prototype.checkGlobals = function(test){ - if (this.ignoreLeaks) return; - var ok = this._globals; - var globals = this.globalProps(); - var isNode = process.kill; - var leaks; - - // check length - 2 ('errno' and 'location' globals) - if (isNode && 1 == ok.length - globals.length) return - else if (2 == ok.length - globals.length) return; - - leaks = filterLeaks(ok, globals); - this._globals = this._globals.concat(leaks); - - if (leaks.length > 1) { - this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + '')); - } else if (leaks.length) { - this.fail(test, new Error('global leak detected: ' + leaks[0])); - } -}; - -/** - * Fail the given `test`. - * - * @param {Test} test - * @param {Error} err - * @api private - */ - -Runner.prototype.fail = function(test, err){ - ++this.failures; - test.state = 'failed'; - - if ('string' == typeof err) { - err = new Error('the string "' + err + '" was thrown, throw an Error :)'); - } - - this.emit('fail', test, err); -}; - -/** - * Fail the given `hook` with `err`. - * - * Hook failures (currently) hard-end due - * to that fact that a failing hook will - * surely cause subsequent tests to fail, - * causing jumbled reporting. - * - * @param {Hook} hook - * @param {Error} err - * @api private - */ - -Runner.prototype.failHook = function(hook, err){ - this.fail(hook, err); - this.emit('end'); -}; - -/** - * Run hook `name` callbacks and then invoke `fn()`. - * - * @param {String} name - * @param {Function} function - * @api private - */ - -Runner.prototype.hook = function(name, fn){ - var suite = this.suite - , hooks = suite['_' + name] - , self = this - , timer; - - function next(i) { - var hook = hooks[i]; - if (!hook) return fn(); - self.currentRunnable = hook; - - self.emit('hook', hook); - - hook.on('error', function(err){ - self.failHook(hook, err); - }); - - hook.run(function(err){ - hook.removeAllListeners('error'); - var testError = hook.error(); - if (testError) self.fail(self.test, testError); - if (err) return self.failHook(hook, err); - self.emit('hook end', hook); - next(++i); - }); - } - - Runner.immediately(function(){ - next(0); - }); -}; - -/** - * Run hook `name` for the given array of `suites` - * in order, and callback `fn(err)`. - * - * @param {String} name - * @param {Array} suites - * @param {Function} fn - * @api private - */ - -Runner.prototype.hooks = function(name, suites, fn){ - var self = this - , orig = this.suite; - - function next(suite) { - self.suite = suite; - - if (!suite) { - self.suite = orig; - return fn(); - } - - self.hook(name, function(err){ - if (err) { - self.suite = orig; - return fn(err); - } - - next(suites.pop()); - }); - } - - next(suites.pop()); -}; - -/** - * Run hooks from the top level down. - * - * @param {String} name - * @param {Function} fn - * @api private - */ - -Runner.prototype.hookUp = function(name, fn){ - var suites = [this.suite].concat(this.parents()).reverse(); - this.hooks(name, suites, fn); -}; - -/** - * Run hooks from the bottom up. - * - * @param {String} name - * @param {Function} fn - * @api private - */ - -Runner.prototype.hookDown = function(name, fn){ - var suites = [this.suite].concat(this.parents()); - this.hooks(name, suites, fn); -}; - -/** - * Return an array of parent Suites from - * closest to furthest. - * - * @return {Array} - * @api private - */ - -Runner.prototype.parents = function(){ - var suite = this.suite - , suites = []; - while (suite = suite.parent) suites.push(suite); - return suites; -}; - -/** - * Run the current test and callback `fn(err)`. - * - * @param {Function} fn - * @api private - */ - -Runner.prototype.runTest = function(fn){ - var test = this.test - , self = this; - - if (this.asyncOnly) test.asyncOnly = true; - - try { - test.on('error', function(err){ - self.fail(test, err); - }); - test.run(fn); - } catch (err) { - fn(err); - } -}; - -/** - * Run tests in the given `suite` and invoke - * the callback `fn()` when complete. - * - * @param {Suite} suite - * @param {Function} fn - * @api private - */ - -Runner.prototype.runTests = function(suite, fn){ - var self = this - , tests = suite.tests.slice() - , test; - - function next(err) { - // if we bail after first err - if (self.failures && suite._bail) return fn(); - - // next test - test = tests.shift(); - - // all done - if (!test) return fn(); - - // grep - var match = self._grep.test(test.fullTitle()); - if (self._invert) match = !match; - if (!match) return next(); - - // pending - if (test.pending) { - self.emit('pending', test); - self.emit('test end', test); - return next(); - } - - // execute test and hook(s) - self.emit('test', self.test = test); - self.hookDown('beforeEach', function(){ - self.currentRunnable = self.test; - self.runTest(function(err){ - test = self.test; - - if (err) { - self.fail(test, err); - self.emit('test end', test); - return self.hookUp('afterEach', next); - } - - test.state = 'passed'; - self.emit('pass', test); - self.emit('test end', test); - self.hookUp('afterEach', next); - }); - }); - } - - this.next = next; - next(); -}; - -/** - * Run the given `suite` and invoke the - * callback `fn()` when complete. - * - * @param {Suite} suite - * @param {Function} fn - * @api private - */ - -Runner.prototype.runSuite = function(suite, fn){ - var total = this.grepTotal(suite) - , self = this - , i = 0; - - debug('run suite %s', suite.fullTitle()); - - if (!total) return fn(); - - this.emit('suite', this.suite = suite); - - function next() { - var curr = suite.suites[i++]; - if (!curr) return done(); - self.runSuite(curr, next); - } - - function done() { - self.suite = suite; - self.hook('afterAll', function(){ - self.emit('suite end', suite); - fn(); - }); - } - - this.hook('beforeAll', function(){ - self.runTests(suite, next); - }); -}; - -/** - * Handle uncaught exceptions. - * - * @param {Error} err - * @api private - */ - -Runner.prototype.uncaught = function(err){ - debug('uncaught exception %s', err.message); - var runnable = this.currentRunnable; - if (!runnable || 'failed' == runnable.state) return; - runnable.clearTimeout(); - err.uncaught = true; - this.fail(runnable, err); - - // recover from test - if ('test' == runnable.type) { - this.emit('test end', runnable); - this.hookUp('afterEach', this.next); - return; - } - - // bail on hooks - this.emit('end'); -}; - -/** - * Run the root suite and invoke `fn(failures)` - * on completion. - * - * @param {Function} fn - * @return {Runner} for chaining - * @api public - */ - -Runner.prototype.run = function(fn){ - var self = this - , fn = fn || function(){}; - - function uncaught(err){ - self.uncaught(err); - } - - debug('start'); - - // callback - this.on('end', function(){ - debug('end'); - process.removeListener('uncaughtException', uncaught); - fn(self.failures); - }); - - // run suites - this.emit('start'); - this.runSuite(this.suite, function(){ - debug('finished running'); - self.emit('end'); - }); - - // uncaught exception - process.on('uncaughtException', uncaught); - - return this; -}; - -/** - * Filter leaks with the given globals flagged as `ok`. - * - * @param {Array} ok - * @param {Array} globals - * @return {Array} - * @api private - */ - -function filterLeaks(ok, globals) { - return filter(globals, function(key){ - var matched = filter(ok, function(ok){ - if (~ok.indexOf('*')) return 0 == key.indexOf(ok.split('*')[0]); - // Opera and IE expose global variables for HTML element IDs (issue #243) - if (/^mocha-/.test(key)) return true; - return key == ok; - }); - return matched.length == 0 && (!global.navigator || 'onerror' !== key); - }); -} - -}); // module: runner.js - -require.register("suite.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var EventEmitter = require('browser/events').EventEmitter - , debug = require('browser/debug')('mocha:suite') - , milliseconds = require('./ms') - , utils = require('./utils') - , Hook = require('./hook'); - -/** - * Expose `Suite`. - */ - -exports = module.exports = Suite; - -/** - * Create a new `Suite` with the given `title` - * and parent `Suite`. When a suite with the - * same title is already present, that suite - * is returned to provide nicer reporter - * and more flexible meta-testing. - * - * @param {Suite} parent - * @param {String} title - * @return {Suite} - * @api public - */ - -exports.create = function(parent, title){ - var suite = new Suite(title, parent.ctx); - suite.parent = parent; - if (parent.pending) suite.pending = true; - title = suite.fullTitle(); - parent.addSuite(suite); - return suite; -}; - -/** - * Initialize a new `Suite` with the given - * `title` and `ctx`. - * - * @param {String} title - * @param {Context} ctx - * @api private - */ - -function Suite(title, ctx) { - this.title = title; - this.ctx = ctx; - this.suites = []; - this.tests = []; - this.pending = false; - this._beforeEach = []; - this._beforeAll = []; - this._afterEach = []; - this._afterAll = []; - this.root = !title; - this._timeout = 2000; - this._slow = 75; - this._bail = false; -} - -/** - * Inherit from `EventEmitter.prototype`. - */ - -function F(){}; -F.prototype = EventEmitter.prototype; -Suite.prototype = new F; -Suite.prototype.constructor = Suite; - - -/** - * Return a clone of this `Suite`. - * - * @return {Suite} - * @api private - */ - -Suite.prototype.clone = function(){ - var suite = new Suite(this.title); - debug('clone'); - suite.ctx = this.ctx; - suite.timeout(this.timeout()); - suite.slow(this.slow()); - suite.bail(this.bail()); - return suite; -}; - -/** - * Set timeout `ms` or short-hand such as "2s". - * - * @param {Number|String} ms - * @return {Suite|Number} for chaining - * @api private - */ - -Suite.prototype.timeout = function(ms){ - if (0 == arguments.length) return this._timeout; - if ('string' == typeof ms) ms = milliseconds(ms); - debug('timeout %d', ms); - this._timeout = parseInt(ms, 10); - return this; -}; - -/** - * Set slow `ms` or short-hand such as "2s". - * - * @param {Number|String} ms - * @return {Suite|Number} for chaining - * @api private - */ - -Suite.prototype.slow = function(ms){ - if (0 === arguments.length) return this._slow; - if ('string' == typeof ms) ms = milliseconds(ms); - debug('slow %d', ms); - this._slow = ms; - return this; -}; - -/** - * Sets whether to bail after first error. - * - * @parma {Boolean} bail - * @return {Suite|Number} for chaining - * @api private - */ - -Suite.prototype.bail = function(bail){ - if (0 == arguments.length) return this._bail; - debug('bail %s', bail); - this._bail = bail; - return this; -}; - -/** - * Run `fn(test[, done])` before running tests. - * - * @param {Function} fn - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.beforeAll = function(fn){ - if (this.pending) return this; - var hook = new Hook('"before all" hook', fn); - hook.parent = this; - hook.timeout(this.timeout()); - hook.slow(this.slow()); - hook.ctx = this.ctx; - this._beforeAll.push(hook); - this.emit('beforeAll', hook); - return this; -}; - -/** - * Run `fn(test[, done])` after running tests. - * - * @param {Function} fn - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.afterAll = function(fn){ - if (this.pending) return this; - var hook = new Hook('"after all" hook', fn); - hook.parent = this; - hook.timeout(this.timeout()); - hook.slow(this.slow()); - hook.ctx = this.ctx; - this._afterAll.push(hook); - this.emit('afterAll', hook); - return this; -}; - -/** - * Run `fn(test[, done])` before each test case. - * - * @param {Function} fn - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.beforeEach = function(fn){ - if (this.pending) return this; - var hook = new Hook('"before each" hook', fn); - hook.parent = this; - hook.timeout(this.timeout()); - hook.slow(this.slow()); - hook.ctx = this.ctx; - this._beforeEach.push(hook); - this.emit('beforeEach', hook); - return this; -}; - -/** - * Run `fn(test[, done])` after each test case. - * - * @param {Function} fn - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.afterEach = function(fn){ - if (this.pending) return this; - var hook = new Hook('"after each" hook', fn); - hook.parent = this; - hook.timeout(this.timeout()); - hook.slow(this.slow()); - hook.ctx = this.ctx; - this._afterEach.push(hook); - this.emit('afterEach', hook); - return this; -}; - -/** - * Add a test `suite`. - * - * @param {Suite} suite - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.addSuite = function(suite){ - suite.parent = this; - suite.timeout(this.timeout()); - suite.slow(this.slow()); - suite.bail(this.bail()); - this.suites.push(suite); - this.emit('suite', suite); - return this; -}; - -/** - * Add a `test` to this suite. - * - * @param {Test} test - * @return {Suite} for chaining - * @api private - */ - -Suite.prototype.addTest = function(test){ - test.parent = this; - test.timeout(this.timeout()); - test.slow(this.slow()); - test.ctx = this.ctx; - this.tests.push(test); - this.emit('test', test); - return this; -}; - -/** - * Return the full title generated by recursively - * concatenating the parent's full title. - * - * @return {String} - * @api public - */ - -Suite.prototype.fullTitle = function(){ - if (this.parent) { - var full = this.parent.fullTitle(); - if (full) return full + ' ' + this.title; - } - return this.title; -}; - -/** - * Return the total number of tests. - * - * @return {Number} - * @api public - */ - -Suite.prototype.total = function(){ - return utils.reduce(this.suites, function(sum, suite){ - return sum + suite.total(); - }, 0) + this.tests.length; -}; - -/** - * Iterates through each suite recursively to find - * all tests. Applies a function in the format - * `fn(test)`. - * - * @param {Function} fn - * @return {Suite} - * @api private - */ - -Suite.prototype.eachTest = function(fn){ - utils.forEach(this.tests, fn); - utils.forEach(this.suites, function(suite){ - suite.eachTest(fn); - }); - return this; -}; - -}); // module: suite.js - -require.register("test.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var Runnable = require('./runnable'); - -/** - * Expose `Test`. - */ - -module.exports = Test; - -/** - * Initialize a new `Test` with the given `title` and callback `fn`. - * - * @param {String} title - * @param {Function} fn - * @api private - */ - -function Test(title, fn) { - Runnable.call(this, title, fn); - this.pending = !fn; - this.type = 'test'; -} - -/** - * Inherit from `Runnable.prototype`. - */ - -function F(){}; -F.prototype = Runnable.prototype; -Test.prototype = new F; -Test.prototype.constructor = Test; - - -}); // module: test.js - -require.register("utils.js", function(module, exports, require){ - -/** - * Module dependencies. - */ - -var fs = require('browser/fs') - , path = require('browser/path') - , join = path.join - , debug = require('browser/debug')('mocha:watch'); - -/** - * Ignored directories. - */ - -var ignore = ['node_modules', '.git']; - -/** - * Escape special characters in the given string of html. - * - * @param {String} html - * @return {String} - * @api private - */ - -exports.escape = function(html){ - return String(html) - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(//g, '>'); -}; - -/** - * Array#forEach (<=IE8) - * - * @param {Array} array - * @param {Function} fn - * @param {Object} scope - * @api private - */ - -exports.forEach = function(arr, fn, scope){ - for (var i = 0, l = arr.length; i < l; i++) - fn.call(scope, arr[i], i); -}; - -/** - * Array#indexOf (<=IE8) - * - * @parma {Array} arr - * @param {Object} obj to find index of - * @param {Number} start - * @api private - */ - -exports.indexOf = function(arr, obj, start){ - for (var i = start || 0, l = arr.length; i < l; i++) { - if (arr[i] === obj) - return i; - } - return -1; -}; - -/** - * Array#reduce (<=IE8) - * - * @param {Array} array - * @param {Function} fn - * @param {Object} initial value - * @api private - */ - -exports.reduce = function(arr, fn, val){ - var rval = val; - - for (var i = 0, l = arr.length; i < l; i++) { - rval = fn(rval, arr[i], i, arr); - } - - return rval; -}; - -/** - * Array#filter (<=IE8) - * - * @param {Array} array - * @param {Function} fn - * @api private - */ - -exports.filter = function(arr, fn){ - var ret = []; - - for (var i = 0, l = arr.length; i < l; i++) { - var val = arr[i]; - if (fn(val, i, arr)) ret.push(val); - } - - return ret; -}; - -/** - * Object.keys (<=IE8) - * - * @param {Object} obj - * @return {Array} keys - * @api private - */ - -exports.keys = Object.keys || function(obj) { - var keys = [] - , has = Object.prototype.hasOwnProperty // for `window` on <=IE8 - - for (var key in obj) { - if (has.call(obj, key)) { - keys.push(key); - } - } - - return keys; -}; - -/** - * Watch the given `files` for changes - * and invoke `fn(file)` on modification. - * - * @param {Array} files - * @param {Function} fn - * @api private - */ - -exports.watch = function(files, fn){ - var options = { interval: 100 }; - files.forEach(function(file){ - debug('file %s', file); - fs.watchFile(file, options, function(curr, prev){ - if (prev.mtime < curr.mtime) fn(file); - }); - }); -}; - -/** - * Ignored files. - */ - -function ignored(path){ - return !~ignore.indexOf(path); -} - -/** - * Lookup files in the given `dir`. - * - * @return {Array} - * @api private - */ - -exports.files = function(dir, ret){ - ret = ret || []; - - fs.readdirSync(dir) - .filter(ignored) - .forEach(function(path){ - path = join(dir, path); - if (fs.statSync(path).isDirectory()) { - exports.files(path, ret); - } else if (path.match(/\.(js|coffee)$/)) { - ret.push(path); - } - }); - - return ret; -}; - -/** - * Compute a slug from the given `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - -exports.slug = function(str){ - return str - .toLowerCase() - .replace(/ +/g, '-') - .replace(/[^-\w]/g, ''); -}; - -/** - * Strip the function definition from `str`, - * and re-indent for pre whitespace. - */ - -exports.clean = function(str) { - str = str - .replace(/^function *\(.*\) *{/, '') - .replace(/\s+\}$/, ''); - - var spaces = str.match(/^\n?( *)/)[1].length - , re = new RegExp('^ {' + spaces + '}', 'gm'); - - str = str.replace(re, ''); - - return exports.trim(str); -}; - -/** - * Escape regular expression characters in `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - -exports.escapeRegexp = function(str){ - return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); -}; - -/** - * Trim the given `str`. - * - * @param {String} str - * @return {String} - * @api private - */ - -exports.trim = function(str){ - return str.replace(/^\s+|\s+$/g, ''); -}; - -/** - * Parse the given `qs`. - * - * @param {String} qs - * @return {Object} - * @api private - */ - -exports.parseQuery = function(qs){ - return exports.reduce(qs.replace('?', '').split('&'), function(obj, pair){ - var i = pair.indexOf('=') - , key = pair.slice(0, i) - , val = pair.slice(++i); - - obj[key] = decodeURIComponent(val); - return obj; - }, {}); -}; - -/** - * Highlight the given string of `js`. - * - * @param {String} js - * @return {String} - * @api private - */ - -function highlight(js) { - return js - .replace(//g, '>') - .replace(/\/\/(.*)/gm, '//$1') - .replace(/('.*?')/gm, '$1') - .replace(/(\d+\.\d+)/gm, '$1') - .replace(/(\d+)/gm, '$1') - .replace(/\bnew *(\w+)/gm, 'new $1') - .replace(/\b(function|new|throw|return|var|if|else)\b/gm, '$1') -} - -/** - * Highlight the contents of tag `name`. - * - * @param {String} name - * @api private - */ - -exports.highlightTags = function(name) { - var code = document.getElementsByTagName(name); - for (var i = 0, len = code.length; i < len; ++i) { - code[i].innerHTML = highlight(code[i].innerHTML); - } -}; - -}); // module: utils.js -/** - * Node shims. - * - * These are meant only to allow - * mocha.js to run untouched, not - * to allow running node code in - * the browser. - */ - -process = {}; -process.exit = function(status){}; -process.stdout = {}; -global = window; - -/** - * Remove uncaughtException listener. - */ - -process.removeListener = function(e){ - if ('uncaughtException' == e) { - window.onerror = null; - } -}; - -/** - * Implements uncaughtException listener. - */ - -process.on = function(e, fn){ - if ('uncaughtException' == e) { - window.onerror = function(err, url, line){ - fn(new Error(err + ' (' + url + ':' + line + ')')); - }; - } -}; - -// boot -;(function(){ - - /** - * Expose mocha. - */ - - var Mocha = window.Mocha = require('mocha'), - mocha = window.mocha = new Mocha({ reporter: 'html' }); - - var immediateQueue = [] - , immediateTimeout; - - function timeslice() { - var immediateStart = new Date().getTime(); - while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) { - immediateQueue.shift()(); - } - if (immediateQueue.length) { - immediateTimeout = setTimeout(timeslice, 0); - } else { - immediateTimeout = null; - } - } - - /** - * High-performance override of Runner.immediately. - */ - - Mocha.Runner.immediately = function(callback) { - immediateQueue.push(callback); - if (!immediateTimeout) { - immediateTimeout = setTimeout(timeslice, 0); - } - }; - - /** - * Override ui to ensure that the ui functions are initialized. - * Normally this would happen in Mocha.prototype.loadFiles. - */ - - mocha.ui = function(ui){ - Mocha.prototype.ui.call(this, ui); - this.suite.emit('pre-require', window, null, this); - return this; - }; - - /** - * Setup mocha with the given setting options. - */ - - mocha.setup = function(opts){ - if ('string' == typeof opts) opts = { ui: opts }; - for (var opt in opts) this[opt](opts[opt]); - return this; - }; - - /** - * Run mocha, returning the Runner. - */ - - mocha.run = function(fn){ - var options = mocha.options; - mocha.globals('location'); - - var query = Mocha.utils.parseQuery(window.location.search || ''); - if (query.grep) mocha.grep(query.grep); - if (query.invert) mocha.invert(); - - return Mocha.prototype.run.call(mocha, function(){ - Mocha.utils.highlightTags('code'); - if (fn) fn(); - }); - }; -})(); -})(); diff --git a/tests/libs/sinon-1.7.1.js b/tests/libs/sinon-1.7.1.js deleted file mode 100644 index fe9529f7..00000000 --- a/tests/libs/sinon-1.7.1.js +++ /dev/null @@ -1,4299 +0,0 @@ -/** - * Sinon.JS 1.7.1, 2013/05/07 - * - * @author Christian Johansen (christian@cjohansen.no) - * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS - * - * (The BSD License) - * - * Copyright (c) 2010-2013, Christian Johansen, christian@cjohansen.no - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of Christian Johansen nor the names of his contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -this.sinon = (function () { -var buster = (function (setTimeout, B) { - var isNode = typeof require == "function" && typeof module == "object"; - var div = typeof document != "undefined" && document.createElement("div"); - var F = function () {}; - - var buster = { - bind: function bind(obj, methOrProp) { - var method = typeof methOrProp == "string" ? obj[methOrProp] : methOrProp; - var args = Array.prototype.slice.call(arguments, 2); - return function () { - var allArgs = args.concat(Array.prototype.slice.call(arguments)); - return method.apply(obj, allArgs); - }; - }, - - partial: function partial(fn) { - var args = [].slice.call(arguments, 1); - return function () { - return fn.apply(this, args.concat([].slice.call(arguments))); - }; - }, - - create: function create(object) { - F.prototype = object; - return new F(); - }, - - extend: function extend(target) { - if (!target) { return; } - for (var i = 1, l = arguments.length, prop; i < l; ++i) { - for (prop in arguments[i]) { - target[prop] = arguments[i][prop]; - } - } - return target; - }, - - nextTick: function nextTick(callback) { - if (typeof process != "undefined" && process.nextTick) { - return process.nextTick(callback); - } - setTimeout(callback, 0); - }, - - functionName: function functionName(func) { - if (!func) return ""; - if (func.displayName) return func.displayName; - if (func.name) return func.name; - var matches = func.toString().match(/function\s+([^\(]+)/m); - return matches && matches[1] || ""; - }, - - isNode: function isNode(obj) { - if (!div) return false; - try { - obj.appendChild(div); - obj.removeChild(div); - } catch (e) { - return false; - } - return true; - }, - - isElement: function isElement(obj) { - return obj && obj.nodeType === 1 && buster.isNode(obj); - }, - - isArray: function isArray(arr) { - return Object.prototype.toString.call(arr) == "[object Array]"; - }, - - flatten: function flatten(arr) { - var result = [], arr = arr || []; - for (var i = 0, l = arr.length; i < l; ++i) { - result = result.concat(buster.isArray(arr[i]) ? flatten(arr[i]) : arr[i]); - } - return result; - }, - - each: function each(arr, callback) { - for (var i = 0, l = arr.length; i < l; ++i) { - callback(arr[i]); - } - }, - - map: function map(arr, callback) { - var results = []; - for (var i = 0, l = arr.length; i < l; ++i) { - results.push(callback(arr[i])); - } - return results; - }, - - parallel: function parallel(fns, callback) { - function cb(err, res) { - if (typeof callback == "function") { - callback(err, res); - callback = null; - } - } - if (fns.length == 0) { return cb(null, []); } - var remaining = fns.length, results = []; - function makeDone(num) { - return function done(err, result) { - if (err) { return cb(err); } - results[num] = result; - if (--remaining == 0) { cb(null, results); } - }; - } - for (var i = 0, l = fns.length; i < l; ++i) { - fns[i](makeDone(i)); - } - }, - - series: function series(fns, callback) { - function cb(err, res) { - if (typeof callback == "function") { - callback(err, res); - } - } - var remaining = fns.slice(); - var results = []; - function callNext() { - if (remaining.length == 0) return cb(null, results); - var promise = remaining.shift()(next); - if (promise && typeof promise.then == "function") { - promise.then(buster.partial(next, null), next); - } - } - function next(err, result) { - if (err) return cb(err); - results.push(result); - callNext(); - } - callNext(); - }, - - countdown: function countdown(num, done) { - return function () { - if (--num == 0) done(); - }; - } - }; - - if (typeof process === "object" && - typeof require === "function" && typeof module === "object") { - var crypto = require("crypto"); - var path = require("path"); - - buster.tmpFile = function (fileName) { - var hashed = crypto.createHash("sha1"); - hashed.update(fileName); - var tmpfileName = hashed.digest("hex"); - - if (process.platform == "win32") { - return path.join(process.env["TEMP"], tmpfileName); - } else { - return path.join("/tmp", tmpfileName); - } - }; - } - - if (Array.prototype.some) { - buster.some = function (arr, fn, thisp) { - return arr.some(fn, thisp); - }; - } else { - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some - buster.some = function (arr, fun, thisp) { - if (arr == null) { throw new TypeError(); } - arr = Object(arr); - var len = arr.length >>> 0; - if (typeof fun !== "function") { throw new TypeError(); } - - for (var i = 0; i < len; i++) { - if (arr.hasOwnProperty(i) && fun.call(thisp, arr[i], i, arr)) { - return true; - } - } - - return false; - }; - } - - if (Array.prototype.filter) { - buster.filter = function (arr, fn, thisp) { - return arr.filter(fn, thisp); - }; - } else { - // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter - buster.filter = function (fn, thisp) { - if (this == null) { throw new TypeError(); } - - var t = Object(this); - var len = t.length >>> 0; - if (typeof fn != "function") { throw new TypeError(); } - - var res = []; - for (var i = 0; i < len; i++) { - if (i in t) { - var val = t[i]; // in case fun mutates this - if (fn.call(thisp, val, i, t)) { res.push(val); } - } - } - - return res; - }; - } - - if (isNode) { - module.exports = buster; - buster.eventEmitter = require("./buster-event-emitter"); - Object.defineProperty(buster, "defineVersionGetter", { - get: function () { - return require("./define-version-getter"); - } - }); - } - - return buster.extend(B || {}, buster); -}(setTimeout, buster)); -if (typeof buster === "undefined") { - var buster = {}; -} - -if (typeof module === "object" && typeof require === "function") { - buster = require("buster-core"); -} - -buster.format = buster.format || {}; -buster.format.excludeConstructors = ["Object", /^.$/]; -buster.format.quoteStrings = true; - -buster.format.ascii = (function () { - - var hasOwn = Object.prototype.hasOwnProperty; - - var specialObjects = []; - if (typeof global != "undefined") { - specialObjects.push({ obj: global, value: "[object global]" }); - } - if (typeof document != "undefined") { - specialObjects.push({ obj: document, value: "[object HTMLDocument]" }); - } - if (typeof window != "undefined") { - specialObjects.push({ obj: window, value: "[object Window]" }); - } - - function keys(object) { - var k = Object.keys && Object.keys(object) || []; - - if (k.length == 0) { - for (var prop in object) { - if (hasOwn.call(object, prop)) { - k.push(prop); - } - } - } - - return k.sort(); - } - - function isCircular(object, objects) { - if (typeof object != "object") { - return false; - } - - for (var i = 0, l = objects.length; i < l; ++i) { - if (objects[i] === object) { - return true; - } - } - - return false; - } - - function ascii(object, processed, indent) { - if (typeof object == "string") { - var quote = typeof this.quoteStrings != "boolean" || this.quoteStrings; - return processed || quote ? '"' + object + '"' : object; - } - - if (typeof object == "function" && !(object instanceof RegExp)) { - return ascii.func(object); - } - - processed = processed || []; - - if (isCircular(object, processed)) { - return "[Circular]"; - } - - if (Object.prototype.toString.call(object) == "[object Array]") { - return ascii.array.call(this, object, processed); - } - - if (!object) { - return "" + object; - } - - if (buster.isElement(object)) { - return ascii.element(object); - } - - if (typeof object.toString == "function" && - object.toString !== Object.prototype.toString) { - return object.toString(); - } - - for (var i = 0, l = specialObjects.length; i < l; i++) { - if (object === specialObjects[i].obj) { - return specialObjects[i].value; - } - } - - return ascii.object.call(this, object, processed, indent); - } - - ascii.func = function (func) { - return "function " + buster.functionName(func) + "() {}"; - }; - - ascii.array = function (array, processed) { - processed = processed || []; - processed.push(array); - var pieces = []; - - for (var i = 0, l = array.length; i < l; ++i) { - pieces.push(ascii.call(this, array[i], processed)); - } - - return "[" + pieces.join(", ") + "]"; - }; - - ascii.object = function (object, processed, indent) { - processed = processed || []; - processed.push(object); - indent = indent || 0; - var pieces = [], properties = keys(object), prop, str, obj; - var is = ""; - var length = 3; - - for (var i = 0, l = indent; i < l; ++i) { - is += " "; - } - - for (i = 0, l = properties.length; i < l; ++i) { - prop = properties[i]; - obj = object[prop]; - - if (isCircular(obj, processed)) { - str = "[Circular]"; - } else { - str = ascii.call(this, obj, processed, indent + 2); - } - - str = (/\s/.test(prop) ? '"' + prop + '"' : prop) + ": " + str; - length += str.length; - pieces.push(str); - } - - var cons = ascii.constructorName.call(this, object); - var prefix = cons ? "[" + cons + "] " : "" - - return (length + indent) > 80 ? - prefix + "{\n " + is + pieces.join(",\n " + is) + "\n" + is + "}" : - prefix + "{ " + pieces.join(", ") + " }"; - }; - - ascii.element = function (element) { - var tagName = element.tagName.toLowerCase(); - var attrs = element.attributes, attribute, pairs = [], attrName; - - for (var i = 0, l = attrs.length; i < l; ++i) { - attribute = attrs.item(i); - attrName = attribute.nodeName.toLowerCase().replace("html:", ""); - - if (attrName == "contenteditable" && attribute.nodeValue == "inherit") { - continue; - } - - if (!!attribute.nodeValue) { - pairs.push(attrName + "=\"" + attribute.nodeValue + "\""); - } - } - - var formatted = "<" + tagName + (pairs.length > 0 ? " " : ""); - var content = element.innerHTML; - - if (content.length > 20) { - content = content.substr(0, 20) + "[...]"; - } - - var res = formatted + pairs.join(" ") + ">" + content + ""; - - return res.replace(/ contentEditable="inherit"/, ""); - }; - - ascii.constructorName = function (object) { - var name = buster.functionName(object && object.constructor); - var excludes = this.excludeConstructors || buster.format.excludeConstructors || []; - - for (var i = 0, l = excludes.length; i < l; ++i) { - if (typeof excludes[i] == "string" && excludes[i] == name) { - return ""; - } else if (excludes[i].test && excludes[i].test(name)) { - return ""; - } - } - - return name; - }; - - return ascii; -}()); - -if (typeof module != "undefined") { - module.exports = buster.format; -} -/*jslint eqeqeq: false, onevar: false, forin: true, nomen: false, regexp: false, plusplus: false*/ -/*global module, require, __dirname, document*/ -/** - * Sinon core utilities. For internal use only. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -var sinon = (function (buster) { - var div = typeof document != "undefined" && document.createElement("div"); - var hasOwn = Object.prototype.hasOwnProperty; - - function isDOMNode(obj) { - var success = false; - - try { - obj.appendChild(div); - success = div.parentNode == obj; - } catch (e) { - return false; - } finally { - try { - obj.removeChild(div); - } catch (e) { - // Remove failed, not much we can do about that - } - } - - return success; - } - - function isElement(obj) { - return div && obj && obj.nodeType === 1 && isDOMNode(obj); - } - - function isFunction(obj) { - return typeof obj === "function" || !!(obj && obj.constructor && obj.call && obj.apply); - } - - function mirrorProperties(target, source) { - for (var prop in source) { - if (!hasOwn.call(target, prop)) { - target[prop] = source[prop]; - } - } - } - - function isRestorable (obj) { - return typeof obj === "function" && typeof obj.restore === "function" && obj.restore.sinon; - } - - var sinon = { - wrapMethod: function wrapMethod(object, property, method) { - if (!object) { - throw new TypeError("Should wrap property of object"); - } - - if (typeof method != "function") { - throw new TypeError("Method wrapper should be function"); - } - - var wrappedMethod = object[property]; - - if (!isFunction(wrappedMethod)) { - throw new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " + - property + " as function"); - } - - if (wrappedMethod.restore && wrappedMethod.restore.sinon) { - throw new TypeError("Attempted to wrap " + property + " which is already wrapped"); - } - - if (wrappedMethod.calledBefore) { - var verb = !!wrappedMethod.returns ? "stubbed" : "spied on"; - throw new TypeError("Attempted to wrap " + property + " which is already " + verb); - } - - // IE 8 does not support hasOwnProperty on the window object. - var owned = hasOwn.call(object, property); - object[property] = method; - method.displayName = property; - - method.restore = function () { - // For prototype properties try to reset by delete first. - // If this fails (ex: localStorage on mobile safari) then force a reset - // via direct assignment. - if (!owned) { - delete object[property]; - } - if (object[property] === method) { - object[property] = wrappedMethod; - } - }; - - method.restore.sinon = true; - mirrorProperties(method, wrappedMethod); - - return method; - }, - - extend: function extend(target) { - for (var i = 1, l = arguments.length; i < l; i += 1) { - for (var prop in arguments[i]) { - if (arguments[i].hasOwnProperty(prop)) { - target[prop] = arguments[i][prop]; - } - - // DONT ENUM bug, only care about toString - if (arguments[i].hasOwnProperty("toString") && - arguments[i].toString != target.toString) { - target.toString = arguments[i].toString; - } - } - } - - return target; - }, - - create: function create(proto) { - var F = function () {}; - F.prototype = proto; - return new F(); - }, - - deepEqual: function deepEqual(a, b) { - if (sinon.match && sinon.match.isMatcher(a)) { - return a.test(b); - } - if (typeof a != "object" || typeof b != "object") { - return a === b; - } - - if (isElement(a) || isElement(b)) { - return a === b; - } - - if (a === b) { - return true; - } - - if ((a === null && b !== null) || (a !== null && b === null)) { - return false; - } - - var aString = Object.prototype.toString.call(a); - if (aString != Object.prototype.toString.call(b)) { - return false; - } - - if (aString == "[object Array]") { - if (a.length !== b.length) { - return false; - } - - for (var i = 0, l = a.length; i < l; i += 1) { - if (!deepEqual(a[i], b[i])) { - return false; - } - } - - return true; - } - - var prop, aLength = 0, bLength = 0; - - for (prop in a) { - aLength += 1; - - if (!deepEqual(a[prop], b[prop])) { - return false; - } - } - - for (prop in b) { - bLength += 1; - } - - return aLength == bLength; - }, - - functionName: function functionName(func) { - var name = func.displayName || func.name; - - // Use function decomposition as a last resort to get function - // name. Does not rely on function decomposition to work - if it - // doesn't debugging will be slightly less informative - // (i.e. toString will say 'spy' rather than 'myFunc'). - if (!name) { - var matches = func.toString().match(/function ([^\s\(]+)/); - name = matches && matches[1]; - } - - return name; - }, - - functionToString: function toString() { - if (this.getCall && this.callCount) { - var thisValue, prop, i = this.callCount; - - while (i--) { - thisValue = this.getCall(i).thisValue; - - for (prop in thisValue) { - if (thisValue[prop] === this) { - return prop; - } - } - } - } - - return this.displayName || "sinon fake"; - }, - - getConfig: function (custom) { - var config = {}; - custom = custom || {}; - var defaults = sinon.defaultConfig; - - for (var prop in defaults) { - if (defaults.hasOwnProperty(prop)) { - config[prop] = custom.hasOwnProperty(prop) ? custom[prop] : defaults[prop]; - } - } - - return config; - }, - - format: function (val) { - return "" + val; - }, - - defaultConfig: { - injectIntoThis: true, - injectInto: null, - properties: ["spy", "stub", "mock", "clock", "server", "requests"], - useFakeTimers: true, - useFakeServer: true - }, - - timesInWords: function timesInWords(count) { - return count == 1 && "once" || - count == 2 && "twice" || - count == 3 && "thrice" || - (count || 0) + " times"; - }, - - calledInOrder: function (spies) { - for (var i = 1, l = spies.length; i < l; i++) { - if (!spies[i - 1].calledBefore(spies[i]) || !spies[i].called) { - return false; - } - } - - return true; - }, - - orderByFirstCall: function (spies) { - return spies.sort(function (a, b) { - // uuid, won't ever be equal - var aCall = a.getCall(0); - var bCall = b.getCall(0); - var aId = aCall && aCall.callId || -1; - var bId = bCall && bCall.callId || -1; - - return aId < bId ? -1 : 1; - }); - }, - - log: function () {}, - - logError: function (label, err) { - var msg = label + " threw exception: " - sinon.log(msg + "[" + err.name + "] " + err.message); - if (err.stack) { sinon.log(err.stack); } - - setTimeout(function () { - err.message = msg + err.message; - throw err; - }, 0); - }, - - typeOf: function (value) { - if (value === null) { - return "null"; - } - else if (value === undefined) { - return "undefined"; - } - var string = Object.prototype.toString.call(value); - return string.substring(8, string.length - 1).toLowerCase(); - }, - - createStubInstance: function (constructor) { - if (typeof constructor !== "function") { - throw new TypeError("The constructor should be a function."); - } - return sinon.stub(sinon.create(constructor.prototype)); - }, - - restore: function (object) { - if (object !== null && typeof object === "object") { - for (var prop in object) { - if (isRestorable(object[prop])) { - object[prop].restore(); - } - } - } - else if (isRestorable(object)) { - object.restore(); - } - } - }; - - var isNode = typeof module == "object" && typeof require == "function"; - - if (isNode) { - try { - buster = { format: require("buster-format") }; - } catch (e) {} - module.exports = sinon; - module.exports.spy = require("./sinon/spy"); - module.exports.spyCall = require("./sinon/call"); - module.exports.stub = require("./sinon/stub"); - module.exports.mock = require("./sinon/mock"); - module.exports.collection = require("./sinon/collection"); - module.exports.assert = require("./sinon/assert"); - module.exports.sandbox = require("./sinon/sandbox"); - module.exports.test = require("./sinon/test"); - module.exports.testCase = require("./sinon/test_case"); - module.exports.assert = require("./sinon/assert"); - module.exports.match = require("./sinon/match"); - } - - if (buster) { - var formatter = sinon.create(buster.format); - formatter.quoteStrings = false; - sinon.format = function () { - return formatter.ascii.apply(formatter, arguments); - }; - } else if (isNode) { - try { - var util = require("util"); - sinon.format = function (value) { - return typeof value == "object" && value.toString === Object.prototype.toString ? util.inspect(value) : value; - }; - } catch (e) { - /* Node, but no util module - would be very old, but better safe than - sorry */ - } - } - - return sinon; -}(typeof buster == "object" && buster)); - -/* @depend ../sinon.js */ -/*jslint eqeqeq: false, onevar: false, plusplus: false*/ -/*global module, require, sinon*/ -/** - * Match functions - * - * @author Maximilian Antoni (mail@maxantoni.de) - * @license BSD - * - * Copyright (c) 2012 Maximilian Antoni - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function assertType(value, type, name) { - var actual = sinon.typeOf(value); - if (actual !== type) { - throw new TypeError("Expected type of " + name + " to be " + - type + ", but was " + actual); - } - } - - var matcher = { - toString: function () { - return this.message; - } - }; - - function isMatcher(object) { - return matcher.isPrototypeOf(object); - } - - function matchObject(expectation, actual) { - if (actual === null || actual === undefined) { - return false; - } - for (var key in expectation) { - if (expectation.hasOwnProperty(key)) { - var exp = expectation[key]; - var act = actual[key]; - if (match.isMatcher(exp)) { - if (!exp.test(act)) { - return false; - } - } else if (sinon.typeOf(exp) === "object") { - if (!matchObject(exp, act)) { - return false; - } - } else if (!sinon.deepEqual(exp, act)) { - return false; - } - } - } - return true; - } - - matcher.or = function (m2) { - if (!isMatcher(m2)) { - throw new TypeError("Matcher expected"); - } - var m1 = this; - var or = sinon.create(matcher); - or.test = function (actual) { - return m1.test(actual) || m2.test(actual); - }; - or.message = m1.message + ".or(" + m2.message + ")"; - return or; - }; - - matcher.and = function (m2) { - if (!isMatcher(m2)) { - throw new TypeError("Matcher expected"); - } - var m1 = this; - var and = sinon.create(matcher); - and.test = function (actual) { - return m1.test(actual) && m2.test(actual); - }; - and.message = m1.message + ".and(" + m2.message + ")"; - return and; - }; - - var match = function (expectation, message) { - var m = sinon.create(matcher); - var type = sinon.typeOf(expectation); - switch (type) { - case "object": - if (typeof expectation.test === "function") { - m.test = function (actual) { - return expectation.test(actual) === true; - }; - m.message = "match(" + sinon.functionName(expectation.test) + ")"; - return m; - } - var str = []; - for (var key in expectation) { - if (expectation.hasOwnProperty(key)) { - str.push(key + ": " + expectation[key]); - } - } - m.test = function (actual) { - return matchObject(expectation, actual); - }; - m.message = "match(" + str.join(", ") + ")"; - break; - case "number": - m.test = function (actual) { - return expectation == actual; - }; - break; - case "string": - m.test = function (actual) { - if (typeof actual !== "string") { - return false; - } - return actual.indexOf(expectation) !== -1; - }; - m.message = "match(\"" + expectation + "\")"; - break; - case "regexp": - m.test = function (actual) { - if (typeof actual !== "string") { - return false; - } - return expectation.test(actual); - }; - break; - case "function": - m.test = expectation; - if (message) { - m.message = message; - } else { - m.message = "match(" + sinon.functionName(expectation) + ")"; - } - break; - default: - m.test = function (actual) { - return sinon.deepEqual(expectation, actual); - }; - } - if (!m.message) { - m.message = "match(" + expectation + ")"; - } - return m; - }; - - match.isMatcher = isMatcher; - - match.any = match(function () { - return true; - }, "any"); - - match.defined = match(function (actual) { - return actual !== null && actual !== undefined; - }, "defined"); - - match.truthy = match(function (actual) { - return !!actual; - }, "truthy"); - - match.falsy = match(function (actual) { - return !actual; - }, "falsy"); - - match.same = function (expectation) { - return match(function (actual) { - return expectation === actual; - }, "same(" + expectation + ")"); - }; - - match.typeOf = function (type) { - assertType(type, "string", "type"); - return match(function (actual) { - return sinon.typeOf(actual) === type; - }, "typeOf(\"" + type + "\")"); - }; - - match.instanceOf = function (type) { - assertType(type, "function", "type"); - return match(function (actual) { - return actual instanceof type; - }, "instanceOf(" + sinon.functionName(type) + ")"); - }; - - function createPropertyMatcher(propertyTest, messagePrefix) { - return function (property, value) { - assertType(property, "string", "property"); - var onlyProperty = arguments.length === 1; - var message = messagePrefix + "(\"" + property + "\""; - if (!onlyProperty) { - message += ", " + value; - } - message += ")"; - return match(function (actual) { - if (actual === undefined || actual === null || - !propertyTest(actual, property)) { - return false; - } - return onlyProperty || sinon.deepEqual(value, actual[property]); - }, message); - }; - } - - match.has = createPropertyMatcher(function (actual, property) { - if (typeof actual === "object") { - return property in actual; - } - return actual[property] !== undefined; - }, "has"); - - match.hasOwn = createPropertyMatcher(function (actual, property) { - return actual.hasOwnProperty(property); - }, "hasOwn"); - - match.bool = match.typeOf("boolean"); - match.number = match.typeOf("number"); - match.string = match.typeOf("string"); - match.object = match.typeOf("object"); - match.func = match.typeOf("function"); - match.array = match.typeOf("array"); - match.regexp = match.typeOf("regexp"); - match.date = match.typeOf("date"); - - if (commonJSModule) { - module.exports = match; - } else { - sinon.match = match; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend match.js - */ -/*jslint eqeqeq: false, onevar: false, plusplus: false*/ -/*global module, require, sinon*/ -/** - * Spy calls - * - * @author Christian Johansen (christian@cjohansen.no) - * @author Maximilian Antoni (mail@maxantoni.de) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - * Copyright (c) 2013 Maximilian Antoni - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function throwYieldError(proxy, text, args) { - var msg = sinon.functionName(proxy) + text; - if (args.length) { - msg += " Received [" + slice.call(args).join(", ") + "]"; - } - throw new Error(msg); - } - - var slice = Array.prototype.slice; - - var callProto = { - calledOn: function calledOn(thisValue) { - if (sinon.match && sinon.match.isMatcher(thisValue)) { - return thisValue.test(this.thisValue); - } - return this.thisValue === thisValue; - }, - - calledWith: function calledWith() { - for (var i = 0, l = arguments.length; i < l; i += 1) { - if (!sinon.deepEqual(arguments[i], this.args[i])) { - return false; - } - } - - return true; - }, - - calledWithMatch: function calledWithMatch() { - for (var i = 0, l = arguments.length; i < l; i += 1) { - var actual = this.args[i]; - var expectation = arguments[i]; - if (!sinon.match || !sinon.match(expectation).test(actual)) { - return false; - } - } - return true; - }, - - calledWithExactly: function calledWithExactly() { - return arguments.length == this.args.length && - this.calledWith.apply(this, arguments); - }, - - notCalledWith: function notCalledWith() { - return !this.calledWith.apply(this, arguments); - }, - - notCalledWithMatch: function notCalledWithMatch() { - return !this.calledWithMatch.apply(this, arguments); - }, - - returned: function returned(value) { - return sinon.deepEqual(value, this.returnValue); - }, - - threw: function threw(error) { - if (typeof error === "undefined" || !this.exception) { - return !!this.exception; - } - - return this.exception === error || this.exception.name === error; - }, - - calledWithNew: function calledWithNew(thisValue) { - return this.thisValue instanceof this.proxy; - }, - - calledBefore: function (other) { - return this.callId < other.callId; - }, - - calledAfter: function (other) { - return this.callId > other.callId; - }, - - callArg: function (pos) { - this.args[pos](); - }, - - callArgOn: function (pos, thisValue) { - this.args[pos].apply(thisValue); - }, - - callArgWith: function (pos) { - this.callArgOnWith.apply(this, [pos, null].concat(slice.call(arguments, 1))); - }, - - callArgOnWith: function (pos, thisValue) { - var args = slice.call(arguments, 2); - this.args[pos].apply(thisValue, args); - }, - - "yield": function () { - this.yieldOn.apply(this, [null].concat(slice.call(arguments, 0))); - }, - - yieldOn: function (thisValue) { - var args = this.args; - for (var i = 0, l = args.length; i < l; ++i) { - if (typeof args[i] === "function") { - args[i].apply(thisValue, slice.call(arguments, 1)); - return; - } - } - throwYieldError(this.proxy, " cannot yield since no callback was passed.", args); - }, - - yieldTo: function (prop) { - this.yieldToOn.apply(this, [prop, null].concat(slice.call(arguments, 1))); - }, - - yieldToOn: function (prop, thisValue) { - var args = this.args; - for (var i = 0, l = args.length; i < l; ++i) { - if (args[i] && typeof args[i][prop] === "function") { - args[i][prop].apply(thisValue, slice.call(arguments, 2)); - return; - } - } - throwYieldError(this.proxy, " cannot yield to '" + prop + - "' since no callback was passed.", args); - }, - - toString: function () { - var callStr = this.proxy.toString() + "("; - var args = []; - - for (var i = 0, l = this.args.length; i < l; ++i) { - args.push(sinon.format(this.args[i])); - } - - callStr = callStr + args.join(", ") + ")"; - - if (typeof this.returnValue != "undefined") { - callStr += " => " + sinon.format(this.returnValue); - } - - if (this.exception) { - callStr += " !" + this.exception.name; - - if (this.exception.message) { - callStr += "(" + this.exception.message + ")"; - } - } - - return callStr; - } - }; - - callProto.invokeCallback = callProto.yield; - - function createSpyCall(spy, thisValue, args, returnValue, exception, id) { - if (typeof id !== "number") { - throw new TypeError("Call id is not a number"); - } - var proxyCall = sinon.create(callProto); - proxyCall.proxy = spy; - proxyCall.thisValue = thisValue; - proxyCall.args = args; - proxyCall.returnValue = returnValue; - proxyCall.exception = exception; - proxyCall.callId = id; - - return proxyCall; - }; - createSpyCall.toString = callProto.toString; // used by mocks - - if (commonJSModule) { - module.exports = createSpyCall; - } else { - sinon.spyCall = createSpyCall; - } -}(typeof sinon == "object" && sinon || null)); - - -/** - * @depend ../sinon.js - * @depend call.js - */ -/*jslint eqeqeq: false, onevar: false, plusplus: false*/ -/*global module, require, sinon*/ -/** - * Spy functions - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - var push = Array.prototype.push; - var slice = Array.prototype.slice; - var callId = 0; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function spy(object, property) { - if (!property && typeof object == "function") { - return spy.create(object); - } - - if (!object && !property) { - return spy.create(function () { }); - } - - var method = object[property]; - return sinon.wrapMethod(object, property, spy.create(method)); - } - - function matchingFake(fakes, args, strict) { - if (!fakes) { - return; - } - - var alen = args.length; - - for (var i = 0, l = fakes.length; i < l; i++) { - if (fakes[i].matches(args, strict)) { - return fakes[i]; - } - } - } - - function incrementCallCount() { - this.called = true; - this.callCount += 1; - this.notCalled = false; - this.calledOnce = this.callCount == 1; - this.calledTwice = this.callCount == 2; - this.calledThrice = this.callCount == 3; - } - - function createCallProperties() { - this.firstCall = this.getCall(0); - this.secondCall = this.getCall(1); - this.thirdCall = this.getCall(2); - this.lastCall = this.getCall(this.callCount - 1); - } - - var vars = "a,b,c,d,e,f,g,h,i,j,k,l"; - function createProxy(func) { - // Retain the function length: - var p; - if (func.length) { - eval("p = (function proxy(" + vars.substring(0, func.length * 2 - 1) + - ") { return p.invoke(func, this, slice.call(arguments)); });"); - } - else { - p = function proxy() { - return p.invoke(func, this, slice.call(arguments)); - }; - } - return p; - } - - var uuid = 0; - - // Public API - var spyApi = { - reset: function () { - this.called = false; - this.notCalled = true; - this.calledOnce = false; - this.calledTwice = false; - this.calledThrice = false; - this.callCount = 0; - this.firstCall = null; - this.secondCall = null; - this.thirdCall = null; - this.lastCall = null; - this.args = []; - this.returnValues = []; - this.thisValues = []; - this.exceptions = []; - this.callIds = []; - if (this.fakes) { - for (var i = 0; i < this.fakes.length; i++) { - this.fakes[i].reset(); - } - } - }, - - create: function create(func) { - var name; - - if (typeof func != "function") { - func = function () { }; - } else { - name = sinon.functionName(func); - } - - var proxy = createProxy(func); - - sinon.extend(proxy, spy); - delete proxy.create; - sinon.extend(proxy, func); - - proxy.reset(); - proxy.prototype = func.prototype; - proxy.displayName = name || "spy"; - proxy.toString = sinon.functionToString; - proxy._create = sinon.spy.create; - proxy.id = "spy#" + uuid++; - - return proxy; - }, - - invoke: function invoke(func, thisValue, args) { - var matching = matchingFake(this.fakes, args); - var exception, returnValue; - - incrementCallCount.call(this); - push.call(this.thisValues, thisValue); - push.call(this.args, args); - push.call(this.callIds, callId++); - - try { - if (matching) { - returnValue = matching.invoke(func, thisValue, args); - } else { - returnValue = (this.func || func).apply(thisValue, args); - } - } catch (e) { - push.call(this.returnValues, undefined); - exception = e; - throw e; - } finally { - push.call(this.exceptions, exception); - } - - push.call(this.returnValues, returnValue); - - createCallProperties.call(this); - - return returnValue; - }, - - getCall: function getCall(i) { - if (i < 0 || i >= this.callCount) { - return null; - } - - return sinon.spyCall(this, this.thisValues[i], this.args[i], - this.returnValues[i], this.exceptions[i], - this.callIds[i]); - }, - - calledBefore: function calledBefore(spyFn) { - if (!this.called) { - return false; - } - - if (!spyFn.called) { - return true; - } - - return this.callIds[0] < spyFn.callIds[spyFn.callIds.length - 1]; - }, - - calledAfter: function calledAfter(spyFn) { - if (!this.called || !spyFn.called) { - return false; - } - - return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1]; - }, - - withArgs: function () { - var args = slice.call(arguments); - - if (this.fakes) { - var match = matchingFake(this.fakes, args, true); - - if (match) { - return match; - } - } else { - this.fakes = []; - } - - var original = this; - var fake = this._create(); - fake.matchingAguments = args; - push.call(this.fakes, fake); - - fake.withArgs = function () { - return original.withArgs.apply(original, arguments); - }; - - for (var i = 0; i < this.args.length; i++) { - if (fake.matches(this.args[i])) { - incrementCallCount.call(fake); - push.call(fake.thisValues, this.thisValues[i]); - push.call(fake.args, this.args[i]); - push.call(fake.returnValues, this.returnValues[i]); - push.call(fake.exceptions, this.exceptions[i]); - push.call(fake.callIds, this.callIds[i]); - } - } - createCallProperties.call(fake); - - return fake; - }, - - matches: function (args, strict) { - var margs = this.matchingAguments; - - if (margs.length <= args.length && - sinon.deepEqual(margs, args.slice(0, margs.length))) { - return !strict || margs.length == args.length; - } - }, - - printf: function (format) { - var spy = this; - var args = slice.call(arguments, 1); - var formatter; - - return (format || "").replace(/%(.)/g, function (match, specifyer) { - formatter = spyApi.formatters[specifyer]; - - if (typeof formatter == "function") { - return formatter.call(null, spy, args); - } else if (!isNaN(parseInt(specifyer), 10)) { - return sinon.format(args[specifyer - 1]); - } - - return "%" + specifyer; - }); - } - }; - - function delegateToCalls(method, matchAny, actual, notCalled) { - spyApi[method] = function () { - if (!this.called) { - if (notCalled) { - return notCalled.apply(this, arguments); - } - return false; - } - - var currentCall; - var matches = 0; - - for (var i = 0, l = this.callCount; i < l; i += 1) { - currentCall = this.getCall(i); - - if (currentCall[actual || method].apply(currentCall, arguments)) { - matches += 1; - - if (matchAny) { - return true; - } - } - } - - return matches === this.callCount; - }; - } - - delegateToCalls("calledOn", true); - delegateToCalls("alwaysCalledOn", false, "calledOn"); - delegateToCalls("calledWith", true); - delegateToCalls("calledWithMatch", true); - delegateToCalls("alwaysCalledWith", false, "calledWith"); - delegateToCalls("alwaysCalledWithMatch", false, "calledWithMatch"); - delegateToCalls("calledWithExactly", true); - delegateToCalls("alwaysCalledWithExactly", false, "calledWithExactly"); - delegateToCalls("neverCalledWith", false, "notCalledWith", - function () { return true; }); - delegateToCalls("neverCalledWithMatch", false, "notCalledWithMatch", - function () { return true; }); - delegateToCalls("threw", true); - delegateToCalls("alwaysThrew", false, "threw"); - delegateToCalls("returned", true); - delegateToCalls("alwaysReturned", false, "returned"); - delegateToCalls("calledWithNew", true); - delegateToCalls("alwaysCalledWithNew", false, "calledWithNew"); - delegateToCalls("callArg", false, "callArgWith", function () { - throw new Error(this.toString() + " cannot call arg since it was not yet invoked."); - }); - spyApi.callArgWith = spyApi.callArg; - delegateToCalls("callArgOn", false, "callArgOnWith", function () { - throw new Error(this.toString() + " cannot call arg since it was not yet invoked."); - }); - spyApi.callArgOnWith = spyApi.callArgOn; - delegateToCalls("yield", false, "yield", function () { - throw new Error(this.toString() + " cannot yield since it was not yet invoked."); - }); - // "invokeCallback" is an alias for "yield" since "yield" is invalid in strict mode. - spyApi.invokeCallback = spyApi.yield; - delegateToCalls("yieldOn", false, "yieldOn", function () { - throw new Error(this.toString() + " cannot yield since it was not yet invoked."); - }); - delegateToCalls("yieldTo", false, "yieldTo", function (property) { - throw new Error(this.toString() + " cannot yield to '" + property + - "' since it was not yet invoked."); - }); - delegateToCalls("yieldToOn", false, "yieldToOn", function (property) { - throw new Error(this.toString() + " cannot yield to '" + property + - "' since it was not yet invoked."); - }); - - spyApi.formatters = { - "c": function (spy) { - return sinon.timesInWords(spy.callCount); - }, - - "n": function (spy) { - return spy.toString(); - }, - - "C": function (spy) { - var calls = []; - - for (var i = 0, l = spy.callCount; i < l; ++i) { - var stringifiedCall = " " + spy.getCall(i).toString(); - if (/\n/.test(calls[i - 1])) { - stringifiedCall = "\n" + stringifiedCall; - } - push.call(calls, stringifiedCall); - } - - return calls.length > 0 ? "\n" + calls.join("\n") : ""; - }, - - "t": function (spy) { - var objects = []; - - for (var i = 0, l = spy.callCount; i < l; ++i) { - push.call(objects, sinon.format(spy.thisValues[i])); - } - - return objects.join(", "); - }, - - "*": function (spy, args) { - var formatted = []; - - for (var i = 0, l = args.length; i < l; ++i) { - push.call(formatted, sinon.format(args[i])); - } - - return formatted.join(", "); - } - }; - - sinon.extend(spy, spyApi); - - spy.spyCall = sinon.spyCall; - - if (commonJSModule) { - module.exports = spy; - } else { - sinon.spy = spy; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend spy.js - */ -/*jslint eqeqeq: false, onevar: false*/ -/*global module, require, sinon*/ -/** - * Stub functions - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function stub(object, property, func) { - if (!!func && typeof func != "function") { - throw new TypeError("Custom stub should be function"); - } - - var wrapper; - - if (func) { - wrapper = sinon.spy && sinon.spy.create ? sinon.spy.create(func) : func; - } else { - wrapper = stub.create(); - } - - if (!object && !property) { - return sinon.stub.create(); - } - - if (!property && !!object && typeof object == "object") { - for (var prop in object) { - if (typeof object[prop] === "function") { - stub(object, prop); - } - } - - return object; - } - - return sinon.wrapMethod(object, property, wrapper); - } - - function getChangingValue(stub, property) { - var index = stub.callCount - 1; - var values = stub[property]; - var prop = index in values ? values[index] : values[values.length - 1]; - stub[property + "Last"] = prop; - - return prop; - } - - function getCallback(stub, args) { - var callArgAt = getChangingValue(stub, "callArgAts"); - - if (callArgAt < 0) { - var callArgProp = getChangingValue(stub, "callArgProps"); - - for (var i = 0, l = args.length; i < l; ++i) { - if (!callArgProp && typeof args[i] == "function") { - return args[i]; - } - - if (callArgProp && args[i] && - typeof args[i][callArgProp] == "function") { - return args[i][callArgProp]; - } - } - - return null; - } - - return args[callArgAt]; - } - - var join = Array.prototype.join; - - function getCallbackError(stub, func, args) { - if (stub.callArgAtsLast < 0) { - var msg; - - if (stub.callArgPropsLast) { - msg = sinon.functionName(stub) + - " expected to yield to '" + stub.callArgPropsLast + - "', but no object with such a property was passed." - } else { - msg = sinon.functionName(stub) + - " expected to yield, but no callback was passed." - } - - if (args.length > 0) { - msg += " Received [" + join.call(args, ", ") + "]"; - } - - return msg; - } - - return "argument at index " + stub.callArgAtsLast + " is not a function: " + func; - } - - var nextTick = (function () { - if (typeof process === "object" && typeof process.nextTick === "function") { - return process.nextTick; - } else if (typeof setImmediate === "function") { - return setImmediate; - } else { - return function (callback) { - setTimeout(callback, 0); - }; - } - })(); - - function callCallback(stub, args) { - if (stub.callArgAts.length > 0) { - var func = getCallback(stub, args); - - if (typeof func != "function") { - throw new TypeError(getCallbackError(stub, func, args)); - } - - var callbackArguments = getChangingValue(stub, "callbackArguments"); - var callbackContext = getChangingValue(stub, "callbackContexts"); - - if (stub.callbackAsync) { - nextTick(function() { - func.apply(callbackContext, callbackArguments); - }); - } else { - func.apply(callbackContext, callbackArguments); - } - } - } - - var uuid = 0; - - sinon.extend(stub, (function () { - var slice = Array.prototype.slice, proto; - - function throwsException(error, message) { - if (typeof error == "string") { - this.exception = new Error(message || ""); - this.exception.name = error; - } else if (!error) { - this.exception = new Error("Error"); - } else { - this.exception = error; - } - - return this; - } - - proto = { - create: function create() { - var functionStub = function () { - - callCallback(functionStub, arguments); - - if (functionStub.exception) { - throw functionStub.exception; - } else if (typeof functionStub.returnArgAt == 'number') { - return arguments[functionStub.returnArgAt]; - } else if (functionStub.returnThis) { - return this; - } - return functionStub.returnValue; - }; - - functionStub.id = "stub#" + uuid++; - var orig = functionStub; - functionStub = sinon.spy.create(functionStub); - functionStub.func = orig; - - functionStub.callArgAts = []; - functionStub.callbackArguments = []; - functionStub.callbackContexts = []; - functionStub.callArgProps = []; - - sinon.extend(functionStub, stub); - functionStub._create = sinon.stub.create; - functionStub.displayName = "stub"; - functionStub.toString = sinon.functionToString; - - return functionStub; - }, - - resetBehavior: function () { - var i; - - this.callArgAts = []; - this.callbackArguments = []; - this.callbackContexts = []; - this.callArgProps = []; - - delete this.returnValue; - delete this.returnArgAt; - this.returnThis = false; - - if (this.fakes) { - for (i = 0; i < this.fakes.length; i++) { - this.fakes[i].resetBehavior(); - } - } - }, - - returns: function returns(value) { - this.returnValue = value; - - return this; - }, - - returnsArg: function returnsArg(pos) { - if (typeof pos != "number") { - throw new TypeError("argument index is not number"); - } - - this.returnArgAt = pos; - - return this; - }, - - returnsThis: function returnsThis() { - this.returnThis = true; - - return this; - }, - - "throws": throwsException, - throwsException: throwsException, - - callsArg: function callsArg(pos) { - if (typeof pos != "number") { - throw new TypeError("argument index is not number"); - } - - this.callArgAts.push(pos); - this.callbackArguments.push([]); - this.callbackContexts.push(undefined); - this.callArgProps.push(undefined); - - return this; - }, - - callsArgOn: function callsArgOn(pos, context) { - if (typeof pos != "number") { - throw new TypeError("argument index is not number"); - } - if (typeof context != "object") { - throw new TypeError("argument context is not an object"); - } - - this.callArgAts.push(pos); - this.callbackArguments.push([]); - this.callbackContexts.push(context); - this.callArgProps.push(undefined); - - return this; - }, - - callsArgWith: function callsArgWith(pos) { - if (typeof pos != "number") { - throw new TypeError("argument index is not number"); - } - - this.callArgAts.push(pos); - this.callbackArguments.push(slice.call(arguments, 1)); - this.callbackContexts.push(undefined); - this.callArgProps.push(undefined); - - return this; - }, - - callsArgOnWith: function callsArgWith(pos, context) { - if (typeof pos != "number") { - throw new TypeError("argument index is not number"); - } - if (typeof context != "object") { - throw new TypeError("argument context is not an object"); - } - - this.callArgAts.push(pos); - this.callbackArguments.push(slice.call(arguments, 2)); - this.callbackContexts.push(context); - this.callArgProps.push(undefined); - - return this; - }, - - yields: function () { - this.callArgAts.push(-1); - this.callbackArguments.push(slice.call(arguments, 0)); - this.callbackContexts.push(undefined); - this.callArgProps.push(undefined); - - return this; - }, - - yieldsOn: function (context) { - if (typeof context != "object") { - throw new TypeError("argument context is not an object"); - } - - this.callArgAts.push(-1); - this.callbackArguments.push(slice.call(arguments, 1)); - this.callbackContexts.push(context); - this.callArgProps.push(undefined); - - return this; - }, - - yieldsTo: function (prop) { - this.callArgAts.push(-1); - this.callbackArguments.push(slice.call(arguments, 1)); - this.callbackContexts.push(undefined); - this.callArgProps.push(prop); - - return this; - }, - - yieldsToOn: function (prop, context) { - if (typeof context != "object") { - throw new TypeError("argument context is not an object"); - } - - this.callArgAts.push(-1); - this.callbackArguments.push(slice.call(arguments, 2)); - this.callbackContexts.push(context); - this.callArgProps.push(prop); - - return this; - } - }; - - // create asynchronous versions of callsArg* and yields* methods - for (var method in proto) { - // need to avoid creating anotherasync versions of the newly added async methods - if (proto.hasOwnProperty(method) && - method.match(/^(callsArg|yields|thenYields$)/) && - !method.match(/Async/)) { - proto[method + 'Async'] = (function (syncFnName) { - return function () { - this.callbackAsync = true; - return this[syncFnName].apply(this, arguments); - }; - })(method); - } - } - - return proto; - - }())); - - if (commonJSModule) { - module.exports = stub; - } else { - sinon.stub = stub; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend stub.js - */ -/*jslint eqeqeq: false, onevar: false, nomen: false*/ -/*global module, require, sinon*/ -/** - * Mock functions. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - var push = [].push; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function mock(object) { - if (!object) { - return sinon.expectation.create("Anonymous mock"); - } - - return mock.create(object); - } - - sinon.mock = mock; - - sinon.extend(mock, (function () { - function each(collection, callback) { - if (!collection) { - return; - } - - for (var i = 0, l = collection.length; i < l; i += 1) { - callback(collection[i]); - } - } - - return { - create: function create(object) { - if (!object) { - throw new TypeError("object is null"); - } - - var mockObject = sinon.extend({}, mock); - mockObject.object = object; - delete mockObject.create; - - return mockObject; - }, - - expects: function expects(method) { - if (!method) { - throw new TypeError("method is falsy"); - } - - if (!this.expectations) { - this.expectations = {}; - this.proxies = []; - } - - if (!this.expectations[method]) { - this.expectations[method] = []; - var mockObject = this; - - sinon.wrapMethod(this.object, method, function () { - return mockObject.invokeMethod(method, this, arguments); - }); - - push.call(this.proxies, method); - } - - var expectation = sinon.expectation.create(method); - push.call(this.expectations[method], expectation); - - return expectation; - }, - - restore: function restore() { - var object = this.object; - - each(this.proxies, function (proxy) { - if (typeof object[proxy].restore == "function") { - object[proxy].restore(); - } - }); - }, - - verify: function verify() { - var expectations = this.expectations || {}; - var messages = [], met = []; - - each(this.proxies, function (proxy) { - each(expectations[proxy], function (expectation) { - if (!expectation.met()) { - push.call(messages, expectation.toString()); - } else { - push.call(met, expectation.toString()); - } - }); - }); - - this.restore(); - - if (messages.length > 0) { - sinon.expectation.fail(messages.concat(met).join("\n")); - } else { - sinon.expectation.pass(messages.concat(met).join("\n")); - } - - return true; - }, - - invokeMethod: function invokeMethod(method, thisValue, args) { - var expectations = this.expectations && this.expectations[method]; - var length = expectations && expectations.length || 0, i; - - for (i = 0; i < length; i += 1) { - if (!expectations[i].met() && - expectations[i].allowsCall(thisValue, args)) { - return expectations[i].apply(thisValue, args); - } - } - - var messages = [], available, exhausted = 0; - - for (i = 0; i < length; i += 1) { - if (expectations[i].allowsCall(thisValue, args)) { - available = available || expectations[i]; - } else { - exhausted += 1; - } - push.call(messages, " " + expectations[i].toString()); - } - - if (exhausted === 0) { - return available.apply(thisValue, args); - } - - messages.unshift("Unexpected call: " + sinon.spyCall.toString.call({ - proxy: method, - args: args - })); - - sinon.expectation.fail(messages.join("\n")); - } - }; - }())); - - var times = sinon.timesInWords; - - sinon.expectation = (function () { - var slice = Array.prototype.slice; - var _invoke = sinon.spy.invoke; - - function callCountInWords(callCount) { - if (callCount == 0) { - return "never called"; - } else { - return "called " + times(callCount); - } - } - - function expectedCallCountInWords(expectation) { - var min = expectation.minCalls; - var max = expectation.maxCalls; - - if (typeof min == "number" && typeof max == "number") { - var str = times(min); - - if (min != max) { - str = "at least " + str + " and at most " + times(max); - } - - return str; - } - - if (typeof min == "number") { - return "at least " + times(min); - } - - return "at most " + times(max); - } - - function receivedMinCalls(expectation) { - var hasMinLimit = typeof expectation.minCalls == "number"; - return !hasMinLimit || expectation.callCount >= expectation.minCalls; - } - - function receivedMaxCalls(expectation) { - if (typeof expectation.maxCalls != "number") { - return false; - } - - return expectation.callCount == expectation.maxCalls; - } - - return { - minCalls: 1, - maxCalls: 1, - - create: function create(methodName) { - var expectation = sinon.extend(sinon.stub.create(), sinon.expectation); - delete expectation.create; - expectation.method = methodName; - - return expectation; - }, - - invoke: function invoke(func, thisValue, args) { - this.verifyCallAllowed(thisValue, args); - - return _invoke.apply(this, arguments); - }, - - atLeast: function atLeast(num) { - if (typeof num != "number") { - throw new TypeError("'" + num + "' is not number"); - } - - if (!this.limitsSet) { - this.maxCalls = null; - this.limitsSet = true; - } - - this.minCalls = num; - - return this; - }, - - atMost: function atMost(num) { - if (typeof num != "number") { - throw new TypeError("'" + num + "' is not number"); - } - - if (!this.limitsSet) { - this.minCalls = null; - this.limitsSet = true; - } - - this.maxCalls = num; - - return this; - }, - - never: function never() { - return this.exactly(0); - }, - - once: function once() { - return this.exactly(1); - }, - - twice: function twice() { - return this.exactly(2); - }, - - thrice: function thrice() { - return this.exactly(3); - }, - - exactly: function exactly(num) { - if (typeof num != "number") { - throw new TypeError("'" + num + "' is not a number"); - } - - this.atLeast(num); - return this.atMost(num); - }, - - met: function met() { - return !this.failed && receivedMinCalls(this); - }, - - verifyCallAllowed: function verifyCallAllowed(thisValue, args) { - if (receivedMaxCalls(this)) { - this.failed = true; - sinon.expectation.fail(this.method + " already called " + times(this.maxCalls)); - } - - if ("expectedThis" in this && this.expectedThis !== thisValue) { - sinon.expectation.fail(this.method + " called with " + thisValue + " as thisValue, expected " + - this.expectedThis); - } - - if (!("expectedArguments" in this)) { - return; - } - - if (!args) { - sinon.expectation.fail(this.method + " received no arguments, expected " + - sinon.format(this.expectedArguments)); - } - - if (args.length < this.expectedArguments.length) { - sinon.expectation.fail(this.method + " received too few arguments (" + sinon.format(args) + - "), expected " + sinon.format(this.expectedArguments)); - } - - if (this.expectsExactArgCount && - args.length != this.expectedArguments.length) { - sinon.expectation.fail(this.method + " received too many arguments (" + sinon.format(args) + - "), expected " + sinon.format(this.expectedArguments)); - } - - for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) { - if (!sinon.deepEqual(this.expectedArguments[i], args[i])) { - sinon.expectation.fail(this.method + " received wrong arguments " + sinon.format(args) + - ", expected " + sinon.format(this.expectedArguments)); - } - } - }, - - allowsCall: function allowsCall(thisValue, args) { - if (this.met() && receivedMaxCalls(this)) { - return false; - } - - if ("expectedThis" in this && this.expectedThis !== thisValue) { - return false; - } - - if (!("expectedArguments" in this)) { - return true; - } - - args = args || []; - - if (args.length < this.expectedArguments.length) { - return false; - } - - if (this.expectsExactArgCount && - args.length != this.expectedArguments.length) { - return false; - } - - for (var i = 0, l = this.expectedArguments.length; i < l; i += 1) { - if (!sinon.deepEqual(this.expectedArguments[i], args[i])) { - return false; - } - } - - return true; - }, - - withArgs: function withArgs() { - this.expectedArguments = slice.call(arguments); - return this; - }, - - withExactArgs: function withExactArgs() { - this.withArgs.apply(this, arguments); - this.expectsExactArgCount = true; - return this; - }, - - on: function on(thisValue) { - this.expectedThis = thisValue; - return this; - }, - - toString: function () { - var args = (this.expectedArguments || []).slice(); - - if (!this.expectsExactArgCount) { - push.call(args, "[...]"); - } - - var callStr = sinon.spyCall.toString.call({ - proxy: this.method || "anonymous mock expectation", - args: args - }); - - var message = callStr.replace(", [...", "[, ...") + " " + - expectedCallCountInWords(this); - - if (this.met()) { - return "Expectation met: " + message; - } - - return "Expected " + message + " (" + - callCountInWords(this.callCount) + ")"; - }, - - verify: function verify() { - if (!this.met()) { - sinon.expectation.fail(this.toString()); - } else { - sinon.expectation.pass(this.toString()); - } - - return true; - }, - - pass: function(message) { - sinon.assert.pass(message); - }, - fail: function (message) { - var exception = new Error(message); - exception.name = "ExpectationError"; - - throw exception; - } - }; - }()); - - if (commonJSModule) { - module.exports = mock; - } else { - sinon.mock = mock; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend stub.js - * @depend mock.js - */ -/*jslint eqeqeq: false, onevar: false, forin: true*/ -/*global module, require, sinon*/ -/** - * Collections of stubs, spies and mocks. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - var push = [].push; - var hasOwnProperty = Object.prototype.hasOwnProperty; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function getFakes(fakeCollection) { - if (!fakeCollection.fakes) { - fakeCollection.fakes = []; - } - - return fakeCollection.fakes; - } - - function each(fakeCollection, method) { - var fakes = getFakes(fakeCollection); - - for (var i = 0, l = fakes.length; i < l; i += 1) { - if (typeof fakes[i][method] == "function") { - fakes[i][method](); - } - } - } - - function compact(fakeCollection) { - var fakes = getFakes(fakeCollection); - var i = 0; - while (i < fakes.length) { - fakes.splice(i, 1); - } - } - - var collection = { - verify: function resolve() { - each(this, "verify"); - }, - - restore: function restore() { - each(this, "restore"); - compact(this); - }, - - verifyAndRestore: function verifyAndRestore() { - var exception; - - try { - this.verify(); - } catch (e) { - exception = e; - } - - this.restore(); - - if (exception) { - throw exception; - } - }, - - add: function add(fake) { - push.call(getFakes(this), fake); - return fake; - }, - - spy: function spy() { - return this.add(sinon.spy.apply(sinon, arguments)); - }, - - stub: function stub(object, property, value) { - if (property) { - var original = object[property]; - - if (typeof original != "function") { - if (!hasOwnProperty.call(object, property)) { - throw new TypeError("Cannot stub non-existent own property " + property); - } - - object[property] = value; - - return this.add({ - restore: function () { - object[property] = original; - } - }); - } - } - if (!property && !!object && typeof object == "object") { - var stubbedObj = sinon.stub.apply(sinon, arguments); - - for (var prop in stubbedObj) { - if (typeof stubbedObj[prop] === "function") { - this.add(stubbedObj[prop]); - } - } - - return stubbedObj; - } - - return this.add(sinon.stub.apply(sinon, arguments)); - }, - - mock: function mock() { - return this.add(sinon.mock.apply(sinon, arguments)); - }, - - inject: function inject(obj) { - var col = this; - - obj.spy = function () { - return col.spy.apply(col, arguments); - }; - - obj.stub = function () { - return col.stub.apply(col, arguments); - }; - - obj.mock = function () { - return col.mock.apply(col, arguments); - }; - - return obj; - } - }; - - if (commonJSModule) { - module.exports = collection; - } else { - sinon.collection = collection; - } -}(typeof sinon == "object" && sinon || null)); - -/*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/ -/*global module, require, window*/ -/** - * Fake timer API - * setTimeout - * setInterval - * clearTimeout - * clearInterval - * tick - * reset - * Date - * - * Inspired by jsUnitMockTimeOut from JsUnit - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -if (typeof sinon == "undefined") { - var sinon = {}; -} - -(function (global) { - var id = 1; - - function addTimer(args, recurring) { - if (args.length === 0) { - throw new Error("Function requires at least 1 parameter"); - } - - var toId = id++; - var delay = args[1] || 0; - - if (!this.timeouts) { - this.timeouts = {}; - } - - this.timeouts[toId] = { - id: toId, - func: args[0], - callAt: this.now + delay, - invokeArgs: Array.prototype.slice.call(args, 2) - }; - - if (recurring === true) { - this.timeouts[toId].interval = delay; - } - - return toId; - } - - function parseTime(str) { - if (!str) { - return 0; - } - - var strings = str.split(":"); - var l = strings.length, i = l; - var ms = 0, parsed; - - if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) { - throw new Error("tick only understands numbers and 'h:m:s'"); - } - - while (i--) { - parsed = parseInt(strings[i], 10); - - if (parsed >= 60) { - throw new Error("Invalid time " + str); - } - - ms += parsed * Math.pow(60, (l - i - 1)); - } - - return ms * 1000; - } - - function createObject(object) { - var newObject; - - if (Object.create) { - newObject = Object.create(object); - } else { - var F = function () {}; - F.prototype = object; - newObject = new F(); - } - - newObject.Date.clock = newObject; - return newObject; - } - - sinon.clock = { - now: 0, - - create: function create(now) { - var clock = createObject(this); - - if (typeof now == "number") { - clock.now = now; - } - - if (!!now && typeof now == "object") { - throw new TypeError("now should be milliseconds since UNIX epoch"); - } - - return clock; - }, - - setTimeout: function setTimeout(callback, timeout) { - return addTimer.call(this, arguments, false); - }, - - clearTimeout: function clearTimeout(timerId) { - if (!this.timeouts) { - this.timeouts = []; - } - - if (timerId in this.timeouts) { - delete this.timeouts[timerId]; - } - }, - - setInterval: function setInterval(callback, timeout) { - return addTimer.call(this, arguments, true); - }, - - clearInterval: function clearInterval(timerId) { - this.clearTimeout(timerId); - }, - - tick: function tick(ms) { - ms = typeof ms == "number" ? ms : parseTime(ms); - var tickFrom = this.now, tickTo = this.now + ms, previous = this.now; - var timer = this.firstTimerInRange(tickFrom, tickTo); - - var firstException; - while (timer && tickFrom <= tickTo) { - if (this.timeouts[timer.id]) { - tickFrom = this.now = timer.callAt; - try { - this.callTimer(timer); - } catch (e) { - firstException = firstException || e; - } - } - - timer = this.firstTimerInRange(previous, tickTo); - previous = tickFrom; - } - - this.now = tickTo; - - if (firstException) { - throw firstException; - } - - return this.now; - }, - - firstTimerInRange: function (from, to) { - var timer, smallest, originalTimer; - - for (var id in this.timeouts) { - if (this.timeouts.hasOwnProperty(id)) { - if (this.timeouts[id].callAt < from || this.timeouts[id].callAt > to) { - continue; - } - - if (!smallest || this.timeouts[id].callAt < smallest) { - originalTimer = this.timeouts[id]; - smallest = this.timeouts[id].callAt; - - timer = { - func: this.timeouts[id].func, - callAt: this.timeouts[id].callAt, - interval: this.timeouts[id].interval, - id: this.timeouts[id].id, - invokeArgs: this.timeouts[id].invokeArgs - }; - } - } - } - - return timer || null; - }, - - callTimer: function (timer) { - if (typeof timer.interval == "number") { - this.timeouts[timer.id].callAt += timer.interval; - } else { - delete this.timeouts[timer.id]; - } - - try { - if (typeof timer.func == "function") { - timer.func.apply(null, timer.invokeArgs); - } else { - eval(timer.func); - } - } catch (e) { - var exception = e; - } - - if (!this.timeouts[timer.id]) { - if (exception) { - throw exception; - } - return; - } - - if (exception) { - throw exception; - } - }, - - reset: function reset() { - this.timeouts = {}; - }, - - Date: (function () { - var NativeDate = Date; - - function ClockDate(year, month, date, hour, minute, second, ms) { - // Defensive and verbose to avoid potential harm in passing - // explicit undefined when user does not pass argument - switch (arguments.length) { - case 0: - return new NativeDate(ClockDate.clock.now); - case 1: - return new NativeDate(year); - case 2: - return new NativeDate(year, month); - case 3: - return new NativeDate(year, month, date); - case 4: - return new NativeDate(year, month, date, hour); - case 5: - return new NativeDate(year, month, date, hour, minute); - case 6: - return new NativeDate(year, month, date, hour, minute, second); - default: - return new NativeDate(year, month, date, hour, minute, second, ms); - } - } - - return mirrorDateProperties(ClockDate, NativeDate); - }()) - }; - - function mirrorDateProperties(target, source) { - if (source.now) { - target.now = function now() { - return target.clock.now; - }; - } else { - delete target.now; - } - - if (source.toSource) { - target.toSource = function toSource() { - return source.toSource(); - }; - } else { - delete target.toSource; - } - - target.toString = function toString() { - return source.toString(); - }; - - target.prototype = source.prototype; - target.parse = source.parse; - target.UTC = source.UTC; - target.prototype.toUTCString = source.prototype.toUTCString; - return target; - } - - var methods = ["Date", "setTimeout", "setInterval", - "clearTimeout", "clearInterval"]; - - function restore() { - var method; - - for (var i = 0, l = this.methods.length; i < l; i++) { - method = this.methods[i]; - if (global[method].hadOwnProperty) { - global[method] = this["_" + method]; - } else { - delete global[method]; - } - } - - // Prevent multiple executions which will completely remove these props - this.methods = []; - } - - function stubGlobal(method, clock) { - clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(global, method); - clock["_" + method] = global[method]; - - if (method == "Date") { - var date = mirrorDateProperties(clock[method], global[method]); - global[method] = date; - } else { - global[method] = function () { - return clock[method].apply(clock, arguments); - }; - - for (var prop in clock[method]) { - if (clock[method].hasOwnProperty(prop)) { - global[method][prop] = clock[method][prop]; - } - } - } - - global[method].clock = clock; - } - - sinon.useFakeTimers = function useFakeTimers(now) { - var clock = sinon.clock.create(now); - clock.restore = restore; - clock.methods = Array.prototype.slice.call(arguments, - typeof now == "number" ? 1 : 0); - - if (clock.methods.length === 0) { - clock.methods = methods; - } - - for (var i = 0, l = clock.methods.length; i < l; i++) { - stubGlobal(clock.methods[i], clock); - } - - return clock; - }; -}(typeof global != "undefined" && typeof global !== "function" ? global : this)); - -sinon.timers = { - setTimeout: setTimeout, - clearTimeout: clearTimeout, - setInterval: setInterval, - clearInterval: clearInterval, - Date: Date -}; - -if (typeof module == "object" && typeof require == "function") { - module.exports = sinon; -} - -/*jslint eqeqeq: false, onevar: false*/ -/*global sinon, module, require, ActiveXObject, XMLHttpRequest, DOMParser*/ -/** - * Minimal Event interface implementation - * - * Original implementation by Sven Fuchs: https://gist.github.com/995028 - * Modifications and tests by Christian Johansen. - * - * @author Sven Fuchs (svenfuchs@artweb-design.de) - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2011 Sven Fuchs, Christian Johansen - */ - -if (typeof sinon == "undefined") { - this.sinon = {}; -} - -(function () { - var push = [].push; - - sinon.Event = function Event(type, bubbles, cancelable, target) { - this.initEvent(type, bubbles, cancelable, target); - }; - - sinon.Event.prototype = { - initEvent: function(type, bubbles, cancelable, target) { - this.type = type; - this.bubbles = bubbles; - this.cancelable = cancelable; - this.target = target; - }, - - stopPropagation: function () {}, - - preventDefault: function () { - this.defaultPrevented = true; - } - }; - - sinon.EventTarget = { - addEventListener: function addEventListener(event, listener, useCapture) { - this.eventListeners = this.eventListeners || {}; - this.eventListeners[event] = this.eventListeners[event] || []; - push.call(this.eventListeners[event], listener); - }, - - removeEventListener: function removeEventListener(event, listener, useCapture) { - var listeners = this.eventListeners && this.eventListeners[event] || []; - - for (var i = 0, l = listeners.length; i < l; ++i) { - if (listeners[i] == listener) { - return listeners.splice(i, 1); - } - } - }, - - dispatchEvent: function dispatchEvent(event) { - var type = event.type; - var listeners = this.eventListeners && this.eventListeners[type] || []; - - for (var i = 0; i < listeners.length; i++) { - if (typeof listeners[i] == "function") { - listeners[i].call(this, event); - } else { - listeners[i].handleEvent(event); - } - } - - return !!event.defaultPrevented; - } - }; -}()); - -/** - * @depend ../../sinon.js - * @depend event.js - */ -/*jslint eqeqeq: false, onevar: false*/ -/*global sinon, module, require, ActiveXObject, XMLHttpRequest, DOMParser*/ -/** - * Fake XMLHttpRequest object - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -if (typeof sinon == "undefined") { - this.sinon = {}; -} -sinon.xhr = { XMLHttpRequest: this.XMLHttpRequest }; - -// wrapper for global -(function(global) { - var xhr = sinon.xhr; - xhr.GlobalXMLHttpRequest = global.XMLHttpRequest; - xhr.GlobalActiveXObject = global.ActiveXObject; - xhr.supportsActiveX = typeof xhr.GlobalActiveXObject != "undefined"; - xhr.supportsXHR = typeof xhr.GlobalXMLHttpRequest != "undefined"; - xhr.workingXHR = xhr.supportsXHR ? xhr.GlobalXMLHttpRequest : xhr.supportsActiveX - ? function() { return new xhr.GlobalActiveXObject("MSXML2.XMLHTTP.3.0") } : false; - - /*jsl:ignore*/ - var unsafeHeaders = { - "Accept-Charset": true, - "Accept-Encoding": true, - "Connection": true, - "Content-Length": true, - "Cookie": true, - "Cookie2": true, - "Content-Transfer-Encoding": true, - "Date": true, - "Expect": true, - "Host": true, - "Keep-Alive": true, - "Referer": true, - "TE": true, - "Trailer": true, - "Transfer-Encoding": true, - "Upgrade": true, - "User-Agent": true, - "Via": true - }; - /*jsl:end*/ - - function FakeXMLHttpRequest() { - this.readyState = FakeXMLHttpRequest.UNSENT; - this.requestHeaders = {}; - this.requestBody = null; - this.status = 0; - this.statusText = ""; - - var xhr = this; - - ["loadstart", "load", "abort", "loadend"].forEach(function (eventName) { - xhr.addEventListener(eventName, function (event) { - var listener = xhr["on" + eventName]; - - if (listener && typeof listener == "function") { - listener(event); - } - }); - }); - - if (typeof FakeXMLHttpRequest.onCreate == "function") { - FakeXMLHttpRequest.onCreate(this); - } - } - - function verifyState(xhr) { - if (xhr.readyState !== FakeXMLHttpRequest.OPENED) { - throw new Error("INVALID_STATE_ERR"); - } - - if (xhr.sendFlag) { - throw new Error("INVALID_STATE_ERR"); - } - } - - // filtering to enable a white-list version of Sinon FakeXhr, - // where whitelisted requests are passed through to real XHR - function each(collection, callback) { - if (!collection) return; - for (var i = 0, l = collection.length; i < l; i += 1) { - callback(collection[i]); - } - } - function some(collection, callback) { - for (var index = 0; index < collection.length; index++) { - if(callback(collection[index]) === true) return true; - }; - return false; - } - // largest arity in XHR is 5 - XHR#open - var apply = function(obj,method,args) { - switch(args.length) { - case 0: return obj[method](); - case 1: return obj[method](args[0]); - case 2: return obj[method](args[0],args[1]); - case 3: return obj[method](args[0],args[1],args[2]); - case 4: return obj[method](args[0],args[1],args[2],args[3]); - case 5: return obj[method](args[0],args[1],args[2],args[3],args[4]); - }; - }; - - FakeXMLHttpRequest.filters = []; - FakeXMLHttpRequest.addFilter = function(fn) { - this.filters.push(fn) - }; - var IE6Re = /MSIE 6/; - FakeXMLHttpRequest.defake = function(fakeXhr,xhrArgs) { - var xhr = new sinon.xhr.workingXHR(); - each(["open","setRequestHeader","send","abort","getResponseHeader", - "getAllResponseHeaders","addEventListener","overrideMimeType","removeEventListener"], - function(method) { - fakeXhr[method] = function() { - return apply(xhr,method,arguments); - }; - }); - - var copyAttrs = function(args) { - each(args, function(attr) { - try { - fakeXhr[attr] = xhr[attr] - } catch(e) { - if(!IE6Re.test(navigator.userAgent)) throw e; - } - }); - }; - - var stateChange = function() { - fakeXhr.readyState = xhr.readyState; - if(xhr.readyState >= FakeXMLHttpRequest.HEADERS_RECEIVED) { - copyAttrs(["status","statusText"]); - } - if(xhr.readyState >= FakeXMLHttpRequest.LOADING) { - copyAttrs(["responseText"]); - } - if(xhr.readyState === FakeXMLHttpRequest.DONE) { - copyAttrs(["responseXML"]); - } - if(fakeXhr.onreadystatechange) fakeXhr.onreadystatechange.call(fakeXhr); - }; - if(xhr.addEventListener) { - for(var event in fakeXhr.eventListeners) { - if(fakeXhr.eventListeners.hasOwnProperty(event)) { - each(fakeXhr.eventListeners[event],function(handler) { - xhr.addEventListener(event, handler); - }); - } - } - xhr.addEventListener("readystatechange",stateChange); - } else { - xhr.onreadystatechange = stateChange; - } - apply(xhr,"open",xhrArgs); - }; - FakeXMLHttpRequest.useFilters = false; - - function verifyRequestSent(xhr) { - if (xhr.readyState == FakeXMLHttpRequest.DONE) { - throw new Error("Request done"); - } - } - - function verifyHeadersReceived(xhr) { - if (xhr.async && xhr.readyState != FakeXMLHttpRequest.HEADERS_RECEIVED) { - throw new Error("No headers received"); - } - } - - function verifyResponseBodyType(body) { - if (typeof body != "string") { - var error = new Error("Attempted to respond to fake XMLHttpRequest with " + - body + ", which is not a string."); - error.name = "InvalidBodyException"; - throw error; - } - } - - sinon.extend(FakeXMLHttpRequest.prototype, sinon.EventTarget, { - async: true, - - open: function open(method, url, async, username, password) { - this.method = method; - this.url = url; - this.async = typeof async == "boolean" ? async : true; - this.username = username; - this.password = password; - this.responseText = null; - this.responseXML = null; - this.requestHeaders = {}; - this.sendFlag = false; - if(sinon.FakeXMLHttpRequest.useFilters === true) { - var xhrArgs = arguments; - var defake = some(FakeXMLHttpRequest.filters,function(filter) { - return filter.apply(this,xhrArgs) - }); - if (defake) { - return sinon.FakeXMLHttpRequest.defake(this,arguments); - } - } - this.readyStateChange(FakeXMLHttpRequest.OPENED); - }, - - readyStateChange: function readyStateChange(state) { - this.readyState = state; - - if (typeof this.onreadystatechange == "function") { - try { - this.onreadystatechange(); - } catch (e) { - sinon.logError("Fake XHR onreadystatechange handler", e); - } - } - - this.dispatchEvent(new sinon.Event("readystatechange")); - - switch (this.readyState) { - case FakeXMLHttpRequest.DONE: - this.dispatchEvent(new sinon.Event("load", false, false, this)); - this.dispatchEvent(new sinon.Event("loadend", false, false, this)); - break; - } - }, - - setRequestHeader: function setRequestHeader(header, value) { - verifyState(this); - - if (unsafeHeaders[header] || /^(Sec-|Proxy-)/.test(header)) { - throw new Error("Refused to set unsafe header \"" + header + "\""); - } - - if (this.requestHeaders[header]) { - this.requestHeaders[header] += "," + value; - } else { - this.requestHeaders[header] = value; - } - }, - - // Helps testing - setResponseHeaders: function setResponseHeaders(headers) { - this.responseHeaders = {}; - - for (var header in headers) { - if (headers.hasOwnProperty(header)) { - this.responseHeaders[header] = headers[header]; - } - } - - if (this.async) { - this.readyStateChange(FakeXMLHttpRequest.HEADERS_RECEIVED); - } else { - this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED; - } - }, - - // Currently treats ALL data as a DOMString (i.e. no Document) - send: function send(data) { - verifyState(this); - - if (!/^(get|head)$/i.test(this.method)) { - if (this.requestHeaders["Content-Type"]) { - var value = this.requestHeaders["Content-Type"].split(";"); - this.requestHeaders["Content-Type"] = value[0] + ";charset=utf-8"; - } else { - this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8"; - } - - this.requestBody = data; - } - - this.errorFlag = false; - this.sendFlag = this.async; - this.readyStateChange(FakeXMLHttpRequest.OPENED); - - if (typeof this.onSend == "function") { - this.onSend(this); - } - - this.dispatchEvent(new sinon.Event("loadstart", false, false, this)); - }, - - abort: function abort() { - this.aborted = true; - this.responseText = null; - this.errorFlag = true; - this.requestHeaders = {}; - - if (this.readyState > sinon.FakeXMLHttpRequest.UNSENT && this.sendFlag) { - this.readyStateChange(sinon.FakeXMLHttpRequest.DONE); - this.sendFlag = false; - } - - this.readyState = sinon.FakeXMLHttpRequest.UNSENT; - - this.dispatchEvent(new sinon.Event("abort", false, false, this)); - if (typeof this.onerror === "function") { - this.onerror(); - } - }, - - getResponseHeader: function getResponseHeader(header) { - if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) { - return null; - } - - if (/^Set-Cookie2?$/i.test(header)) { - return null; - } - - header = header.toLowerCase(); - - for (var h in this.responseHeaders) { - if (h.toLowerCase() == header) { - return this.responseHeaders[h]; - } - } - - return null; - }, - - getAllResponseHeaders: function getAllResponseHeaders() { - if (this.readyState < FakeXMLHttpRequest.HEADERS_RECEIVED) { - return ""; - } - - var headers = ""; - - for (var header in this.responseHeaders) { - if (this.responseHeaders.hasOwnProperty(header) && - !/^Set-Cookie2?$/i.test(header)) { - headers += header + ": " + this.responseHeaders[header] + "\r\n"; - } - } - - return headers; - }, - - setResponseBody: function setResponseBody(body) { - verifyRequestSent(this); - verifyHeadersReceived(this); - verifyResponseBodyType(body); - - var chunkSize = this.chunkSize || 10; - var index = 0; - this.responseText = ""; - - do { - if (this.async) { - this.readyStateChange(FakeXMLHttpRequest.LOADING); - } - - this.responseText += body.substring(index, index + chunkSize); - index += chunkSize; - } while (index < body.length); - - var type = this.getResponseHeader("Content-Type"); - - if (this.responseText && - (!type || /(text\/xml)|(application\/xml)|(\+xml)/.test(type))) { - try { - this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText); - } catch (e) { - // Unable to parse XML - no biggie - } - } - - if (this.async) { - this.readyStateChange(FakeXMLHttpRequest.DONE); - } else { - this.readyState = FakeXMLHttpRequest.DONE; - } - }, - - respond: function respond(status, headers, body) { - this.setResponseHeaders(headers || {}); - this.status = typeof status == "number" ? status : 200; - this.statusText = FakeXMLHttpRequest.statusCodes[this.status]; - this.setResponseBody(body || ""); - if (typeof this.onload === "function"){ - this.onload(); - } - - } - }); - - sinon.extend(FakeXMLHttpRequest, { - UNSENT: 0, - OPENED: 1, - HEADERS_RECEIVED: 2, - LOADING: 3, - DONE: 4 - }); - - // Borrowed from JSpec - FakeXMLHttpRequest.parseXML = function parseXML(text) { - var xmlDoc; - - if (typeof DOMParser != "undefined") { - var parser = new DOMParser(); - xmlDoc = parser.parseFromString(text, "text/xml"); - } else { - xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); - xmlDoc.async = "false"; - xmlDoc.loadXML(text); - } - - return xmlDoc; - }; - - FakeXMLHttpRequest.statusCodes = { - 100: "Continue", - 101: "Switching Protocols", - 200: "OK", - 201: "Created", - 202: "Accepted", - 203: "Non-Authoritative Information", - 204: "No Content", - 205: "Reset Content", - 206: "Partial Content", - 300: "Multiple Choice", - 301: "Moved Permanently", - 302: "Found", - 303: "See Other", - 304: "Not Modified", - 305: "Use Proxy", - 307: "Temporary Redirect", - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Request Entity Too Large", - 414: "Request-URI Too Long", - 415: "Unsupported Media Type", - 416: "Requested Range Not Satisfiable", - 417: "Expectation Failed", - 422: "Unprocessable Entity", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported" - }; - - sinon.useFakeXMLHttpRequest = function () { - sinon.FakeXMLHttpRequest.restore = function restore(keepOnCreate) { - if (xhr.supportsXHR) { - global.XMLHttpRequest = xhr.GlobalXMLHttpRequest; - } - - if (xhr.supportsActiveX) { - global.ActiveXObject = xhr.GlobalActiveXObject; - } - - delete sinon.FakeXMLHttpRequest.restore; - - if (keepOnCreate !== true) { - delete sinon.FakeXMLHttpRequest.onCreate; - } - }; - if (xhr.supportsXHR) { - global.XMLHttpRequest = sinon.FakeXMLHttpRequest; - } - - if (xhr.supportsActiveX) { - global.ActiveXObject = function ActiveXObject(objId) { - if (objId == "Microsoft.XMLHTTP" || /^Msxml2\.XMLHTTP/i.test(objId)) { - - return new sinon.FakeXMLHttpRequest(); - } - - return new xhr.GlobalActiveXObject(objId); - }; - } - - return sinon.FakeXMLHttpRequest; - }; - - sinon.FakeXMLHttpRequest = FakeXMLHttpRequest; -})(this); - -if (typeof module == "object" && typeof require == "function") { - module.exports = sinon; -} - -/** - * @depend fake_xml_http_request.js - */ -/*jslint eqeqeq: false, onevar: false, regexp: false, plusplus: false*/ -/*global module, require, window*/ -/** - * The Sinon "server" mimics a web server that receives requests from - * sinon.FakeXMLHttpRequest and provides an API to respond to those requests, - * both synchronously and asynchronously. To respond synchronuously, canned - * answers have to be provided upfront. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -if (typeof sinon == "undefined") { - var sinon = {}; -} - -sinon.fakeServer = (function () { - var push = [].push; - function F() {} - - function create(proto) { - F.prototype = proto; - return new F(); - } - - function responseArray(handler) { - var response = handler; - - if (Object.prototype.toString.call(handler) != "[object Array]") { - response = [200, {}, handler]; - } - - if (typeof response[2] != "string") { - throw new TypeError("Fake server response body should be string, but was " + - typeof response[2]); - } - - return response; - } - - var wloc = typeof window !== "undefined" ? window.location : {}; - var rCurrLoc = new RegExp("^" + wloc.protocol + "//" + wloc.host); - - function matchOne(response, reqMethod, reqUrl) { - var rmeth = response.method; - var matchMethod = !rmeth || rmeth.toLowerCase() == reqMethod.toLowerCase(); - var url = response.url; - var matchUrl = !url || url == reqUrl || (typeof url.test == "function" && url.test(reqUrl)); - - return matchMethod && matchUrl; - } - - function match(response, request) { - var requestMethod = this.getHTTPMethod(request); - var requestUrl = request.url; - - if (!/^https?:\/\//.test(requestUrl) || rCurrLoc.test(requestUrl)) { - requestUrl = requestUrl.replace(rCurrLoc, ""); - } - - if (matchOne(response, this.getHTTPMethod(request), requestUrl)) { - if (typeof response.response == "function") { - var ru = response.url; - var args = [request].concat(!ru ? [] : requestUrl.match(ru).slice(1)); - return response.response.apply(response, args); - } - - return true; - } - - return false; - } - - function log(response, request) { - var str; - - str = "Request:\n" + sinon.format(request) + "\n\n"; - str += "Response:\n" + sinon.format(response) + "\n\n"; - - sinon.log(str); - } - - return { - create: function () { - var server = create(this); - this.xhr = sinon.useFakeXMLHttpRequest(); - server.requests = []; - - this.xhr.onCreate = function (xhrObj) { - server.addRequest(xhrObj); - }; - - return server; - }, - - addRequest: function addRequest(xhrObj) { - var server = this; - push.call(this.requests, xhrObj); - - xhrObj.onSend = function () { - server.handleRequest(this); - }; - - if (this.autoRespond && !this.responding) { - setTimeout(function () { - server.responding = false; - server.respond(); - }, this.autoRespondAfter || 10); - - this.responding = true; - } - }, - - getHTTPMethod: function getHTTPMethod(request) { - if (this.fakeHTTPMethods && /post/i.test(request.method)) { - var matches = (request.requestBody || "").match(/_method=([^\b;]+)/); - return !!matches ? matches[1] : request.method; - } - - return request.method; - }, - - handleRequest: function handleRequest(xhr) { - if (xhr.async) { - if (!this.queue) { - this.queue = []; - } - - push.call(this.queue, xhr); - } else { - this.processRequest(xhr); - } - }, - - respondWith: function respondWith(method, url, body) { - if (arguments.length == 1 && typeof method != "function") { - this.response = responseArray(method); - return; - } - - if (!this.responses) { this.responses = []; } - - if (arguments.length == 1) { - body = method; - url = method = null; - } - - if (arguments.length == 2) { - body = url; - url = method; - method = null; - } - - push.call(this.responses, { - method: method, - url: url, - response: typeof body == "function" ? body : responseArray(body) - }); - }, - - respond: function respond() { - if (arguments.length > 0) this.respondWith.apply(this, arguments); - var queue = this.queue || []; - var request; - - while(request = queue.shift()) { - this.processRequest(request); - } - }, - - processRequest: function processRequest(request) { - try { - if (request.aborted) { - return; - } - - var response = this.response || [404, {}, ""]; - - if (this.responses) { - for (var i = 0, l = this.responses.length; i < l; i++) { - if (match.call(this, this.responses[i], request)) { - response = this.responses[i].response; - break; - } - } - } - - if (request.readyState != 4) { - log(response, request); - - request.respond(response[0], response[1], response[2]); - } - } catch (e) { - sinon.logError("Fake server request processing", e); - } - }, - - restore: function restore() { - return this.xhr.restore && this.xhr.restore.apply(this.xhr, arguments); - } - }; -}()); - -if (typeof module == "object" && typeof require == "function") { - module.exports = sinon; -} - -/** - * @depend fake_server.js - * @depend fake_timers.js - */ -/*jslint browser: true, eqeqeq: false, onevar: false*/ -/*global sinon*/ -/** - * Add-on for sinon.fakeServer that automatically handles a fake timer along with - * the FakeXMLHttpRequest. The direct inspiration for this add-on is jQuery - * 1.3.x, which does not use xhr object's onreadystatehandler at all - instead, - * it polls the object for completion with setInterval. Dispite the direct - * motivation, there is nothing jQuery-specific in this file, so it can be used - * in any environment where the ajax implementation depends on setInterval or - * setTimeout. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function () { - function Server() {} - Server.prototype = sinon.fakeServer; - - sinon.fakeServerWithClock = new Server(); - - sinon.fakeServerWithClock.addRequest = function addRequest(xhr) { - if (xhr.async) { - if (typeof setTimeout.clock == "object") { - this.clock = setTimeout.clock; - } else { - this.clock = sinon.useFakeTimers(); - this.resetClock = true; - } - - if (!this.longestTimeout) { - var clockSetTimeout = this.clock.setTimeout; - var clockSetInterval = this.clock.setInterval; - var server = this; - - this.clock.setTimeout = function (fn, timeout) { - server.longestTimeout = Math.max(timeout, server.longestTimeout || 0); - - return clockSetTimeout.apply(this, arguments); - }; - - this.clock.setInterval = function (fn, timeout) { - server.longestTimeout = Math.max(timeout, server.longestTimeout || 0); - - return clockSetInterval.apply(this, arguments); - }; - } - } - - return sinon.fakeServer.addRequest.call(this, xhr); - }; - - sinon.fakeServerWithClock.respond = function respond() { - var returnVal = sinon.fakeServer.respond.apply(this, arguments); - - if (this.clock) { - this.clock.tick(this.longestTimeout || 0); - this.longestTimeout = 0; - - if (this.resetClock) { - this.clock.restore(); - this.resetClock = false; - } - } - - return returnVal; - }; - - sinon.fakeServerWithClock.restore = function restore() { - if (this.clock) { - this.clock.restore(); - } - - return sinon.fakeServer.restore.apply(this, arguments); - }; -}()); - -/** - * @depend ../sinon.js - * @depend collection.js - * @depend util/fake_timers.js - * @depend util/fake_server_with_clock.js - */ -/*jslint eqeqeq: false, onevar: false, plusplus: false*/ -/*global require, module*/ -/** - * Manages fake collections as well as fake utilities such as Sinon's - * timers and fake XHR implementation in one convenient object. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -if (typeof module == "object" && typeof require == "function") { - var sinon = require("../sinon"); - sinon.extend(sinon, require("./util/fake_timers")); -} - -(function () { - var push = [].push; - - function exposeValue(sandbox, config, key, value) { - if (!value) { - return; - } - - if (config.injectInto) { - config.injectInto[key] = value; - } else { - push.call(sandbox.args, value); - } - } - - function prepareSandboxFromConfig(config) { - var sandbox = sinon.create(sinon.sandbox); - - if (config.useFakeServer) { - if (typeof config.useFakeServer == "object") { - sandbox.serverPrototype = config.useFakeServer; - } - - sandbox.useFakeServer(); - } - - if (config.useFakeTimers) { - if (typeof config.useFakeTimers == "object") { - sandbox.useFakeTimers.apply(sandbox, config.useFakeTimers); - } else { - sandbox.useFakeTimers(); - } - } - - return sandbox; - } - - sinon.sandbox = sinon.extend(sinon.create(sinon.collection), { - useFakeTimers: function useFakeTimers() { - this.clock = sinon.useFakeTimers.apply(sinon, arguments); - - return this.add(this.clock); - }, - - serverPrototype: sinon.fakeServer, - - useFakeServer: function useFakeServer() { - var proto = this.serverPrototype || sinon.fakeServer; - - if (!proto || !proto.create) { - return null; - } - - this.server = proto.create(); - return this.add(this.server); - }, - - inject: function (obj) { - sinon.collection.inject.call(this, obj); - - if (this.clock) { - obj.clock = this.clock; - } - - if (this.server) { - obj.server = this.server; - obj.requests = this.server.requests; - } - - return obj; - }, - - create: function (config) { - if (!config) { - return sinon.create(sinon.sandbox); - } - - var sandbox = prepareSandboxFromConfig(config); - sandbox.args = sandbox.args || []; - var prop, value, exposed = sandbox.inject({}); - - if (config.properties) { - for (var i = 0, l = config.properties.length; i < l; i++) { - prop = config.properties[i]; - value = exposed[prop] || prop == "sandbox" && sandbox; - exposeValue(sandbox, config, prop, value); - } - } else { - exposeValue(sandbox, config, "sandbox", value); - } - - return sandbox; - } - }); - - sinon.sandbox.useFakeXMLHttpRequest = sinon.sandbox.useFakeServer; - - if (typeof module == "object" && typeof require == "function") { - module.exports = sinon.sandbox; - } -}()); - -/** - * @depend ../sinon.js - * @depend stub.js - * @depend mock.js - * @depend sandbox.js - */ -/*jslint eqeqeq: false, onevar: false, forin: true, plusplus: false*/ -/*global module, require, sinon*/ -/** - * Test function, sandboxes fakes - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function test(callback) { - var type = typeof callback; - - if (type != "function") { - throw new TypeError("sinon.test needs to wrap a test function, got " + type); - } - - return function () { - var config = sinon.getConfig(sinon.config); - config.injectInto = config.injectIntoThis && this || config.injectInto; - var sandbox = sinon.sandbox.create(config); - var exception, result; - var args = Array.prototype.slice.call(arguments).concat(sandbox.args); - - try { - result = callback.apply(this, args); - } catch (e) { - exception = e; - } - - if (typeof exception !== "undefined") { - sandbox.restore(); - throw exception; - } - else { - sandbox.verifyAndRestore(); - } - - return result; - }; - } - - test.config = { - injectIntoThis: true, - injectInto: null, - properties: ["spy", "stub", "mock", "clock", "server", "requests"], - useFakeTimers: true, - useFakeServer: true - }; - - if (commonJSModule) { - module.exports = test; - } else { - sinon.test = test; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend test.js - */ -/*jslint eqeqeq: false, onevar: false, eqeqeq: false*/ -/*global module, require, sinon*/ -/** - * Test case, sandboxes all test functions - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon || !Object.prototype.hasOwnProperty) { - return; - } - - function createTest(property, setUp, tearDown) { - return function () { - if (setUp) { - setUp.apply(this, arguments); - } - - var exception, result; - - try { - result = property.apply(this, arguments); - } catch (e) { - exception = e; - } - - if (tearDown) { - tearDown.apply(this, arguments); - } - - if (exception) { - throw exception; - } - - return result; - }; - } - - function testCase(tests, prefix) { - /*jsl:ignore*/ - if (!tests || typeof tests != "object") { - throw new TypeError("sinon.testCase needs an object with test functions"); - } - /*jsl:end*/ - - prefix = prefix || "test"; - var rPrefix = new RegExp("^" + prefix); - var methods = {}, testName, property, method; - var setUp = tests.setUp; - var tearDown = tests.tearDown; - - for (testName in tests) { - if (tests.hasOwnProperty(testName)) { - property = tests[testName]; - - if (/^(setUp|tearDown)$/.test(testName)) { - continue; - } - - if (typeof property == "function" && rPrefix.test(testName)) { - method = property; - - if (setUp || tearDown) { - method = createTest(property, setUp, tearDown); - } - - methods[testName] = sinon.test(method); - } else { - methods[testName] = tests[testName]; - } - } - } - - return methods; - } - - if (commonJSModule) { - module.exports = testCase; - } else { - sinon.testCase = testCase; - } -}(typeof sinon == "object" && sinon || null)); - -/** - * @depend ../sinon.js - * @depend stub.js - */ -/*jslint eqeqeq: false, onevar: false, nomen: false, plusplus: false*/ -/*global module, require, sinon*/ -/** - * Assertions matching the test spy retrieval interface. - * - * @author Christian Johansen (christian@cjohansen.no) - * @license BSD - * - * Copyright (c) 2010-2013 Christian Johansen - */ - -(function (sinon, global) { - var commonJSModule = typeof module == "object" && typeof require == "function"; - var slice = Array.prototype.slice; - var assert; - - if (!sinon && commonJSModule) { - sinon = require("../sinon"); - } - - if (!sinon) { - return; - } - - function verifyIsStub() { - var method; - - for (var i = 0, l = arguments.length; i < l; ++i) { - method = arguments[i]; - - if (!method) { - assert.fail("fake is not a spy"); - } - - if (typeof method != "function") { - assert.fail(method + " is not a function"); - } - - if (typeof method.getCall != "function") { - assert.fail(method + " is not stubbed"); - } - } - } - - function failAssertion(object, msg) { - object = object || global; - var failMethod = object.fail || assert.fail; - failMethod.call(object, msg); - } - - function mirrorPropAsAssertion(name, method, message) { - if (arguments.length == 2) { - message = method; - method = name; - } - - assert[name] = function (fake) { - verifyIsStub(fake); - - var args = slice.call(arguments, 1); - var failed = false; - - if (typeof method == "function") { - failed = !method(fake); - } else { - failed = typeof fake[method] == "function" ? - !fake[method].apply(fake, args) : !fake[method]; - } - - if (failed) { - failAssertion(this, fake.printf.apply(fake, [message].concat(args))); - } else { - assert.pass(name); - } - }; - } - - function exposedName(prefix, prop) { - return !prefix || /^fail/.test(prop) ? prop : - prefix + prop.slice(0, 1).toUpperCase() + prop.slice(1); - }; - - assert = { - failException: "AssertError", - - fail: function fail(message) { - var error = new Error(message); - error.name = this.failException || assert.failException; - - throw error; - }, - - pass: function pass(assertion) {}, - - callOrder: function assertCallOrder() { - verifyIsStub.apply(null, arguments); - var expected = "", actual = ""; - - if (!sinon.calledInOrder(arguments)) { - try { - expected = [].join.call(arguments, ", "); - var calls = slice.call(arguments); - var i = calls.length; - while (i) { - if (!calls[--i].called) { - calls.splice(i, 1); - } - } - actual = sinon.orderByFirstCall(calls).join(", "); - } catch (e) { - // If this fails, we'll just fall back to the blank string - } - - failAssertion(this, "expected " + expected + " to be " + - "called in order but were called as " + actual); - } else { - assert.pass("callOrder"); - } - }, - - callCount: function assertCallCount(method, count) { - verifyIsStub(method); - - if (method.callCount != count) { - var msg = "expected %n to be called " + sinon.timesInWords(count) + - " but was called %c%C"; - failAssertion(this, method.printf(msg)); - } else { - assert.pass("callCount"); - } - }, - - expose: function expose(target, options) { - if (!target) { - throw new TypeError("target is null or undefined"); - } - - var o = options || {}; - var prefix = typeof o.prefix == "undefined" && "assert" || o.prefix; - var includeFail = typeof o.includeFail == "undefined" || !!o.includeFail; - - for (var method in this) { - if (method != "export" && (includeFail || !/^(fail)/.test(method))) { - target[exposedName(prefix, method)] = this[method]; - } - } - - return target; - } - }; - - mirrorPropAsAssertion("called", "expected %n to have been called at least once but was never called"); - mirrorPropAsAssertion("notCalled", function (spy) { return !spy.called; }, - "expected %n to not have been called but was called %c%C"); - mirrorPropAsAssertion("calledOnce", "expected %n to be called once but was called %c%C"); - mirrorPropAsAssertion("calledTwice", "expected %n to be called twice but was called %c%C"); - mirrorPropAsAssertion("calledThrice", "expected %n to be called thrice but was called %c%C"); - mirrorPropAsAssertion("calledOn", "expected %n to be called with %1 as this but was called with %t"); - mirrorPropAsAssertion("alwaysCalledOn", "expected %n to always be called with %1 as this but was called with %t"); - mirrorPropAsAssertion("calledWithNew", "expected %n to be called with new"); - mirrorPropAsAssertion("alwaysCalledWithNew", "expected %n to always be called with new"); - mirrorPropAsAssertion("calledWith", "expected %n to be called with arguments %*%C"); - mirrorPropAsAssertion("calledWithMatch", "expected %n to be called with match %*%C"); - mirrorPropAsAssertion("alwaysCalledWith", "expected %n to always be called with arguments %*%C"); - mirrorPropAsAssertion("alwaysCalledWithMatch", "expected %n to always be called with match %*%C"); - mirrorPropAsAssertion("calledWithExactly", "expected %n to be called with exact arguments %*%C"); - mirrorPropAsAssertion("alwaysCalledWithExactly", "expected %n to always be called with exact arguments %*%C"); - mirrorPropAsAssertion("neverCalledWith", "expected %n to never be called with arguments %*%C"); - mirrorPropAsAssertion("neverCalledWithMatch", "expected %n to never be called with match %*%C"); - mirrorPropAsAssertion("threw", "%n did not throw exception%C"); - mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C"); - - if (commonJSModule) { - module.exports = assert; - } else { - sinon.assert = assert; - } -}(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global)); - -return sinon;}.call(typeof window != 'undefined' && window || {})); diff --git a/tests/libs/sinon-chai-2.4.0.js b/tests/libs/sinon-chai-2.4.0.js deleted file mode 100644 index 26cee36a..00000000 --- a/tests/libs/sinon-chai-2.4.0.js +++ /dev/null @@ -1,109 +0,0 @@ -(function (sinonChai) { - "use strict"; - - // Module systems magic dance. - - if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { - // NodeJS - module.exports = sinonChai; - } else if (typeof define === "function" && define.amd) { - // AMD - define(function () { - return sinonChai; - }); - } else { - // Other environment (usually - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From c1d6c14291d3c3bfc9a5894db7c2cd96799e2fd5 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 11:26:40 -0400 Subject: [PATCH 074/153] Update test formatting to be consistent --- test/language/haskell-test.js | 203 ++++++++++++++++++++++--------- test/language/html-test.js | 152 +++++++++++------------ test/language/java-test.js | 61 +++++++++- test/language/javascript-test.js | 141 ++++++++++----------- test/language/json-test.js | 46 ++++--- test/language/php-test.js | 113 ++++++++--------- test/language/python-test.js | 131 ++++++++++---------- test/language/r-test.js | 113 ++++++++--------- test/language/ruby-test.js | 28 +++-- 9 files changed, 577 insertions(+), 411 deletions(-) diff --git a/test/language/haskell-test.js b/test/language/haskell-test.js index ec7af3ca..04d85217 100644 --- a/test/language/haskell-test.js +++ b/test/language/haskell-test.js @@ -1,3 +1,4 @@ +import '../../src/language/generic'; import '../../src/language/haskell'; import { run } from '../helper'; @@ -9,154 +10,244 @@ const language = 'haskell'; describe(language, () => { run( language, + '-- comments', + '-- fn2 :: String -> [String]', + '-- fn2 :: String -> [String]' ); run( language, + '{-- comments --}', + '{-- this is a comment --}', + '{-- this is a comment --}' ); run( language, '{-- comments with multiple lines --}', - '{--\n' + - ' this is a comment\n' + - '--}', - '{--\n this is a comment\n--}' + + `{-- + this is a comment + --}`, + + `{-- + this is a comment + --}` ); run( language, + 'module declaration', + 'module A where', + 'module A where' ); run( language, + 'module with exported functions and comments', - 'module A (\n' + - ' B,\n' + - ' C(..),\n' + - ' fn1,\n' + - ' fn2, -- fn2 :: String -> [String]\n' + - ' fn3\n' + - ') where', - 'module A (\n B,\n C(..),\n fn1,\n fn2, -- fn2 :: String -> [String]\n fn3\n) where' + + `module A ( + B, + C(..), + fn1, + fn2, -- fn2 :: String -> [String] + fn3 + ) where`, + + `module A ( + B, + C(..), + fn1, + fn2, -- fn2 :: String -> [String] + fn3 + ) where` ); run( language, + 'import', - 'import Data.List qualified DL\n' + - 'import Prelude hiding ((*))', - 'import Data.List qualified DL\nimport Prelude hiding ((*))' + + `import Data.List qualified DL + import Prelude hiding ((*))`, + + `import Data.List qualified DL + import Prelude hiding ((*))` ); run( language, + 'function declaration', + 'fn :: String -> [(String,Int)]', + 'fn :: String -> [(String,Int)]' ); run( language, + 'IO function declaration', - 'getLine :: IO String\n' + - 'getLine = do c <- getChar\n' + - ' if c == \'\\n\' then return ""\n' + - ' else do s <- getLine\n' + - ' return (c:s)', - 'getLine :: IO String\ngetLine = do c <- getChar\n if c == \'\\n\' then return ""\n else do s <- getLine\n return (c:s)' + + `getLine :: IO String + getLine = do c <- getChar + if c == '\\n' then return "" + else do s <- getLine + return (c:s)`, + + `getLine :: IO String + getLine = do c <- getChar + if c == '\\n' then return "" + else do s <- getLine + return (c:s)` ); run( language, + 'infix declaration', + 'infix 4 >*', + 'infix 4 >*' ); run( language, + 'let declaration', - 'let a\' = s :: String\n' + - 'in a\' \"some string\"', - 'let a\' = s :: String\nin a\' "some string"' + + `let a' = s :: String + in a' \"some string\"`, + + `let a' = s :: String + in a' "some string"` ); run( language, + 'if declaration', - 'if a == 0\n' + - 'then A\n' + - 'else B', - 'if a == 0\nthen A\nelse B' + + `if a == 0 + then A + else B`, + + `if a == 0 + then A + else B` ); run( language, + 'data types decaration', - 'data S = S1 { x :: Int }\n' + - ' | S2 { x :: Int }\n' + - ' deriving (Show, Eq)\n\n' + - 'newtype NString = [String]\n\n' + - 'type String = [Char]', - 'data S = S1 { x :: Int }\n | S2 { x :: Int }\n deriving (Show, Eq)\n\nnewtype NString = [String]\n\ntype String = [Char]' + + `data S = S1 { x :: Int } + | S2 { x :: Int } + deriving (Show, Eq) + + newtype NString = [String] + + type String = [Char]`, + + `data S = S1 { x :: Int } + | S2 { x :: Int } + deriving (Show, Eq) + + newtype NString = [String] + + type String = [Char]` ); run( language, + 'classes', - 'class Eq a where\n' + - ' (==), (/=) :: a -> a -> Bool\n\n' + - ' x /= y = not (x == y)\n' + - ' x == y = not (x /= y)', - 'class Eq a where\n (==), (/=) :: a -> a -> Bool\n\n x /= y = not (x == y)\n x == y = not (x /= y)' + + `class Eq a where + (==), (/=) :: a -> a -> Bool + + x /= y = not (x == y) + x == y = not (x /= y)`, + + `class Eq a where + (==), (/=) :: a -> a -> Bool + + x /= y = not (x == y) + x == y = not (x /= y)` ); run( language, + 'instances', - 'instance Monad IO where\n' + - ' fail s = ioError (userError s)', - 'instance Monad IO where\n fail s = ioError (userError s)' + + `instance Monad IO where + fail s = ioError (userError s)`, + + `instance Monad IO where + fail s = ioError (userError s)` ); run( language, + 'list comprehensions', + '[ x | x <- x, x <- x ]', + '[ x | x <- x, x <- x ]' ); run( language, + 'case statement', - 'case e of\n' + - ' A -> Just a\n' + - ' _ -> Nothing', - 'case e of\n A -> Just a\n _ -> Nothing' + + `case e of + A -> Just a + _ -> Nothing`, + + `case e of + A -> Just a + _ -> Nothing` ); run( language, + 'C Preprocessors', - '#ifndef __NHC__\n' + - 'exitWith :: ExitCode -> IO a\n' + - 'exitWith ExitSuccess = throwIO ExitSuccess\n' + - 'exitWith code@(ExitFailure n)\n' + - ' | n /= 0 = throwIO code\n' + - '#ifdef __GLASGOW_HASKELL__\n' + - ' | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)\n' + - '#endif\n' + - '#endif /* ! __NHC__ */', - '#ifndef __NHC__\nexitWith :: ExitCode -> IO a\nexitWith ExitSuccess = throwIO ExitSuccess\nexitWith code@(ExitFailure n)\n | n /= 0 = throwIO code\n#ifdef __GLASGOW_HASKELL__\n | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)\n#endif\n#endif /* ! __NHC__ */' + +`#ifndef __NHC__ +exitWith :: ExitCode -> IO a +exitWith ExitSuccess = throwIO ExitSuccess +exitWith code@(ExitFailure n) + | n /= 0 = throwIO code +#ifdef __GLASGOW_HASKELL__ + | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing) +#endif +#endif /* ! __NHC__ */`, + +`#ifndef __NHC__ +exitWith :: ExitCode -> IO a +exitWith ExitSuccess = throwIO ExitSuccess +exitWith code@(ExitFailure n) + | n /= 0 = throwIO code +#ifdef __GLASGOW_HASKELL__ + | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing) +#endif +#endif /* ! __NHC__ */` ); }); diff --git a/test/language/html-test.js b/test/language/html-test.js index d79a0298..92e2cab4 100644 --- a/test/language/html-test.js +++ b/test/language/html-test.js @@ -1,5 +1,7 @@ +import '../../src/language/generic'; import '../../src/language/javascript'; import '../../src/language/php'; +import '../../src/language/css'; import '../../src/language/html'; import { run } from '../helper'; @@ -25,11 +27,11 @@ describe(language, () => { 'multi-line comment', - '', + ``, - '<!-- this is a comment\n' + - 'on two lines -->' + `<!-- this is a comment + on two lines -->` ); @@ -49,17 +51,17 @@ describe(language, () => { 'inline php', - '
      \n' + - ' \n' + - '
    • title; ?>
    • \n' + - ' \n' + - '
    ', + `
      + +
    • title; ?>
    • + +
    `, - '<ul class="articles">\n' + - ' <?php foreach ($articles as $article): ?>\n' + - ' <li><?php echo $article->title; ?></li>\n' + - ' <?php endforeach; ?>\n' + - '</ul>' + `<ul class="articles"> + <?php foreach ($articles as $article): ?> + <li><?php echo $article->title; ?></li> + <?php endforeach; ?> + </ul>` ); run( @@ -67,13 +69,13 @@ describe(language, () => { 'php short tag', - '<? foreach ($users as $key => $user): ?>\n' + - '

    <?= $user->getBio() ?>

    \n' + - '<? endforeach ?>', + `<? foreach ($users as $key => $user): ?> +

    <?= $user->getBio() ?>

    + <? endforeach ?>`, - '<? foreach ($users as $key => $user): ?>\n' + - ' <p><?= $user->getBio() ?></p>\n' + - '<? endforeach ?>' + `<? foreach ($users as $key => $user): ?> + <p><?= $user->getBio() ?></p> + <? endforeach ?>` ); run( @@ -92,19 +94,19 @@ describe(language, () => { 'inline css 1', - '', + ``, - '<style type="text/css">\n' + - ' body span.blah {\n' + - ' background: #000;\n' + - ' color: #fff;\n' + - ' }\n' + - '</style>' + `<style type="text/css"> + body span.blah { + background: #000; + color: #fff; + } + </style>` ); @@ -113,19 +115,19 @@ describe(language, () => { 'inline css 2', - '', + ``, - '<style>\n' + - ' body span.blah {\n' + - ' background: #000;\n' + - ' color: #fff;\n' + - ' }\n' + - '</style>' + `<style> + body span.blah { + background: #000; + color: #fff; + } + </style>` ); @@ -134,17 +136,17 @@ describe(language, () => { 'inline js 1', - '', + ``, - '<script type="text/javascript">\n' + - ' function prettyCool() {\n' + - ' doSomeJQueryOrWhatever();\n' + - ' }\n' + - '</script>' + `<script type="text/javascript"> + function prettyCool() { + doSomeJQueryOrWhatever(); + } + </script>` ); @@ -153,17 +155,17 @@ describe(language, () => { 'inline js 2', - '', + ``, - '<script>\n' + - ' function prettyCool() {\n' + - ' doSomeJQueryOrWhatever();\n' + - ' }\n' + - '</script>' + `<script> + function prettyCool() { + doSomeJQueryOrWhatever(); + } + </script>` ); @@ -232,16 +234,16 @@ describe(language, () => { 'string inside tags', - '
    def openFile(path):\n' +
    -        'file = open(path, "r")\n' +
    -        'content = file.read()\n' +
    -        'file.close()\n' +
    -        'return content
    ', - - '<pre><code data-language="python">def openFile(path):\n' + - 'file = open(path, "r")\n' + - 'content = file.read()\n' + - 'file.close()\n' + - 'return content</code></pre>' + `
    def openFile(path):
    +        file = open(path, "r")
    +        content = file.read()
    +        file.close()
    +        return content
    `, + + `<pre><code data-language="python">def openFile(path): + file = open(path, "r") + content = file.read() + file.close() + return content</code></pre>` ); }); diff --git a/test/language/java-test.js b/test/language/java-test.js index 73c2a988..46bdd1a9 100644 --- a/test/language/java-test.js +++ b/test/language/java-test.js @@ -9,106 +9,155 @@ const language = 'java'; describe(language, () => { run( language, - "package declaration", + + 'package declaration', + 'package com.example.rainbow;', + 'package com.example.rainbow;' ); run( language, + "import statement", + 'import com.example.rainbow.util.RainbowUtil;', + 'import com.example.rainbow.util.RainbowUtil;' ); run( language, - "multi-line comment", - '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */', - '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */' + + 'multi-line comment', + + `/** + * This is a Javadoc style comment. It is pretty awesome. + */`, + + `/** + * This is a Javadoc style comment. It is pretty awesome. + */` ); run( language, - "single-line comment", + + 'single-line comment', + '// This is a good comment.', + '// This is a good comment.' ); run( language, - "complicated class declaration", + + 'complicated class declaration', + 'public class Rainbow> extends Spectrum implements HasColors, IsPretty {', + 'public class Rainbow<T, List<? extends T>> extends Spectrum implements HasColors, IsPretty {' ); run( language, + "simple class declaration", + 'public class Rainbow {', + 'public class Rainbow {' ); run( language, + "constant declaration", + 'private static final int RESOLUTION = 7;', + 'private static final int RESOLUTION = 7;' ); run( language, + "field declaration", + 'private final String name;', + 'private final String name;' ); run( language, + "method declaration", + 'public void shine() {', + 'public void shine() {' ); run( language, + "simple annotation", + '@Override', + '@Override' ); run( language, + "complex annotation", + '@RequestMapping( value = "/rainbow", method = Method.POST )', + '@RequestMapping( value = "/rainbow", method = Method.POST )' ); run( language, + "string concatenation", + '"I found " + numberOfTurtles + " turtles."', + '"I found " + numberOfTurtles + " turtles."' ); run( language, + "local method invocation", + 'wait(1000L)', + 'wait(1000L)' ); run( language, + "static method invocation", + 'System.out.println("Hello, world!");', + 'System.out.println("Hello, world!");' ); run( language, + "variable assignment", + 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );', + 'int numberOfColors = (int) Math.ceil( Math.random() * 256 );' ); }); diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js index fd6bf284..c3198bd3 100644 --- a/test/language/javascript-test.js +++ b/test/language/javascript-test.js @@ -1,3 +1,4 @@ +import '../../src/language/generic'; import '../../src/language/javascript'; import { run } from '../helper'; @@ -102,15 +103,15 @@ describe(language, () => { 'inline function', - 'var foo = true,\n' + - ' something = function() {\n' + - ' // do something\n' + - ' };', + `var foo = true, + something = function() { + // do something + };`, - 'var foo = true,\n' + - ' something = function() {\n' + - ' // do something\n' + - ' };' + `var foo = true, + something = function() { + // do something + };` ); run( @@ -118,13 +119,13 @@ describe(language, () => { 'inline function beginning of line', - 'something = function() {\n' + - ' // do something\n' + - '};', + `something = function() { + // do something + };`, - 'something = function() {\n' + - ' // do something\n' + - '};' + `something = function() { + // do something + };` ); run( @@ -132,21 +133,21 @@ describe(language, () => { 'functions in object', - 'window.Rainbow = {\n' + - ' color: function() {\n' + - ' // do something\n' + - ' },\n' + - '\n' + - ' other: function() {}\n' + - '};', + `window.Rainbow = { + color: function() { + // do something + }, - 'window.Rainbow = {\n' + - ' color: function() {\n' + - ' // do something\n' + - ' },\n' + - '\n' + - ' other: function() {}\n' + - '};' + other: function() {} + };`, + + `window.Rainbow = { + color: function() { + // do something + }, + + other: function() {} + };` ); run( @@ -154,25 +155,25 @@ describe(language, () => { 'JSON 1', - '{\n' + - ' "generated_in": "0.0423",\n' + - ' "stat": "fail"\n' + - ' "err": {\n' + - ' "code": "1",\n' + - ' "expl": "The user id or name was either not valid or not provided.",\n' + - ' "msg": "User not found"\n' + - ' }\n' + - '}', + `{ + "generated_in": "0.0423", + "stat": "fail" + "err": { + "code": "1", + "expl": "The user id or name was either not valid or not provided.", + "msg": "User not found" + } + }`, - '{\n' + - ' "generated_in": "0.0423",\n' + - ' "stat": "fail"\n' + - ' "err": {\n' + - ' "code": "1",\n' + - ' "expl": "The user id or name was either not valid or not provided.",\n' + - ' "msg": "User not found"\n' + - ' }\n' + - '}' + `{ + "generated_in": "0.0423", + "stat": "fail" + "err": { + "code": "1", + "expl": "The user id or name was either not valid or not provided.", + "msg": "User not found" + } + }` ); run( @@ -180,25 +181,25 @@ describe(language, () => { 'JSON 2', - '{\n' + - ' "generated_in":"0.0423",\n' + - ' "stat":"fail"\n' + - ' "err":{\n' + - ' "code":"1",\n' + - ' "expl":"The user id or name was either not valid or not provided.",\n' + - ' "msg":"User not found"\n' + - ' }\n' + - '}', + `{ + "generated_in":"0.0423", + "stat":"fail" + "err":{ + "code":"1", + "expl":"The user id or name was either not valid or not provided.", + "msg":"User not found" + } + }`, - '{\n' + - ' "generated_in":"0.0423",\n' + - ' "stat":"fail"\n' + - ' "err":{\n' + - ' "code":"1",\n' + - ' "expl":"The user id or name was either not valid or not provided.",\n' + - ' "msg":"User not found"\n' + - ' }\n' + - '}' + `{ + "generated_in":"0.0423", + "stat":"fail" + "err":{ + "code":"1", + "expl":"The user id or name was either not valid or not provided.", + "msg":"User not found" + } + }` ); run( @@ -206,13 +207,13 @@ describe(language, () => { 'multiple var declarations', - 'var language = getLanguage(source);\n' + - 'var parseAndHighlight = function() {};\n' + - 'var parseAndHighlight2 = function() {};', + `var language = getLanguage(source); + var parseAndHighlight = function() {}; + var parseAndHighlight2 = function() {};`, - 'var language = getLanguage(source);\n' + - 'var parseAndHighlight = function() {};\n' + - 'var parseAndHighlight2 = function() {};' + `var language = getLanguage(source); + var parseAndHighlight = function() {}; + var parseAndHighlight2 = function() {};` ); run( diff --git a/test/language/json-test.js b/test/language/json-test.js index 145d6a04..bb3617e3 100644 --- a/test/language/json-test.js +++ b/test/language/json-test.js @@ -12,22 +12,36 @@ describe(language, () => { 'json string', - '{\n' + - ' "id": 23,\n' + - ' "name": "Something",\n' + - ' "description": "He said, \"Double quotes inside of other double quotes.\"",\n' + - ' "tags": [\n' + - ' "one",\n' + - ' "two",\n' + - ' "three"\n' + - ' ],\n' + - ' "image": {\n' + - ' "url": "http://example.com/image.jpg",\n' + - ' "width": 100,\n' + - ' "height": 100\n' + - ' }\n' + - '}', + `{ + "id": 23, + "name": "Something", + "description": "He said, \"Double quotes inside of other double quotes.\"", + "tags": [ + "one", + "two", + "three" + ], + "image": { + "url": "http://example.com/image.jpg", + "width": 100, + "height": 100 + } + }`, - '{\n "id": 23,\n "name": "Something",\n "description": "He said, "Double quotes inside of other double quotes."",\n "tags": [\n "one",\n "two",\n "three"\n ],\n "image": {\n "url": "http://example.com/image.jpg",\n "width": 100,\n "height": 100\n }\n}' + `{ + "id": 23, + "name": "Something", + "description": "He said, "Double quotes inside of other double quotes."", + "tags": [ + "one", + "two", + "three" + ], + "image": { + "url": "http://example.com/image.jpg", + "width": 100, + "height": 100 + } + }` ); }); diff --git a/test/language/php-test.js b/test/language/php-test.js index 5069ae70..ae1f1ac3 100644 --- a/test/language/php-test.js +++ b/test/language/php-test.js @@ -1,5 +1,6 @@ +import '../../src/language/generic'; import '../../src/language/php'; -import { run } from '../helper'; +import { run, skip } from '../helper'; //////////////// // Test suite // @@ -72,7 +73,7 @@ describe(language, () => { 'instanceof', - "$is_array_object = $collection instanceof ArrayObject;", + '$is_array_object = $collection instanceof ArrayObject;', '$is_array_object = $collection instanceof ArrayObject;' ); @@ -82,7 +83,7 @@ describe(language, () => { 'instanceof namespace class', - "$is_user = $object instanceof App\\User;", + '$is_user = $object instanceof App\\User;', '$is_user = $object instanceof App\\User;' ); @@ -92,23 +93,23 @@ describe(language, () => { 'array stuff', - '$turtles = array(\n' + - ' \'leonardo\',\n' + - ' \'michaelangelo\',\n' + - ' \'donatello\',\n' + - ' \'raphael\'\n' + - ');\n' + - '\n' + - '$exists = array_key_exists(0, $turtles);', + `$turtles = array( + 'leonardo', + 'michaelangelo', + 'donatello', + 'raphael' + ); - '$turtles = array(\n' + - ' \'leonardo\',\n' + - ' \'michaelangelo\',\n' + - ' \'donatello\',\n' + - ' \'raphael\'\n' + - ');\n' + - '\n' + - '$exists = array_key_exists(0, $turtles);' + $exists = array_key_exists(0, $turtles);`, + + `$turtles = array( + 'leonardo', + 'michaelangelo', + 'donatello', + 'raphael' + ); + + $exists = array_key_exists(0, $turtles);` ); run( @@ -196,13 +197,13 @@ describe(language, () => { 'final class declaration', - 'final class TestClass\n' + - '{\n' + - '}', + `final class TestClass + { + }`, - 'final class TestClass\n' + - '{\n' + - '}' + `final class TestClass + { + }` ); run( @@ -250,11 +251,11 @@ describe(language, () => { 'test static', - 'self::_doSomething();\n' + - 'static::_doSomethingElse();', + `self::_doSomething(); + static::_doSomethingElse();`, - 'self::_doSomething();\n' + - 'static::_doSomethingElse();' + `self::_doSomething(); + static::_doSomethingElse();` ); run( @@ -262,15 +263,15 @@ describe(language, () => { 'test magic function', - 'function __autoload($class)\n' + - '{\n' + - ' // do whatever\n' + - '}', + `function __autoload($class) + { + // do whatever + }`, - 'function __autoload($class)\n' + - '{\n' + - ' // do whatever\n' + - '}' + `function __autoload($class) + { + // do whatever + }` ); run( @@ -278,25 +279,25 @@ describe(language, () => { 'test magic method', - 'class SomeThing\n' + - '{\n' + - ' protected $_foo;\n' + - '\n' + - ' public function __construct($foo)\n' + - ' {\n' + - ' $this->_foo = $foo;\n' + - ' }\n' + - '}', - - 'class SomeThing\n' + - '{\n' + - ' protected $_foo;\n' + - '\n' + - ' public function __construct($foo)\n' + - ' {\n' + - ' $this->_foo = $foo;\n' + - ' }\n' + - '}' + `class SomeThing + { + protected $_foo; + + public function __construct($foo) + { + $this->_foo = $foo; + } + }`, + + `class SomeThing + { + protected $_foo; + + public function __construct($foo) + { + $this->_foo = $foo; + } + }` ); run( diff --git a/test/language/python-test.js b/test/language/python-test.js index b5ec7cbc..8ac24375 100644 --- a/test/language/python-test.js +++ b/test/language/python-test.js @@ -1,3 +1,4 @@ +import '../../src/language/generic'; import '../../src/language/python'; import { run } from '../helper'; @@ -32,13 +33,13 @@ describe(language, () => { 'language constants', - 'var1 = None\n' + - 'var2 = True\n' + - 'someFunction(var3=False)', + `var1 = None + var2 = True + someFunction(var3=False)`, - 'var1 = None\n' + - 'var2 = True\n' + - 'someFunction(var3=False)' + `var1 = None + var2 = True + someFunction(var3=False)` ); run( @@ -66,11 +67,11 @@ describe(language, () => { 'class', - 'class Something(object):\n' + - ' pass', + `class Something(object): + pass`, - 'class Something(object):\n' + - ' pass' + `class Something(object): + pass` ); run( @@ -78,11 +79,11 @@ describe(language, () => { 'special method', - 'def __init__(self, some_var):\n' + - ' pass', + `def __init__(self, some_var): + pass`, - 'def __init__(self, some_var):\n' + - ' pass' + `def __init__(self, some_var): + pass` ); run( @@ -90,17 +91,17 @@ describe(language, () => { 'function', - 'def openFile(path):\n' + - ' file = open(path, "r")\n' + - ' content = file.read()\n' + - ' file.close()\n' + - ' return content', + `def openFile(path): + file = open(path, "r") + content = file.read() + file.close() + return content`, - 'def openFile(path):\n' + - ' file = open(path, "r")\n' + - ' content = file.read()\n' + - ' file.close()\n' + - ' return content' + `def openFile(path): + file = open(path, "r") + content = file.read() + file.close() + return content` ); run( @@ -108,15 +109,15 @@ describe(language, () => { 'decorator', - '@makebold\n' + - '@makeitalic\n' + - 'def hello():\n' + - ' return "hello world"', + `@makebold + @makeitalic + def hello(): + return "hello world"`, - '@makebold\n' + - '@makeitalic\n' + - 'def hello():\n' + - ' return "hello world"' + `@makebold + @makeitalic + def hello(): + return "hello world"` ); run( @@ -124,11 +125,11 @@ describe(language, () => { '__main__', - 'if __name__ == \'__main__\':\n' + - ' pass', + `if __name__ == '__main__': + pass`, - 'if __name__ == \'__main__\':\n' + - ' pass' + `if __name__ == '__main__': + pass` ); run( @@ -136,15 +137,15 @@ describe(language, () => { 'try catch', - 'try:\n' + - ' import cPickle as pickle\n' + - 'except ImportError:\n' + - ' import pickle', + `try: + import cPickle as pickle + except ImportError: + import pickle`, - 'try:\n' + - ' import cPickle as pickle\n' + - 'except ImportError:\n' + - ' import pickle' + `try: + import cPickle as pickle + except ImportError: + import pickle` ); run( @@ -172,13 +173,13 @@ describe(language, () => { 'docstring multiline', - '"""test\n' + - 'multiline\n' + - 'yes"""', + `"""test + multiline + yes"""`, - '"""test\n' + - 'multiline\n' + - 'yes"""' + `"""test + multiline + yes"""` ); run( @@ -196,20 +197,20 @@ describe(language, () => { 'multiple docstrings', - '"""\n' + - 'x\n' + - '"""\n' + - '2 + 2\n' + - '"""\n' + - 'y\n' + - '"""', - - '"""\n' + - 'x\n' + - '"""\n' + - '2 + 2\n' + - '"""\n' + - 'y\n' + - '"""' + `""" + x + """ + 2 + 2 + """ + y + """`, + + `""" + x + """ + 2 + 2 + """ + y + """` ); }); diff --git a/test/language/r-test.js b/test/language/r-test.js index 8f021f32..40fd2189 100644 --- a/test/language/r-test.js +++ b/test/language/r-test.js @@ -1,3 +1,4 @@ +import '../../src/language/generic'; import '../../src/language/r'; import { run, skip } from '../helper'; @@ -12,11 +13,11 @@ describe(language, () => { 'comments', - '# A comment\n' + - 'a <- "b" # Another comment', + `# A comment + a <- "b" # Another comment`, - '# A comment\n' + - 'a <- "b" # Another comment' + `# A comment + a <- "b" # Another comment` ); run( @@ -24,11 +25,11 @@ describe(language, () => { 'assignment', - 'foo.bar <- "foo"\n' + - 'baz1 = 1.62e-4', + `foo.bar <- "foo" + baz1 = 1.62e-4`, - 'foo.bar <- "foo"\n' + - 'baz1 = 1.62e-4' + `foo.bar <- "foo" + baz1 = 1.62e-4` ); run( @@ -36,15 +37,15 @@ describe(language, () => { 'constants', - 'baz <- NA\n' + - 'my.pi <- pi\n' + - 'all.letters <- c(LETTERS, letters)\n' + - 'xrange <- c(-Inf, TRUE)', + `baz <- NA + my.pi <- pi + all.letters <- c(LETTERS, letters) + xrange <- c(-Inf, TRUE)`, - 'baz <- NA\n' + - 'my.pi <- pi\n' + - 'all.letters <- c(LETTERS, letters)\n' + - 'xrange <- c(-Inf, TRUE)' + `baz <- NA + my.pi <- pi + all.letters <- c(LETTERS, letters) + xrange <- c(-Inf, TRUE)` ); run( @@ -52,17 +53,17 @@ describe(language, () => { 'operators', - 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + - 'bound.rect <- grid::rectGrob()\n' + - 'my_seq <- 1:10\n' + - 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + - 'plot(y ~ x, type = "l")', - - 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' + - 'bound.rect <- grid::rectGrob()\n' + - 'my_seq <- 1:10\n' + - 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' + - 'plot(y ~ x, type = "l")' + `beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y + bound.rect <- grid::rectGrob() + my_seq <- 1:10 + is_in_seq <- c(2, 7, 23) %in% my_seq + plot(y ~ x, type = "l")`, + + `beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y + bound.rect <- grid::rectGrob() + my_seq <- 1:10 + is_in_seq <- c(2, 7, 23) %in% my_seq + plot(y ~ x, type = "l")` ); /** @@ -74,17 +75,17 @@ describe(language, () => { 'function creation', - 'square <- function(x) x * x\n' + - 'square2 <- testfunction(x) x * x\n' + - 'area <- function (r) {\n' + - ' pi * r^2\n' + - '}', - - 'square <- function(x) x * x\n' + - 'square2 <- testfunction(x) x * x\n' + - 'area <- function (r) {\n' + - ' pi * r^2\n' + - '}' + `square <- function(x) x * x + square2 <- testfunction(x) x * x + area <- function (r) { + pi * r^2 + }`, + + `square <- function(x) x * x + square2 <- testfunction(x) x * x + area <- function (r) { + pi * r^2 + }` ); skip( @@ -92,13 +93,13 @@ describe(language, () => { 'variable', - 'tmp <- 1\n' + - 'another.tmp <- 2\n' + - 'this.is.a.var <- 3', + `tmp <- 1 + another.tmp <- 2 + this.is.a.var <- 3`, - 'tmp <- 1\n' + - 'another.tmp <- 2\n' + - 'this.is.a.var <- 3' + `tmp <- 1 + another.tmp <- 2 + this.is.a.var <- 3` ); skip( @@ -106,11 +107,11 @@ describe(language, () => { 'subsetting', - 'tmp[1]\n' + - 'tmp[["test"]]', + `tmp[1] + tmp[["test"]]`, - 'tmp[1]\n' + - 'tmp[["test"]]' + `tmp[1] + tmp[["test"]]` ); skip( @@ -118,14 +119,14 @@ describe(language, () => { 'support functions', - 'logical(10)\n' + - 'test.logical(10)\n' + - 'data.frame(a = 1:10, b = 15:24)\n' + - 'complex(real = 1, imaginary = 0.5)', + `logical(10) + test.logical(10) + data.frame(a = 1:10, b = 15:24) + complex(real = 1, imaginary = 0.5)`, - 'logical(10)\n' + - 'test.logical(10)\n' + - 'data.frame(a = 1:10, b = 15:24)\n' + - 'complex(real = 1, imaginary = 0.5)' + `logical(10) + test.logical(10) + data.frame(a = 1:10, b = 15:24) + complex(real = 1, imaginary = 0.5)` ); }); diff --git a/test/language/ruby-test.js b/test/language/ruby-test.js index 0fa8290c..a00470df 100644 --- a/test/language/ruby-test.js +++ b/test/language/ruby-test.js @@ -12,11 +12,11 @@ describe(language, () => { 'multiple (non-greedy) strings', - '"me" && "you"\n', + `"me" && "you" + `, - '"me"' + - ' && ' + - '"you"\n' + `"me" && "you" + ` ); run( @@ -40,8 +40,8 @@ describe(language, () => { 'foo = ["one", "two", "three"];', - 'foo = ['+ - '"one", '+ + 'foo = [' + + '"one", ' + '"two", ' + '"three"];' ); @@ -51,11 +51,17 @@ describe(language, () => { '__END__', - 'class Test;end;\n__END__\nthis is just text\ntrue\n', - - 'class Test;' + - 'end;\n__END__\n' + - 'this is just text\ntrue\n' + `class Test;end; +__END__ +this is just text +true +`, + + `class Test;end; +__END__ +this is just text +true +` ); }); From a7fedef5851ee59a922b5122a0c4323300891b89 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 11:27:44 -0400 Subject: [PATCH 075/153] Remove trailing whitespaces --- src/language/haskell.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/language/haskell.js b/src/language/haskell.js index 614afbaf..00f94077 100644 --- a/src/language/haskell.js +++ b/src/language/haskell.js @@ -11,14 +11,14 @@ Rainbow.extend('haskell', [ 'name': 'comment', 'pattern': /\{\-\-[\s\S(\w+)]+[\-\-][\}$]/gm // /\{\-{2}[\s\S(.*)]+[\-\-][\}$]/gm [multiple lines] - }, + }, { 'name': 'comment', 'pattern': /\-\-(.*)/g // /\-\-\s(.+)$/gm [single] }, ///- End Comments - + ///- Namespace (module) { 'matches': { @@ -28,7 +28,7 @@ Rainbow.extend('haskell', [ 'pattern': /\b(module)\s(\w+)\s[\(]?(\w+)?[\)?]\swhere/g }, ///- End Namespace (module) - + ///- Keywords and Operators { 'name': 'keyword.operator', @@ -54,7 +54,7 @@ Rainbow.extend('haskell', [ 'pattern': /\b(infix|infixr|infixl)+\s\d+\s(\w+)*/g }, ///- End Infix|Infixr|Infixl - + { 'name': 'entity.class', 'pattern': /\b([A-Z][A-Za-z0-9_']*)/g @@ -91,4 +91,4 @@ Rainbow.extend('haskell', [ }, 'pattern': /^\#([\S\s]*?)$/gm } -]); +]); From b482d42904a157682dea03dd957cd94f8b0b2af1 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 11:27:57 -0400 Subject: [PATCH 076/153] Remove rainbow min from src --- src/rainbow.min.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 src/rainbow.min.js diff --git a/src/rainbow.min.js b/src/rainbow.min.js deleted file mode 100644 index 9cd1d811..00000000 --- a/src/rainbow.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/* Rainbow v1.1.9 rainbowco.de */ -window.Rainbow=function(){function q(a){var b,c=a.getAttribute&&a.getAttribute("data-language")||0;if(!c){a=a.attributes;for(b=0;b=e[d][c])delete e[d][c],delete j[d][c];if(a>=c&&ac&&b'+b+""}function s(a,b,c,h){var f=a.exec(c);if(f){++t;!b.name&&"string"==typeof b.matches[0]&&(b.name=b.matches[0],delete b.matches[0]);var k=f[0],i=f.index,u=f[0].length+i,g=function(){function f(){s(a,b,c,h)}t%100>0?f():setTimeout(f,0)};if(C(i,u))g();else{var m=v(b.matches),l=function(a,c,h){if(a>=c.length)h(k);else{var d=f[c[a]];if(d){var e=b.matches[c[a]],i=e.language,g=e.name&&e.matches? -e.matches:e,j=function(b,d,e){var i;i=0;var g;for(g=1;g/g,">").replace(/&(?![\w\#]+;)/g, -"&"),b,c)}function o(a,b,c){if(b Date: Sun, 26 Jun 2016 15:38:08 -0400 Subject: [PATCH 077/153] Fix paths for usage with node --- package.json | 2 +- src/rainbow-node.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 4da185f9..a378c09c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "rainbow", "version": "1.2.0", "description": "Simple library for code syntax highlighting", - "main": "./js/rainbow-node.js", + "main": "./src/rainbow-node.js", "homepage": "http://rainbowco.de", "directories": { "test": "tests" diff --git a/src/rainbow-node.js b/src/rainbow-node.js index 8788b241..620a9c7f 100644 --- a/src/rainbow-node.js +++ b/src/rainbow-node.js @@ -1,6 +1,7 @@ #!/usr/bin/env node +/* eslint-disable */ var fs = require('fs'); -global.Rainbow = require('./rainbow.js'); +global.Rainbow = require('../dist/rainbow.js'); var files = fs.readdirSync(__dirname + '/language'); for (var i = 0; i < files.length; i++) { @@ -8,4 +9,5 @@ for (var i = 0; i < files.length; i++) { } module.exports = global.Rainbow; -delete global['Rainbow']; +delete global.Rainbow; +/* eslint-enable */ From 9d3c0475e586e485b3df0c3eec6daa06f8f06faa Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 15:38:48 -0400 Subject: [PATCH 078/153] Rewrite pretty much everything I know this really should have been in multiple commits but some of the work can probably be seen in the 2.0 branch before it was migrated here. --- src/rainbow.js | 1104 ++++++++++++----------------------------------- src/raindrop.js | 283 ++++++++++++ src/util.js | 285 ++++++++++++ src/worker.js | 22 + 4 files changed, 862 insertions(+), 832 deletions(-) create mode 100644 src/raindrop.js create mode 100644 src/util.js create mode 100644 src/worker.js diff --git a/src/rainbow.js b/src/rainbow.js index eeed9832..88265288 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -1,5 +1,5 @@ /** - * Copyright 2012-2014 Craig Campbell + * Copyright 2012-2016 Craig Campbell * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,878 +17,318 @@ * * @see rainbowco.de */ -(function(global) { - "use strict"; - - /** - * An array of the language patterns specified for each language - * - * @type {Object} - */ - var languagePatterns = {}; - - /** - * An array of languages and whether they should bypass the - * default patterns - * - * @type {Object} - */ - var bypassDefaults = {}; - - /** - * A mapping of language aliases - * - * @type {Object} - */ - var aliases = {}; - - /** - * Constant used to refer to the default language - * - * @type {number} - */ - var DEFAULT_LANGUAGE = 0; - - /** - * Global class added to each span in the highlighted code - * - * @type {null|string} - */ - var globalClass; - - /** - * Callback to fire after each block is highlighted - * - * @type {null|Function} - */ - var onHighlight; - - /** - * Reference to web worker for doing the heavy lifting - * - * @type Worker - */ - var worker; - - var isNode = typeof module !== 'undefined' && typeof module.exports === 'object'; - /** - * Flag for if this is the web worker or not - * - * @type {Boolean} - */ - var isWorker = !isNode && typeof document === 'undefined'; - if (isNode) { - global.Worker = require('webworker-threads').Worker; - } - - /** - * Browser Only - Gets the language for this block of code - * - * @param {Element} block - * @returns {string|null} - */ - function _getLanguageForBlock(block) { - - // If this doesn't have a language but the parent does then use that. - // - // This means if for example you have:
    -        // with a bunch of  blocks inside then you do not have
    -        // to specify the language for each block.
    -        var language = block.getAttribute('data-language') || block.parentNode.getAttribute('data-language');
    -
    -        // This adds support for specifying language via a CSS class.
    -        //
    -        // You can use the Google Code Prettify style: 
    -        // or the HTML5 style: 
    
    -        if (!language) {
    -            var pattern = /\blang(?:uage)?-(\w+)/;
    -            var match = block.className.match(pattern) || block.parentNode.className.match(pattern);
    -
    -            if (match) {
    -                language = match[1];
    -            }
    -        }
    -
    -        if (language) {
    -            return language.toLowerCase();
    -        }
    -    }
    -
    -    /**
    -     * Encodes < and > as html entities
    -     *
    -     * @param {string} code
    -     * @returns {string}
    -     */
    -    function _htmlEntities(code) {
    -        return code.replace(//g, '>').replace(/&(?![\w\#]+;)/g, '&');
    -    }
    -
    -    /**
    -     * Determines if a new match intersects with an existing one
    -     *
    -     * @param {number} start1    start position of existing match
    -     * @param {number} end1      end position of existing match
    -     * @param {number} start2    start position of new match
    -     * @param {number} end2      end position of new match
    -     * @returns {boolean}
    -     */
    -    function _intersects(start1, end1, start2, end2) {
    -        if (start2 >= start1 && start2 < end1) {
    -            return true;
    -        }
    -
    -        return end2 > start1 && end2 < end1;
    -    }
    -
    -    /**
    -     * Determines if two different matches have complete overlap with each other
    -     *
    -     * @param {number} start1   start position of existing match
    -     * @param {number} end1     end position of existing match
    -     * @param {number} start2   start position of new match
    -     * @param {number} end2     end position of new match
    -     * @returns {boolean}
    -     */
    -    function _hasCompleteOverlap(start1, end1, start2, end2) {
    -
    -        // If the starting and end positions are exactly the same
    -        // then the first one should stay and this one should be ignored.
    -        if (start2 == start1 && end2 == end1) {
    -            return false;
    -        }
    -
    -        return start2 <= start1 && end2 >= end1;
    -    }
    -
    -    /**
    -     * Takes a string of code and wraps it in a span tag based on the name
    -     *
    -     * @param {string} name     name of the pattern (ie keyword.regex)
    -     * @param {string} code     block of code to wrap
    -     * @returns {string}
    -     */
    -    function _wrapCodeInSpan(name, code) {
    -        return '' + code + '';
    -    }
    -
    -    /**
    -     * Finds out the position of group match for a regular expression
    -     *
    -     * @see http://stackoverflow.com/questions/1985594/how-to-find-index-of-groups-in-match
    -     * @param {Object} match
    -     * @param {number} groupNumber
    -     * @returns {number}
    -     */
    -    function _indexOfGroup(match, groupNumber) {
    -        var index = 0;
    -        var i;
    -
    -        for (i = 1; i < groupNumber; ++i) {
    -            if (match[i]) {
    -                index += match[i].length;
    -            }
    -        }
    -
    -        return index;
    -    }
    -
    -    /**
    -     * Determines if a language should bypass the default patterns
    -     *
    -     * If you create a language and call Rainbow.extend() with `true` as the
    -     * third argument it will bypass the defaults.
    -     *
    -     * @param {string} language
    -     * @returns {boolean}
    -     */
    -    function _bypassDefaultPatterns(language)
    -    {
    -        return bypassDefaults[language];
    -    }
    -
    -    /**
    -     * Returns a list of regex patterns for this language
    -     *
    -     * @param {string} language
    -     * @returns {Array}
    -     */
    -    function _getPatternsForLanguage(language) {
    -        var patterns = languagePatterns[language] || [];
    -        var defaultPatterns = languagePatterns[DEFAULT_LANGUAGE] || [];
    -
    -        return _bypassDefaultPatterns(language) ? patterns : patterns.concat(defaultPatterns);
    -    }
    -
    -    /**
    -     * Substring replace call to replace part of a string at a certain position
    -     *
    -     * @param {number} position         the position where the replacement
    -     *                                  should happen
    -     * @param {string} replace          the text we want to replace
    -     * @param {string} replaceWith      the text we want to replace it with
    -     * @param {string} code             the code we are doing the replacing in
    -     * @returns {string}
    -     */
    -    function _replaceAtPosition(position, replace, replaceWith, code) {
    -        var subString = code.substr(position);
    -        return code.substr(0, position) + subString.replace(replace, replaceWith);
    -    }
    -
    -   /**
    -     * Sorts an objects keys by index descending
    -     *
    -     * @param {Object} object
    -     * @return {Array}
    -     */
    -    function keys(object) {
    -        var locations = [];
    -
    -        for(var location in object) {
    -            if (object.hasOwnProperty(location)) {
    -                locations.push(location);
    -            }
    -        }
    +import Raindrop from './raindrop';
    +import * as util from './util';
    +import rainbowWorker from './worker';
     
    -        // numeric descending
    -        return locations.sort(function(a, b) {
    -            return b - a;
    -        });
    -    }
    -
    -    /**
    -     * Raindrop is a class used to highlight individual blocks of code
    -     *
    -     * @class
    -     */
    -    function Raindrop() {
    -
    -        /**
    -         * Object of replacements to process at the end of the processing
    -         *
    -         * @type {Object}
    -         */
    -        var replacements = {};
    -
    -        /**
    -         * Language associated with this Raindrop object
    -         *
    -         * @type {string}
    -         */
    -        var currentLanguage;
    -
    -        /**
    -         * Object of start and end positions of blocks to be replaced
    -         *
    -         * @type {Object}
    -         */
    -        var replacementPositions = {};
    -
    -        /**
    -         * Determines if the match passed in falls inside of an existing match.
    -         * This prevents a regex pattern from matching inside of another pattern
    -         * that matches a larger amount of code.
    -         *
    -         * For example this prevents a keyword from matching `function` if there
    -         * is already a match for `function (.*)`.
    -         *
    -         * @param {number} start    start position of new match
    -         * @param {number} end      end position of new match
    -         * @returns {boolean}
    -         */
    -        function _matchIsInsideOtherMatch(start, end) {
    -            for (var key in replacementPositions) {
    -                key = parseInt(key, 10);
    -
    -                // If this block completely overlaps with another block
    -                // then we should remove the other block and return `false`.
    -                if (_hasCompleteOverlap(key, replacementPositions[key], start, end)) {
    -                    delete replacementPositions[key];
    -                    delete replacements[key];
    -                }
    -
    -                if (_intersects(key, replacementPositions[key], start, end)) {
    -                    return true;
    -                }
    -            }
    -
    -            return false;
    -        }
    -
    -        /**
    -         * Process replacements in the string of code to actually update
    -         * the markup
    -         *
    -         * @param {string} code         the code to process replacements in
    -         * @returns void
    -         */
    -        function _processReplacements(code) {
    -            var positions = keys(replacements);
    -            for (var i = 0; i < positions.length; i++) {
    -                var pos = positions[i];
    -                var replacement = replacements[pos];
    -                code = _replaceAtPosition(pos, replacement['replace'], replacement['with'], code);
    -            }
    -            return code;
    -        }
    -
    -        /**
    -         * Matches a regex pattern against a block of code, finds all matches
    -         * that should be processed, and stores the positions of where they
    -         * should be replaced within the string.
    -         *
    -         * This is where pretty much all the work is done but it should not
    -         * be called directly.
    -         *
    -         * @param {Object} pattern
    -         * @param {string} code
    -         * @returns void
    -         */
    -        function _processPattern(pattern, code) {
    -            var regex = pattern.pattern;
    -
    -            if (!regex) {
    -                return;
    -            }
    -
    -            var match = regex.exec(code);
    -
    -            if (!match) {
    -                return;
    -            }
    -
    -            // Treat match 0 the same way as name
    -            if (!pattern['name'] && typeof pattern['matches'][0] == 'string') {
    -                pattern['name'] = pattern['matches'][0];
    -                delete pattern['matches'][0];
    -            }
    -
    -            var replacement = match[0];
    -            var startPos = match.index;
    -            var endPos = match[0].length + startPos;
    -
    -            // If this is not a child match and it falls inside of another
    -            // match that already happened we should skip it and continue
    -            // processing.
    -            if (_matchIsInsideOtherMatch(startPos, endPos)) {
    -                _processPattern(pattern, code);
    -                return;
    -            }
    -
    -            /**
    -             * Callback for when a match was successfully processed
    -             *
    -             * @param {string} replacement
    -             * @returns void
    -             */
    -            function onMatchSuccess(replacement) {
    -
    -                // If this match has a name then wrap it in a span tag
    -                if (pattern['name']) {
    -                    replacement = _wrapCodeInSpan(pattern['name'], replacement);
    -                }
    -
    -                // For debugging
    -                // console.log('Replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos);
    -
    -                // Store what needs to be replaced with what at this position
    -                replacements[startPos] = {
    -                    'replace': match[0],
    -                    'with': replacement
    -                };
    -
    -                // Store the range of this match so we can use it for
    -                // comparisons with other matches later.
    -                replacementPositions[startPos] = endPos;
    -
    -                _processPattern(pattern, code);
    -            }
    -
    -            /**
    -             * Helper function for processing a sub group
    -             *
    -             * @param {number} groupKey      index of group
    -             * @returns void
    -             */
    -            function _processGroup(groupKey) {
    -                var block = match[groupKey];
    -
    -                // If there is no match here then move on
    -                if (!block) {
    -                    return;
    -                }
    -
    -                var group = pattern['matches'][groupKey];
    -                var language = group['language'];
    -
    -                /**
    -                 * Process group is what group we should use to actually process
    -                 * this match group.
    -                 *
    -                 * For example if the subgroup pattern looks like this:
    -                 *
    -                 * 2: {
    -                 *     'name': 'keyword',
    -                 *     'pattern': /true/g
    -                 * }
    -                 *
    -                 * then we use that as is, but if it looks like this:
    -                 *
    -                 * 2: {
    -                 *     'name': 'keyword',
    -                 *     'matches': {
    -                 *          'name': 'special',
    -                 *          'pattern': /whatever/g
    -                 *      }
    -                 * }
    -                 *
    -                 * we treat the 'matches' part as the pattern and keep
    -                 * the name around to wrap it with later
    -                 */
    -                var groupToProcess = group['name'] && group['matches'] ? group['matches'] : group;
    -
    -                /**
    -                 * Takes the code block matched at this group, replaces it
    -                 * with the highlighted block, and optionally wraps it with
    -                 * a span with a name
    -                 *
    -                 * @param {string} block
    -                 * @param {string} replaceBlock
    -                 * @param {string|null} matchName
    -                 */
    -                var _getReplacement = function(block, replaceBlock, matchName) {
    -                    replacement = _replaceAtPosition(_indexOfGroup(match, groupKey), block, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement);
    -                    return;
    -                };
    -
    -                // If this is a string then this match is directly mapped
    -                // to selector so all we have to do is wrap it in a span
    -                // and continue.
    -                if (typeof group === 'string') {
    -                    _getReplacement(block, block, group);
    -                    return;
    -                }
    -
    -                var localCode;
    -                var drop = new Raindrop();
    -
    -                // If this is a sublanguage go and process the block using
    -                // that language
    -                if (language) {
    -                    localCode = drop.refract(block, language);
    -                    _getReplacement(block, localCode);
    -                    return;
    -                }
    -
    -                // The process group can be a single pattern or an array of
    -                // patterns. `_processCodeWithPatterns` always expects an array
    -                // so we convert it here.
    -                localCode = drop.refract(block, currentLanguage, groupToProcess.length ? groupToProcess : [groupToProcess]);
    -                _getReplacement(block, localCode, group['matches'] ? group['name'] : 0);
    -            }
    -
    -            // If this pattern has sub matches for different groups in the regex
    -            // then we should process them one at a time by running them through
    -            // the _processGroup function to generate the new replacement.
    -            //
    -            // We use the `keys` function to run through them backwards because
    -            // the match position of earlier matches will not change depending
    -            // on what gets replaced in later matches.
    -            var groupKeys = keys(pattern['matches']);
    -            for (var i = 0; i < groupKeys.length; i++) {
    -                _processGroup(groupKeys[i]);
    -            }
    -
    -            // Finally, call `onMatchSuccess` with the replacement
    -            onMatchSuccess(replacement);
    -        }
    -
    -        /**
    -         * Takes a string of code and highlights it according to the language
    -         * specified
    -         *
    -         * @param {string} code
    -         * @param {string} language
    -         * @returns void
    -         */
    -        function _highlightBlockForLanguage(code, language, patterns) {
    -            currentLanguage = language;
    -            patterns = patterns || _getPatternsForLanguage(language);
    -            return _processCodeWithPatterns(_htmlEntities(code), patterns);
    -        }
    +/**
    + * Global class added to each span in the highlighted code
    + *
    + * @type {null|string}
    + */
    +let globalClass;
     
    -        /**
    -         * Processes a block of code using specified patterns
    -         *
    -         * @param {string} code
    -         * @param {Array} patterns
    -         * @returns void
    -         */
    -        function _processCodeWithPatterns(code, patterns) {
    -            for (var i = 0; i < patterns.length; i++) {
    -                _processPattern(patterns[i], code);
    -            }
    -
    -            // We are done processing the patterns so we should actually replace
    -            // what needs to be replaced in the code.
    -            return _processReplacements(code);
    -        }
    +/**
    + * Callback to fire after each block is highlighted
    + *
    + * @type {null|Function}
    + */
    +let onHighlight;
     
    -        return {
    -            refract: _highlightBlockForLanguage
    -        };
    -    }
    +/**
    + * Reference to web worker for doing the heavy lifting
    + *
    + * @type Worker
    + */
    +const isNode = util.isNode();
    +const isWorker = util.isWorker();
     
    -    /**
    -     * Web Worker Only - Handles message from main script giving commands about
    -     * what to highlight
    -     *
    -     * @param {object} message      message received from worker.postMessage
    -     * @returns void
    -     */
    -    function _handleMessageFromRainbow(message) {
    -        languagePatterns = message.data.languagePatterns;
    -        bypassDefaults = message.data.bypassDefaults;
    -        globalClass = message.data.globalClass;
    -        var drop = new Raindrop();
    -        var result = drop.refract(message.data.code, message.data.lang);
    -        var data = {
    -            id: message.data.id,
    -            lang: message.data.lang,
    -            result: result
    -        };
    -        self.postMessage(data);
    -    }
    +/**
    + * Helper for matching up callbacks directly with the
    + * post message requests to a web worker.
    + *
    + * @param {object} message      data to send to web worker
    + * @param {Function} callback   callback function for worker to reply to
    + * @return {void}
    + */
    +function _messageWorker(message, callback) {
    +    const worker = util.createWorker(rainbowWorker, [Raindrop, util]);
     
    -    /**
    -     * Browser Only - Helper for matching up callbacks directly with the
    -     * post message requests to a web worker.
    -     *
    -     * @param {object} message      data to send to web worker
    -     * @param {Function} callback   callback function for worker to reply to
    -     * @return void
    -     */
    -    function _messageWorker(message, callback) {
    -        function _listen(e) {
    -            if (e.data.id === message.id) {
    -                callback(e.data);
    -                worker.removeEventListener('message', _listen);
    -            }
    +    function _listen(e) {
    +        if (e.data.id === message.id) {
    +            callback(e.data);
    +            worker.removeEventListener('message', _listen);
             }
    -
    -        worker.addEventListener('message', _listen);
    -        worker.postMessage(message);
         }
     
    -    /**
    -     * Browser Only - Handles response from web worker, updates DOM with
    -     * resulting code, and fires callback
    -     *
    -     * @param {object} message      message received from self.postMessage
    -     * @returns void
    -     */
    -    function _generateHandler(element, waitingOn, callback) {
    -        return function _handleResponseFromWorker(data) {
    -            element.innerHTML = data.result;
    -            element.classList.add('rainbow');
    -            element.classList.remove('loading');
    -            element.classList.remove('stop-animation');
    -
    -            if (onHighlight) {
    -                onHighlight(element, data.lang);
    -            }
    -
    -            if (--waitingOn.c === 0) {
    -                callback();
    -            }
    -        };
    -    }
    +    worker.addEventListener('message', _listen);
    +    worker.postMessage(message);
    +}
     
    -    /**
    -     * Browser Only - Gets data to send to webworker
    -     * @param  {string} code
    -     * @param  {string} lang
    -     * @return {object}
    -     */
    -    function _getWorkerData(code, lang) {
    -        lang = aliases[lang] || lang;
    -
    -        var workerData = {
    -            id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(),
    -            code: code,
    -            lang: lang,
    -            languagePatterns: languagePatterns,
    -            bypassDefaults: bypassDefaults,
    -            globalClass: globalClass
    -        };
    -
    -        return workerData;
    -    }
    +/**
    + * Browser Only - Handles response from web worker, updates DOM with
    + * resulting code, and fires callback
    + *
    + * @param {Element} element
    + * @param {object} waitingOn
    + * @param {Function} callback
    + * @return {void}
    + */
    +function _generateHandler(element, waitingOn, callback) {
    +    return function _handleResponseFromWorker(data) {
    +        element.innerHTML = data.result;
    +        element.classList.remove('loading');
    +        element.classList.remove('stop-animation');
    +        // element.addEventListener('animationend', (e) => {
    +        //     if (e.animationName === 'fade-in') {
    +        //         setTimeout(() => {
    +        //             element.classList.remove('decrease-delay');
    +        //         }, 1000);
    +        //     }
    +        // });
     
    -    /**
    -     * Browser Only - Sends messages to web worker to highlight elements passed
    -     * in
    -     *
    -     * @param {Array} codeBlocks
    -     * @returns void
    -     */
    -    function _highlightCodeBlocks(codeBlocks, callback) {
    -        var waitingOn = {c: 0};
    -        for (var i = 0; i < codeBlocks.length; i++) {
    -            var block = codeBlocks[i];
    -
    -            // This cancels the pending animation to fade the code in on load
    -            // since we want to delay doing this until it is actually
    -            // highlighted
    -            block.classList.add('stop-animation');
    -
    -            var language = _getLanguageForBlock(block);
    -
    -            if (block.classList.contains('rainbow') || !language) {
    -                continue;
    -            }
    -
    -            // for long files show a spinner
    -            if (block.innerHTML.length > 20000) {
    -                block.classList.add('loading');
    -            }
    -
    -            ++waitingOn.c;
    -            _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback));
    +        if (onHighlight) {
    +            onHighlight(element, data.lang);
             }
     
    -        if (waitingOn.c === 0) {
    +        if (--waitingOn.c === 0) {
                 callback();
             }
    -    }
    +    };
    +}
     
    -    /**
    -     * Browser Only - Start highlighting all the code blocks
    -     *
    -     * @param {Element} node       HTMLElement to search within
    -     * @returns void
    -     */
    -    function _highlight(node, callback) {
    -        callback = callback || function() {};
    +/**
    + * Gets data to send to webworker
    + *
    + * @param  {string} code
    + * @param  {string} lang
    + * @return {object}
    + */
    +function _getWorkerData(code, lang) {
    +    lang = util.aliases[lang] || lang;
    +
    +    const workerData = {
    +        id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(),
    +        code,
    +        lang,
    +        languagePatterns: util.languagePatterns,
    +        bypassDefaults: util.bypassDefaults,
    +        aliases: util.aliases,
    +        DEFAULT_LANGUAGE: util.DEFAULT_LANGUAGE,
    +        globalClass
    +    };
     
    -        // The first argument can be an Event or a DOM Element.
    -        //
    -        // I was originally checking instanceof Event but that made it break
    -        // when using mootools.
    -        //
    -        // @see https://github.com/ccampbell/rainbow/issues/32
    -        node = node && typeof node.getElementsByTagName == 'function' ? node : document;
    -
    -        var preBlocks = node.getElementsByTagName('pre');
    -        var codeBlocks = node.getElementsByTagName('code');
    -        var i;
    -        var finalPreBlocks = [];
    -        var finalCodeBlocks = [];
    -
    -        // First loop through all pre blocks to find which ones to highlight
    -        for (i = 0; i < preBlocks.length; ++i) {
    -
    -            // Strip whitespace around code tags when they are inside of a pre
    -            // tag.  This makes the themes look better because you can't
    -            // accidentally add extra linebreaks at the start and end.
    -            //
    -            // When the pre tag contains a code tag then strip any extra
    -            // whitespace.
    -            //
    -            // For example:
    -            //
    -            // 
    -            //      var foo = true;
    -            // 
    - // - // will become: - // - //
    var foo = true;
    - // - // If you want to preserve whitespace you can use a pre tag on - // its own without a code tag inside of it. - if (preBlocks[i].getElementsByTagName('code').length) { - preBlocks[i].innerHTML = preBlocks[i].innerHTML.trim(); - continue; - } - - // If the pre block has no code blocks then we are going to want to - // process it directly. - finalPreBlocks.push(preBlocks[i]); - } + return workerData; +} - // @see http://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript - // We are going to process all blocks - for (i = 0; i < codeBlocks.length; ++i) { - finalCodeBlocks.push(codeBlocks[i]); +/** + * Browser Only - Sends messages to web worker to highlight elements passed + * in + * + * @param {Array} codeBlocks + * @param {Function} callback + * @return {void} + */ +function _highlightCodeBlocks(codeBlocks, callback) { + const waitingOn = { c: 0 }; + for (const block of codeBlocks) { + const language = util.getLanguageForBlock(block); + if (block.classList.contains('rainbow') || !language) { + continue; } - _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks), callback); - } - - /** - * Extends the language pattern matches - * - * @param {string} language name of language - * @param {object} patterns object of patterns to add on - * @param {boolean|null} bypass if `true` this will not inherit the - * default language patterns - */ - function _extend(language, patterns, bypass) { - if (isWorker) { - return; - } + // This cancels the pending animation to fade the code in on load + // since we want to delay doing this until it is actually + // highlighted + block.classList.add('stop-animation'); + block.classList.add('rainbow'); - // If there is only one argument then we assume that we want to - // extend the default language rules. - if (arguments.length == 1) { - patterns = language; - language = DEFAULT_LANGUAGE; + // for long files show a spinner + if (block.innerHTML.length > 20000) { + block.classList.add('loading'); } - bypassDefaults[language] = bypass; - languagePatterns[language] = patterns.concat(languagePatterns[language] || []); + ++waitingOn.c; + _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback)); } - /** - * Callback to let you do stuff in your app after a piece of code has - * been highlighted - * - * @param {Function} callback - */ - function _onHighlight(callback) { - onHighlight = callback; + if (waitingOn.c === 0) { + callback(); } +} - /** - * Method to set a global class that will be applied to all spans. - * - * This is realy only useful for the effect on rainbowco.de where you can - * force all blocks to not be highlighted and remove this class to - * transition them to being highlighted. - * - * @param {string} className - * @returns void - */ - function _addGlobalClass(className) { - globalClass = className; - } - - /** - * Method to add an alias for an existing language. - * - * For example if you want to have "coffee" map to "coffeescript" - * - * @see https://github.com/ccampbell/rainbow/issues/154 - */ - function _addAlias(alias, originalLanguage) { - aliases[alias] = originalLanguage; - } - - /** - * Starts the magic rainbow - * - * @returns void - */ - function _color() { - - // If you want to straight up highlight a string you can pass the - // string of code, the language, and a callback function. - // - // Example: +/** + * Browser Only - Start highlighting all the code blocks + * + * @param {Element} node HTMLElement to search within + * @param {Function} callback + * @return {void} + */ +function _highlight(node, callback) { + callback = callback || function() {}; + + // The first argument can be an Event or a DOM Element. + // + // I was originally checking instanceof Event but that made it break + // when using mootools. + // + // @see https://github.com/ccampbell/rainbow/issues/32 + node = node && typeof node.getElementsByTagName === 'function' ? node : document; + + const preBlocks = node.getElementsByTagName('pre'); + const codeBlocks = node.getElementsByTagName('code'); + const finalPreBlocks = []; + const finalCodeBlocks = []; + + // First loop through all pre blocks to find which ones to highlight + for (const preBlock of preBlocks) { + + // Strip whitespace around code tags when they are inside of a pre + // tag. This makes the themes look better because you can't + // accidentally add extra linebreaks at the start and end. // - // Rainbow.color(code, language, function(highlightedCode, language) { - // // this code block is now highlighted - // }); - if (typeof arguments[0] == 'string') { - var workerData = _getWorkerData(arguments[0], arguments[1]); - _messageWorker(workerData, (function(cb) { - return function(data) { - if (cb) { - cb(data.result, data.lang); - } - }; - } (arguments[2]))); - return; - } - - // If you pass a callback function then we rerun the color function - // on all the code and call the callback function on complete. + // When the pre tag contains a code tag then strip any extra + // whitespace. // - // Example: + // For example: // - // Rainbow.color(function() { - // console.log('All matching tags on the page are now highlighted'); - // }); - if (typeof arguments[0] == 'function') { - return _highlight(0, arguments[0]); - } - - // Otherwise we use whatever node you passed in with an optional - // callback function as the second parameter. + //
    +        //      var foo = true;
    +        // 
    // - // Example: + // will become: // - // var preElement = document.createElement('pre'); - // var codeElement = document.createElement('code'); - // codeElement.setAttribute('data-language', 'javascript'); - // codeElement.innerHTML = '// Here is some JavaScript'; - // preElement.appendChild(codeElement); - // Rainbow.color(preElement, function() { - // // New element is now highlighted - // }); + //
    var foo = true;
    // - // If you don't pass an element it will default to `document` - _highlight(arguments[0], arguments[1]); - } - - /** - * public methods - */ - var _rainbow = { - extend: _extend, - onHighlight: _onHighlight, - addClass: _addGlobalClass, - addAlias: _addAlias, - color: _color - }; + // If you want to preserve whitespace you can use a pre tag on + // its own without a code tag inside of it. + if (preBlock.getElementsByTagName('code').length) { + preBlock.innerHTML = preBlock.innerHTML.trim(); + continue; + } - if (isNode) { - _rainbow.colorSync = function(code, lang) { - var drop = new Raindrop(); - return drop.refract(code, aliases[lang] || lang); - }; + // If the pre block has no code blocks then we are going to want to + // process it directly. + finalPreBlocks.push(preBlock); } - global.Rainbow = _rainbow; - if (isNode) { - module.exports = _rainbow; + // @see http://stackoverflow.com/questions/2735067/how-to-convert-a-dom-node-list-to-an-array-in-javascript + // We are going to process all blocks + for (const codeBlock of codeBlocks) { + finalCodeBlocks.push(codeBlock); } - var setUpWorker = !isWorker && typeof global.Worker !== 'undefined'; + _highlightCodeBlocks(finalCodeBlocks.concat(finalPreBlocks), callback); +} - /** - * Set up web worker and add event listener to start highlighting - * - * @see http://stackoverflow.com/questions/5408406/web-workers-without-a-separate-javascript-file - */ - if (setUpWorker) { - var currentSrc; - if (!isNode) { - - // @see http://stackoverflow.com/questions/2255689/how-to-get-the-file-path-of-the-currently-executing-javascript-code - var scripts = document.getElementsByTagName('script'); - currentSrc = scripts[scripts.length - 1].src; - } +/** + * Callback to let you do stuff in your app after a piece of code has + * been highlighted + * + * @param {Function} callback + * @return {void} + */ +function _onHighlight(callback) { + onHighlight = callback; +} - worker = new global.Worker(isNode ? __filename : currentSrc); +/** + * Method to set a global class that will be applied to all spans. + * + * This is realy only useful for the effect on rainbowco.de where you can + * force all blocks to not be highlighted and remove this class to + * transition them to being highlighted. + * + * @param {string} className + * @return {void} + */ +function _addGlobalClass(className) { + globalClass = className; +} - if (!isNode) { - document.addEventListener('DOMContentLoaded', _rainbow.color, false); - } +/** + * Starts the magic rainbow + * + * @return {void} + */ +function _color(...args) { + // If you want to straight up highlight a string you can pass the + // string of code, the language, and a callback function. + // + // Example: + // + // Rainbow.color(code, language, function(highlightedCode, language) { + // // this code block is now highlighted + // }); + if (typeof args[0] === 'string') { + const workerData = _getWorkerData(args[0], args[1]); + _messageWorker(workerData, (function(cb) { + return function(data) { + if (cb) { + cb(data.result, data.lang); + } + }; + }(args[2]))); + return; + } + // If you pass a callback function then we rerun the color function + // on all the code and call the callback function on complete. + // + // Example: + // + // Rainbow.color(function() { + // console.log('All matching tags on the page are now highlighted'); + // }); + if (typeof args[0] === 'function') { + _highlight(0, args[0]); return; } - self.addEventListener('message', _handleMessageFromRainbow); -}) (this); + // Otherwise we use whatever node you passed in with an optional + // callback function as the second parameter. + // + // Example: + // + // var preElement = document.createElement('pre'); + // var codeElement = document.createElement('code'); + // codeElement.setAttribute('data-language', 'javascript'); + // codeElement.innerHTML = '// Here is some JavaScript'; + // preElement.appendChild(codeElement); + // Rainbow.color(preElement, function() { + // // New element is now highlighted + // }); + // + // If you don't pass an element it will default to `document` + _highlight(args[0], args[1]); +} + +/** + * public methods + */ +const _rainbow = { + extend: util.extend, + onHighlight: _onHighlight, + addClass: _addGlobalClass, + addAlias: util.addAlias, + color: _color +}; + +if (isNode) { + _rainbow.colorSync = function(code, lang) { + const drop = new Raindrop(); + return drop.refract(code, util.aliases[lang] || lang); + }; +} + +// In the browser hook it up to color on page load +if (!isNode && !isWorker) { + document.addEventListener('DOMContentLoaded', _rainbow.color, false); +} + +// From a node worker, handle the postMessage requests to it +if (isWorker) { + self.onmessage = rainbowWorker; +} + +export default _rainbow; diff --git a/src/raindrop.js b/src/raindrop.js new file mode 100644 index 00000000..46924daa --- /dev/null +++ b/src/raindrop.js @@ -0,0 +1,283 @@ +import * as util from './util'; + +/** + * Raindrop is a class used to highlight individual blocks of code + * + * @class + */ +class Raindrop { + constructor() { + /** + * Object of replacements to process at the end of the processing + * + * @type {Object} + */ + const replacements = {}; + + /** + * Language associated with this Raindrop object + * + * @type {string} + */ + let currentLanguage; + + /** + * Object of start and end positions of blocks to be replaced + * + * @type {Object} + */ + const replacementPositions = {}; + + /** + * Determines if the match passed in falls inside of an existing match. + * This prevents a regex pattern from matching inside of another pattern + * that matches a larger amount of code. + * + * For example this prevents a keyword from matching `function` if there + * is already a match for `function (.*)`. + * + * @param {number} start start position of new match + * @param {number} end end position of new match + * @return {boolean} + */ + function _matchIsInsideOtherMatch(start, end) { + for (let key in replacementPositions) { + key = parseInt(key, 10); + + // If this block completely overlaps with another block + // then we should remove the other block and return `false`. + if (util.hasCompleteOverlap(key, replacementPositions[key], start, end)) { + delete replacementPositions[key]; + delete replacements[key]; + } + + if (util.intersects(key, replacementPositions[key], start, end)) { + return true; + } + } + + return false; + } + + /** + * Process replacements in the string of code to actually update + * the markup + * + * @param {string} code the code to process replacements in + * @return {string} + */ + function _processReplacements(code) { + const positions = util.keys(replacements); + for (const position of positions) { + const replacement = replacements[position]; + code = util.replaceAtPosition(position, replacement.replace, replacement.with, code); + } + return code; + } + + /** + * Matches a regex pattern against a block of code, finds all matches + * that should be processed, and stores the positions of where they + * should be replaced within the string. + * + * This is where pretty much all the work is done but it should not + * be called directly. + * + * @param {Object} pattern + * @param {string} code + * @return {void} + */ + function _processPattern(pattern, code) { + const regex = pattern.pattern; + if (!regex) { + return; + } + + const match = regex.exec(code); + if (!match) { + return; + } + + // Treat match 0 the same way as name + if (!pattern.name && typeof pattern.matches[0] === 'string') { + pattern.name = pattern.matches[0]; + delete pattern.matches[0]; + } + + let replacement = match[0]; + const startPos = match.index; + const endPos = match[0].length + startPos; + + // If this is not a child match and it falls inside of another + // match that already happened we should skip it and continue + // processing. + if (_matchIsInsideOtherMatch(startPos, endPos)) { + _processPattern(pattern, code); + return; + } + + /** + * Callback for when a match was successfully processed + * + * @param {string} repl + * @return {void} + */ + function onMatchSuccess(repl) { + + // If this match has a name then wrap it in a span tag + if (pattern.name) { + repl = util.wrapCodeInSpan(pattern.name, repl); + } + + // For debugging + // console.log('Replace ' + match[0] + ' with ' + replacement + ' at position ' + startPos + ' to ' + endPos); + + // Store what needs to be replaced with what at this position + replacements[startPos] = { + 'replace': match[0], + 'with': repl + }; + + // Store the range of this match so we can use it for + // comparisons with other matches later. + replacementPositions[startPos] = endPos; + + _processPattern(pattern, code); + } + + /** + * Helper function for processing a sub group + * + * @param {number} groupKey index of group + * @return {void} + */ + function _processGroup(groupKey) { + const block = match[groupKey]; + + // If there is no match here then move on + if (!block) { + return; + } + + const group = pattern.matches[groupKey]; + const language = group.language; + + /** + * Process group is what group we should use to actually process + * this match group. + * + * For example if the subgroup pattern looks like this: + * + * 2: { + * 'name': 'keyword', + * 'pattern': /true/g + * } + * + * then we use that as is, but if it looks like this: + * + * 2: { + * 'name': 'keyword', + * 'matches': { + * 'name': 'special', + * 'pattern': /whatever/g + * } + * } + * + * we treat the 'matches' part as the pattern and keep + * the name around to wrap it with later + */ + const groupToProcess = group.name && group.matches ? group.matches : group; + + /** + * Takes the code block matched at this group, replaces it + * with the highlighted block, and optionally wraps it with + * a span with a name + * + * @param {string} passedBlock + * @param {string} replaceBlock + * @param {string|null} matchName + */ + const _getReplacement = function(passedBlock, replaceBlock, matchName) { + replacement = util.replaceAtPosition(util.indexOfGroup(match, groupKey), passedBlock, matchName ? util.wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement); + return; + }; + + // If this is a string then this match is directly mapped + // to selector so all we have to do is wrap it in a span + // and continue. + if (typeof group === 'string') { + _getReplacement(block, block, group); + return; + } + + let localCode; + const drop = new Raindrop(); + + // If this is a sublanguage go and process the block using + // that language + if (language) { + localCode = drop.refract(block, language); + _getReplacement(block, localCode); + return; + } + + // The process group can be a single pattern or an array of + // patterns. `_processCodeWithPatterns` always expects an array + // so we convert it here. + localCode = drop.refract(block, currentLanguage, groupToProcess.length ? groupToProcess : [groupToProcess]); + _getReplacement(block, localCode, group.matches ? group.name : 0); + } + + // If this pattern has sub matches for different groups in the regex + // then we should process them one at a time by running them through + // the _processGroup function to generate the new replacement. + // + // We use the `keys` function to run through them backwards because + // the match position of earlier matches will not change depending + // on what gets replaced in later matches. + const groupKeys = util.keys(pattern.matches); + for (const groupKey of groupKeys) { + _processGroup(groupKey); + } + + // Finally, call `onMatchSuccess` with the replacement + onMatchSuccess(replacement); + } + + /** + * Processes a block of code using specified patterns + * + * @param {string} code + * @param {Array} patterns + * @return {string} + */ + function _processCodeWithPatterns(code, patterns) { + for (const pattern of patterns) { + _processPattern(pattern, code); + } + + // We are done processing the patterns so we should actually replace + // what needs to be replaced in the code. + return _processReplacements(code); + } + + /** + * Takes a string of code and highlights it according to the language + * specified + * + * @param {string} code + * @param {string} language + * @param {object} patterns optionally specify a list of patterns + * @return {string} + */ + function _highlightBlockForLanguage(code, language, patterns) { + currentLanguage = language; + patterns = patterns || util.getPatternsForLanguage(language, this); + return _processCodeWithPatterns(util.htmlEntities(code), patterns); + } + + this.refract = _highlightBlockForLanguage; + } +} + +export default Raindrop; diff --git a/src/util.js b/src/util.js new file mode 100644 index 00000000..2ceb992b --- /dev/null +++ b/src/util.js @@ -0,0 +1,285 @@ +/** + * An array of the language patterns specified for each language + * + * @type {Object} + */ +export const languagePatterns = {}; + +/** + * An array of languages and whether they should bypass the + * default patterns + * + * @type {Object} + */ +export const bypassDefaults = {}; + +/** + * A mapping of language aliases + * + * @type {Object} + */ +export const aliases = {}; + +/** + * Constant used to refer to the default language + * + * @type {number} + */ +export const DEFAULT_LANGUAGE = 1; + +/** + * Method to add an alias for an existing language. + * + * For example if you want to have "coffee" map to "coffeescript" + * + * @see https://github.com/ccampbell/rainbow/issues/154 + * @param {string} alias + * @param {string} originalLanguage + * @return {void} + */ +export function addAlias(alias, originalLanguage) { + aliases[alias] = originalLanguage; +} + +function _addGlobal(thing) { + if (typeof thing === 'function') { + return `\n${thing.toString()}`; + } + + let toAdd = ''; + if (typeof thing === 'object') { + for (const key in thing) { + toAdd += _addGlobal(thing[key]); + } + } + + return toAdd; +} + +export function isNode() { + /* globals module */ + return typeof module !== 'undefined' && typeof module.exports === 'object'; +} + +export function isWorker() { + return typeof document === 'undefined' && typeof self !== 'undefined'; +} + +/** + * Creates a usable web worker from an anonymous function + * + * mostly borrowed from https://github.com/zevero/worker-create + * + * @param {Function} fn + * @param {Array} globals global functions that should be added to the worker scope + * @return {Worker} + */ +export function createWorker(fn, globals) { + if (isNode()) { + /* globals global, require, __filename */ + global.Worker = require('webworker-threads').Worker; + return new Worker(__filename); + } + + if (!Array.isArray(globals)) { + globals = [globals]; + } + + let code = '"use strict"'; + for (const thing of globals) { + code += _addGlobal(thing); + } + + const str = fn.toString(); + const fullString = `${code}\tthis.onmessage =${str}`; + + const blob = new Blob([fullString], { type: 'text/javascript' }); + return new Worker((window.URL || window.webkitURL).createObjectURL(blob)); +} + +/** + * Extends the language pattern matches + * + * @param {string} language name of language + * @param {object} patterns object of patterns to add on + * @param {boolean|null} bypass if `true` this will not inherit the + * default language patterns + */ +export function extend(...args) { + let [language, patterns, bypass] = args; + + // If there is only one argument then we assume that we want to + // extend the default language rules. + if (args.length === 1) { + patterns = language; + language = DEFAULT_LANGUAGE; + bypass = null; + } + + bypassDefaults[language] = bypass; + languagePatterns[language] = patterns.concat(languagePatterns[language] || []); +} + +/** + * Browser Only - Gets the language for this block of code + * + * @param {Element} block + * @return {string|null} + */ +export function getLanguageForBlock(block) { + + // If this doesn't have a language but the parent does then use that. + // + // This means if for example you have:
    +    // with a bunch of  blocks inside then you do not have
    +    // to specify the language for each block.
    +    let language = block.getAttribute('data-language') || block.parentNode.getAttribute('data-language');
    +
    +    // This adds support for specifying language via a CSS class.
    +    //
    +    // You can use the Google Code Prettify style: 
    +    // or the HTML5 style: 
    
    +    if (!language) {
    +        const pattern = /\blang(?:uage)?-(\w+)/;
    +        const match = block.className.match(pattern) || block.parentNode.className.match(pattern);
    +
    +        if (match) {
    +            language = match[1];
    +        }
    +    }
    +
    +    if (language) {
    +        return language.toLowerCase();
    +    }
    +
    +    return null;
    +}
    +
    +/**
    + * Returns a list of regex patterns for this language
    + *
    + * @param {string} language
    + * @return {Array}
    + */
    +export function getPatternsForLanguage(language) {
    +    const langPatterns = isWorker() ? self.languagePatterns : languagePatterns;
    +    const bypass = isWorker() ? self.bypassDefaults : bypassDefaults;
    +
    +    const patterns = langPatterns[language] || [];
    +    const defaultPatterns = langPatterns[DEFAULT_LANGUAGE] || [];
    +
    +    return bypass[language] ? patterns : patterns.concat(defaultPatterns);
    +}
    +
    +/**
    + * Determines if two different matches have complete overlap with each other
    + *
    + * @param {number} start1   start position of existing match
    + * @param {number} end1     end position of existing match
    + * @param {number} start2   start position of new match
    + * @param {number} end2     end position of new match
    + * @return {boolean}
    + */
    +export function hasCompleteOverlap(start1, end1, start2, end2) {
    +
    +    // If the starting and end positions are exactly the same
    +    // then the first one should stay and this one should be ignored.
    +    if (start2 === start1 && end2 === end1) {
    +        return false;
    +    }
    +
    +    return start2 <= start1 && end2 >= end1;
    +}
    +
    +/**
    + * Encodes < and > as html entities
    + *
    + * @param {string} code
    + * @return {string}
    + */
    +export function htmlEntities(code) {
    +    return code.replace(//g, '>').replace(/&(?![\w\#]+;)/g, '&');
    +}
    +
    +/**
    + * Finds out the position of group match for a regular expression
    + *
    + * @see http://stackoverflow.com/questions/1985594/how-to-find-index-of-groups-in-match
    + * @param {Object} match
    + * @param {number} groupNumber
    + * @return {number}
    + */
    +export function indexOfGroup(match, groupNumber) {
    +    let index = 0;
    +
    +    for (let i = 1; i < groupNumber; ++i) {
    +        if (match[i]) {
    +            index += match[i].length;
    +        }
    +    }
    +
    +    return index;
    +}
    +
    +/**
    + * Determines if a new match intersects with an existing one
    + *
    + * @param {number} start1    start position of existing match
    + * @param {number} end1      end position of existing match
    + * @param {number} start2    start position of new match
    + * @param {number} end2      end position of new match
    + * @return {boolean}
    + */
    +export function intersects(start1, end1, start2, end2) {
    +    if (start2 >= start1 && start2 < end1) {
    +        return true;
    +    }
    +
    +    return end2 > start1 && end2 < end1;
    +}
    +
    +/**
    + * Sorts an objects keys by index descending
    + *
    + * @param {Object} object
    + * @return {Array}
    + */
    +export function keys(object) {
    +    const locations = [];
    +
    +    for (const location in object) {
    +        if (object.hasOwnProperty(location)) {
    +            locations.push(location);
    +        }
    +    }
    +
    +    // numeric descending
    +    return locations.sort((a, b) => b - a);
    +}
    +
    +/**
    + * Substring replace call to replace part of a string at a certain position
    + *
    + * @param {number} position         the position where the replacement
    + *                                  should happen
    + * @param {string} replace          the text we want to replace
    + * @param {string} replaceWith      the text we want to replace it with
    + * @param {string} code             the code we are doing the replacing in
    + * @return {string}
    + */
    +export function replaceAtPosition(position, replace, replaceWith, code) {
    +    const subString = code.substr(position);
    +    return code.substr(0, position) + subString.replace(replace, replaceWith);
    +}
    +
    +/**
    + * Takes a string of code and wraps it in a span tag based on the name
    + *
    + * @param {string} name        name of the pattern (ie keyword.regex)
    + * @param {string} code        block of code to wrap
    + * @param {string} globalClass class to apply to every span
    + * @return {string}
    + */
    +export function wrapCodeInSpan(name, code, globalClass) {
    +    return `${code}`;
    +}
    diff --git a/src/worker.js b/src/worker.js
    new file mode 100644
    index 00000000..60b35b9b
    --- /dev/null
    +++ b/src/worker.js
    @@ -0,0 +1,22 @@
    +import Raindrop from './raindrop';
    +
    +export default function rainbowWorker(e) {
    +    const message = e.data;
    +
    +    self.languagePatterns = message.languagePatterns;
    +    self.bypassDefaults = message.bypassDefaults;
    +    self.aliases = message.aliases;
    +    self.globalClass = message.globalClass;
    +    self.DEFAULT_LANGUAGE = message.DEFAULT_LANGUAGE;
    +
    +    const drop = new Raindrop();
    +    const result = drop.refract(message.code, message.lang);
    +
    +    self.postMessage({
    +        id: message.id,
    +        lang: message.lang,
    +        result
    +    });
    +
    +    self.close();
    +}
    
    From 54ffff2c81e74c109f6219fdf2288bb053dc814c Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sun, 26 Jun 2016 15:39:09 -0400
    Subject: [PATCH 079/153] Use rainbow class to decrease animation delay
    
    ---
     themes/sass/_init.sass | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index b7ffc261..b41babd1 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -20,7 +20,7 @@
     
         animation: 50ms ease-in-out 1000ms forwards fade-in
     
    -    &.decrease-delay
    +    &.rainbow
             animation-delay: 75ms
     
         &.stop-animation
    
    From d35024f56acc1f41894e5c91159d8cf31385e5a2 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sun, 26 Jun 2016 15:39:22 -0400
    Subject: [PATCH 080/153] Update all themes
    
    ---
     themes/css/all-hallows-eve.css | 2 +-
     themes/css/blackboard.css      | 2 +-
     themes/css/dreamweaver.css     | 2 +-
     themes/css/espresso-libre.css  | 2 +-
     themes/css/github.css          | 2 +-
     themes/css/kimbie-dark.css     | 2 +-
     themes/css/kimbie-light.css    | 2 +-
     themes/css/monokai.css         | 2 +-
     themes/css/obsidian.css        | 2 +-
     themes/css/paraiso-dark.css    | 2 +-
     themes/css/paraiso-light.css   | 2 +-
     themes/css/pastie.css          | 2 +-
     themes/css/solarized-dark.css  | 2 +-
     themes/css/solarized-light.css | 2 +-
     themes/css/sunburst.css        | 2 +-
     themes/css/tomorrow-night.css  | 2 +-
     themes/css/tricolore.css       | 2 +-
     themes/css/twilight.css        | 2 +-
     themes/css/zenburnesque.css    | 2 +-
     19 files changed, 19 insertions(+), 19 deletions(-)
    
    diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css
    index d42ce481..2afb5295 100644
    --- a/themes/css/all-hallows-eve.css
    +++ b/themes/css/all-hallows-eve.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730}
    diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css
    index 69d9b924..5ed8308d 100644
    --- a/themes/css/blackboard.css
    +++ b/themes/css/blackboard.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE}
    diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css
    index f493fd08..35d4614f 100644
    --- a/themes/css/dreamweaver.css
    +++ b/themes/css/dreamweaver.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal}
    diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css
    index b0553031..45b45882 100644
    --- a/themes/css/espresso-libre.css
    +++ b/themes/css/espresso-libre.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495}
    diff --git a/themes/css/github.css b/themes/css/github.css
    index 1fa6e4f5..b5d4fd41 100644
    --- a/themes/css/github.css
    +++ b/themes/css/github.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926}
    diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css
    index ee77a553..47d7fe36 100644
    --- a/themes/css/kimbie-dark.css
    +++ b/themes/css/kimbie-dark.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a}
    diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css
    index 252dcfba..f7034f29 100644
    --- a/themes/css/kimbie-light.css
    +++ b/themes/css/kimbie-light.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a}
    diff --git a/themes/css/monokai.css b/themes/css/monokai.css
    index 0aa03cde..2a6631fe 100644
    --- a/themes/css/monokai.css
    +++ b/themes/css/monokai.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff}
    diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css
    index 0667ddb3..6a332a10 100644
    --- a/themes/css/obsidian.css
    +++ b/themes/css/obsidian.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22}
    diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css
    index 18abb0e1..6396bbba 100644
    --- a/themes/css/paraiso-dark.css
    +++ b/themes/css/paraiso-dark.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4}
    diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css
    index e3c57a47..8ace263e 100644
    --- a/themes/css/paraiso-light.css
    +++ b/themes/css/paraiso-light.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4}
    diff --git a/themes/css/pastie.css b/themes/css/pastie.css
    index 1ccb161b..6a592253 100644
    --- a/themes/css/pastie.css
    +++ b/themes/css/pastie.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold}
    diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css
    index 41d35dd4..7380244a 100644
    --- a/themes/css/solarized-dark.css
    +++ b/themes/css/solarized-dark.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900}
    diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css
    index 5b504bd0..57ac2135 100644
    --- a/themes/css/solarized-light.css
    +++ b/themes/css/solarized-light.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900}
    diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css
    index da353c9b..fcda5455 100644
    --- a/themes/css/sunburst.css
    +++ b/themes/css/sunburst.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE}
    diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css
    index a2d2b896..3b6358d7 100644
    --- a/themes/css/tomorrow-night.css
    +++ b/themes/css/tomorrow-night.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb}
    diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css
    index 4ba92274..50972fd8 100644
    --- a/themes/css/tricolore.css
    +++ b/themes/css/tricolore.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F}
    diff --git a/themes/css/twilight.css b/themes/css/twilight.css
    index a1a02a45..dc922ae1 100644
    --- a/themes/css/twilight.css
    +++ b/themes/css/twilight.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC}
    diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css
    index 8962d9af..899dd808 100644
    --- a/themes/css/zenburnesque.css
    +++ b/themes/css/zenburnesque.css
    @@ -1 +1 @@
    -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.decrease-delay,pre [data-language].decrease-delay{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000}
    +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000}
    
    From 9440129e48f1696902740a0bd72b1d559e8c63e0 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sun, 26 Jun 2016 16:19:45 -0400
    Subject: [PATCH 081/153] Make sure not to trim the same pre elements multiple
     times
    
    Fixes race condition where sometimes calls to Rainbow.color while other
    calls are happening could prevent code from being highlighted
    ---
     src/rainbow.js | 8 +++++++-
     1 file changed, 7 insertions(+), 1 deletion(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 88265288..14758cdc 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -203,7 +203,13 @@ function _highlight(node, callback) {
             // If you want to preserve whitespace you can use a pre tag on
             // its own without a code tag inside of it.
             if (preBlock.getElementsByTagName('code').length) {
    -            preBlock.innerHTML = preBlock.innerHTML.trim();
    +
    +            // This fixes a race condition when Rainbow.color is called before
    +            // the previous color call has finished.
    +            if (!preBlock.getAttribute('data-trimmed')) {
    +                preBlock.setAttribute('data-trimmed', true);
    +                preBlock.innerHTML = preBlock.innerHTML.trim();
    +            }
                 continue;
             }
     
    
    From d760bc58c6897e86c2cab64a24dae7129899c32d Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sun, 26 Jun 2016 16:31:51 -0400
    Subject: [PATCH 082/153] Fix path to demo files
    
    ---
     demos/index.html | 30 +++++++++++++++---------------
     1 file changed, 15 insertions(+), 15 deletions(-)
    
    diff --git a/demos/index.html b/demos/index.html
    index 62bb7aa7..ad17bc35 100644
    --- a/demos/index.html
    +++ b/demos/index.html
    @@ -3,20 +3,20 @@
     Syntax Highlighting
     
         
     
    
    From 52e71b412d29340a36abd3f9d7c24e913560954e Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sun, 26 Jun 2016 16:32:35 -0400
    Subject: [PATCH 083/153] Alphabetize list of demos
    
    ---
     demos/index.html | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/demos/index.html b/demos/index.html
    index ad17bc35..f1152181 100644
    --- a/demos/index.html
    +++ b/demos/index.html
    @@ -8,6 +8,7 @@
             
  • go demo
  • html demo
  • js demo
  • +
  • lua demo
  • php demo
  • php long demo
  • python demo
  • @@ -16,7 +17,5 @@
  • ruby-test demo
  • scheme demo
  • shell demo
  • -
  • lua demo
  • -
  • go demo
  • From 264d2830fc78f6c21e60cecbcd2c3b52815ed622 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 16:33:37 -0400 Subject: [PATCH 084/153] Add Menlo as default fallback font before courier --- themes/sass/_base.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/sass/_base.sass b/themes/sass/_base.sass index d34867ef..a00cc1a6 100644 --- a/themes/sass/_base.sass +++ b/themes/sass/_base.sass @@ -10,4 +10,4 @@ pre margin-bottom: 20px pre, code - font-family: 'Monaco', courier, monospace + font-family: 'Monaco', 'Menlo', courier, monospace From 7802714b441d1c708ad71993fc915df19b51656c Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 16:34:05 -0400 Subject: [PATCH 085/153] Update all themes --- themes/css/all-hallows-eve.css | 2 +- themes/css/blackboard.css | 2 +- themes/css/dreamweaver.css | 2 +- themes/css/espresso-libre.css | 2 +- themes/css/kimbie-dark.css | 2 +- themes/css/kimbie-light.css | 2 +- themes/css/monokai.css | 2 +- themes/css/obsidian.css | 2 +- themes/css/paraiso-dark.css | 2 +- themes/css/paraiso-light.css | 2 +- themes/css/pastie.css | 2 +- themes/css/solarized-dark.css | 2 +- themes/css/solarized-light.css | 2 +- themes/css/sunburst.css | 2 +- themes/css/tomorrow-night.css | 2 +- themes/css/tricolore.css | 2 +- themes/css/twilight.css | 2 +- themes/css/zenburnesque.css | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css index 2afb5295..f71e996d 100644 --- a/themes/css/all-hallows-eve.css +++ b/themes/css/all-hallows-eve.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css index 5ed8308d..6c1cf9e2 100644 --- a/themes/css/blackboard.css +++ b/themes/css/blackboard.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css index 35d4614f..fea054ab 100644 --- a/themes/css/dreamweaver.css +++ b/themes/css/dreamweaver.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css index 45b45882..eab3e4c7 100644 --- a/themes/css/espresso-libre.css +++ b/themes/css/espresso-libre.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css index 47d7fe36..794aae6c 100644 --- a/themes/css/kimbie-dark.css +++ b/themes/css/kimbie-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css index f7034f29..13465214 100644 --- a/themes/css/kimbie-light.css +++ b/themes/css/kimbie-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/monokai.css b/themes/css/monokai.css index 2a6631fe..60debd4b 100644 --- a/themes/css/monokai.css +++ b/themes/css/monokai.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css index 6a332a10..e587c805 100644 --- a/themes/css/obsidian.css +++ b/themes/css/obsidian.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css index 6396bbba..396d7112 100644 --- a/themes/css/paraiso-dark.css +++ b/themes/css/paraiso-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css index 8ace263e..79ccd801 100644 --- a/themes/css/paraiso-light.css +++ b/themes/css/paraiso-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/pastie.css b/themes/css/pastie.css index 6a592253..b5b206b6 100644 --- a/themes/css/pastie.css +++ b/themes/css/pastie.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css index 7380244a..7ed3f3af 100644 --- a/themes/css/solarized-dark.css +++ b/themes/css/solarized-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css index 57ac2135..d3494092 100644 --- a/themes/css/solarized-light.css +++ b/themes/css/solarized-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css index fcda5455..524029c7 100644 --- a/themes/css/sunburst.css +++ b/themes/css/sunburst.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css index 3b6358d7..51a946df 100644 --- a/themes/css/tomorrow-night.css +++ b/themes/css/tomorrow-night.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css index 50972fd8..001be02c 100644 --- a/themes/css/tricolore.css +++ b/themes/css/tricolore.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} diff --git a/themes/css/twilight.css b/themes/css/twilight.css index dc922ae1..58273afa 100644 --- a/themes/css/twilight.css +++ b/themes/css/twilight.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css index 899dd808..34238d5b 100644 --- a/themes/css/zenburnesque.css +++ b/themes/css/zenburnesque.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} +@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} From 7782c3251d3b7045e433b56d5efbc8e5d38089aa Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 16:46:20 -0400 Subject: [PATCH 086/153] Update release process to match previous convention --- gulpfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 164e6f4d..c97a7671 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -66,7 +66,7 @@ gulp.task('pack', function() { }); function _getComment() { - return '/* ' + lowercaseAppName + ' v' + argv.version + ' */'; + return '/* ' + appName + ' v' + argv.version + ' rainbowco.de */'; } gulp.task('update-version', function() { @@ -78,12 +78,12 @@ gulp.task('update-version', function() { .pipe(inject.prepend(_getComment())) .pipe(gulp.dest('dist')); - var message = 'Update version to v' + argv.version; + var message = 'Update version to ' + argv.version; gulp.src(['./package.json', 'dist/' + lowercaseAppName + '.min.js']) .pipe(git.add()) .pipe(git.commit(message)) .on('data', function(err) { - git.tag('v' + argv.version, message); + git.tag(argv.version, message); }); }); From 4902bcd65364391613ce05f387e4c38621d46bba Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:18:11 -0400 Subject: [PATCH 087/153] Remove default language constant This was causing some sort of issue with uglify that I can't figure out right now. Using the string "generic" in its place works fine --- src/rainbow.js | 1 - src/util.js | 11 ++--------- src/worker.js | 1 - 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index 14758cdc..6f969946 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -114,7 +114,6 @@ function _getWorkerData(code, lang) { languagePatterns: util.languagePatterns, bypassDefaults: util.bypassDefaults, aliases: util.aliases, - DEFAULT_LANGUAGE: util.DEFAULT_LANGUAGE, globalClass }; diff --git a/src/util.js b/src/util.js index 2ceb992b..a9e4211a 100644 --- a/src/util.js +++ b/src/util.js @@ -20,13 +20,6 @@ export const bypassDefaults = {}; */ export const aliases = {}; -/** - * Constant used to refer to the default language - * - * @type {number} - */ -export const DEFAULT_LANGUAGE = 1; - /** * Method to add an alias for an existing language. * @@ -112,7 +105,7 @@ export function extend(...args) { // extend the default language rules. if (args.length === 1) { patterns = language; - language = DEFAULT_LANGUAGE; + language = 'generic'; bypass = null; } @@ -166,7 +159,7 @@ export function getPatternsForLanguage(language) { const bypass = isWorker() ? self.bypassDefaults : bypassDefaults; const patterns = langPatterns[language] || []; - const defaultPatterns = langPatterns[DEFAULT_LANGUAGE] || []; + const defaultPatterns = langPatterns['generic'] || []; return bypass[language] ? patterns : patterns.concat(defaultPatterns); } diff --git a/src/worker.js b/src/worker.js index 60b35b9b..1380f2cd 100644 --- a/src/worker.js +++ b/src/worker.js @@ -7,7 +7,6 @@ export default function rainbowWorker(e) { self.bypassDefaults = message.bypassDefaults; self.aliases = message.aliases; self.globalClass = message.globalClass; - self.DEFAULT_LANGUAGE = message.DEFAULT_LANGUAGE; const drop = new Raindrop(); const result = drop.refract(message.code, message.lang); From e3d4797498f0fcea75f16ca61a7c25481711aafa Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:19:46 -0400 Subject: [PATCH 088/153] Fix issue where minified code does not work I have no idea what is causing this to happen but when the Raindrop class is used as part of fn.toString() inside of a blob/web worker it gets named the wrong variable. This is an awful hack and there has to be a better way to handle this. --- src/util.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index a9e4211a..0e3ea46e 100644 --- a/src/util.js +++ b/src/util.js @@ -78,12 +78,18 @@ export function createWorker(fn, globals) { globals = [globals]; } - let code = '"use strict"'; + let code = ''; for (const thing of globals) { code += _addGlobal(thing); } - const str = fn.toString(); + // This is an awful hack, but something to do with how uglify renames stuff + // and rollup means that the variable the worker.js is using to reference + // Raindrop will not be the same one available in this context + const raindropName = globals[0].toString().match(/function (\w*?)\(/)[1]; + let str = fn.toString(); + str = str.replace(/=new \w*/, `= new ${raindropName}`); + const fullString = `${code}\tthis.onmessage =${str}`; const blob = new Blob([fullString], { type: 'text/javascript' }); From fb7e14b4d4c8d2f55246a7f655ff20decfe99fb3 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:19:54 -0400 Subject: [PATCH 089/153] Update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 66beb2c4..590910cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ *.pyc *.sw? -js/rainbow-custom.min.js +dist/rainbow-custom.min.js .AppleDouble node_modules rainbow.sublime-workspace .sass-cache coverage +src/build.js From 5736c75fdfbf66f226e21bb1885c5139685a6827 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:20:33 -0400 Subject: [PATCH 090/153] Add src/build.js to sublime ignore --- rainbow.sublime-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rainbow.sublime-project b/rainbow.sublime-project index ad8e7373..78f4b076 100644 --- a/rainbow.sublime-project +++ b/rainbow.sublime-project @@ -26,7 +26,7 @@ { "path": "./", "folder_exclude_patterns": ["dist", "node_modules"], - "file_exclude_patterns": ["*.sublime-workspace"] + "file_exclude_patterns": ["*.sublime-workspace", "src/build.js"] } ] } From 3e53530442b166ec0599d4e0a3fa7652a736aec2 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:21:41 -0400 Subject: [PATCH 091/153] Add ability to do custom builds --- gulpfile.js | 104 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 96 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c97a7671..3e313ba8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,7 @@ var del = require('del'); var KarmaServer = require('karma').Server; var argv = require('yargs').argv; var eslint = require('gulp-eslint'); +var fs = require('fs'); var rollup = require("rollup").rollup; var buble = require('rollup-plugin-buble'); var uglify = require('rollup-plugin-uglify'); @@ -21,6 +22,19 @@ var version = require('./package.json').version; var appName = 'Rainbow'; var lowercaseAppName = 'rainbow'; +function _getDestinationPath() { + var destination = 'dist/' + lowercaseAppName + '.js'; + if (argv.release) { + destination = 'dist/' + lowercaseAppName + '.min.js'; + } + + if (argv.custom) { + destination = 'dist/' + lowercaseAppName + '-custom.min.js'; + } + + return destination; +} + gulp.task('pack', function() { var plugins = [ buble({ @@ -35,18 +49,16 @@ gulp.task('pack', function() { } var includeSourceMaps = true; - if (argv.sourcemaps == '0' || argv.release) { + if (argv.sourcemaps == '0' || argv.release || argv.custom) { includeSourceMaps = false; } - var dest = 'dist/' + lowercaseAppName + '.js'; + var entry = 'src/' + lowercaseAppName + '.js'; + var dest = _getDestinationPath(); var format = 'umd'; - if (argv.release) { - dest = 'dist/' + lowercaseAppName + '.min.js'; - } return rollup({ - entry: 'src/' + lowercaseAppName + '.js', + entry: entry, sourceMap: includeSourceMaps, plugins: plugins }).then(function (bundle) { @@ -65,8 +77,50 @@ gulp.task('pack', function() { }); }); +function _needsGeneric(languages) { + var needsGeneric = ['php', 'python', 'javascript', 'go', 'c', 'r', 'coffeescript', 'haskell']; + + for (var i = 0; i < languages.length; i++) { + if (needsGeneric.indexOf(languages[i]) !== -1) { + return true; + } + } + + return false; +} + +function _getLanguageList() { + if (argv.languages.toLowerCase() === 'all') { + var files = fs.readdirSync('./src/language'); + var languages = ['generic']; + for (var i = 0; i < files.length; i++) { + var lang = files[i].replace('.js', ''); + if (lang !== 'generic') { + languages.push(lang); + } + } + + return languages; + } + + var languages = argv.languages.toLowerCase().split(','); + if (_needsGeneric(languages) && languages.indexOf('generic') === -1) { + languages.unshift('generic'); + } + + return languages; +} + function _getComment() { - return '/* ' + appName + ' v' + argv.version + ' rainbowco.de */'; + var comment = '/* ' + appName + ' v' + (argv.version || version) + ' rainbowco.de' + + if (argv.languages) { + var languages = _getLanguageList(); + comment += ' | included languages: ' + languages.sort().join(', '); + } + + comment += ' */'; + return comment; } gulp.task('update-version', function() { @@ -74,7 +128,9 @@ gulp.task('update-version', function() { .pipe(bump({version: argv.version})) .pipe(gulp.dest('./')); - gulp.src('dist/' + lowercaseAppName + '.min.js') + var dest = _getDestinationPath(); + + gulp.src(dest) .pipe(inject.prepend(_getComment())) .pipe(gulp.dest('dist')); @@ -121,6 +177,38 @@ gulp.task('release', function(callback) { runSequence('test', 'pack', 'update-version', callback); }); +gulp.task('append-languages', function() { + var languageCode = []; + + var languages = _getLanguageList(); + for (var i = 0; i < languages.length; i++) { + languageCode.push('import \'./language/' + languages[i] + '\';'); + } + + fs.writeFileSync('src/build.js', languageCode.join('\n')); + + rollup({ + entry: 'src/build.js', + plugins: [uglify()] + }).then(function (bundle) { + var dest = _getDestinationPath(); + gulp.src(dest) + .pipe(inject.prepend(_getComment())) + .pipe(inject.append("\n" + bundle.generate().code)) + .pipe(gulp.dest('dist')); + }); +}); + +gulp.task('build', function(callback) { + if (!argv.languages) { + argv.languages = 'all'; + } + + argv.ugly = true; + argv.custom = true; + runSequence('pack', 'append-languages', callback); +}); + gulp.task('sass', function() { return gulp.src('./themes/sass/*.sass') .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) From 3ea78c19c11d9bc9b550c3c3e9074bdd738d414a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:35:12 -0400 Subject: [PATCH 092/153] Make release include all languages by default --- gulpfile.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3e313ba8..25379028 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -114,7 +114,7 @@ function _getLanguageList() { function _getComment() { var comment = '/* ' + appName + ' v' + (argv.version || version) + ' rainbowco.de' - if (argv.languages) { + if (argv.languages !== 'all') { var languages = _getLanguageList(); comment += ' | included languages: ' + languages.sort().join(', '); } @@ -123,17 +123,13 @@ function _getComment() { return comment; } -gulp.task('update-version', function() { +gulp.task('update-package-version', function() { gulp.src('./package.json') .pipe(bump({version: argv.version})) .pipe(gulp.dest('./')); +}); - var dest = _getDestinationPath(); - - gulp.src(dest) - .pipe(inject.prepend(_getComment())) - .pipe(gulp.dest('dist')); - +gulp.task('update-version', function() { var message = 'Update version to ' + argv.version; gulp.src(['./package.json', 'dist/' + lowercaseAppName + '.min.js']) .pipe(git.add()) @@ -174,7 +170,7 @@ gulp.task('release', function(callback) { argv.release = true; argv.version = newVersion; - runSequence('test', 'pack', 'update-version', callback); + runSequence('test', 'update-package-version', 'build', 'update-version', callback); }); gulp.task('append-languages', function() { @@ -205,7 +201,10 @@ gulp.task('build', function(callback) { } argv.ugly = true; - argv.custom = true; + if (argv.languages !== 'all') { + argv.custom = true; + } + runSequence('pack', 'append-languages', callback); }); From b6692ee979be10835482a11d6273f1f1463c0497 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:44:56 -0400 Subject: [PATCH 093/153] Allow specifying "none" for languages --- gulpfile.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 25379028..1eec2a3f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -103,6 +103,10 @@ function _getLanguageList() { return languages; } + if (!argv.languages) { + return []; + } + var languages = argv.languages.toLowerCase().split(','); if (_needsGeneric(languages) && languages.indexOf('generic') === -1) { languages.unshift('generic'); @@ -173,6 +177,14 @@ gulp.task('release', function(callback) { runSequence('test', 'update-package-version', 'build', 'update-version', callback); }); +function _appendCode(code) { + var dest = _getDestinationPath(); + gulp.src(dest) + .pipe(inject.prepend(_getComment())) + .pipe(inject.append(code)) + .pipe(gulp.dest('dist')); +} + gulp.task('append-languages', function() { var languageCode = []; @@ -181,17 +193,19 @@ gulp.task('append-languages', function() { languageCode.push('import \'./language/' + languages[i] + '\';'); } + if (languageCode.length === 0) { + argv.languages = 'none'; + _appendCode(''); + return; + } + fs.writeFileSync('src/build.js', languageCode.join('\n')); rollup({ entry: 'src/build.js', plugins: [uglify()] }).then(function (bundle) { - var dest = _getDestinationPath(); - gulp.src(dest) - .pipe(inject.prepend(_getComment())) - .pipe(inject.append("\n" + bundle.generate().code)) - .pipe(gulp.dest('dist')); + _appendCode("\n" + bundle.generate().code); }); }); @@ -205,6 +219,10 @@ gulp.task('build', function(callback) { argv.custom = true; } + if (argv.languages === 'none') { + argv.languages = ''; + } + runSequence('pack', 'append-languages', callback); }); From e8c4a77a13e96e7205da1bd0185998f43cc5f372 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:51:48 -0400 Subject: [PATCH 094/153] Always use custom when you run build yourself --- gulpfile.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1eec2a3f..41889d56 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -215,9 +215,7 @@ gulp.task('build', function(callback) { } argv.ugly = true; - if (argv.languages !== 'all') { - argv.custom = true; - } + argv.custom = true; if (argv.languages === 'none') { argv.languages = ''; From 9e57852237bfbcd9cee6c0f95a77fe60fcfd49ce Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 19:52:08 -0400 Subject: [PATCH 095/153] Force release builds to go to .min.js --- gulpfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 41889d56..4f1d9706 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,11 +23,12 @@ var appName = 'Rainbow'; var lowercaseAppName = 'rainbow'; function _getDestinationPath() { - var destination = 'dist/' + lowercaseAppName + '.js'; if (argv.release) { destination = 'dist/' + lowercaseAppName + '.min.js'; + return destination; } + var destination = 'dist/' + lowercaseAppName + '.js'; if (argv.custom) { destination = 'dist/' + lowercaseAppName + '-custom.min.js'; } From e095454233e3b40b51a4469c481b237eeeaf59c1 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 21:14:36 -0400 Subject: [PATCH 096/153] Remove comment about Worker --- src/rainbow.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index 6f969946..61ea5172 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -35,11 +35,6 @@ let globalClass; */ let onHighlight; -/** - * Reference to web worker for doing the heavy lifting - * - * @type Worker - */ const isNode = util.isNode(); const isWorker = util.isWorker(); From f21cf674426fc7f27bf5cc4ccd164e526a403f3f Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 21:45:12 -0400 Subject: [PATCH 097/153] Handle quotes inside curly braces Applying 34b9c622b34654f390a45eba5e09905e09fd1b5a from master --- src/language/generic.js | 2 +- test/language/javascript-test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/language/generic.js b/src/language/generic.js index 7e1dde65..0c70d375 100644 --- a/src/language/generic.js +++ b/src/language/generic.js @@ -25,7 +25,7 @@ Rainbow.extend([ } } }, - 'pattern': /(\(|\s|\[|\=|:|\+|\.)(('|")([^\\\1]|\\.)*?(\3))/gm + 'pattern': /(\(|\s|\[|\=|:|\+|\.|\{)(('|")([^\\\1]|\\.)*?(\3))/gm }, { 'name': 'comment', diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js index c3198bd3..252619e9 100644 --- a/test/language/javascript-test.js +++ b/test/language/javascript-test.js @@ -225,5 +225,17 @@ describe(language, () => { 'code.replace(/</g, \'<\').replace(/>/g, \'>\')' ); + + run( + language, + + 'quotes inside curly brackets', + + '{\' \'}\n' + + 'var str = \'something\';', + + '{\' \'}\n' + + 'var str = \'something\';' + ); }); From 2282b9c34fd337522f603041084416bc37fa9d2e Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 21:45:22 -0400 Subject: [PATCH 098/153] Decrease animation delay/time --- themes/sass/_init.sass | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index b41babd1..740d02d4 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -2,9 +2,6 @@ 0% opacity: 0 - 5% - opacity: 0 - 100% opacity: 1 @@ -18,10 +15,10 @@ // IE 10+ and all modern browsers support CSS animations -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)" - animation: 50ms ease-in-out 1000ms forwards fade-in + animation: 40ms ease-in-out 1000ms forwards fade-in &.rainbow - animation-delay: 75ms + animation-delay: 0ms &.stop-animation opacity: 0 From 502f4fff2579b9f7cf84feac9345117a3cbcc1ec Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 21:45:36 -0400 Subject: [PATCH 099/153] Update all themes --- themes/css/all-hallows-eve.css | 2 +- themes/css/blackboard.css | 2 +- themes/css/dreamweaver.css | 2 +- themes/css/espresso-libre.css | 2 +- themes/css/github.css | 2 +- themes/css/kimbie-dark.css | 2 +- themes/css/kimbie-light.css | 2 +- themes/css/monokai.css | 2 +- themes/css/obsidian.css | 2 +- themes/css/paraiso-dark.css | 2 +- themes/css/paraiso-light.css | 2 +- themes/css/pastie.css | 2 +- themes/css/solarized-dark.css | 2 +- themes/css/solarized-light.css | 2 +- themes/css/sunburst.css | 2 +- themes/css/tomorrow-night.css | 2 +- themes/css/tricolore.css | 2 +- themes/css/twilight.css | 2 +- themes/css/zenburnesque.css | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css index f71e996d..346996c3 100644 --- a/themes/css/all-hallows-eve.css +++ b/themes/css/all-hallows-eve.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css index 6c1cf9e2..210520a3 100644 --- a/themes/css/blackboard.css +++ b/themes/css/blackboard.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css index fea054ab..da0fe8fe 100644 --- a/themes/css/dreamweaver.css +++ b/themes/css/dreamweaver.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css index eab3e4c7..2ddcadc8 100644 --- a/themes/css/espresso-libre.css +++ b/themes/css/espresso-libre.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} diff --git a/themes/css/github.css b/themes/css/github.css index b5d4fd41..fe4eab4d 100644 --- a/themes/css/github.css +++ b/themes/css/github.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css index 794aae6c..820e770e 100644 --- a/themes/css/kimbie-dark.css +++ b/themes/css/kimbie-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css index 13465214..cff5ff0b 100644 --- a/themes/css/kimbie-light.css +++ b/themes/css/kimbie-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/monokai.css b/themes/css/monokai.css index 60debd4b..d02987dc 100644 --- a/themes/css/monokai.css +++ b/themes/css/monokai.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css index e587c805..a8384dfa 100644 --- a/themes/css/obsidian.css +++ b/themes/css/obsidian.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css index 396d7112..8983b14b 100644 --- a/themes/css/paraiso-dark.css +++ b/themes/css/paraiso-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css index 79ccd801..2fb50f2f 100644 --- a/themes/css/paraiso-light.css +++ b/themes/css/paraiso-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/pastie.css b/themes/css/pastie.css index b5b206b6..4a5896cd 100644 --- a/themes/css/pastie.css +++ b/themes/css/pastie.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css index 7ed3f3af..1b97e5e8 100644 --- a/themes/css/solarized-dark.css +++ b/themes/css/solarized-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css index d3494092..b35a52c6 100644 --- a/themes/css/solarized-light.css +++ b/themes/css/solarized-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css index 524029c7..52bac9b5 100644 --- a/themes/css/sunburst.css +++ b/themes/css/sunburst.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css index 51a946df..27c52765 100644 --- a/themes/css/tomorrow-night.css +++ b/themes/css/tomorrow-night.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css index 001be02c..8231c929 100644 --- a/themes/css/tricolore.css +++ b/themes/css/tricolore.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} diff --git a/themes/css/twilight.css b/themes/css/twilight.css index 58273afa..e4b04492 100644 --- a/themes/css/twilight.css +++ b/themes/css/twilight.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css index 34238d5b..a58cea72 100644 --- a/themes/css/zenburnesque.css +++ b/themes/css/zenburnesque.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}5%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:75ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} From 6835024fe2e74dcd67ab9fecc09085bbc47308a8 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 22:31:23 -0400 Subject: [PATCH 100/153] Move globalClass setting into util --- src/rainbow.js | 25 ++----------------------- src/util.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index 61ea5172..a64885af 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -21,13 +21,6 @@ import Raindrop from './raindrop'; import * as util from './util'; import rainbowWorker from './worker'; -/** - * Global class added to each span in the highlighted code - * - * @type {null|string} - */ -let globalClass; - /** * Callback to fire after each block is highlighted * @@ -109,7 +102,7 @@ function _getWorkerData(code, lang) { languagePatterns: util.languagePatterns, bypassDefaults: util.bypassDefaults, aliases: util.aliases, - globalClass + globalClass: util.globalClass, }; return workerData; @@ -232,20 +225,6 @@ function _onHighlight(callback) { onHighlight = callback; } -/** - * Method to set a global class that will be applied to all spans. - * - * This is realy only useful for the effect on rainbowco.de where you can - * force all blocks to not be highlighted and remove this class to - * transition them to being highlighted. - * - * @param {string} className - * @return {void} - */ -function _addGlobalClass(className) { - globalClass = className; -} - /** * Starts the magic rainbow * @@ -309,7 +288,7 @@ function _color(...args) { const _rainbow = { extend: util.extend, onHighlight: _onHighlight, - addClass: _addGlobalClass, + addClass: util.setGlobalClass, addAlias: util.addAlias, color: _color }; diff --git a/src/util.js b/src/util.js index 0e3ea46e..8a1b7066 100644 --- a/src/util.js +++ b/src/util.js @@ -20,6 +20,13 @@ export const bypassDefaults = {}; */ export const aliases = {}; +/** + * Global class added to each span in the highlighted code + * + * @type {null|string} + */ +export let globalClass; + /** * Method to add an alias for an existing language. * @@ -271,6 +278,20 @@ export function replaceAtPosition(position, replace, replaceWith, code) { return code.substr(0, position) + subString.replace(replace, replaceWith); } +/** + * Method to set a global class that will be applied to all spans. + * + * This is realy only useful for the effect on rainbowco.de where you can + * force all blocks to not be highlighted and remove this class to + * transition them to being highlighted. + * + * @param {string} className + * @return {void} + */ +export function setGlobalClass(name) { + globalClass = name; +} + /** * Takes a string of code and wraps it in a span tag based on the name * From 5eca87e270dc11292fe40e41fafa64b3976b3251 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 22:31:43 -0400 Subject: [PATCH 101/153] Use globalClass defined here already --- src/util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 8a1b7066..63d70f17 100644 --- a/src/util.js +++ b/src/util.js @@ -300,6 +300,7 @@ export function setGlobalClass(name) { * @param {string} globalClass class to apply to every span * @return {string} */ -export function wrapCodeInSpan(name, code, globalClass) { - return `${code}`; +export function wrapCodeInSpan(name, code) { + const gClass = isWorker() ? self.globalClass : globalClass; + return `${code}`; } From 73551bd256ff96e5aa6ae62b07c23df81b129d6b Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 22:32:08 -0400 Subject: [PATCH 102/153] Add unit test for applying global class --- test/rainbow-test.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/rainbow-test.js b/test/rainbow-test.js index 81352016..34b36652 100644 --- a/test/rainbow-test.js +++ b/test/rainbow-test.js @@ -1,3 +1,4 @@ +/* global Rainbow */ ///////////////////////// // Helpers and globals // @@ -9,7 +10,7 @@ const expect = chai.expect; // Test suite // //////////////// -describe('Rainbow', function() { +describe('Rainbow', () => { it('Basic things are defined', () => { expect(Rainbow).to.exist; expect(Rainbow.color).to.be.a('function'); @@ -18,4 +19,18 @@ describe('Rainbow', function() { expect(Rainbow.addClass).to.be.a('function'); expect(Rainbow.addAlias).to.be.a('function'); }); + + it('Should apply global class', (done) => { + Rainbow.extend([{ + name: 'name', + pattern: /Craig/gm + }]); + + Rainbow.addClass('global'); + + Rainbow.color('My name is Craig', 'generic', function(result) { + expect(result).to.equal('My name is Craig'); + done(); + }); + }); }); From 6b76710db570a0dbdd60119bb001be6c153b7c16 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 22:35:41 -0400 Subject: [PATCH 103/153] Only create a new worker for every block with node Creating a new worker with every block that needs to be highlighted causes things to get really slow in the browser especially if there are lots of blocks on a page. It should be fine to reuse the same worker. --- src/rainbow.js | 12 +++++++++++- src/worker.js | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index a64885af..7eb6683b 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -31,6 +31,15 @@ let onHighlight; const isNode = util.isNode(); const isWorker = util.isWorker(); +let cachedWorker = null; +function _getWorker() { + if (isNode || cachedWorker === null) { + cachedWorker = util.createWorker(rainbowWorker, [Raindrop, util]); + } + + return cachedWorker; +} + /** * Helper for matching up callbacks directly with the * post message requests to a web worker. @@ -40,7 +49,7 @@ const isWorker = util.isWorker(); * @return {void} */ function _messageWorker(message, callback) { - const worker = util.createWorker(rainbowWorker, [Raindrop, util]); + const worker = _getWorker(); function _listen(e) { if (e.data.id === message.id) { @@ -103,6 +112,7 @@ function _getWorkerData(code, lang) { bypassDefaults: util.bypassDefaults, aliases: util.aliases, globalClass: util.globalClass, + isNode }; return workerData; diff --git a/src/worker.js b/src/worker.js index 1380f2cd..fbe2e63f 100644 --- a/src/worker.js +++ b/src/worker.js @@ -17,5 +17,18 @@ export default function rainbowWorker(e) { result }); - self.close(); + // I realized down the road I might look at this and wonder what is going on + // so probably it is not a bad idea to leave a comment. + // + // This is needed because right now the node library for simulating web + // workers “webworker-threads” will keep the worker open and it causes + // scripts running from the command line to hang unless the worker is + // explicitly closed. + // + // This means for node we will spawn a new thread for every asynchronous + // block we are highlighting, but in the browser we will keep a single + // worker open for all requests. + if (message.isNode) { + self.close(); + } } From de8568d10a98163ea504c65e7f0ad439c5b1f350 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 23:24:39 -0400 Subject: [PATCH 104/153] Add ability to run only a single test for debugging --- test/helper.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/helper.js b/test/helper.js index 43584bbc..dce703c4 100644 --- a/test/helper.js +++ b/test/helper.js @@ -5,8 +5,13 @@ const expect = chai.expect; -export function run(lang, description, code, result) { - it(description, (done) => { +export function run(lang, description, code, result, only = false) { + let toCall = it; + if (only) { + toCall = it.only; + } + + toCall(description, (done) => { Rainbow.color(code, lang, (html) => { expect(result).to.equal(html); done(); From d83ffb8839a1103a9ca0ed848ddb05eccceff1cc Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 23:26:07 -0400 Subject: [PATCH 105/153] Improve javascript regex matching --- src/language/javascript.js | 7 ++++--- test/language/javascript-test.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/language/javascript.js b/src/language/javascript.js index 6caae39f..892bbb52 100644 --- a/src/language/javascript.js +++ b/src/language/javascript.js @@ -2,7 +2,7 @@ * Javascript patterns * * @author Craig Campbell - * @version 1.0.10 + * @version 1.0.11 */ Rainbow.extend('javascript', [ @@ -45,7 +45,8 @@ Rainbow.extend('javascript', [ * this was causing single line comments to fail so it now makes sure * the opening / is not directly followed by a * * - * @todo check that there is valid regex in match group 1 + * The body of the regex to match a regex was borrowed from: + * http://stackoverflow.com/a/17843773/421333 */ { 'name': 'string.regexp', @@ -58,7 +59,7 @@ Rainbow.extend('javascript', [ 3: 'string.regexp.close', 4: 'string.regexp.modifier' }, - 'pattern': /(\/)(?!\*)(.+?)(\/)([igm]{0,3})/g + 'pattern': /(\/)((?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+)(\/)([igm]{0,3})/g }, /** diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js index 252619e9..c1556b0c 100644 --- a/test/language/javascript-test.js +++ b/test/language/javascript-test.js @@ -237,5 +237,15 @@ describe(language, () => { '{\' \'}\n' + 'var str = \'something\';' ); + + run( + language, + + 'complex regex', + + '/\\/\\*[\\s\\S]*?\\*\\//gm', + + '/\\/\\*[\\s\\S]*?\\*\\//gm' + ); }); From 888caee066f97425a661a4716394af5ee73f238e Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sun, 26 Jun 2016 23:38:40 -0400 Subject: [PATCH 106/153] Do not use native es6 get function which buble does by default --- src/rainbow.js | 2 +- src/util.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index 7eb6683b..d2cabefb 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -111,7 +111,7 @@ function _getWorkerData(code, lang) { languagePatterns: util.languagePatterns, bypassDefaults: util.bypassDefaults, aliases: util.aliases, - globalClass: util.globalClass, + globalClass: util.getGlobalClass(), isNode }; diff --git a/src/util.js b/src/util.js index 63d70f17..1df88f49 100644 --- a/src/util.js +++ b/src/util.js @@ -25,7 +25,7 @@ export const aliases = {}; * * @type {null|string} */ -export let globalClass; +let globalClass; /** * Method to add an alias for an existing language. @@ -292,6 +292,10 @@ export function setGlobalClass(name) { globalClass = name; } +export function getGlobalClass() { + return globalClass; +} + /** * Takes a string of code and wraps it in a span tag based on the name * From b6c5e5f30b5161c998de5c673ef3ab5072aea2a7 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 27 Jun 2016 00:03:57 -0400 Subject: [PATCH 107/153] Use proper license value for package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a378c09c..1e5b4947 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "highlighter" ], "author": "Craig Campbell", - "license": "Apache 2.0", + "license": "Apache-2.0", "readmeFilename": "README.md", "devDependencies": { "babel-polyfill": "6.9.1", From 25f80141f16b6d801d6887909eae6963fc8794c9 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 27 Jun 2016 00:11:39 -0400 Subject: [PATCH 108/153] Add ability to output code directly to console --- gulpfile.js | 13 ++++++++++--- package.json | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 4f1d9706..34802fc9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,6 +16,7 @@ var git = require('gulp-git'); var bump = require('gulp-bump'); var semver = require('semver'); var sass = require('gulp-sass'); +var through = require('through'); var autoprefixer = require('gulp-autoprefixer'); var version = require('./package.json').version; @@ -180,10 +181,16 @@ gulp.task('release', function(callback) { function _appendCode(code) { var dest = _getDestinationPath(); - gulp.src(dest) + var stream = gulp.src(dest) .pipe(inject.prepend(_getComment())) - .pipe(inject.append(code)) - .pipe(gulp.dest('dist')); + .pipe(inject.append(code)); + + if (argv.output) { + stream.pipe(through(function(data) { this.queue(data.contents); })).pipe(process.stdout); + return; + } + + stream.pipe(gulp.dest('dist')); } gulp.task('append-languages', function() { diff --git a/package.json b/package.json index 1e5b4947..9bedb2b0 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "semver": "5.1.0", "sinon": "1.17.4", "sinon-chai": "2.8.0", + "through": "2.3.8", "yargs": "4.7.1" }, "dependencies": { From 67507235a68a49e998703fce28afc56de8b19dc6 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 27 Jun 2016 22:50:08 -0400 Subject: [PATCH 109/153] Simplify logic to remove global state Rainbow will still store global state, but it will pass off the state to the worker, and the Raindrop object will maintain its own state vs. depending on the util module. This means all logic revolving around the Rainbow api will live in rainbow.js instead of util.js which makes more sense. This also removes around 0.3 KB of code (0.1 KB gzipped) --- src/rainbow.js | 127 +++++++++++++++++++++++++++++++++++++++++------- src/raindrop.js | 35 +++++++++++-- src/util.js | 113 ------------------------------------------ src/worker.js | 7 +-- 4 files changed, 140 insertions(+), 142 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index d2cabefb..df1c57f5 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -21,12 +21,41 @@ import Raindrop from './raindrop'; import * as util from './util'; import rainbowWorker from './worker'; +/** + * An array of the language patterns specified for each language + * + * @type {Object} + */ +const patterns = {}; + +/** + * An array of languages and whether they should bypass the + * default patterns + * + * @type {Object} + */ +const bypass = {}; + +/** + * A mapping of language aliases + * + * @type {Object} + */ +const aliases = {}; + +/** + * Global class added to each span in the highlighted code + * + * @type {null|string} + */ +let globalClass; + /** * Callback to fire after each block is highlighted * * @type {null|Function} */ -let onHighlight; +let onHighlightCallback; const isNode = util.isNode(); const isWorker = util.isWorker(); @@ -84,8 +113,8 @@ function _generateHandler(element, waitingOn, callback) { // } // }); - if (onHighlight) { - onHighlight(element, data.lang); + if (onHighlightCallback) { + onHighlightCallback(element, data.lang); } if (--waitingOn.c === 0) { @@ -94,6 +123,20 @@ function _generateHandler(element, waitingOn, callback) { }; } +/** + * Gets options needed to pass into Raindrop + * + * @return {object} + */ +function _getRaindropOptions() { + return { + patterns, + bypass, + aliases, + globalClass + }; +} + /** * Gets data to send to webworker * @@ -102,16 +145,13 @@ function _generateHandler(element, waitingOn, callback) { * @return {object} */ function _getWorkerData(code, lang) { - lang = util.aliases[lang] || lang; + lang = aliases[lang] || lang; const workerData = { id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(), code, lang, - languagePatterns: util.languagePatterns, - bypassDefaults: util.bypassDefaults, - aliases: util.aliases, - globalClass: util.getGlobalClass(), + options: _getRaindropOptions(), isNode }; @@ -231,8 +271,45 @@ function _highlight(node, callback) { * @param {Function} callback * @return {void} */ -function _onHighlight(callback) { - onHighlight = callback; +function onHighlight(callback) { + onHighlightCallback = callback; +} + +/** + * Method to set a global class that will be applied to all spans. + * + * This is realy only useful for the effect on rainbowco.de where you can + * force all blocks to not be highlighted and remove this class to + * transition them to being highlighted. + * + * @param {string} className + * @return {void} + */ +function addClass(name) { + globalClass = name; +} + +/** + * Extends the language pattern matches + * + * @param {string} language name of language + * @param {object} patterns object of patterns to add on + * @param {boolean|null} bypass if `true` this will not inherit the + * default language patterns + */ +function extend(...args) { + let [localLanguage, localPatterns, localBypass] = args; + + // If there is only one argument then we assume that we want to + // extend the default language rules. + if (args.length === 1) { + localPatterns = localLanguage; + localLanguage = 'generic'; + localBypass = null; + } + + bypass[localLanguage] = localBypass; + patterns[localLanguage] = localPatterns.concat(patterns[localLanguage] || []); } /** @@ -240,7 +317,7 @@ function _onHighlight(callback) { * * @return {void} */ -function _color(...args) { +function color(...args) { // If you want to straight up highlight a string you can pass the // string of code, the language, and a callback function. // @@ -292,21 +369,35 @@ function _color(...args) { _highlight(args[0], args[1]); } +/** + * Method to add an alias for an existing language. + * + * For example if you want to have "coffee" map to "coffeescript" + * + * @see https://github.com/ccampbell/rainbow/issues/154 + * @param {string} alias + * @param {string} originalLanguage + * @return {void} + */ +function addAlias(alias, originalLanguage) { + aliases[alias] = originalLanguage; +} + /** * public methods */ const _rainbow = { - extend: util.extend, - onHighlight: _onHighlight, - addClass: util.setGlobalClass, - addAlias: util.addAlias, - color: _color + extend, + onHighlight, + addClass, + addAlias, + color }; if (isNode) { _rainbow.colorSync = function(code, lang) { - const drop = new Raindrop(); - return drop.refract(code, util.aliases[lang] || lang); + const drop = new Raindrop(_getRaindropOptions()); + return drop.refract(code, aliases[lang] || lang); }; } diff --git a/src/raindrop.js b/src/raindrop.js index 46924daa..d393b7e0 100644 --- a/src/raindrop.js +++ b/src/raindrop.js @@ -6,7 +6,7 @@ import * as util from './util'; * @class */ class Raindrop { - constructor() { + constructor(options) { /** * Object of replacements to process at the end of the processing * @@ -59,6 +59,19 @@ class Raindrop { return false; } + /** + * Takes a string of code and wraps it in a span tag based on the name + * + * @param {string} name name of the pattern (ie keyword.regex) + * @param {string} code block of code to wrap + * @param {string} globalClass class to apply to every span + * @return {string} + */ + function _wrapCodeInSpan(name, code) { + const globalClass = options.globalClass; + return `${code}`; + } + /** * Process replacements in the string of code to actually update * the markup @@ -126,7 +139,7 @@ class Raindrop { // If this match has a name then wrap it in a span tag if (pattern.name) { - repl = util.wrapCodeInSpan(pattern.name, repl); + repl = _wrapCodeInSpan(pattern.name, repl); } // For debugging @@ -198,7 +211,7 @@ class Raindrop { * @param {string|null} matchName */ const _getReplacement = function(passedBlock, replaceBlock, matchName) { - replacement = util.replaceAtPosition(util.indexOfGroup(match, groupKey), passedBlock, matchName ? util.wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement); + replacement = util.replaceAtPosition(util.indexOfGroup(match, groupKey), passedBlock, matchName ? _wrapCodeInSpan(matchName, replaceBlock) : replaceBlock, replacement); return; }; @@ -211,7 +224,7 @@ class Raindrop { } let localCode; - const drop = new Raindrop(); + const drop = new Raindrop(options); // If this is a sublanguage go and process the block using // that language @@ -261,6 +274,18 @@ class Raindrop { return _processReplacements(code); } + /** + * Returns a list of regex patterns for this language + * + * @param {string} language + * @return {Array} + */ + function getPatternsForLanguage(language) { + const patterns = options.patterns[language] || []; + const defaultPatterns = options.patterns.generic || []; + return options.bypass[language] ? patterns : patterns.concat(defaultPatterns); + } + /** * Takes a string of code and highlights it according to the language * specified @@ -272,7 +297,7 @@ class Raindrop { */ function _highlightBlockForLanguage(code, language, patterns) { currentLanguage = language; - patterns = patterns || util.getPatternsForLanguage(language, this); + patterns = patterns || getPatternsForLanguage(language); return _processCodeWithPatterns(util.htmlEntities(code), patterns); } diff --git a/src/util.js b/src/util.js index 1df88f49..ab7b02e0 100644 --- a/src/util.js +++ b/src/util.js @@ -1,46 +1,3 @@ -/** - * An array of the language patterns specified for each language - * - * @type {Object} - */ -export const languagePatterns = {}; - -/** - * An array of languages and whether they should bypass the - * default patterns - * - * @type {Object} - */ -export const bypassDefaults = {}; - -/** - * A mapping of language aliases - * - * @type {Object} - */ -export const aliases = {}; - -/** - * Global class added to each span in the highlighted code - * - * @type {null|string} - */ -let globalClass; - -/** - * Method to add an alias for an existing language. - * - * For example if you want to have "coffee" map to "coffeescript" - * - * @see https://github.com/ccampbell/rainbow/issues/154 - * @param {string} alias - * @param {string} originalLanguage - * @return {void} - */ -export function addAlias(alias, originalLanguage) { - aliases[alias] = originalLanguage; -} - function _addGlobal(thing) { if (typeof thing === 'function') { return `\n${thing.toString()}`; @@ -103,29 +60,6 @@ export function createWorker(fn, globals) { return new Worker((window.URL || window.webkitURL).createObjectURL(blob)); } -/** - * Extends the language pattern matches - * - * @param {string} language name of language - * @param {object} patterns object of patterns to add on - * @param {boolean|null} bypass if `true` this will not inherit the - * default language patterns - */ -export function extend(...args) { - let [language, patterns, bypass] = args; - - // If there is only one argument then we assume that we want to - // extend the default language rules. - if (args.length === 1) { - patterns = language; - language = 'generic'; - bypass = null; - } - - bypassDefaults[language] = bypass; - languagePatterns[language] = patterns.concat(languagePatterns[language] || []); -} - /** * Browser Only - Gets the language for this block of code * @@ -161,22 +95,6 @@ export function getLanguageForBlock(block) { return null; } -/** - * Returns a list of regex patterns for this language - * - * @param {string} language - * @return {Array} - */ -export function getPatternsForLanguage(language) { - const langPatterns = isWorker() ? self.languagePatterns : languagePatterns; - const bypass = isWorker() ? self.bypassDefaults : bypassDefaults; - - const patterns = langPatterns[language] || []; - const defaultPatterns = langPatterns['generic'] || []; - - return bypass[language] ? patterns : patterns.concat(defaultPatterns); -} - /** * Determines if two different matches have complete overlap with each other * @@ -277,34 +195,3 @@ export function replaceAtPosition(position, replace, replaceWith, code) { const subString = code.substr(position); return code.substr(0, position) + subString.replace(replace, replaceWith); } - -/** - * Method to set a global class that will be applied to all spans. - * - * This is realy only useful for the effect on rainbowco.de where you can - * force all blocks to not be highlighted and remove this class to - * transition them to being highlighted. - * - * @param {string} className - * @return {void} - */ -export function setGlobalClass(name) { - globalClass = name; -} - -export function getGlobalClass() { - return globalClass; -} - -/** - * Takes a string of code and wraps it in a span tag based on the name - * - * @param {string} name name of the pattern (ie keyword.regex) - * @param {string} code block of code to wrap - * @param {string} globalClass class to apply to every span - * @return {string} - */ -export function wrapCodeInSpan(name, code) { - const gClass = isWorker() ? self.globalClass : globalClass; - return `${code}`; -} diff --git a/src/worker.js b/src/worker.js index fbe2e63f..04ca5cb2 100644 --- a/src/worker.js +++ b/src/worker.js @@ -3,12 +3,7 @@ import Raindrop from './raindrop'; export default function rainbowWorker(e) { const message = e.data; - self.languagePatterns = message.languagePatterns; - self.bypassDefaults = message.bypassDefaults; - self.aliases = message.aliases; - self.globalClass = message.globalClass; - - const drop = new Raindrop(); + const drop = new Raindrop(message.options); const result = drop.refract(message.code, message.lang); self.postMessage({ From fba237f37d622db6940dff7bcb2fbad0bc08d92a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 27 Jun 2016 22:50:19 -0400 Subject: [PATCH 110/153] Add newline to end of build.js --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 34802fc9..b4f4a0cc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -207,7 +207,7 @@ gulp.task('append-languages', function() { return; } - fs.writeFileSync('src/build.js', languageCode.join('\n')); + fs.writeFileSync('src/build.js', languageCode.join('\n') + '\n'); rollup({ entry: 'src/build.js', From 4cf19e05d27db9cff59981d34af4e0f5111ccce0 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Mon, 27 Jun 2016 22:58:44 -0400 Subject: [PATCH 111/153] Rename Raindrop class to Prism MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I know there is another syntax highlighting library named Prism so that might cause confusion, but it is only ever used internally and Prism makes more sense for the component that actually turns the code to color than Raindrop. ¯\_(ツ)_/¯ --- src/{raindrop.js => prism.js} | 10 +++++----- src/rainbow.js | 12 ++++++------ src/util.js | 6 +++--- src/worker.js | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) rename src/{raindrop.js => prism.js} (98%) diff --git a/src/raindrop.js b/src/prism.js similarity index 98% rename from src/raindrop.js rename to src/prism.js index d393b7e0..5e659567 100644 --- a/src/raindrop.js +++ b/src/prism.js @@ -1,11 +1,11 @@ import * as util from './util'; /** - * Raindrop is a class used to highlight individual blocks of code + * Prism is a class used to highlight individual blocks of code * * @class */ -class Raindrop { +class Prism { constructor(options) { /** * Object of replacements to process at the end of the processing @@ -15,7 +15,7 @@ class Raindrop { const replacements = {}; /** - * Language associated with this Raindrop object + * Language associated with this Prism object * * @type {string} */ @@ -224,7 +224,7 @@ class Raindrop { } let localCode; - const drop = new Raindrop(options); + const drop = new Prism(options); // If this is a sublanguage go and process the block using // that language @@ -305,4 +305,4 @@ class Raindrop { } } -export default Raindrop; +export default Prism; diff --git a/src/rainbow.js b/src/rainbow.js index df1c57f5..8333a1d9 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -17,7 +17,7 @@ * * @see rainbowco.de */ -import Raindrop from './raindrop'; +import Prism from './prism'; import * as util from './util'; import rainbowWorker from './worker'; @@ -63,7 +63,7 @@ const isWorker = util.isWorker(); let cachedWorker = null; function _getWorker() { if (isNode || cachedWorker === null) { - cachedWorker = util.createWorker(rainbowWorker, [Raindrop, util]); + cachedWorker = util.createWorker(rainbowWorker, [Prism, util]); } return cachedWorker; @@ -124,11 +124,11 @@ function _generateHandler(element, waitingOn, callback) { } /** - * Gets options needed to pass into Raindrop + * Gets options needed to pass into Prism * * @return {object} */ -function _getRaindropOptions() { +function _getPrismOptions() { return { patterns, bypass, @@ -151,7 +151,7 @@ function _getWorkerData(code, lang) { id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(), code, lang, - options: _getRaindropOptions(), + options: _getPrismOptions(), isNode }; @@ -396,7 +396,7 @@ const _rainbow = { if (isNode) { _rainbow.colorSync = function(code, lang) { - const drop = new Raindrop(_getRaindropOptions()); + const drop = new Prism(_getPrismOptions()); return drop.refract(code, aliases[lang] || lang); }; } diff --git a/src/util.js b/src/util.js index ab7b02e0..24b995a9 100644 --- a/src/util.js +++ b/src/util.js @@ -49,10 +49,10 @@ export function createWorker(fn, globals) { // This is an awful hack, but something to do with how uglify renames stuff // and rollup means that the variable the worker.js is using to reference - // Raindrop will not be the same one available in this context - const raindropName = globals[0].toString().match(/function (\w*?)\(/)[1]; + // Prism will not be the same one available in this context + const prismName = globals[0].toString().match(/function (\w*?)\(/)[1]; let str = fn.toString(); - str = str.replace(/=new \w*/, `= new ${raindropName}`); + str = str.replace(/=new \w*/, `= new ${prismName}`); const fullString = `${code}\tthis.onmessage =${str}`; diff --git a/src/worker.js b/src/worker.js index 04ca5cb2..2bd003b7 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,9 +1,9 @@ -import Raindrop from './raindrop'; +import Prism from './prism'; export default function rainbowWorker(e) { const message = e.data; - const drop = new Raindrop(message.options); + const drop = new Prism(message.options); const result = drop.refract(message.code, message.lang); self.postMessage({ From 331275e6fdeae15b84e592bdf2c624e2e514dccf Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 00:20:14 -0400 Subject: [PATCH 112/153] Rename other references for clarity --- src/prism.js | 6 +++--- src/rainbow.js | 4 ++-- src/worker.js | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/prism.js b/src/prism.js index 5e659567..b09eaf77 100644 --- a/src/prism.js +++ b/src/prism.js @@ -224,12 +224,12 @@ class Prism { } let localCode; - const drop = new Prism(options); + const prism = new Prism(options); // If this is a sublanguage go and process the block using // that language if (language) { - localCode = drop.refract(block, language); + localCode = prism.refract(block, language); _getReplacement(block, localCode); return; } @@ -237,7 +237,7 @@ class Prism { // The process group can be a single pattern or an array of // patterns. `_processCodeWithPatterns` always expects an array // so we convert it here. - localCode = drop.refract(block, currentLanguage, groupToProcess.length ? groupToProcess : [groupToProcess]); + localCode = prism.refract(block, currentLanguage, groupToProcess.length ? groupToProcess : [groupToProcess]); _getReplacement(block, localCode, group.matches ? group.name : 0); } diff --git a/src/rainbow.js b/src/rainbow.js index 8333a1d9..a2f6716b 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -396,8 +396,8 @@ const _rainbow = { if (isNode) { _rainbow.colorSync = function(code, lang) { - const drop = new Prism(_getPrismOptions()); - return drop.refract(code, aliases[lang] || lang); + const prism = new Prism(_getPrismOptions()); + return prism.refract(code, aliases[lang] || lang); }; } diff --git a/src/worker.js b/src/worker.js index 2bd003b7..3709f8c5 100644 --- a/src/worker.js +++ b/src/worker.js @@ -3,8 +3,8 @@ import Prism from './prism'; export default function rainbowWorker(e) { const message = e.data; - const drop = new Prism(message.options); - const result = drop.refract(message.code, message.lang); + const prism = new Prism(message.options); + const result = prism.refract(message.code, message.lang); self.postMessage({ id: message.id, From 6f708c9c0fdf05babc901e2ebd997facf319401e Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 22:02:43 -0400 Subject: [PATCH 113/153] Remove unnecessary quotes from language grammar files --- src/language/c.js | 46 ++++++------ src/language/coffeescript.js | 67 +++++++++-------- src/language/csharp.js | 60 ++++++++-------- src/language/css.js | 54 +++++++------- src/language/d.js | 56 +++++++-------- src/language/generic.js | 50 ++++++------- src/language/go.js | 44 ++++++------ src/language/haskell.js | 54 +++++++------- src/language/html.js | 86 +++++++++++----------- src/language/javascript.js | 43 ++++++----- src/language/json.js | 20 +++--- src/language/lua.js | 44 ++++++------ src/language/php.js | 84 +++++++++++----------- src/language/python.js | 48 ++++++------- src/language/r.js | 44 ++++++------ src/language/ruby.js | 136 +++++++++++++++++------------------ src/language/scheme.js | 36 +++++----- src/language/shell.js | 32 ++++----- src/language/smalltalk.js | 44 ++++++------ 19 files changed, 523 insertions(+), 525 deletions(-) diff --git a/src/language/c.js b/src/language/c.js index 79b02502..ce12c4d5 100644 --- a/src/language/c.js +++ b/src/language/c.js @@ -7,63 +7,63 @@ */ Rainbow.extend('c', [ { - 'name': 'meta.preprocessor', - 'matches': { + name: 'meta.preprocessor', + matches: { 1: [ { - 'matches': { + matches: { 1: 'keyword.define', 2: 'entity.name' }, - 'pattern': /(\w+)\s(\w+)\b/g + pattern: /(\w+)\s(\w+)\b/g }, { - 'name': 'keyword.define', - 'pattern': /endif/g + name: 'keyword.define', + pattern: /endif/g }, { - 'name': 'constant.numeric', - 'pattern': /\d+/g + name: 'constant.numeric', + pattern: /\d+/g }, { - 'matches': { + matches: { 1: 'keyword.include', 2: 'string' }, - 'pattern': /(include)\s(.*?)$/g + pattern: /(include)\s(.*?)$/g } ] }, - 'pattern': /\#([\S\s]*?)$/gm + pattern: /\#([\S\s]*?)$/gm }, { - 'name': 'keyword', - 'pattern': /\b(do|goto|typedef)\b/g + name: 'keyword', + pattern: /\b(do|goto|typedef)\b/g }, { - 'name': 'entity.label', - 'pattern': /\w+:/g + name: 'entity.label', + pattern: /\w+:/g }, { - 'matches': { + matches: { 1: 'storage.type', 3: 'storage.type', 4: 'entity.name.function' }, - 'pattern': /\b((un)?signed|const)? ?(void|char|short|int|long|float|double)\*? +((\w+)(?= ?\())?/g + pattern: /\b((un)?signed|const)? ?(void|char|short|int|long|float|double)\*? +((\w+)(?= ?\())?/g }, { - 'matches': { + matches: { 2: 'entity.name.function' }, - 'pattern': /(\w|\*) +((\w+)(?= ?\())/g + pattern: /(\w|\*) +((\w+)(?= ?\())/g }, { - 'name': 'storage.modifier', - 'pattern': /\b(static|extern|auto|register|volatile|inline)\b/g + name: 'storage.modifier', + pattern: /\b(static|extern|auto|register|volatile|inline)\b/g }, { - 'name': 'support.type', - 'pattern': /\b(struct|union|enum)\b/g + name: 'support.type', + pattern: /\b(struct|union|enum)\b/g } ]); diff --git a/src/language/coffeescript.js b/src/language/coffeescript.js index 876a6240..b93bf068 100644 --- a/src/language/coffeescript.js +++ b/src/language/coffeescript.js @@ -6,52 +6,52 @@ */ Rainbow.extend('coffeescript', [ { - 'name': 'comment.block', - 'pattern': /(\#{3})[\s\S]*\1/gm + name: 'comment.block', + pattern: /(\#{3})[\s\S]*\1/gm }, { - 'name': 'string.block', - 'pattern': /('{3}|"{3})[\s\S]*\1/gm + name: 'string.block', + pattern: /('{3}|"{3})[\s\S]*\1/gm }, /** * multiline regex with comments */ { - 'name': 'string.regex', - 'matches': { + name: 'string.regex', + matches: { 2: { - 'name': 'comment', - 'pattern': /\#(.*?)(?=\n)/g + name: 'comment', + pattern: /\#(.*?)(?=\n)/g } }, - 'pattern': /(\/{3})([\s\S]*)\1/gm + pattern: /(\/{3})([\s\S]*)\1/gm }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b(in|when|is|isnt|of|not|unless|until|super)(?=\b)/gi + pattern: /\b(in|when|is|isnt|of|not|unless|until|super)(?=\b)/gi }, { - 'name': 'keyword.operator', - 'pattern': /\?/g + name: 'keyword.operator', + pattern: /\?/g }, { - 'name': 'constant.language', - 'pattern': /\b(undefined|yes|on|no|off)\b/g + name: 'constant.language', + pattern: /\b(undefined|yes|on|no|off)\b/g }, { - 'name': 'keyword.variable.coffee', - 'pattern': /@(\w+)/gi + name: 'keyword.variable.coffee', + pattern: /@(\w+)/gi }, /** * reset global keywards from generic */ { - 'name': 'reset', - 'pattern': /object|class|print/gi + name: 'reset', + pattern: /object|class|print/gi }, /** @@ -62,26 +62,26 @@ Rainbow.extend('coffeescript', [ 1: 'entity.name.function', 2: 'keyword.operator', 3: { - 'name': 'function.argument.coffee', - 'pattern': /([\@\w]+)/g + name: 'function.argument.coffee', + pattern: /([\@\w]+)/g }, 4: 'keyword.function' }, - 'pattern': /(\w+)\s{0,}(=|:)\s{0,}\((.*?)((-|=)>)/gi + pattern: /(\w+)\s{0,}(=|:)\s{0,}\((.*?)((-|=)>)/gi }, /** * anonymous function */ { - 'matches': { + matches: { 1: { - 'name': 'function.argument.coffee', - 'pattern': /([\@\w]+)/g + name: 'function.argument.coffee', + pattern: /([\@\w]+)/g }, 2: 'keyword.function' }, - 'pattern': /\s\((.*?)\)\s{0,}((-|=)>)/gi + pattern: /\s\((.*?)\)\s{0,}((-|=)>)/gi }, /** @@ -93,36 +93,35 @@ Rainbow.extend('coffeescript', [ 2: 'keyword.operator', 3: 'keyword.function' }, - 'pattern': /(\w+)\s{0,}(=|:)\s{0,}((-|=)>)/gi + pattern: /(\w+)\s{0,}(=|:)\s{0,}((-|=)>)/gi }, /** * class definitions */ { - 'matches': { + matches: { 1: 'storage.class', 2: 'entity.name.class', 3: 'storage.modifier.extends', 4: 'entity.other.inherited-class' }, - 'pattern': /\b(class)\s(\w+)(\sextends\s)?([\w\\]*)?\b/g + pattern: /\b(class)\s(\w+)(\sextends\s)?([\w\\]*)?\b/g }, /** * object instantiation */ { - 'matches': { + matches: { 1: 'keyword.new', 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /\b(new)\s(.*?)(?=\s)/g + pattern: /\b(new)\s(.*?)(?=\s)/g } ]); Rainbow.addAlias('coffee', 'coffeescript'); - diff --git a/src/language/csharp.js b/src/language/csharp.js index 14682da1..9266c77f 100644 --- a/src/language/csharp.js +++ b/src/language/csharp.js @@ -7,81 +7,81 @@ Rainbow.extend('csharp', [ { // @see http://msdn.microsoft.com/en-us/library/23954zh5.aspx - 'name': 'constant', - 'pattern': /\b(false|null|true)\b/g + name: 'constant', + pattern: /\b(false|null|true)\b/g }, { // @see http://msdn.microsoft.com/en-us/library/x53a06bb%28v=vs.100%29.aspx // Does not support putting an @ in front of a keyword which makes it not a keyword anymore. - 'name': 'keyword', - 'pattern': /\b(abstract|add|alias|ascending|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|double|do|dynamic|else|enum|event|explicit|extern|false|finally|fixed|float|foreach|for|from|get|global|goto|group|if|implicit|int|interface|internal|into|in|is|join|let|lock|long|namespace|new|object|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|remove|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|try|typeof|uint|unchecked|ulong|unsafe|ushort|using|value|var|virtual|void|volatile|where|while|yield)\b/g + name: 'keyword', + pattern: /\b(abstract|add|alias|ascending|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|double|do|dynamic|else|enum|event|explicit|extern|false|finally|fixed|float|foreach|for|from|get|global|goto|group|if|implicit|int|interface|internal|into|in|is|join|let|lock|long|namespace|new|object|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|remove|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|try|typeof|uint|unchecked|ulong|unsafe|ushort|using|value|var|virtual|void|volatile|where|while|yield)\b/g }, { - 'matches': { + matches: { 1: 'keyword', 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /(typeof)\s([^\$].*?)(\)|;)/g + pattern: /(typeof)\s([^\$].*?)(\)|;)/g }, { - 'matches': { + matches: { 1: 'keyword.namespace', 2: { - 'name': 'support.namespace', - 'pattern': /\w+/g + name: 'support.namespace', + pattern: /\w+/g } }, - 'pattern': /\b(namespace)\s(.*?);/g + pattern: /\b(namespace)\s(.*?);/g }, { - 'matches': { + matches: { 1: 'storage.modifier', 2: 'storage.class', 3: 'entity.name.class', 4: 'storage.modifier.extends', 5: 'entity.other.inherited-class' }, - 'pattern': /\b(abstract|sealed)?\s?(class)\s(\w+)(\sextends\s)?([\w\\]*)?\s?\{?(\n|\})/g + pattern: /\b(abstract|sealed)?\s?(class)\s(\w+)(\sextends\s)?([\w\\]*)?\s?\{?(\n|\})/g }, { - 'name': 'keyword.static', - 'pattern': /\b(static)\b/g + name: 'keyword.static', + pattern: /\b(static)\b/g }, { - 'matches': { + matches: { 1: 'keyword.new', 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;|&)/g + pattern: /\b(new)\s([^\$].*?)(?=\)|\(|;|&)/g }, { - 'name': 'string', - 'pattern': /(")(.*?)\1/g + name: 'string', + pattern: /(")(.*?)\1/g }, { - 'name': 'integer', - 'pattern': /\b(0x[\da-f]+|\d+)\b/g + name: 'integer', + pattern: /\b(0x[\da-f]+|\d+)\b/g }, { - 'name': 'comment', - 'pattern': /\/\*[\s\S]*?\*\/|(\/\/)[\s\S]*?$/gm + name: 'comment', + pattern: /\/\*[\s\S]*?\*\/|(\/\/)[\s\S]*?$/gm }, { - 'name': 'operator', + name: 'operator', // @see http://msdn.microsoft.com/en-us/library/6a71f45d%28v=vs.100%29.aspx // ++ += + -- -= - <<= << <= => >>= >> >= != ! ~ ^ || && &= & ?? :: : *= * |= %= |= == = - 'pattern': /(\+\+|\+=|\+|--|-=|-|<<=|<<|<=|=>|>>=|>>|>=|!=|!|~|\^|\|\||&&|&=|&|\?\?|::|:|\*=|\*|\/=|%=|\|=|==|=)/g + pattern: /(\+\+|\+=|\+|--|-=|-|<<=|<<|<=|=>|>>=|>>|>=|!=|!|~|\^|\|\||&&|&=|&|\?\?|::|:|\*=|\*|\/=|%=|\|=|==|=)/g }, { // @see http://msdn.microsoft.com/en-us/library/ed8yd1ha%28v=vs.100%29.aspx - 'name': 'preprocessor', - 'pattern': /(\#if|\#else|\#elif|\#endif|\#define|\#undef|\#warning|\#error|\#line|\#region|\#endregion|\#pragma)[\s\S]*?$/gm + name: 'preprocessor', + pattern: /(\#if|\#else|\#elif|\#endif|\#define|\#undef|\#warning|\#error|\#line|\#region|\#endregion|\#pragma)[\s\S]*?$/gm } ], true); diff --git a/src/language/css.js b/src/language/css.js index 766ea0ba..761e7f1d 100644 --- a/src/language/css.js +++ b/src/language/css.js @@ -6,68 +6,68 @@ */ Rainbow.extend('css', [ { - 'name': 'comment', - 'pattern': /\/\*[\s\S]*?\*\//gm + name: 'comment', + pattern: /\/\*[\s\S]*?\*\//gm }, { - 'name': 'constant.hex-color', - 'pattern': /#([a-f0-9]{3}|[a-f0-9]{6})(?=;|\s|,|\))/gi + name: 'constant.hex-color', + pattern: /#([a-f0-9]{3}|[a-f0-9]{6})(?=;|\s|,|\))/gi }, { - 'matches': { + matches: { 1: 'constant.numeric', 2: 'keyword.unit' }, - 'pattern': /(\d+)(px|em|cm|s|%)?/g + pattern: /(\d+)(px|em|cm|s|%)?/g }, { - 'name': 'string', - 'pattern': /('|")(.*?)\1/g + name: 'string', + pattern: /('|")(.*?)\1/g }, { - 'name': 'support.css-property', - 'matches': { + name: 'support.css-property', + matches: { 1: 'support.vendor-prefix' }, - 'pattern': /(-o-|-moz-|-webkit-|-ms-)?[\w-]+(?=\s?:)(?!.*\{)/g + pattern: /(-o-|-moz-|-webkit-|-ms-)?[\w-]+(?=\s?:)(?!.*\{)/g }, { - 'matches': { + matches: { 1: [ { - 'name': 'entity.name.sass', - 'pattern': /&/g + name: 'entity.name.sass', + pattern: /&/g }, { - 'name': 'direct-descendant', - 'pattern': />/g + name: 'direct-descendant', + pattern: />/g }, { - 'name': 'entity.name.class', - 'pattern': /\.[\w\-_]+/g + name: 'entity.name.class', + pattern: /\.[\w\-_]+/g }, { - 'name': 'entity.name.id', - 'pattern': /\#[\w\-_]+/g + name: 'entity.name.id', + pattern: /\#[\w\-_]+/g }, { - 'name': 'entity.name.pseudo', - 'pattern': /:[\w\-_]+/g + name: 'entity.name.pseudo', + pattern: /:[\w\-_]+/g }, { - 'name': 'entity.name.tag', - 'pattern': /\w+/g + name: 'entity.name.tag', + pattern: /\w+/g } ] }, - 'pattern': /([\w\ ,\n:\.\#\&\;\-_]+)(?=.*\{)/g + pattern: /([\w\ ,\n:\.\#\&\;\-_]+)(?=.*\{)/g }, { - 'matches': { + matches: { 2: 'support.vendor-prefix', 3: 'support.css-value' }, - 'pattern': /(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g + pattern: /(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g } ], true); diff --git a/src/language/d.js b/src/language/d.js index f4c19f24..548bbb10 100644 --- a/src/language/d.js +++ b/src/language/d.js @@ -6,76 +6,76 @@ */ Rainbow.extend('d', [ { - 'name': 'constant', - 'pattern': /\b(false|null|true)\b/gm + name: 'constant', + pattern: /\b(false|null|true)\b/gm }, { // http://dlang.org/lex.html - 'name': 'keyword', - 'pattern': /\b(abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|in|inout|int|interface|invariant|ireal|is|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|size_t|static|string|struct|super|switch|synchronized|template|this|throw|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__FILE__|__LINE__|__gshared|__traits|__vector|__parameters)\b/gm + name: 'keyword', + pattern: /\b(abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|in|inout|int|interface|invariant|ireal|is|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|size_t|static|string|struct|super|switch|synchronized|template|this|throw|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__FILE__|__LINE__|__gshared|__traits|__vector|__parameters)\b/gm }, { - 'matches': { + matches: { 1: 'keyword', 2: { - 'name': 'support.class', - 'pattern': /\w+/gm + name: 'support.class', + pattern: /\w+/gm } }, - 'pattern': /(typeof)\s([^\$].*?)(\)|;)/gm + pattern: /(typeof)\s([^\$].*?)(\)|;)/gm }, { - 'matches': { + matches: { 1: 'keyword.namespace', 2: { - 'name': 'support.namespace', - 'pattern': /\w+/gm + name: 'support.namespace', + pattern: /\w+/gm } }, - 'pattern': /\b(namespace)\s(.*?);/gm + pattern: /\b(namespace)\s(.*?);/gm }, { - 'matches': { + matches: { 1: 'storage.modifier', 2: 'storage.class', 3: 'entity.name.class', 4: 'storage.modifier.extends', 5: 'entity.other.inherited-class' }, - 'pattern': /\b(abstract|sealed)?\s?(class)\s(\w+)(\sextends\s)?([\w\\]*)?\s?\{?(\n|\})/gm + pattern: /\b(abstract|sealed)?\s?(class)\s(\w+)(\sextends\s)?([\w\\]*)?\s?\{?(\n|\})/gm }, { - 'name': 'keyword.static', - 'pattern': /\b(static)\b/gm + name: 'keyword.static', + pattern: /\b(static)\b/gm }, { - 'matches': { + matches: { 1: 'keyword.new', 2: { - 'name': 'support.class', - 'pattern': /\w+/gm + name: 'support.class', + pattern: /\w+/gm } }, - 'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;|&)/gm + pattern: /\b(new)\s([^\$].*?)(?=\)|\(|;|&)/gm }, { - 'name': 'string', - 'pattern': /("|')(.*?)\1/gm + name: 'string', + pattern: /("|')(.*?)\1/gm }, { - 'name': 'integer', - 'pattern': /\b(0x[\da-f]+|\d+)\b/gm + name: 'integer', + pattern: /\b(0x[\da-f]+|\d+)\b/gm }, { - 'name': 'comment', - 'pattern': /\/\*[\s\S]*?\*\/|\/\+[\s\S]*?\+\/|(\/\/)[\s\S]*?$/gm + name: 'comment', + pattern: /\/\*[\s\S]*?\*\/|\/\+[\s\S]*?\+\/|(\/\/)[\s\S]*?$/gm }, { // http://dlang.org/operatoroverloading.html - 'name': 'operator', + name: 'operator', // / /= &= && & |= || | -= -- - += ++ + <= << < <<= <>= <> > >>>= >>= >= >> >>> != !<>= !<> !<= !< !>= !> ! [ ] $ == = *= * %= % ^^= ^= ^^ ^ ~= ~ @ => : - 'pattern': /(\/|\/=|&=|&&|&|\|=|\|\|\||\-=|\-\-|\-|\+=|\+\+|\+|<=|<<|<|<<=|<>=|<>|>|>>>=|>>=|>=|>>|>>>|!=|!<>=|!<>|!<=|!<|!>=|!>|!|[|]|\$|==|=|\*=|\*|%=|%|\^\^=|\^=|\^\^|\^|~=|~|@|=>|\:)/gm + pattern: /(\/|\/=|&=|&&|&|\|=|\|\|\||\-=|\-\-|\-|\+=|\+\+|\+|<=|<<|<|<<=|<>=|<>|>|>>>=|>>=|>=|>>|>>>|!=|!<>=|!<>|!<=|!<|!>=|!>|!|[|]|\$|==|=|\*=|\*|%=|%|\^\^=|\^=|\^\^|\^|~=|~|@|=>|\:)/gm } ], true); diff --git a/src/language/generic.js b/src/language/generic.js index 0c70d375..baf5b90c 100644 --- a/src/language/generic.js +++ b/src/language/generic.js @@ -1,4 +1,4 @@ -/** + /** * Generic language patterns * * @author Craig Campbell @@ -6,60 +6,60 @@ */ Rainbow.extend([ { - 'matches': { + matches: { 1: [ { - 'name': 'keyword.operator', - 'pattern': /\=|\+/g + name: 'keyword.operator', + pattern: /\=|\+/g }, { - 'name': 'keyword.dot', - 'pattern': /\./g + name: 'keyword.dot', + pattern: /\./g } ], 2: { - 'name': 'string', - 'matches': { - 'name': 'constant.character.escape', - 'pattern': /\\('|"){1}/g + name: 'string', + matches: { + name: 'constant.character.escape', + pattern: /\\('|"){1}/g } } }, - 'pattern': /(\(|\s|\[|\=|:|\+|\.|\{)(('|")([^\\\1]|\\.)*?(\3))/gm + pattern: /(\(|\s|\[|\=|:|\+|\.|\{)(('|")([^\\\1]|\\.)*?(\3))/gm }, { - 'name': 'comment', - 'pattern': /\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm + name: 'comment', + pattern: /\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm }, { - 'name': 'constant.numeric', - 'pattern': /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi + name: 'constant.numeric', + pattern: /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b(and|array|as|b(ool(ean)?|reak)|c(ase|atch|har|lass|on(st|tinue))|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi + pattern: /\b(and|array|as|b(ool(ean)?|reak)|c(ase|atch|har|lass|on(st|tinue))|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi }, { - 'name': 'constant.language', - 'pattern': /true|false|null/g + name: 'constant.language', + pattern: /true|false|null/g }, { - 'name': 'keyword.operator', - 'pattern': /\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g + name: 'keyword.operator', + pattern: /\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g }, { - 'matches': { + matches: { 1: 'function.call' }, - 'pattern': /(\w+?)(?=\()/g + pattern: /(\w+?)(?=\()/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'entity.name.function' }, - 'pattern': /(function)\s(.*?)(?=\()/g + pattern: /(function)\s(.*?)(?=\()/g } ]); diff --git a/src/language/go.js b/src/language/go.js index 400c2e97..c7561c7d 100644 --- a/src/language/go.js +++ b/src/language/go.js @@ -6,54 +6,54 @@ */ Rainbow.extend('go', [ { - 'matches': { + matches: { 1: { - 'name': 'keyword.operator', - 'pattern': /\=/g + name: 'keyword.operator', + pattern: /\=/g }, 2: { - 'name': 'string', - 'matches': { - 'name': 'constant.character.escape', - 'pattern': /\\(`|"){1}/g + name: 'string', + matches: { + name: 'constant.character.escape', + pattern: /\\(`|"){1}/g } } }, - 'pattern': /(\(|\s|\[|\=|:)((`|")([^\\\1]|\\.)*?(\3))/gm + pattern: /(\(|\s|\[|\=|:)((`|")([^\\\1]|\\.)*?(\3))/gm }, { - 'name': 'comment', - 'pattern': /\/\*[\s\S]*?\*\/|(\/\/)[\s\S]*?$/gm + name: 'comment', + pattern: /\/\*[\s\S]*?\*\/|(\/\/)[\s\S]*?$/gm }, { - 'name': 'constant.numeric', - 'pattern': /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi + name: 'constant.numeric', + pattern: /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b(break|c(ase|onst|ontinue)|d(efault|efer)|else|fallthrough|for|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)(?=\(|\b)/gi + pattern: /\b(break|c(ase|onst|ontinue)|d(efault|efer)|else|fallthrough|for|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)(?=\(|\b)/gi }, { - 'name': 'constant.language', - 'pattern': /true|false|null|string|byte|rune|u?int(8|16|32|64)?|float(32|64)|complex(64|128)/g + name: 'constant.language', + pattern: /true|false|null|string|byte|rune|u?int(8|16|32|64)?|float(32|64)|complex(64|128)/g }, { - 'name': 'keyword.operator', - 'pattern': /\+|\!|\-|&(gt|lt|amp);|\||\*|\:?=/g + name: 'keyword.operator', + pattern: /\+|\!|\-|&(gt|lt|amp);|\||\*|\:?=/g }, { - 'matches': { + matches: { 1: 'function.call' }, - 'pattern': /(\w+?)(?=\()/g + pattern: /(\w+?)(?=\()/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'entity.name.function' }, - 'pattern': /(func)\s(.*?)(?=\()/g + pattern: /(func)\s(.*?)(?=\()/g } ]); diff --git a/src/language/haskell.js b/src/language/haskell.js index 00f94077..9c8db73f 100644 --- a/src/language/haskell.js +++ b/src/language/haskell.js @@ -8,87 +8,87 @@ Rainbow.extend('haskell', [ ///- Comments { - 'name': 'comment', - 'pattern': /\{\-\-[\s\S(\w+)]+[\-\-][\}$]/gm + name: 'comment', + pattern: /\{\-\-[\s\S(\w+)]+[\-\-][\}$]/gm // /\{\-{2}[\s\S(.*)]+[\-\-][\}$]/gm [multiple lines] }, { - 'name': 'comment', - 'pattern': /\-\-(.*)/g + name: 'comment', + pattern: /\-\-(.*)/g // /\-\-\s(.+)$/gm [single] }, ///- End Comments ///- Namespace (module) { - 'matches': { + matches: { 1: 'keyword', 2: 'support.namespace' }, - 'pattern': /\b(module)\s(\w+)\s[\(]?(\w+)?[\)?]\swhere/g + pattern: /\b(module)\s(\w+)\s[\(]?(\w+)?[\)?]\swhere/g }, ///- End Namespace (module) ///- Keywords and Operators { - 'name': 'keyword.operator', - 'pattern': /\+|\!|\-|&(gt|lt|amp);|\/\=|\||\@|\:|\.|\+{2}|\:|\*|\=|#|\.{2}|(\\)[a-zA-Z_]/g + name: 'keyword.operator', + pattern: /\+|\!|\-|&(gt|lt|amp);|\/\=|\||\@|\:|\.|\+{2}|\:|\*|\=|#|\.{2}|(\\)[a-zA-Z_]/g }, { - 'name': 'keyword', - 'pattern': /\b(case|class|foreign|hiding|qualified|data|family|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|in|otherwise|module|newtype|of|then|type|where)\b/g + name: 'keyword', + pattern: /\b(case|class|foreign|hiding|qualified|data|family|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|in|otherwise|module|newtype|of|then|type|where)\b/g }, { - 'name': 'keyword', - 'pattern': /[\`][a-zA-Z_']*?[\`]/g + name: 'keyword', + pattern: /[\`][a-zA-Z_']*?[\`]/g }, ///- End Keywords and Operators ///- Infix|Infixr|Infixl { - 'matches': { + matches: { 1: 'keyword', 2: 'keyword.operator' }, - 'pattern': /\b(infix|infixr|infixl)+\s\d+\s(\w+)*/g + pattern: /\b(infix|infixr|infixl)+\s\d+\s(\w+)*/g }, ///- End Infix|Infixr|Infixl { - 'name': 'entity.class', - 'pattern': /\b([A-Z][A-Za-z0-9_']*)/g + name: 'entity.class', + pattern: /\b([A-Z][A-Za-z0-9_']*)/g }, // From c.js { - 'name': 'meta.preprocessor', - 'matches': { + name: 'meta.preprocessor', + matches: { 1: [ { - 'matches': { + matches: { 1: 'keyword.define', 2: 'entity.name' }, - 'pattern': /(\w+)\s(\w+)\b/g + pattern: /(\w+)\s(\w+)\b/g }, { - 'name': 'keyword.define', - 'pattern': /endif/g + name: 'keyword.define', + pattern: /endif/g }, { - 'name': 'constant.numeric', - 'pattern': /\d+/g + name: 'constant.numeric', + pattern: /\d+/g }, { - 'matches': { + matches: { 1: 'keyword.include', 2: 'string' }, - 'pattern': /(include)\s(.*?)$/g + pattern: /(include)\s(.*?)$/g } ] }, - 'pattern': /^\#([\S\s]*?)$/gm + pattern: /^\#([\S\s]*?)$/gm } ]); diff --git a/src/language/html.js b/src/language/html.js index 095497ad..6cf7a025 100644 --- a/src/language/html.js +++ b/src/language/html.js @@ -6,128 +6,128 @@ */ Rainbow.extend('html', [ { - 'name': 'source.php.embedded', - 'matches': { + name: 'source.php.embedded', + matches: { 2: { - 'language': 'php' + language: 'php' } }, - 'pattern': /<\?=?(?!xml)(php)?([\s\S]*?)(\?>)/gm + pattern: /<\?=?(?!xml)(php)?([\s\S]*?)(\?>)/gm }, { - 'name': 'source.css.embedded', - 'matches': { + name: 'source.css.embedded', + matches: { 1: { - 'matches': { + matches: { 1: 'support.tag.style', 2: [ { - 'name': 'entity.tag.style', - 'pattern': /^style/g + name: 'entity.tag.style', + pattern: /^style/g }, { - 'name': 'string', - 'pattern': /('|")(.*?)(\1)/g + name: 'string', + pattern: /('|")(.*?)(\1)/g }, { - 'name': 'entity.tag.style.attribute', - 'pattern': /(\w+)/g + name: 'entity.tag.style.attribute', + pattern: /(\w+)/g } ], 3: 'support.tag.style' }, - 'pattern': /(<\/?)(style.*?)(>)/g + pattern: /(<\/?)(style.*?)(>)/g }, 2: { - 'language': 'css' + language: 'css' }, 3: 'support.tag.style', 4: 'entity.tag.style', 5: 'support.tag.style' }, - 'pattern': /(<style.*?>)([\s\S]*?)(<\/)(style)(>)/gm + pattern: /(<style.*?>)([\s\S]*?)(<\/)(style)(>)/gm }, { - 'name': 'source.js.embedded', - 'matches': { + name: 'source.js.embedded', + matches: { 1: { - 'matches': { + matches: { 1: 'support.tag.script', 2: [ { - 'name': 'entity.tag.script', - 'pattern': /^script/g + name: 'entity.tag.script', + pattern: /^script/g }, { - 'name': 'string', - 'pattern': /('|")(.*?)(\1)/g + name: 'string', + pattern: /('|")(.*?)(\1)/g }, { - 'name': 'entity.tag.script.attribute', - 'pattern': /(\w+)/g + name: 'entity.tag.script.attribute', + pattern: /(\w+)/g } ], 3: 'support.tag.script' }, - 'pattern': /(<\/?)(script.*?)(>)/g + pattern: /(<\/?)(script.*?)(>)/g }, 2: { - 'language': 'javascript' + language: 'javascript' }, 3: 'support.tag.script', 4: 'entity.tag.script', 5: 'support.tag.script' }, - 'pattern': /(<script(?! src).*?>)([\s\S]*?)(<\/)(script)(>)/gm + pattern: /(<script(?! src).*?>)([\s\S]*?)(<\/)(script)(>)/gm }, { - 'name': 'comment.html', - 'pattern': /<\!--[\S\s]*?-->/g + name: 'comment.html', + pattern: /<\!--[\S\s]*?-->/g }, { - 'matches': { + matches: { 1: 'support.tag.open', 2: 'support.tag.close' }, - 'pattern': /(<)|(\/?\??>)/g + pattern: /(<)|(\/?\??>)/g }, { - 'name': 'support.tag', - 'matches': { + name: 'support.tag', + matches: { 1: 'support.tag', 2: 'support.tag.special', 3: 'support.tag-name' }, - 'pattern': /(<\??)(\/|\!?)(\w+)/g + pattern: /(<\??)(\/|\!?)(\w+)/g }, { - 'matches': { + matches: { 1: 'support.attribute' }, - 'pattern': /([a-z-]+)(?=\=)/gi + pattern: /([a-z-]+)(?=\=)/gi }, { - 'matches': { + matches: { 1: 'support.operator', 2: 'string.quote', 3: 'string.value', 4: 'string.quote' }, - 'pattern': /(=)('|")(.*?)(\2)/g + pattern: /(=)('|")(.*?)(\2)/g }, { - 'matches': { + matches: { 1: 'support.operator', 2: 'support.value' }, - 'pattern': /(=)([a-zA-Z\-0-9]*)\b/g + pattern: /(=)([a-zA-Z\-0-9]*)\b/g }, { - 'matches': { + matches: { 1: 'support.attribute' }, - 'pattern': /\s(\w+)(?=\s|>)(?![\s\S]*<)/g + pattern: /\s(\w+)(?=\s|>)(?![\s\S]*<)/g } ], true); diff --git a/src/language/javascript.js b/src/language/javascript.js index 892bbb52..673e916b 100644 --- a/src/language/javascript.js +++ b/src/language/javascript.js @@ -10,31 +10,30 @@ Rainbow.extend('javascript', [ * matches $. or $( */ { - 'name': 'selector', - 'pattern': /(\s|^)\$(?=\.|\()/g + name: 'selector', + pattern: /(\s|^)\$(?=\.|\()/g }, { - 'name': 'support', - 'pattern': /\b(window|document)\b/g + name: 'support', + pattern: /\b(window|document)\b/g }, { - 'matches': { + matches: { 1: 'support.property' }, - 'pattern': /\.(length|node(Name|Value))\b/g + pattern: /\.(length|node(Name|Value))\b/g }, { - 'matches': { + matches: { 1: 'support.function' }, - 'pattern': /(setTimeout|setInterval)(?=\()/g - + pattern: /(setTimeout|setInterval)(?=\()/g }, { - 'matches': { + matches: { 1: 'support.method' }, - 'pattern': /\.(getAttribute|replace|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g + pattern: /\.(getAttribute|replace|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g }, /** @@ -49,47 +48,47 @@ Rainbow.extend('javascript', [ * http://stackoverflow.com/a/17843773/421333 */ { - 'name': 'string.regexp', - 'matches': { + name: 'string.regexp', + matches: { 1: 'string.regexp.open', 2: { - 'name': 'constant.regexp.escape', - 'pattern': /\\(.){1}/g + name: 'constant.regexp.escape', + pattern: /\\(.){1}/g }, 3: 'string.regexp.close', 4: 'string.regexp.modifier' }, - 'pattern': /(\/)((?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+)(\/)([igm]{0,3})/g + pattern: /(\/)((?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+)(\/)([igm]{0,3})/g }, /** * matches runtime function declarations */ { - 'matches': { + matches: { 1: 'storage', 3: 'entity.function' }, - 'pattern': /(var)?(\s|^)(\S*)(?=\s?=\s?function\()/g + pattern: /(var)?(\s|^)(\S*)(?=\s?=\s?function\()/g }, /** * matches constructor call */ { - 'matches': { + matches: { 1: 'keyword', 2: 'entity.function' }, - 'pattern': /(new)\s+(.*)(?=\()/g + pattern: /(new)\s+(.*)(?=\()/g }, /** * matches any function call in the style functionName: function() */ { - 'name': 'entity.function', - 'pattern': /(\w+)(?=:\s{0,}function)/g + name: 'entity.function', + pattern: /(\w+)(?=:\s{0,}function)/g } ]); diff --git a/src/language/json.js b/src/language/json.js index bb8f06a0..3aa708c2 100644 --- a/src/language/json.js +++ b/src/language/json.js @@ -7,23 +7,23 @@ */ Rainbow.extend('json', [ { - 'matches': { + matches: { 0: { - 'name': 'string', - 'matches': { - 'name': 'constant.character.escape', - 'pattern': /\\('|"){1}/g + name: 'string', + matches: { + name: 'constant.character.escape', + pattern: /\\('|"){1}/g } } }, - 'pattern': /(\"|\')(\\?.)*?\1/g + pattern: /(\"|\')(\\?.)*?\1/g }, { - 'name': 'constant.numeric', - 'pattern': /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/gi + name: 'constant.numeric', + pattern: /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/gi }, { - 'name': 'constant.language', - 'pattern': /\b(true|false|null)\b/g + name: 'constant.language', + pattern: /\b(true|false|null)\b/g } ], true); diff --git a/src/language/lua.js b/src/language/lua.js index 41306fe7..1afa8e3b 100644 --- a/src/language/lua.js +++ b/src/language/lua.js @@ -6,54 +6,54 @@ */ Rainbow.extend('lua', [ { - 'matches': { + matches: { 1: { - 'name': 'keyword.operator', - 'pattern': /\=/g + name: 'keyword.operator', + pattern: /\=/g }, 2: { - 'name': 'string', - 'matches': { - 'name': 'constant.character.escape', - 'pattern': /\\('|"){1}/g + name: 'string', + matches: { + name: 'constant.character.escape', + pattern: /\\('|"){1}/g } } }, - 'pattern': /(\(|\s|\[|\=)(('|")([^\\\1]|\\.)*?(\3))/gm + pattern: /(\(|\s|\[|\=)(('|")([^\\\1]|\\.)*?(\3))/gm }, { - 'name': 'comment', - 'pattern': /\-{2}\[{2}\-{2}[\s\S]*?\-{2}\]{2}\-{2}|(\-{2})[\s\S]*?$/gm + name: 'comment', + pattern: /\-{2}\[{2}\-{2}[\s\S]*?\-{2}\]{2}\-{2}|(\-{2})[\s\S]*?$/gm }, { - 'name': 'constant.numeric', - 'pattern': /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi + name: 'constant.numeric', + pattern: /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b((a|e)nd|in|repeat|break|local|return|do|for|then|else(if)?|function|not|if|or|until|while)(?=\(|\b)/gi + pattern: /\b((a|e)nd|in|repeat|break|local|return|do|for|then|else(if)?|function|not|if|or|until|while)(?=\(|\b)/gi }, { - 'name': 'constant.language', - 'pattern': /true|false|nil/g + name: 'constant.language', + pattern: /true|false|nil/g }, { - 'name': 'keyword.operator', - 'pattern': /\+|\!|\-|&(gt|lt|amp);|\||\*|\=|#|\.{2}/g + name: 'keyword.operator', + pattern: /\+|\!|\-|&(gt|lt|amp);|\||\*|\=|#|\.{2}/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'entity.name.function' }, - 'pattern': /(function)\s+(\w+[\:|\.]?\w+?)(?=\()/g + pattern: /(function)\s+(\w+[\:|\.]?\w+?)(?=\()/g }, { - 'matches': { + matches: { 1: 'support.function' }, - 'pattern': /\b(print|require|module|\w+\.\w+)(?=\()/g + pattern: /\b(print|require|module|\w+\.\w+)(?=\()/g } ], true); diff --git a/src/language/php.js b/src/language/php.js index 943f37d3..eda04401 100644 --- a/src/language/php.js +++ b/src/language/php.js @@ -6,41 +6,41 @@ */ Rainbow.extend('php', [ { - 'name': 'support', - 'pattern': /\becho\b/g + name: 'support', + pattern: /\becho\b/g }, { - 'matches': { + matches: { 1: 'variable.dollar-sign', 2: 'variable' }, - 'pattern': /(\$)(\w+)\b/g + pattern: /(\$)(\w+)\b/g }, { - 'name': 'constant.language', - 'pattern': /true|false|null/ig + name: 'constant.language', + pattern: /true|false|null/ig }, { - 'name': 'constant', - 'pattern': /\b[A-Z0-9_]{2,}\b/g + name: 'constant', + pattern: /\b[A-Z0-9_]{2,}\b/g }, { - 'name': 'keyword.dot', - 'pattern': /\./g + name: 'keyword.dot', + pattern: /\./g }, { - 'name': 'keyword', - 'pattern': /\b(die|end(for(each)?|switch|if)|case|require(_once)?|include(_once)?)(?=\(|\b)/g + name: 'keyword', + pattern: /\b(die|end(for(each)?|switch|if)|case|require(_once)?|include(_once)?)(?=\(|\b)/g }, { - 'matches': { + matches: { 1: 'keyword', 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /(instanceof)\s([^\$].*?)(\)|;)/g + pattern: /(instanceof)\s([^\$].*?)(\)|;)/g }, /** @@ -49,27 +49,27 @@ Rainbow.extend('php', [ * over a bunch of popular PHP frameworks then combining the results */ { - 'matches': { + matches: { 1: 'support.function' }, - 'pattern': /\b(array(_key_exists|_merge|_keys|_shift)?|isset|count|empty|unset|printf|is_(array|string|numeric|object)|sprintf|each|date|time|substr|pos|str(len|pos|tolower|_replace|totime)?|ord|trim|in_array|implode|end|preg_match|explode|fmod|define|link|list|get_class|serialize|file|sort|mail|dir|idate|log|intval|header|chr|function_exists|dirname|preg_replace|file_exists)(?=\()/g + pattern: /\b(array(_key_exists|_merge|_keys|_shift)?|isset|count|empty|unset|printf|is_(array|string|numeric|object)|sprintf|each|date|time|substr|pos|str(len|pos|tolower|_replace|totime)?|ord|trim|in_array|implode|end|preg_match|explode|fmod|define|link|list|get_class|serialize|file|sort|mail|dir|idate|log|intval|header|chr|function_exists|dirname|preg_replace|file_exists)(?=\()/g }, { - 'name': 'variable.language.php-tag', - 'pattern': /(<\?(php)?|\?>)/g + name: 'variable.language.php-tag', + pattern: /(<\?(php)?|\?>)/g }, { - 'matches': { + matches: { 1: 'keyword.namespace', 2: { - 'name': 'support.namespace', - 'pattern': /\w+/g + name: 'support.namespace', + pattern: /\w+/g } }, - 'pattern': /\b(namespace|use)\s(.*?);/g + pattern: /\b(namespace|use)\s(.*?);/g }, { - 'matches': { + matches: { 1: 'storage.modifier', 2: 'storage.class', 3: 'entity.name.class', @@ -78,46 +78,46 @@ Rainbow.extend('php', [ 6: 'storage.modifier.extends', 7: 'entity.other.inherited-class' }, - 'pattern': /\b(abstract|final)?\s?(class|interface|trait)\s(\w+)(\sextends\s)?([\w\\]*)?(\simplements\s)?([\w\\]*)?\s?\{?(\n|\})/g + pattern: /\b(abstract|final)?\s?(class|interface|trait)\s(\w+)(\sextends\s)?([\w\\]*)?(\simplements\s)?([\w\\]*)?\s?\{?(\n|\})/g }, { - 'name': 'keyword.static', - 'pattern': /self::|static::/g + name: 'keyword.static', + pattern: /self::|static::/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'support.magic' }, - 'pattern': /(function)\s(__.*?)(?=\()/g + pattern: /(function)\s(__.*?)(?=\()/g }, { - 'matches': { + matches: { 1: 'keyword.new', 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;)/g + pattern: /\b(new)\s([^\$].*?)(?=\)|\(|;)/g }, { - 'matches': { + matches: { 1: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g }, 2: 'keyword.static' }, - 'pattern': /([\w\\]*?)(::)(?=\b|\$)/g + pattern: /([\w\\]*?)(::)(?=\b|\$)/g }, { - 'matches': { + matches: { 2: { - 'name': 'support.class', - 'pattern': /\w+/g + name: 'support.class', + pattern: /\w+/g } }, - 'pattern': /(\(|,\s?)([\w\\]*?)(?=\s\$)/g + pattern: /(\(|,\s?)([\w\\]*?)(?=\s\$)/g } ]); diff --git a/src/language/python.js b/src/language/python.js index 261195cf..555c8046 100644 --- a/src/language/python.js +++ b/src/language/python.js @@ -9,16 +9,16 @@ Rainbow.extend('python', [ * don't highlight self as a keyword */ { - 'name': 'variable.self', - 'pattern': /self/g + name: 'variable.self', + pattern: /self/g }, { - 'name': 'constant.language', - 'pattern': /None|True|False|NotImplemented|\.\.\./g + name: 'constant.language', + pattern: /None|True|False|NotImplemented|\.\.\./g }, { - 'name': 'support.object', - 'pattern': /object/g + name: 'support.object', + pattern: /object/g }, /** @@ -31,54 +31,54 @@ Rainbow.extend('python', [ * @todo strip some out or consolidate the regexes with matching patterns? */ { - 'name': 'support.function.python', - 'pattern': /\b(bs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|bin|file|iter|property|tuple|bool|filter|len|range|type|bytearray|float|list|raw_input|unichr|callable|format|locals|reduce|unicode|chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|__import__|complex|hash|min|set|apply|delattr|help|next|setattr|buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern)(?=\()/g + name: 'support.function.python', + pattern: /\b(bs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|bin|file|iter|property|tuple|bool|filter|len|range|type|bytearray|float|list|raw_input|unichr|callable|format|locals|reduce|unicode|chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|__import__|complex|hash|min|set|apply|delattr|help|next|setattr|buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern)(?=\()/g }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b(pass|lambda|with|is|not|in|from|elif|raise|del)(?=\(|\b)/g + pattern: /\b(pass|lambda|with|is|not|in|from|elif|raise|del)(?=\(|\b)/g }, { - 'matches': { + matches: { 1: 'storage.class', 2: 'entity.name.class', 3: 'entity.other.inherited-class' }, - 'pattern': /(class)\s+(\w+)\((\w+?)\)/g + pattern: /(class)\s+(\w+)\((\w+?)\)/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'support.magic' }, - 'pattern': /(def)\s+(__\w+)(?=\()/g + pattern: /(def)\s+(__\w+)(?=\()/g }, { - 'name': 'support.magic', - 'pattern': /__(name)__/g + name: 'support.magic', + pattern: /__(name)__/g }, { - 'matches': { + matches: { 1: 'keyword.control', 2: 'support.exception.type' }, - 'pattern': /(except) (\w+):/g + pattern: /(except) (\w+):/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'entity.name.function' }, - 'pattern': /(def)\s+(\w+)(?=\()/g + pattern: /(def)\s+(\w+)(?=\()/g }, { - 'name': 'entity.name.function.decorator', - 'pattern': /@([\w\.]+)/g + name: 'entity.name.function.decorator', + pattern: /@([\w\.]+)/g }, { - 'name': 'comment.docstring', - 'pattern': /('{3}|"{3})[\s\S]*?\1/gm + name: 'comment.docstring', + pattern: /('{3}|"{3})[\s\S]*?\1/gm } ]); diff --git a/src/language/r.js b/src/language/r.js index 86e11e95..f03e6468 100644 --- a/src/language/r.js +++ b/src/language/r.js @@ -10,20 +10,20 @@ Rainbow.extend('r', [ * [.a-zA-Z][0-9a-zA-Z._]* */ { - 'matches': { + matches: { 1: { - 'name': 'keyword.operator', - 'pattern': /\=|<\-|<-/g + name: 'keyword.operator', + pattern: /\=|<\-|<-/g }, 2: { - 'name': 'string', - 'matches': { - 'name': 'constant.character.escape', - 'pattern': /\\('|"){1}/g + name: 'string', + matches: { + name: 'constant.character.escape', + pattern: /\\('|"){1}/g } } }, - 'pattern': /(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm + pattern: /(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm }, /** @@ -31,16 +31,16 @@ Rainbow.extend('r', [ * The built-in constant symbols are known via ?Constants. */ { - 'matches': { + matches: { 1: 'constant.language' }, - 'pattern': /\b(NULL|NA|TRUE|FALSE|T|F|NaN|Inf|NA_integer_|NA_real_|NA_complex_|NA_character_)\b/g + pattern: /\b(NULL|NA|TRUE|FALSE|T|F|NaN|Inf|NA_integer_|NA_real_|NA_complex_|NA_character_)\b/g }, { - 'matches': { + matches: { 1: 'constant.symbol' }, - 'pattern': /[^0-9a-zA-Z\._](LETTERS|letters|month\.(abb|name)|pi)/g + pattern: /[^0-9a-zA-Z\._](LETTERS|letters|month\.(abb|name)|pi)/g }, /** @@ -48,29 +48,29 @@ Rainbow.extend('r', [ * It includes the previous variable when it should only match [[ */ { - 'name': 'keyword.operator', - 'pattern': /<-|<-|-|==|<=|<=|>>|>=|<|>|&&|&&|&|&|!=|\|\|?|\*|\+|\^|\/|%%|%\/%|\=|%in%|%\*%|%o%|%x%|\$|:|~|\[{1,2}|\]{1,2}/g + name: 'keyword.operator', + pattern: /<-|<-|-|==|<=|<=|>>|>=|<|>|&&|&&|&|&|!=|\|\|?|\*|\+|\^|\/|%%|%\/%|\=|%in%|%\*%|%o%|%x%|\$|:|~|\[{1,2}|\]{1,2}/g }, { - 'matches': { + matches: { 1: 'storage', 3: 'entity.function' }, - 'pattern': /(\s|^)(.*)(?=\s?=\s?function\s\()/g + pattern: /(\s|^)(.*)(?=\s?=\s?function\s\()/g }, { - 'matches': { + matches: { 1: 'storage.function' }, - 'pattern': /[^a-zA-Z0-9._](function)(?=\s*\()/g + pattern: /[^a-zA-Z0-9._](function)(?=\s*\()/g }, { - 'matches': { + matches: { 1: 'namespace', 2: 'keyword.operator', 3: 'function.call' }, - 'pattern': /([a-zA-Z][a-zA-Z0-9._]+)([:]{2,3})([.a-zA-Z][a-zA-Z0-9._]*(?=\s*\())\b/g + pattern: /([a-zA-Z][a-zA-Z0-9._]+)([:]{2,3})([.a-zA-Z][a-zA-Z0-9._]*(?=\s*\())\b/g }, /* @@ -83,7 +83,7 @@ Rainbow.extend('r', [ * only partly a function all. */ { - 'name': 'support.function', - 'pattern': /(^|[^0-9a-zA-Z\._])(array|character|complex|data\.frame|double|integer|list|logical|matrix|numeric|vector)(?=\s*\()/g + name: 'support.function', + pattern: /(^|[^0-9a-zA-Z\._])(array|character|complex|data\.frame|double|integer|list|logical|matrix|numeric|vector)(?=\s*\()/g } ]); diff --git a/src/language/ruby.js b/src/language/ruby.js index a90fc960..4d5ef7ce 100644 --- a/src/language/ruby.js +++ b/src/language/ruby.js @@ -12,133 +12,133 @@ Rainbow.extend('ruby', [ * __END__ DATA */ { - 'matches': { + matches: { 1: 'variable.language', 2: { - 'language': null + language: null } }, //find __END__ and consume remaining text - 'pattern': /^(__END__)\n((?:.*\n)*)/gm + pattern: /^(__END__)\n((?:.*\n)*)/gm }, /** * Strings * 1. No support for multi-line strings */ { - 'name': 'string', - 'matches': { + name: 'string', + matches: { 1: 'string.open', 2: [{ - 'name': 'string.interpolation', - 'matches': { + name: 'string.interpolation', + matches: { 1: 'string.open', 2: { - 'language': 'ruby' + language: 'ruby' }, 3: 'string.close' }, - 'pattern': /(\#\{)(.*?)(\})/g + pattern: /(\#\{)(.*?)(\})/g }], 3: 'string.close' }, - 'pattern': /("|`)(.*?[^\\\1])?(\1)/g + pattern: /("|`)(.*?[^\\\1])?(\1)/g }, { - 'name': 'string', - 'pattern': /('|"|`)([^\\\1\n]|\\.)*?\1/g + name: 'string', + pattern: /('|"|`)([^\\\1\n]|\\.)*?\1/g }, { - 'name': 'string', - 'pattern': /%[qQ](?=(\(|\[|\{|<|.)(.*?)(?:'|\)|\]|\}|>|\1))(?:\(\2\)|\[\2\]|\{\2\}|\<\2>|\1\2\1)/g + name: 'string', + pattern: /%[qQ](?=(\(|\[|\{|<|.)(.*?)(?:'|\)|\]|\}|>|\1))(?:\(\2\)|\[\2\]|\{\2\}|\<\2>|\1\2\1)/g }, /** * Heredocs * Heredocs of the form `<<'HTML' ... HTML` are unsupported. */ { - 'matches': { + matches: { 1: 'string', 2: 'string', 3: 'string' }, - 'pattern': /(<<)(\w+).*?$([\s\S]*?^\2)/gm + pattern: /(<<)(\w+).*?$([\s\S]*?^\2)/gm }, { - 'matches': { + matches: { 1: 'string', 2: 'string', 3: 'string' }, - 'pattern': /(<<\-)(\w+).*?$([\s\S]*?\2)/gm + pattern: /(<<\-)(\w+).*?$([\s\S]*?\2)/gm }, /** * Regular expressions * Escaped delimiter (`/\//`) is unsupported. */ { - 'name': 'string.regexp', - 'matches': { + name: 'string.regexp', + matches: { 1: 'string.regexp', 2: { - 'name': 'string.regexp', - 'pattern': /\\(.){1}/g + name: 'string.regexp', + pattern: /\\(.){1}/g }, 3: 'string.regexp', 4: 'string.regexp' }, - 'pattern': /(\/)(.*?)(\/)([a-z]*)/g + pattern: /(\/)(.*?)(\/)([a-z]*)/g }, { - 'name': 'string.regexp', - 'matches': { + name: 'string.regexp', + matches: { 1: 'string.regexp', 2: { - 'name': 'string.regexp', - 'pattern': /\\(.){1}/g + name: 'string.regexp', + pattern: /\\(.){1}/g }, 3: 'string.regexp', 4: 'string.regexp' }, - 'pattern': /%r(?=(\(|\[|\{|<|.)(.*?)('|\)|\]|\}|>|\1))(?:\(\2\)|\[\2\]|\{\2\}|\<\2>|\1\2\1)([a-z]*)/g + pattern: /%r(?=(\(|\[|\{|<|.)(.*?)('|\)|\]|\}|>|\1))(?:\(\2\)|\[\2\]|\{\2\}|\<\2>|\1\2\1)([a-z]*)/g }, /** * Comments */ { - 'name': 'comment', - 'pattern': /#.*$/gm + name: 'comment', + pattern: /#.*$/gm }, { - 'name': 'comment', - 'pattern': /^\=begin[\s\S]*?\=end$/gm + name: 'comment', + pattern: /^\=begin[\s\S]*?\=end$/gm }, /** * Symbols */ { - 'matches': { + matches: { 1: 'constant' }, - 'pattern': /(\w+:)[^:]/g + pattern: /(\w+:)[^:]/g }, { - 'matches': { + matches: { 1: 'constant.symbol' }, - 'pattern': /[^:](:(?:\w+|(?=['"](.*?)['"])(?:"\2"|'\2')))/g + pattern: /[^:](:(?:\w+|(?=['"](.*?)['"])(?:"\2"|'\2')))/g }, { - 'name': 'constant.numeric', - 'pattern': /\b(0x[\da-f]+|\d+)\b/g + name: 'constant.numeric', + pattern: /\b(0x[\da-f]+|\d+)\b/g }, { - 'name': 'support.class', - 'pattern': /\b[A-Z]\w*(?=((\.|::)[A-Za-z]|\[))/g + name: 'support.class', + pattern: /\b[A-Z]\w*(?=((\.|::)[A-Za-z]|\[))/g }, { - 'name': 'constant', - 'pattern': /\b[A-Z]\w*\b/g + name: 'constant', + pattern: /\b[A-Z]\w*\b/g }, /** * Keywords, variables, constants, and operators @@ -146,71 +146,71 @@ Rainbow.extend('ruby', [ * Don't mark those instances as "keywords" */ { - 'matches': { + matches: { 1: 'storage.class', 2: 'entity.name.class', 3: 'entity.other.inherited-class' }, - 'pattern': /\s*(class)\s+((?:(?:::)?[A-Z]\w*)+)(?:\s+<\s+((?:(?:::)?[A-Z]\w*)+))?/g + pattern: /\s*(class)\s+((?:(?:::)?[A-Z]\w*)+)(?:\s+<\s+((?:(?:::)?[A-Z]\w*)+))?/g }, { - 'matches': { + matches: { 1: 'storage.module', 2: 'entity.name.class' }, - 'pattern': /\s*(module)\s+((?:(?:::)?[A-Z]\w*)+)/g + pattern: /\s*(module)\s+((?:(?:::)?[A-Z]\w*)+)/g }, { - 'name': 'variable.global', - 'pattern': /\$([a-zA-Z_]\w*)\b/g + name: 'variable.global', + pattern: /\$([a-zA-Z_]\w*)\b/g }, { - 'name': 'variable.class', - 'pattern': /@@([a-zA-Z_]\w*)\b/g + name: 'variable.class', + pattern: /@@([a-zA-Z_]\w*)\b/g }, { - 'name': 'variable.instance', - 'pattern': /@([a-zA-Z_]\w*)\b/g + name: 'variable.instance', + pattern: /@([a-zA-Z_]\w*)\b/g }, { - 'matches': { + matches: { 1: 'keyword.control' }, - 'pattern': /[^\.]\b(BEGIN|begin|case|class|do|else|elsif|END|end|ensure|for|if|in|module|rescue|then|unless|until|when|while)\b(?![?!])/g + pattern: /[^\.]\b(BEGIN|begin|case|class|do|else|elsif|END|end|ensure|for|if|in|module|rescue|then|unless|until|when|while)\b(?![?!])/g }, { - 'matches': { + matches: { 1: 'keyword.control.pseudo-method' }, - 'pattern': /[^\.]\b(alias|alias_method|break|next|redo|retry|return|super|undef|yield)\b(?![?!])|\bdefined\?|\bblock_given\?/g + pattern: /[^\.]\b(alias|alias_method|break|next|redo|retry|return|super|undef|yield)\b(?![?!])|\bdefined\?|\bblock_given\?/g }, { - 'matches': { + matches: { 1: 'constant.language' }, - 'pattern': /\b(nil|true|false)\b(?![?!])/g + pattern: /\b(nil|true|false)\b(?![?!])/g }, { - 'matches': { + matches: { 1: 'variable.language' }, - 'pattern': /\b(__(FILE|LINE)__|self)\b(?![?!])/g + pattern: /\b(__(FILE|LINE)__|self)\b(?![?!])/g }, { - 'matches': { + matches: { 1: 'keyword.special-method' }, - 'pattern': /\b(require|gem|initialize|new|loop|include|extend|raise|attr_reader|attr_writer|attr_accessor|attr|catch|throw|private|module_function|public|protected)\b(?![?!])/g + pattern: /\b(require|gem|initialize|new|loop|include|extend|raise|attr_reader|attr_writer|attr_accessor|attr|catch|throw|private|module_function|public|protected)\b(?![?!])/g }, { - 'name': 'keyword.operator', - 'pattern': /\s\?\s|=|<<|<<=|%=|&=|\*=|\*\*=|\+=|\-=|\^=|\|{1,2}=|<<|<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|%|&|\*\*|\*|\+|\-|\/|\||~|>>/g + name: 'keyword.operator', + pattern: /\s\?\s|=|<<|<<=|%=|&=|\*=|\*\*=|\+=|\-=|\^=|\|{1,2}=|<<|<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|%|&|\*\*|\*|\+|\-|\/|\||~|>>/g }, { - 'matches': { + matches: { 1: 'keyword.operator.logical' }, - 'pattern': /[^\.]\b(and|not|or)\b/g + pattern: /[^\.]\b(and|not|or)\b/g }, /** @@ -218,10 +218,10 @@ Rainbow.extend('ruby', [ * 1. No support for marking function parameters */ { - 'matches': { + matches: { 1: 'storage.function', 2: 'entity.name.function' }, - 'pattern': /(def)\s(.*?)(?=(\s|\())/g + pattern: /(def)\s(.*?)(?=(\s|\())/g } ], true); diff --git a/src/language/scheme.js b/src/language/scheme.js index 8cb20c00..1470e99c 100644 --- a/src/language/scheme.js +++ b/src/language/scheme.js @@ -7,46 +7,46 @@ Rainbow.extend('scheme', [ { /* making peace with HTML */ - 'name': 'plain', - 'pattern': />|</g + name: 'plain', + pattern: />|</g }, { - 'name': 'comment', - 'pattern': /;.*$/gm + name: 'comment', + pattern: /;.*$/gm }, { - 'name': 'constant.language', - 'pattern': /#t|#f|'\(\)/g + name: 'constant.language', + pattern: /#t|#f|'\(\)/g }, { - 'name': 'constant.symbol', - 'pattern': /'[^()\s#]+/g + name: 'constant.symbol', + pattern: /'[^()\s#]+/g }, { - 'name': 'constant.number', - 'pattern': /\b\d+(?:\.\d*)?\b/g + name: 'constant.number', + pattern: /\b\d+(?:\.\d*)?\b/g }, { - 'name': 'string', - 'pattern': /".+?"/g + name: 'string', + pattern: /".+?"/g }, { - 'matches': { + matches: { 1: 'storage.function', 2: 'variable' }, - 'pattern': /\(\s*(define)\s+\(?(\S+)/g + pattern: /\(\s*(define)\s+\(?(\S+)/g }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\(\s*(begin|define\-syntax|if|lambda|quasiquote|quote|set!|syntax\-rules|and|and\-let\*|case|cond|delay|do|else|or|let|let\*|let\-syntax|letrec|letrec\-syntax)(?=[\]()\s#])/g + pattern: /\(\s*(begin|define\-syntax|if|lambda|quasiquote|quote|set!|syntax\-rules|and|and\-let\*|case|cond|delay|do|else|or|let|let\*|let\-syntax|letrec|letrec\-syntax)(?=[\]()\s#])/g }, { - 'matches': { + matches: { 1: 'entity.function' }, - 'pattern': /\(\s*(eqv\?|eq\?|equal\?|number\?|complex\?|real\?|rational\?|integer\?|exact\?|inexact\?|=|<|>|<=|>=|zero\?|positive\?|negative\?|odd\?|even\?|max|min|\+|\-|\*|\/|abs|quotient|remainder|modulo|gcd|lcm|numerator|denominator|floor|ceiling|truncate|round|rationalize|exp|log|sin|cos|tan|asin|acos|atan|sqrt|expt|make\-rectangular|make\-polar|real\-part|imag\-part|magnitude|angle|exact\->inexact|inexact\->exact|number\->string|string\->number|not|boolean\?|pair\?|cons|car|cdr|set\-car!|set\-cdr!|caar|cadr|cdar|cddr|caaar|caadr|cadar|caddr|cdaar|cdadr|cddar|cdddr|caaaar|caaadr|caadar|caaddr|cadaar|cadadr|caddar|cadddr|cdaaar|cdaadr|cdadar|cdaddr|cddaar|cddadr|cdddar|cddddr|null\?|list\?|list|length|append|reverse|list\-tail|list\-ref|memq|memv|member|assq|assv|assoc|symbol\?|symbol\->string|string\->symbol|char\?|char=\?|char<\?|char>\?|char<=\?|char>=\?|char\-ci=\?|char\-ci<\?|char\-ci>\?|char\-ci<=\?|char\-ci>=\?|char\-alphabetic\?|char\-numeric\?|char\-whitespace\?|char\-upper\-case\?|char\-lower\-case\?|char\->integer|integer\->char|char\-upcase|char\-downcase|string\?|make\-string|string|string\-length|string\-ref|string\-set!|string=\?|string\-ci=\?|string<\?|string>\?|string<=\?|string>=\?|string\-ci<\?|string\-ci>\?|string\-ci<=\?|string\-ci>=\?|substring|string\-append|string\->list|list\->string|string\-copy|string\-fill!|vector\?|make\-vector|vector|vector\-length|vector\-ref|vector\-set!|vector\->list|list\->vector|vector\-fill!|procedure\?|apply|map|for\-each|force|call\-with\-current\-continuation|call\/cc|values|call\-with\-values|dynamic\-wind|eval|scheme\-report\-environment|null\-environment|interaction\-environment|call\-with\-input\-file|call\-with\-output\-file|input\-port\?|output\-port\?|current\-input\-port|current\-output\-port|with\-input\-from\-file|with\-output\-to\-file|open\-input\-file|open\-output\-file|close\-input\-port|close\-output\-port|read|read\-char|peek\-char|eof\-object\?|char\-ready\?|write|display|newline|write\-char|load|transcript\-on|transcript\-off)(?=[\]()\s#])/g + pattern: /\(\s*(eqv\?|eq\?|equal\?|number\?|complex\?|real\?|rational\?|integer\?|exact\?|inexact\?|=|<|>|<=|>=|zero\?|positive\?|negative\?|odd\?|even\?|max|min|\+|\-|\*|\/|abs|quotient|remainder|modulo|gcd|lcm|numerator|denominator|floor|ceiling|truncate|round|rationalize|exp|log|sin|cos|tan|asin|acos|atan|sqrt|expt|make\-rectangular|make\-polar|real\-part|imag\-part|magnitude|angle|exact\->inexact|inexact\->exact|number\->string|string\->number|not|boolean\?|pair\?|cons|car|cdr|set\-car!|set\-cdr!|caar|cadr|cdar|cddr|caaar|caadr|cadar|caddr|cdaar|cdadr|cddar|cdddr|caaaar|caaadr|caadar|caaddr|cadaar|cadadr|caddar|cadddr|cdaaar|cdaadr|cdadar|cdaddr|cddaar|cddadr|cdddar|cddddr|null\?|list\?|list|length|append|reverse|list\-tail|list\-ref|memq|memv|member|assq|assv|assoc|symbol\?|symbol\->string|string\->symbol|char\?|char=\?|char<\?|char>\?|char<=\?|char>=\?|char\-ci=\?|char\-ci<\?|char\-ci>\?|char\-ci<=\?|char\-ci>=\?|char\-alphabetic\?|char\-numeric\?|char\-whitespace\?|char\-upper\-case\?|char\-lower\-case\?|char\->integer|integer\->char|char\-upcase|char\-downcase|string\?|make\-string|string|string\-length|string\-ref|string\-set!|string=\?|string\-ci=\?|string<\?|string>\?|string<=\?|string>=\?|string\-ci<\?|string\-ci>\?|string\-ci<=\?|string\-ci>=\?|substring|string\-append|string\->list|list\->string|string\-copy|string\-fill!|vector\?|make\-vector|vector|vector\-length|vector\-ref|vector\-set!|vector\->list|list\->vector|vector\-fill!|procedure\?|apply|map|for\-each|force|call\-with\-current\-continuation|call\/cc|values|call\-with\-values|dynamic\-wind|eval|scheme\-report\-environment|null\-environment|interaction\-environment|call\-with\-input\-file|call\-with\-output\-file|input\-port\?|output\-port\?|current\-input\-port|current\-output\-port|with\-input\-from\-file|with\-output\-to\-file|open\-input\-file|open\-output\-file|close\-input\-port|close\-output\-port|read|read\-char|peek\-char|eof\-object\?|char\-ready\?|write|display|newline|write\-char|load|transcript\-on|transcript\-off)(?=[\]()\s#])/g } ], true); diff --git a/src/language/shell.js b/src/language/shell.js index a01d6c32..c2abd985 100644 --- a/src/language/shell.js +++ b/src/language/shell.js @@ -14,43 +14,43 @@ Rainbow.extend('shell', [ * @see http://stackoverflow.com/questions/133601/can-regular-expressions-be-used-to-match-nested-patterns */ { - 'name': 'shell', - 'matches': { + name: 'shell', + matches: { 1: { - 'language': 'shell' + language: 'shell' } }, - 'pattern': /\$\(([\s\S]*?)\)/gm + pattern: /\$\(([\s\S]*?)\)/gm }, { - 'matches': { + matches: { 2: 'string' }, - 'pattern': /(\(|\s|\[|\=)(('|")[\s\S]*?(\3))/gm + pattern: /(\(|\s|\[|\=)(('|")[\s\S]*?(\3))/gm }, { - 'name': 'keyword.operator', - 'pattern': /<|>|&/g + name: 'keyword.operator', + pattern: /<|>|&/g }, { - 'name': 'comment', - 'pattern': /\#[\s\S]*?$/gm + name: 'comment', + pattern: /\#[\s\S]*?$/gm }, { - 'name': 'storage.function', - 'pattern': /(.+?)(?=\(\)\s{0,}\{)/g + name: 'storage.function', + pattern: /(.+?)(?=\(\)\s{0,}\{)/g }, /** * Environment variables */ { - 'name': 'support.command', - 'pattern': /\b(echo|rm|ls|(mk|rm)dir|cd|find|cp|exit|pwd|exec|trap|source|shift|unset)/g + name: 'support.command', + pattern: /\b(echo|rm|ls|(mk|rm)dir|cd|find|cp|exit|pwd|exec|trap|source|shift|unset)/g }, { - 'matches': { + matches: { 1: 'keyword' }, - 'pattern': /\b(break|case|continue|do|done|elif|else|esac|eval|export|fi|for|function|if|in|local|return|set|then|unset|until|while)(?=\(|\b)/g + pattern: /\b(break|case|continue|do|done|elif|else|esac|eval|export|fi|for|function|if|in|local|return|set|then|unset|until|while)(?=\(|\b)/g } ], true); diff --git a/src/language/smalltalk.js b/src/language/smalltalk.js index 16c2b5e5..d9148f04 100644 --- a/src/language/smalltalk.js +++ b/src/language/smalltalk.js @@ -6,47 +6,47 @@ */ Rainbow.extend('smalltalk', [ { - 'name': 'keyword.pseudovariable', - 'pattern': /self|thisContext/g + name: 'keyword.pseudovariable', + pattern: /self|thisContext/g }, { - 'name': 'keyword.constant', - 'pattern': /false|nil|true/g + name: 'keyword.constant', + pattern: /false|nil|true/g }, { - 'name': 'string', - 'pattern': /'([^']|'')*'/g + name: 'string', + pattern: /'([^']|'')*'/g }, { - 'name': 'string.symbol', - 'pattern': /#\w+|#'([^']|'')*'/g + name: 'string.symbol', + pattern: /#\w+|#'([^']|'')*'/g }, { - 'name': 'string.character', - 'pattern': /\$\w+/g + name: 'string.character', + pattern: /\$\w+/g }, { - 'name': 'comment', - 'pattern': /"([^"]|"")*"/g + name: 'comment', + pattern: /"([^"]|"")*"/g }, { - 'name': 'constant.numeric', - 'pattern': /-?\d+(\.\d+)?((r-?|s)[A-Za-z0-9]+|e-?[0-9]+)?/g + name: 'constant.numeric', + pattern: /-?\d+(\.\d+)?((r-?|s)[A-Za-z0-9]+|e-?[0-9]+)?/g }, { - 'name': 'entity.name.class', - 'pattern': /\b[A-Z]\w*/g + name: 'entity.name.class', + pattern: /\b[A-Z]\w*/g }, { - 'name': 'entity.name.function', - 'pattern': /\b[a-z]\w*:?/g + name: 'entity.name.function', + pattern: /\b[a-z]\w*:?/g }, { - 'name': 'entity.name.binary', - 'pattern': /(<|>|&|[=~\|\\\/!@*\-_+])+/g + name: 'entity.name.binary', + pattern: /(<|>|&|[=~\|\\\/!@*\-_+])+/g }, { - 'name': 'operator.delimiter', - 'pattern': /;[\(\)\[\]\{\}]|#\[|#\(^\./g + name: 'operator.delimiter', + pattern: /;[\(\)\[\]\{\}]|#\[|#\(^\./g } ], true); From 16cfca88ad2d5d42d2d9af3d0689b006063f6144 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 22:02:53 -0400 Subject: [PATCH 114/153] Add Rainbow as global in eslint config --- .eslintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index f1652e23..1d5cee04 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,8 @@ "es6": true }, "globals": { - "console": false + "console": false, + "Rainbow": false }, "parserOptions": { "ecmaVersion": 6, From 1436d108ad9ff670af20e17b8f8925e4cbe32e5d Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 22:50:06 -0400 Subject: [PATCH 115/153] Simplify how this is written --- src/prism.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/prism.js b/src/prism.js index b09eaf77..55cd5d72 100644 --- a/src/prism.js +++ b/src/prism.js @@ -68,8 +68,14 @@ class Prism { * @return {string} */ function _wrapCodeInSpan(name, code) { + let className = name.replace(/\./g, ' '); + const globalClass = options.globalClass; - return `${code}`; + if (globalClass) { + className += ` ${globalClass}`; + } + + return `${code}`; } /** From 7783e6b87ec162986497e31f18857aa5e33d07e4 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 22:50:56 -0400 Subject: [PATCH 116/153] Update language selectors to include all valid variations --- themes/sass/_init.sass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index 740d02d4..2173803d 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -5,7 +5,8 @@ 100% opacity: 1 -[data-language] code, pre [data-language] +[data-language] code, [class^="lang"] code, +pre [data-language], pre [class^="lang"] opacity: 0 // IE9 supports unprefixed opacity property but does not support keyframe From 29818813c5fc678f509f006335f1c23f392a2b7a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Tue, 28 Jun 2016 22:51:20 -0400 Subject: [PATCH 117/153] Add a mixin to style things specifically for a certain language --- themes/sass/_init.sass | 4 ++++ themes/sass/blackboard.sass | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index 2173803d..cf9e3afb 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -1,3 +1,7 @@ +@mixin language($name) + [data-language="#{$name}"], .lang-#{$name}, .language-#{$name} + @content + @keyframes #{fade-in} 0% opacity: 0 diff --git a/themes/sass/blackboard.sass b/themes/sass/blackboard.sass index 1b79696b..aef2b2dd 100644 --- a/themes/sass/blackboard.sass +++ b/themes/sass/blackboard.sass @@ -42,5 +42,6 @@ pre .variable.global, .variable.class, .variable.instance color: #FF6400 -*[data-language="c"] .function.call - color: #8DA6CE +@include language("c") + .function.call + color: #8DA6CE From 84351da7455c6899b5837acc51bf09535c62c4f7 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 01:25:20 -0400 Subject: [PATCH 118/153] Improve javascript grammars - Fix some existing issues - Add first round of ES6 support --- src/language/javascript.js | 63 ++++++++++++- test/language/javascript-test.js | 148 ++++++++++++++++++++++++++++--- 2 files changed, 198 insertions(+), 13 deletions(-) diff --git a/src/language/javascript.js b/src/language/javascript.js index 673e916b..b6774b2d 100644 --- a/src/language/javascript.js +++ b/src/language/javascript.js @@ -17,6 +17,22 @@ Rainbow.extend('javascript', [ name: 'support', pattern: /\b(window|document)\b/g }, + { + name: 'keyword', + pattern: /export|default|from/g + }, + { + name: 'variable.language.this', + pattern: /this/g + }, + { + name: 'variable.language.super', + pattern: /super/g + }, + { + name: 'storage.type', + pattern: /const|let|var/g + }, { matches: { 1: 'support.property' @@ -66,7 +82,7 @@ Rainbow.extend('javascript', [ */ { matches: { - 1: 'storage', + 1: 'storage.type', 3: 'entity.function' }, pattern: /(var)?(\s|^)(\S*)(?=\s?=\s?function\()/g @@ -78,9 +94,9 @@ Rainbow.extend('javascript', [ { matches: { 1: 'keyword', - 2: 'entity.function' + 2: 'variable.type' }, - pattern: /(new)\s+(.*)(?=\()/g + pattern: /(new)\s+(?!Promise)([^\(]*)(?=\()/g }, /** @@ -89,6 +105,47 @@ Rainbow.extend('javascript', [ { name: 'entity.function', pattern: /(\w+)(?=:\s{0,}function)/g + }, + { + name: 'constant.other', + pattern: /\*(?= as)/g + }, + { + matches: { + 1: 'keyword', + 2: 'constant.other' + }, + pattern: /(export)\s+(\*)/g + }, + { + matches: { + 1: 'storage.type.accessor', + 2: 'entity.name.function' + }, + pattern: /(get|set)\s+(\w+)(?=\()/g + }, + { + matches: { + 2: 'entity.name.function' + }, + pattern: /(^\s*)(\w+)(?=\([^\)]*?\)\s*\{)/gm + }, + { + matches: { + 1: 'storage.type.class', + 2: 'entity.name.class', + 3: 'storage.modifier.extends', + 4: 'entity.other.inherited-class' + }, + pattern: /(class)\s+(\w+)(?:\s+(extends)\s+(\w+))?(?=\s*\{)/g + }, + { + name: 'storage.type.function.arrow', + pattern: /=>/g + }, + { + name: 'support.class.promise', + pattern: /Promise(?=(\(|\.))/g } ]); diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js index c1556b0c..d2d25725 100644 --- a/test/language/javascript-test.js +++ b/test/language/javascript-test.js @@ -55,7 +55,7 @@ describe(language, () => { 'var pattern = /\\((.*?)\\)/g', - 'var pattern = /\\((.*?)\\)/g' + 'var pattern = /\\((.*?)\\)/g' ); run( @@ -65,7 +65,7 @@ describe(language, () => { 'var pattern = /true/', - 'var pattern = /true/' + 'var pattern = /true/' ); run( @@ -75,7 +75,7 @@ describe(language, () => { 'var test = "http://website.com/could/match/regex/i";', - 'var test = "http://website.com/could/match/regex/i";' + 'var test = "http://website.com/could/match/regex/i";' ); run( @@ -85,7 +85,7 @@ describe(language, () => { 'var Animal = function() { /* some comment */ };', - 'var Animal = function() { /* some comment */ };' + 'var Animal = function() { /* some comment */ };' ); run( @@ -95,7 +95,7 @@ describe(language, () => { 'var animal = new Animal();', - 'var animal = new Animal();' + 'var animal = new Animal();' ); run( @@ -108,7 +108,7 @@ describe(language, () => { // do something };`, - `var foo = true, + `var foo = true, something = function() { // do something };` @@ -211,9 +211,9 @@ describe(language, () => { var parseAndHighlight = function() {}; var parseAndHighlight2 = function() {};`, - `var language = getLanguage(source); - var parseAndHighlight = function() {}; - var parseAndHighlight2 = function() {};` + `var language = getLanguage(source); + var parseAndHighlight = function() {}; + var parseAndHighlight2 = function() {};` ); run( @@ -235,7 +235,7 @@ describe(language, () => { 'var str = \'something\';', '{\' \'}\n' + - 'var str = \'something\';' + 'var str = \'something\';' ); run( @@ -247,5 +247,133 @@ describe(language, () => { '/\\/\\*[\\s\\S]*?\\*\\//gm' ); + + run( + language, + + 'const declaration', + + 'const something = true;', + + 'const something = true;' + ); + + run( + language, + + 'let declaration', + + 'let something = true;', + + 'let something = true;' + ); + + run( + language, + + 'import statement', + + 'import * as templates from \'./templates\'', + + 'import * as templates from \'./templates\'' + ); + + run( + language, + + 'export statement', + + 'export default Template;', + + 'export default Template;' + ); + + run( + language, + + 'export statement with asterisk', + + 'export * from "./othermod";', + + 'export * from "./othermod";' + ); + + run( + language, + + 'class definition', + + `class Test { + constructor(blah) { + super(blah); + } + }`, + + `class Test { + constructor(blah) { + super(blah); + } + }` + ); + + run( + language, + + 'child class definition', + + 'class Test extends SomethingElse {}', + + 'class Test extends SomethingElse {}' + ); + + run( + language, + + 'setters and getters', + + `set name(name) { + this._name = name; + } + + get name() { + return this._name; + }`, + + `set name(name) { + this._name = name; + } + + get name() { + return this._name; + }` + ); + + run( + language, + + 'default function arguments', + + 'function something({ one = true, two = 123 } = {}) {}', + + 'function something({ one = true, two = 123 } = {}) {}' + ); + + run( + language, + + 'arrow function with promise', + + `function test() { + return new Promise((resolve, reject) => { + resolve(); + }); + }`, + + `function test() { + return new Promise((resolve, reject) => { + resolve(); + }); + }` + ); }); From a09148f1c91bb15dfe47787011ff4011f139bc6f Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 01:25:43 -0400 Subject: [PATCH 119/153] Add support for passing a list of languages --- themes/sass/_init.sass | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index cf9e3afb..c30f6837 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -1,6 +1,12 @@ -@mixin language($name) - [data-language="#{$name}"], .lang-#{$name}, .language-#{$name} - @content +$name: "" +@mixin language($names) + @if length($names) == 1 + [data-language="#{$name}"], .lang-#{$name}, .language-#{$name} + @content + @else + @each $name in $names + [data-language="#{$name}"], .lang-#{$name}, .language-#{$name} + @content @keyframes #{fade-in} 0% From d621950a039c134b1674175336923f7aa5ed2d8e Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 01:26:05 -0400 Subject: [PATCH 120/153] Update some styles in the monokai theme --- themes/sass/monokai.sass | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/themes/sass/monokai.sass b/themes/sass/monokai.sass index 744e4d8b..e74c5143 100644 --- a/themes/sass/monokai.sass +++ b/themes/sass/monokai.sass @@ -33,7 +33,7 @@ pre /*color: #66D9EF*/ color: #F92672 - .selector + .selector, .storage.modifier.extends color: #F92672 .inherited-class @@ -54,5 +54,10 @@ pre .variable.global, .variable.class, .variable.instance color: #A6E22E -*[data-language="html"] .support.operator - color: #fff +@include language("html") + .support.operator + color: #fff + +@include language(("javascript", "js")) + .variable.super + color: #66D9EF From fd3c9f1f3b38f21b0afea1827fea647bb9f4393a Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 01:59:15 -0400 Subject: [PATCH 121/153] Use a capital Rainbow variable to represent the object --- src/rainbow.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/rainbow.js b/src/rainbow.js index a2f6716b..4a40e4c2 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -50,6 +50,13 @@ const aliases = {}; */ let globalClass; +/** + * Representation of the actual rainbow object + * + * @type {Object} + */ +let Rainbow = {}; + /** * Callback to fire after each block is highlighted * @@ -282,7 +289,7 @@ function onHighlight(callback) { * force all blocks to not be highlighted and remove this class to * transition them to being highlighted. * - * @param {string} className + * @param {string} name * @return {void} */ function addClass(name) { @@ -386,7 +393,7 @@ function addAlias(alias, originalLanguage) { /** * public methods */ -const _rainbow = { +Rainbow = { extend, onHighlight, addClass, @@ -395,7 +402,7 @@ const _rainbow = { }; if (isNode) { - _rainbow.colorSync = function(code, lang) { + Rainbow.colorSync = function(code, lang) { const prism = new Prism(_getPrismOptions()); return prism.refract(code, aliases[lang] || lang); }; @@ -403,7 +410,7 @@ if (isNode) { // In the browser hook it up to color on page load if (!isNode && !isWorker) { - document.addEventListener('DOMContentLoaded', _rainbow.color, false); + document.addEventListener('DOMContentLoaded', Rainbow.color, false); } // From a node worker, handle the postMessage requests to it @@ -411,4 +418,4 @@ if (isWorker) { self.onmessage = rainbowWorker; } -export default _rainbow; +export default Rainbow; From 02e3ff735f89842e922d2a1c86e132c885d8f12b Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 01:59:59 -0400 Subject: [PATCH 122/153] Add an option to defer so Rainbow will not highlight on load --- src/rainbow.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rainbow.js b/src/rainbow.js index 4a40e4c2..fffdb74b 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -325,6 +325,11 @@ function extend(...args) { * @return {void} */ function color(...args) { + if (Rainbow.defer) { + Rainbow.defer = false; + return; + } + // If you want to straight up highlight a string you can pass the // string of code, the language, and a callback function. // From 59122052d634f5463aed9ca4f80132d29a0329c7 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Wed, 29 Jun 2016 23:34:38 -0400 Subject: [PATCH 123/153] Change the way language extending works Instead of all patterne extending the generic patterns by default like how it works in 1.0, now each language will be considered a standalone language unless you pass in a third argument into Rainbow.extend representing another language to extend. This allows you to extend any language with any other one. For example, you could make rules for jsx that extend from javascript or scss that extend from css. --- src/language/c.js | 2 +- src/language/coffeescript.js | 2 +- src/language/csharp.js | 2 +- src/language/css.js | 2 +- src/language/d.js | 2 +- src/language/go.js | 2 +- src/language/haskell.js | 2 +- src/language/html.js | 2 +- src/language/java.js | 2 +- src/language/javascript.js | 2 +- src/language/json.js | 2 +- src/language/lua.js | 2 +- src/language/php.js | 2 +- src/language/python.js | 2 +- src/language/r.js | 2 +- src/language/ruby.js | 2 +- src/language/scheme.js | 2 +- src/language/shell.js | 2 +- src/language/smalltalk.js | 2 +- src/prism.js | 10 +++++++--- src/rainbow.js | 21 ++++++++++----------- 21 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/language/c.js b/src/language/c.js index ce12c4d5..39dab7dd 100644 --- a/src/language/c.js +++ b/src/language/c.js @@ -66,4 +66,4 @@ Rainbow.extend('c', [ name: 'support.type', pattern: /\b(struct|union|enum)\b/g } -]); +], 'generic'); diff --git a/src/language/coffeescript.js b/src/language/coffeescript.js index b93bf068..61d28cb9 100644 --- a/src/language/coffeescript.js +++ b/src/language/coffeescript.js @@ -122,6 +122,6 @@ Rainbow.extend('coffeescript', [ }, pattern: /\b(new)\s(.*?)(?=\s)/g } -]); +], 'generic'); Rainbow.addAlias('coffee', 'coffeescript'); diff --git a/src/language/csharp.js b/src/language/csharp.js index 9266c77f..b8678bda 100644 --- a/src/language/csharp.js +++ b/src/language/csharp.js @@ -84,4 +84,4 @@ Rainbow.extend('csharp', [ name: 'preprocessor', pattern: /(\#if|\#else|\#elif|\#endif|\#define|\#undef|\#warning|\#error|\#line|\#region|\#endregion|\#pragma)[\s\S]*?$/gm } -], true); +]); diff --git a/src/language/css.js b/src/language/css.js index 761e7f1d..7fa96786 100644 --- a/src/language/css.js +++ b/src/language/css.js @@ -69,6 +69,6 @@ Rainbow.extend('css', [ }, pattern: /(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g } -], true); +]); Rainbow.addAlias('scss', 'css'); diff --git a/src/language/d.js b/src/language/d.js index 548bbb10..b94de7c1 100644 --- a/src/language/d.js +++ b/src/language/d.js @@ -77,5 +77,5 @@ Rainbow.extend('d', [ // / /= &= && & |= || | -= -- - += ++ + <= << < <<= <>= <> > >>>= >>= >= >> >>> != !<>= !<> !<= !< !>= !> ! [ ] $ == = *= * %= % ^^= ^= ^^ ^ ~= ~ @ => : pattern: /(\/|\/=|&=|&&|&|\|=|\|\|\||\-=|\-\-|\-|\+=|\+\+|\+|<=|<<|<|<<=|<>=|<>|>|>>>=|>>=|>=|>>|>>>|!=|!<>=|!<>|!<=|!<|!>=|!>|!|[|]|\$|==|=|\*=|\*|%=|%|\^\^=|\^=|\^\^|\^|~=|~|@|=>|\:)/gm } -], true); +]); diff --git a/src/language/go.js b/src/language/go.js index c7561c7d..fb56ba4f 100644 --- a/src/language/go.js +++ b/src/language/go.js @@ -56,4 +56,4 @@ Rainbow.extend('go', [ }, pattern: /(func)\s(.*?)(?=\()/g } -]); +], 'generic'); diff --git a/src/language/haskell.js b/src/language/haskell.js index 9c8db73f..f2a1ad29 100644 --- a/src/language/haskell.js +++ b/src/language/haskell.js @@ -91,4 +91,4 @@ Rainbow.extend('haskell', [ }, pattern: /^\#([\S\s]*?)$/gm } -]); +], 'generic'); diff --git a/src/language/html.js b/src/language/html.js index 6cf7a025..0863021a 100644 --- a/src/language/html.js +++ b/src/language/html.js @@ -129,6 +129,6 @@ Rainbow.extend('html', [ }, pattern: /\s(\w+)(?=\s|>)(?![\s\S]*<)/g } -], true); +]); Rainbow.addAlias('xml', 'html'); diff --git a/src/language/java.js b/src/language/java.js index dd560f8c..1d78814a 100644 --- a/src/language/java.js +++ b/src/language/java.js @@ -56,4 +56,4 @@ Rainbow.extend( "java", [ name: "operator", pattern: /(\+{1,2}|-{1,2}|~|!|\*|\/|%|(?:<){1,2}|(?:>){1,3}|instanceof|(?:&){1,2}|\^|\|{1,2}|\?|:|(?:=|!|\+|-|\*|\/|%|\^|\||(?:<){1,2}|(?:>){1,3})?=)/g } -], true ); +]); diff --git a/src/language/javascript.js b/src/language/javascript.js index b6774b2d..e5d3164d 100644 --- a/src/language/javascript.js +++ b/src/language/javascript.js @@ -147,7 +147,7 @@ Rainbow.extend('javascript', [ name: 'support.class.promise', pattern: /Promise(?=(\(|\.))/g } -]); +], 'generic'); Rainbow.addAlias('js', 'javascript'); diff --git a/src/language/json.js b/src/language/json.js index 3aa708c2..45b9c25e 100644 --- a/src/language/json.js +++ b/src/language/json.js @@ -26,4 +26,4 @@ Rainbow.extend('json', [ name: 'constant.language', pattern: /\b(true|false|null)\b/g } -], true); +]); diff --git a/src/language/lua.js b/src/language/lua.js index 1afa8e3b..99cc22b2 100644 --- a/src/language/lua.js +++ b/src/language/lua.js @@ -56,4 +56,4 @@ Rainbow.extend('lua', [ }, pattern: /\b(print|require|module|\w+\.\w+)(?=\()/g } -], true); +]); diff --git a/src/language/php.js b/src/language/php.js index eda04401..47d19f52 100644 --- a/src/language/php.js +++ b/src/language/php.js @@ -120,4 +120,4 @@ Rainbow.extend('php', [ }, pattern: /(\(|,\s?)([\w\\]*?)(?=\s\$)/g } -]); +], 'generic'); diff --git a/src/language/python.js b/src/language/python.js index 555c8046..bec0117d 100644 --- a/src/language/python.js +++ b/src/language/python.js @@ -81,4 +81,4 @@ Rainbow.extend('python', [ name: 'comment.docstring', pattern: /('{3}|"{3})[\s\S]*?\1/gm } -]); +], 'generic'); diff --git a/src/language/r.js b/src/language/r.js index f03e6468..71f758c7 100644 --- a/src/language/r.js +++ b/src/language/r.js @@ -86,4 +86,4 @@ Rainbow.extend('r', [ name: 'support.function', pattern: /(^|[^0-9a-zA-Z\._])(array|character|complex|data\.frame|double|integer|list|logical|matrix|numeric|vector)(?=\s*\()/g } -]); +], 'generic'); diff --git a/src/language/ruby.js b/src/language/ruby.js index 4d5ef7ce..bdd37ec0 100644 --- a/src/language/ruby.js +++ b/src/language/ruby.js @@ -224,4 +224,4 @@ Rainbow.extend('ruby', [ }, pattern: /(def)\s(.*?)(?=(\s|\())/g } -], true); +]); diff --git a/src/language/scheme.js b/src/language/scheme.js index 1470e99c..dc0a1606 100644 --- a/src/language/scheme.js +++ b/src/language/scheme.js @@ -49,4 +49,4 @@ Rainbow.extend('scheme', [ }, pattern: /\(\s*(eqv\?|eq\?|equal\?|number\?|complex\?|real\?|rational\?|integer\?|exact\?|inexact\?|=|<|>|<=|>=|zero\?|positive\?|negative\?|odd\?|even\?|max|min|\+|\-|\*|\/|abs|quotient|remainder|modulo|gcd|lcm|numerator|denominator|floor|ceiling|truncate|round|rationalize|exp|log|sin|cos|tan|asin|acos|atan|sqrt|expt|make\-rectangular|make\-polar|real\-part|imag\-part|magnitude|angle|exact\->inexact|inexact\->exact|number\->string|string\->number|not|boolean\?|pair\?|cons|car|cdr|set\-car!|set\-cdr!|caar|cadr|cdar|cddr|caaar|caadr|cadar|caddr|cdaar|cdadr|cddar|cdddr|caaaar|caaadr|caadar|caaddr|cadaar|cadadr|caddar|cadddr|cdaaar|cdaadr|cdadar|cdaddr|cddaar|cddadr|cdddar|cddddr|null\?|list\?|list|length|append|reverse|list\-tail|list\-ref|memq|memv|member|assq|assv|assoc|symbol\?|symbol\->string|string\->symbol|char\?|char=\?|char<\?|char>\?|char<=\?|char>=\?|char\-ci=\?|char\-ci<\?|char\-ci>\?|char\-ci<=\?|char\-ci>=\?|char\-alphabetic\?|char\-numeric\?|char\-whitespace\?|char\-upper\-case\?|char\-lower\-case\?|char\->integer|integer\->char|char\-upcase|char\-downcase|string\?|make\-string|string|string\-length|string\-ref|string\-set!|string=\?|string\-ci=\?|string<\?|string>\?|string<=\?|string>=\?|string\-ci<\?|string\-ci>\?|string\-ci<=\?|string\-ci>=\?|substring|string\-append|string\->list|list\->string|string\-copy|string\-fill!|vector\?|make\-vector|vector|vector\-length|vector\-ref|vector\-set!|vector\->list|list\->vector|vector\-fill!|procedure\?|apply|map|for\-each|force|call\-with\-current\-continuation|call\/cc|values|call\-with\-values|dynamic\-wind|eval|scheme\-report\-environment|null\-environment|interaction\-environment|call\-with\-input\-file|call\-with\-output\-file|input\-port\?|output\-port\?|current\-input\-port|current\-output\-port|with\-input\-from\-file|with\-output\-to\-file|open\-input\-file|open\-output\-file|close\-input\-port|close\-output\-port|read|read\-char|peek\-char|eof\-object\?|char\-ready\?|write|display|newline|write\-char|load|transcript\-on|transcript\-off)(?=[\]()\s#])/g } -], true); +]); diff --git a/src/language/shell.js b/src/language/shell.js index c2abd985..2707afe1 100644 --- a/src/language/shell.js +++ b/src/language/shell.js @@ -53,4 +53,4 @@ Rainbow.extend('shell', [ }, pattern: /\b(break|case|continue|do|done|elif|else|esac|eval|export|fi|for|function|if|in|local|return|set|then|unset|until|while)(?=\(|\b)/g } -], true); +]); diff --git a/src/language/smalltalk.js b/src/language/smalltalk.js index d9148f04..220af448 100644 --- a/src/language/smalltalk.js +++ b/src/language/smalltalk.js @@ -49,4 +49,4 @@ Rainbow.extend('smalltalk', [ name: 'operator.delimiter', pattern: /;[\(\)\[\]\{\}]|#\[|#\(^\./g } -], true); +]); diff --git a/src/prism.js b/src/prism.js index 55cd5d72..7d66fc0e 100644 --- a/src/prism.js +++ b/src/prism.js @@ -287,9 +287,13 @@ class Prism { * @return {Array} */ function getPatternsForLanguage(language) { - const patterns = options.patterns[language] || []; - const defaultPatterns = options.patterns.generic || []; - return options.bypass[language] ? patterns : patterns.concat(defaultPatterns); + let patterns = options.patterns[language] || []; + while (options.inheritenceMap[language]) { + language = options.inheritenceMap[language]; + patterns = patterns.concat(options.patterns[language]); + } + + return patterns; } /** diff --git a/src/rainbow.js b/src/rainbow.js index fffdb74b..ad4c0037 100644 --- a/src/rainbow.js +++ b/src/rainbow.js @@ -29,12 +29,11 @@ import rainbowWorker from './worker'; const patterns = {}; /** - * An array of languages and whether they should bypass the - * default patterns + * An object of languages mapping to what language they should inherit from * * @type {Object} */ -const bypass = {}; +const inheritenceMap = {}; /** * A mapping of language aliases @@ -138,7 +137,7 @@ function _generateHandler(element, waitingOn, callback) { function _getPrismOptions() { return { patterns, - bypass, + inheritenceMap, aliases, globalClass }; @@ -299,23 +298,23 @@ function addClass(name) { /** * Extends the language pattern matches * - * @param {string} language name of language - * @param {object} patterns object of patterns to add on - * @param {boolean|null} bypass if `true` this will not inherit the - * default language patterns + * @param {string} language name of language + * @param {object} patterns object of patterns to add on + * @param {string|undefined} inherits optional language that this language + * should inherit rules from */ function extend(...args) { - let [localLanguage, localPatterns, localBypass] = args; + let [localLanguage, localPatterns, inherits] = args; // If there is only one argument then we assume that we want to // extend the default language rules. if (args.length === 1) { localPatterns = localLanguage; localLanguage = 'generic'; - localBypass = null; + inherits = null; } - bypass[localLanguage] = localBypass; + inheritenceMap[localLanguage] = inherits; patterns[localLanguage] = localPatterns.concat(patterns[localLanguage] || []); } From 22f414e43120014c823958417afcd66bcc052bda Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Thu, 30 Jun 2016 00:15:05 -0400 Subject: [PATCH 124/153] Add some es6 code to the javascript demo --- demos/js.html | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/demos/js.html b/demos/js.html index 23fe2eeb..51573e5d 100644 --- a/demos/js.html +++ b/demos/js.html @@ -3,6 +3,44 @@ Syntax Highlighting +
    /*
    + * This is some sample code to illustrate how things look!
    + */
    +import * as templates from './somewhere';
    +import Musician from './musician';
    +
    +const something = true;
    +export let blah = 123;
    +var somethingElse = false;
    +
    +function test() {
    +    return new Promise((resolve, reject) => {
    +        resolve();
    +    });
    +}
    +
    +class SomeClass {
    +    render() {
    +        return templates.helloWorld();
    +    }
    +}
    +
    +class TaylorSwift extends Musician {
    +    constructor(position) {
    +        super(position);
    +    }
    +
    +    get yearOfBirth() {
    +        return 1989;
    +    }
    +
    +    perform(song) {
    +        this.sing(song)
    +    }
    +}
    +
    +export default Paul;
    +
     /**
      * test function
    
    From 9649b2439059014b0f99299878e402827629b9f9 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Thu, 30 Jun 2016 00:55:46 -0400
    Subject: [PATCH 125/153] Use loading class instead of stop-animation
    
    ---
     src/rainbow.js         | 3 +--
     themes/sass/_init.sass | 4 +---
     2 files changed, 2 insertions(+), 5 deletions(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index ad4c0037..de02fdfc 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -110,7 +110,6 @@ function _generateHandler(element, waitingOn, callback) {
         return function _handleResponseFromWorker(data) {
             element.innerHTML = data.result;
             element.classList.remove('loading');
    -        element.classList.remove('stop-animation');
             // element.addEventListener('animationend', (e) => {
             //     if (e.animationName === 'fade-in') {
             //         setTimeout(() => {
    @@ -183,7 +182,7 @@ function _highlightCodeBlocks(codeBlocks, callback) {
             // This cancels the pending animation to fade the code in on load
             // since we want to delay doing this until it is actually
             // highlighted
    -        block.classList.add('stop-animation');
    +        block.classList.add('loading');
             block.classList.add('rainbow');
     
             // for long files show a spinner
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index c30f6837..d96cf9e4 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -31,7 +31,5 @@ pre [data-language], pre [class^="lang"]
         &.rainbow
             animation-delay: 0ms
     
    -    &.stop-animation
    -        opacity: 0
    -        // background: red
    +    &.loading
             animation-play-state: paused
    
    From 740b55a5947782d8c7db7c3119ef17a7328030aa Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Thu, 30 Jun 2016 00:57:46 -0400
    Subject: [PATCH 126/153] Add ability to set custom options for each block
    
    This removes the globalClass option in favor of being able to set a
    globalClass using a data attribute on the div or when calling
    Rainbow.color using the API
    ---
     src/rainbow.js       | 28 +++++++++++++---------------
     src/worker.js        | 12 +++++++-----
     test/rainbow-test.js |  4 +---
     3 files changed, 21 insertions(+), 23 deletions(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index de02fdfc..3014f1aa 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -42,13 +42,6 @@ const inheritenceMap = {};
      */
     const aliases = {};
     
    -/**
    - * Global class added to each span in the highlighted code
    - *
    - * @type {null|string}
    - */
    -let globalClass;
    -
     /**
      * Representation of the actual rainbow object
      *
    @@ -133,12 +126,13 @@ function _generateHandler(element, waitingOn, callback) {
      *
      * @return {object}
      */
    -function _getPrismOptions() {
    +function _getPrismOptions(options) {
         return {
             patterns,
             inheritenceMap,
             aliases,
    -        globalClass
    +        globalClass: options.globalClass,
    +        delay: !isNaN(options.delay) ? options.delay : 0
         };
     }
     
    @@ -150,13 +144,19 @@ function _getPrismOptions() {
      * @return {object}
      */
     function _getWorkerData(code, lang) {
    +    let options = {};
    +    if (typeof lang === 'object') {
    +        options = lang;
    +        lang = options.language;
    +    }
    +
         lang = aliases[lang] || lang;
     
         const workerData = {
             id: String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now(),
             code,
             lang,
    -        options: _getPrismOptions(),
    +        options: _getPrismOptions(options),
             isNode
         };
     
    @@ -185,13 +185,11 @@ function _highlightCodeBlocks(codeBlocks, callback) {
             block.classList.add('loading');
             block.classList.add('rainbow');
     
    -        // for long files show a spinner
    -        if (block.innerHTML.length > 20000) {
    -            block.classList.add('loading');
    -        }
    +        const globalClass = block.getAttribute('data-global-class');
    +        const delay = parseInt(block.getAttribute('data-delay'), 10);
     
             ++waitingOn.c;
    -        _messageWorker(_getWorkerData(block.innerHTML, language), _generateHandler(block, waitingOn, callback));
    +        _messageWorker(_getWorkerData(block.innerHTML, { language, globalClass, delay }), _generateHandler(block, waitingOn, callback));
         }
     
         if (waitingOn.c === 0) {
    diff --git a/src/worker.js b/src/worker.js
    index 3709f8c5..1f0e6386 100644
    --- a/src/worker.js
    +++ b/src/worker.js
    @@ -6,11 +6,13 @@ export default function rainbowWorker(e) {
         const prism = new Prism(message.options);
         const result = prism.refract(message.code, message.lang);
     
    -    self.postMessage({
    -        id: message.id,
    -        lang: message.lang,
    -        result
    -    });
    +    setTimeout(() => {
    +        self.postMessage({
    +            id: message.id,
    +            lang: message.lang,
    +            result
    +        });
    +    }, message.options.delay * 1000);
     
         // I realized down the road I might look at this and wonder what is going on
         // so probably it is not a bad idea to leave a comment.
    diff --git a/test/rainbow-test.js b/test/rainbow-test.js
    index 34b36652..cecb82d6 100644
    --- a/test/rainbow-test.js
    +++ b/test/rainbow-test.js
    @@ -26,9 +26,7 @@ describe('Rainbow', () => {
                 pattern: /Craig/gm
             }]);
     
    -        Rainbow.addClass('global');
    -
    -        Rainbow.color('My name is Craig', 'generic', function(result) {
    +        Rainbow.color('My name is Craig', { language: 'generic', globalClass: 'global' }, function(result) {
                 expect(result).to.equal('My name is Craig');
                 done();
             });
    
    From 9c37ac4fcf1e8c5b47061cefd1b34306792e91d7 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Thu, 30 Jun 2016 00:59:09 -0400
    Subject: [PATCH 127/153] Use es6 style function
    
    ---
     test/rainbow-test.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/test/rainbow-test.js b/test/rainbow-test.js
    index cecb82d6..2e8b2cdb 100644
    --- a/test/rainbow-test.js
    +++ b/test/rainbow-test.js
    @@ -26,7 +26,7 @@ describe('Rainbow', () => {
                 pattern: /Craig/gm
             }]);
     
    -        Rainbow.color('My name is Craig', { language: 'generic', globalClass: 'global' }, function(result) {
    +        Rainbow.color('My name is Craig', { language: 'generic', globalClass: 'global' }, (result) => {
                 expect(result).to.equal('My name is Craig');
                 done();
             });
    
    From fe400c21dd8d7093d363ca0484f02db0fd7609f3 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 00:50:09 -0400
    Subject: [PATCH 128/153] Always add loading class to pre tag
    
    ---
     src/rainbow.js | 11 +++++++++++
     1 file changed, 11 insertions(+)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 3014f1aa..b4cd7796 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -103,6 +103,11 @@ function _generateHandler(element, waitingOn, callback) {
         return function _handleResponseFromWorker(data) {
             element.innerHTML = data.result;
             element.classList.remove('loading');
    +
    +        if (element.parentNode.tagName === 'PRE') {
    +            element.parentNode.classList.remove('loading');
    +        }
    +
             // element.addEventListener('animationend', (e) => {
             //     if (e.animationName === 'fade-in') {
             //         setTimeout(() => {
    @@ -185,6 +190,12 @@ function _highlightCodeBlocks(codeBlocks, callback) {
             block.classList.add('loading');
             block.classList.add('rainbow');
     
    +        // We need to make sure to also add the loading class to the pre tag
    +        // because that is how we will know to show a preloader
    +        if (block.parentNode.tagName === 'PRE') {
    +            block.parentNode.classList.add('loading');
    +        }
    +
             const globalClass = block.getAttribute('data-global-class');
             const delay = parseInt(block.getAttribute('data-delay'), 10);
     
    
    From 54d85ed2bf185282bb74d988804751644dd95e28 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 00:50:27 -0400
    Subject: [PATCH 129/153] Add preloader to markup before highlighting
    
    ---
     src/rainbow.js | 10 ++++++++++
     1 file changed, 10 insertions(+)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index b4cd7796..18f98ca5 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -208,6 +208,15 @@ function _highlightCodeBlocks(codeBlocks, callback) {
         }
     }
     
    +function _addPreloader(preBlock) {
    +    const preloader = document.createElement('div');
    +    preloader.className = 'preloader';
    +    for (let i = 0; i < 7; i++) {
    +        preloader.appendChild(document.createElement('div'));
    +    }
    +    preBlock.appendChild(preloader);
    +}
    +
     /**
      * Browser Only - Start highlighting all the code blocks
      *
    @@ -233,6 +242,7 @@ function _highlight(node, callback) {
     
         // First loop through all pre blocks to find which ones to highlight
         for (const preBlock of preBlocks) {
    +        _addPreloader(preBlock);
     
             // Strip whitespace around code tags when they are inside of a pre
             // tag.  This makes the themes look better because you can't
    
    From c35a3d113dd1afb1ec86058ccf224043142ef885 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 00:52:21 -0400
    Subject: [PATCH 130/153] Add first round of preloader code
    
    ---
     themes/sass/_init.sass | 58 ++++++++++++++++++++++++++++++++++++++++--
     1 file changed, 56 insertions(+), 2 deletions(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index d96cf9e4..5a96491a 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -1,3 +1,13 @@
    +$red: #f50419
    +$orange: #f57900
    +$yellow: #f5e600
    +$green: #00f50c
    +$blue: #0081f5
    +$indigo: #5000f5
    +$violet: #9000f5
    +
    +$rainbow: $blue, $indigo, $violet, $red, $orange, $yellow, $green
    +
     $name: ""
     @mixin language($names)
         @if length($names) == 1
    @@ -8,13 +18,24 @@ $name: ""
                 [data-language="#{$name}"], .lang-#{$name}, .language-#{$name}
                     @content
     
    -@keyframes #{fade-in}
    +@keyframes fade-in
         0%
             opacity: 0
    -
         100%
             opacity: 1
     
    +@keyframes fade
    +    0%
    +        transform: translateY(0px)
    +    25%
    +        transform: translateY(2px)
    +    50%
    +        transform: translateY(-2px)
    +        opacity: 1
    +    100%
    +        transform: translateY(2px)
    +        opacity: 0
    +
     [data-language] code, [class^="lang"] code,
     pre [data-language], pre [class^="lang"]
         opacity: 0
    @@ -33,3 +54,36 @@ pre [data-language], pre [class^="lang"]
     
         &.loading
             animation-play-state: paused
    +
    +pre
    +    position: relative
    +
    +    &.loading
    +        .preloader div
    +            animation-play-state: running
    +
    +            $dur: 0.83s
    +            $start: 1
    +            $num: 6
    +            @for $i from $start through $start + $num
    +                &:nth-of-type(#{$i})
    +                    background: nth($rainbow, $i)
    +                    animation: fade 1.5s (($i - $start) * $dur / $num + 500ms) linear infinite
    +
    +
    +    .preloader
    +        position: absolute
    +        top: 12px
    +        left: 10px
    +
    +        div
    +            width: 10px
    +            height: 15px
    +            border-radius: 4px
    +            display: inline-block
    +            margin-right: 3px
    +
    +            opacity: 0
    +            animation-play-state: paused
    +            animation-fill-mode: forwards
    +
    
    From 6a013e8e2a2227e3667aff831208e6bdc2a91030 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 00:52:35 -0400
    Subject: [PATCH 131/153] Increase normal animation time by 10ms
    
    ---
     themes/sass/_init.sass | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index 5a96491a..52501df5 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -47,7 +47,7 @@ pre [data-language], pre [class^="lang"]
         // IE 10+ and all modern browsers support CSS animations
         -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"
     
    -    animation: 40ms ease-in-out 1000ms forwards fade-in
    +    animation: 50ms ease-in-out 1000ms forwards fade-in
     
         &.rainbow
             animation-delay: 0ms
    
    From 98b56401512d2e87c5597bc29111c5a7298ff144 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 12:34:51 -0400
    Subject: [PATCH 132/153] Move defer logic into DOMContentLoaded callback
    
    ---
     src/rainbow.js | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 18f98ca5..30636e50 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -342,10 +342,6 @@ function extend(...args) {
      * @return {void}
      */
     function color(...args) {
    -    if (Rainbow.defer) {
    -        Rainbow.defer = false;
    -        return;
    -    }
     
         // If you want to straight up highlight a string you can pass the
         // string of code, the language, and a callback function.
    @@ -432,7 +428,11 @@ if (isNode) {
     
     // In the browser hook it up to color on page load
     if (!isNode && !isWorker) {
    -    document.addEventListener('DOMContentLoaded', Rainbow.color, false);
    +    document.addEventListener('DOMContentLoaded', (event) => {
    +        if (!Rainbow.defer) {
    +            Rainbow.color(event);
    +        }
    +    }, false);
     }
     
     // From a node worker, handle the postMessage requests to it
    
    From 303f97c73ca3bb126f3cd5d7d4b673ee165706db Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 12:35:08 -0400
    Subject: [PATCH 133/153] Remove Rainbow.addClass function
    
    ---
     src/rainbow.js       | 15 ---------------
     test/rainbow-test.js |  1 -
     2 files changed, 16 deletions(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 30636e50..be65b1f9 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -299,20 +299,6 @@ function onHighlight(callback) {
         onHighlightCallback = callback;
     }
     
    -/**
    - * Method to set a global class that will be applied to all spans.
    - *
    - * This is realy only useful for the effect on rainbowco.de where you can
    - * force all blocks to not be highlighted and remove this class to
    - * transition them to being highlighted.
    - *
    - * @param {string} name
    - * @return {void}
    - */
    -function addClass(name) {
    -    globalClass = name;
    -}
    -
     /**
      * Extends the language pattern matches
      *
    @@ -414,7 +400,6 @@ function addAlias(alias, originalLanguage) {
     Rainbow = {
         extend,
         onHighlight,
    -    addClass,
         addAlias,
         color
     };
    diff --git a/test/rainbow-test.js b/test/rainbow-test.js
    index 2e8b2cdb..4595172b 100644
    --- a/test/rainbow-test.js
    +++ b/test/rainbow-test.js
    @@ -16,7 +16,6 @@ describe('Rainbow', () => {
             expect(Rainbow.color).to.be.a('function');
             expect(Rainbow.extend).to.be.a('function');
             expect(Rainbow.onHighlight).to.be.a('function');
    -        expect(Rainbow.addClass).to.be.a('function');
             expect(Rainbow.addAlias).to.be.a('function');
         });
     
    
    From e0f37883b3f9d49f294ff75213c885bb8ff5843d Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 12:35:41 -0400
    Subject: [PATCH 134/153] Remove special highlighting for .log()
    
    ---
     src/language/javascript.js       | 2 +-
     test/language/javascript-test.js | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/src/language/javascript.js b/src/language/javascript.js
    index e5d3164d..69769449 100644
    --- a/src/language/javascript.js
    +++ b/src/language/javascript.js
    @@ -49,7 +49,7 @@ Rainbow.extend('javascript', [
             matches: {
                 1: 'support.method'
             },
    -        pattern: /\.(getAttribute|replace|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g
    +        pattern: /\.(getAttribute|replace|push|getElementById|getElementsByClassName|setTimeout|setInterval)(?=\()/g
         },
     
         /**
    diff --git a/test/language/javascript-test.js b/test/language/javascript-test.js
    index d2d25725..673c0955 100644
    --- a/test/language/javascript-test.js
    +++ b/test/language/javascript-test.js
    @@ -35,7 +35,7 @@ describe(language, () => {
     
             'console.log(window.scrollX)',
     
    -        'console.log(window.scrollX)'
    +        'console.log(window.scrollX)'
         );
     
         run(
    
    From d10da338aba67682b5ea2422b5be2491cf45c472 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 12:46:12 -0400
    Subject: [PATCH 135/153] Make sure language mixin still works with single
     languages
    
    ---
     themes/sass/_init.sass | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index 52501df5..90c95162 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -11,7 +11,7 @@ $rainbow: $blue, $indigo, $violet, $red, $orange, $yellow, $green
     $name: ""
     @mixin language($names)
         @if length($names) == 1
    -        [data-language="#{$name}"], .lang-#{$name}, .language-#{$name}
    +        [data-language="#{$names}"], .lang-#{$names}, .language-#{$names}
                 @content
         @else
             @each $name in $names
    
    From 64eb24dce2d52c05a3e67800df2cc12ab819be30 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 13:20:35 -0400
    Subject: [PATCH 136/153] Decrease delay and move into its own variable
    
    ---
     themes/sass/_init.sass | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index 90c95162..8d03769a 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -62,13 +62,14 @@ pre
             .preloader div
                 animation-play-state: running
     
    -            $dur: 0.83s
    +            $dur: 830ms
    +            $delay: 300ms
                 $start: 1
                 $num: 6
                 @for $i from $start through $start + $num
                     &:nth-of-type(#{$i})
                         background: nth($rainbow, $i)
    -                    animation: fade 1.5s (($i - $start) * $dur / $num + 500ms) linear infinite
    +                    animation: fade 1.5s (($i - $start) * $dur / $num + $delay) linear infinite
     
     
         .preloader
    
    From 1fd67f02a1158232fb8877528208734eb02aeef7 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 19:07:38 -0400
    Subject: [PATCH 137/153] Make sure extending other languages works correctly
    
    ---
     src/rainbow.js       | 13 ++++++++++-
     test/rainbow-test.js | 51 ++++++++++++++++++++++++++++++++++++++++++++
     2 files changed, 63 insertions(+), 1 deletion(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index be65b1f9..60888b32 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -318,7 +318,18 @@ function extend(...args) {
             inherits = null;
         }
     
    -    inheritenceMap[localLanguage] = inherits;
    +    // If we extend a language again we shouldn't need to specify the
    +    // inheritence for it. For example, if you are adding special highlighting
    +    // for a javascript function that is not in the base javascript rules, you
    +    // should be able to do
    +    //
    +    // Rainbow.extend('javascript', [ … ]);
    +    //
    +    // Without specifying a language it should inherit (generic in this case)
    +    if (!inheritenceMap[localLanguage]) {
    +        inheritenceMap[localLanguage] = inherits;
    +    }
    +
         patterns[localLanguage] = localPatterns.concat(patterns[localLanguage] || []);
     }
     
    diff --git a/test/rainbow-test.js b/test/rainbow-test.js
    index 4595172b..00c4a7ab 100644
    --- a/test/rainbow-test.js
    +++ b/test/rainbow-test.js
    @@ -6,6 +6,21 @@
     
     const expect = chai.expect;
     
    +const genericPatterns = [{
    +    name: 'test',
    +    pattern: /test/gi
    +}];
    +
    +const patternA = [{
    +    name: 'a',
    +    pattern: /here/gi
    +}];
    +
    +const patternB = [{
    +    name: 'b',
    +    pattern: /is/gi
    +}];
    +
     ////////////////
     // Test suite //
     ////////////////
    @@ -30,4 +45,40 @@ describe('Rainbow', () => {
                 done();
             });
         });
    +
    +    it('Should properly use patterns', (done) => {
    +        Rainbow.extend(genericPatterns);
    +
    +        Rainbow.color('here is a test', 'generic', (result) => {
    +            expect(result).to.equal('here is a test');
    +            done();
    +        });
    +    });
    +
    +    it('Should properly extend generic patterns', (done) => {
    +        Rainbow.extend('newLanguage', patternA, 'generic');
    +
    +        Rainbow.color('here is a test', 'newLanguage', (result) => {
    +            expect(result).to.equal('here is a test');
    +            done();
    +        });
    +    });
    +
    +    it('Should properly extend other patterns that extend generic patterns', (done) => {
    +        Rainbow.extend('newLanguage', patternB);
    +
    +        Rainbow.color('here is a test', 'newLanguage', (result) => {
    +            expect(result).to.equal('here is a test');
    +            done();
    +        });
    +    });
    +
    +    it('Should properly apply aliases', (done) => {
    +        Rainbow.addAlias('new', 'newLanguage');
    +
    +        Rainbow.color('here is a test', 'new', (result) => {
    +            expect(result).to.equal('here is a test');
    +            done();
    +        });
    +    });
     });
    
    From c743feaa73cf5f6d20aa6d10f47922d014043e48 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 19:08:18 -0400
    Subject: [PATCH 138/153] Increase initial fade-in delay
    
    Want to make sure there is enough time for the js to execute before the
    unstyled text shows up
    ---
     themes/sass/_init.sass | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index 8d03769a..8489d3ce 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -47,7 +47,7 @@ pre [data-language], pre [class^="lang"]
         // IE 10+ and all modern browsers support CSS animations
         -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"
     
    -    animation: 50ms ease-in-out 1000ms forwards fade-in
    +    animation: 50ms ease-in-out 2000ms forwards fade-in
     
         &.rainbow
             animation-delay: 0ms
    
    From f45c261460ec76157b54e68c87e6fd407db0fc80 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 19:53:18 -0400
    Subject: [PATCH 139/153] Update preloader styles again
    
    ---
     themes/sass/_init.sass | 21 ++++++++++++---------
     1 file changed, 12 insertions(+), 9 deletions(-)
    
    diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass
    index 8489d3ce..455a7b30 100644
    --- a/themes/sass/_init.sass
    +++ b/themes/sass/_init.sass
    @@ -25,15 +25,18 @@ $name: ""
             opacity: 1
     
     @keyframes fade
    -    0%
    -        transform: translateY(0px)
    -    25%
    -        transform: translateY(2px)
    +    10%
    +        transform: scale(1.0, 1.0)
    +    35%
    +        transform: scale(1.0, 1.7)
    +    40%
    +        transform: scale(1.0, 1.7)
         50%
    -        transform: translateY(-2px)
             opacity: 1
    +    60%
    +        transform: scale(1.0, 1.0)
         100%
    -        transform: translateY(2px)
    +        transform: scale(1.0, 1.0)
             opacity: 0
     
     [data-language] code, [class^="lang"] code,
    @@ -78,11 +81,11 @@ pre
             left: 10px
     
             div
    -            width: 10px
    -            height: 15px
    +            width: 12px
    +            height: 12px
                 border-radius: 4px
                 display: inline-block
    -            margin-right: 3px
    +            margin-right: 4px
     
                 opacity: 0
                 animation-play-state: paused
    
    From bf828e4fb90a8f567af01caa2f9240642d6072c4 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Fri, 1 Jul 2016 23:08:17 -0400
    Subject: [PATCH 140/153] Require language to be specified explicitly
    
    ---
     src/language/generic.js |  2 +-
     src/rainbow.js          | 19 +++++--------------
     test/rainbow-test.js    |  4 ++--
     3 files changed, 8 insertions(+), 17 deletions(-)
    
    diff --git a/src/language/generic.js b/src/language/generic.js
    index baf5b90c..638df614 100644
    --- a/src/language/generic.js
    +++ b/src/language/generic.js
    @@ -4,7 +4,7 @@
      * @author Craig Campbell
      * @version 1.0.11
      */
    -Rainbow.extend([
    +Rainbow.extend('generic', [
         {
             matches: {
                 1: [
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 60888b32..0a102cec 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -303,20 +303,11 @@ function onHighlight(callback) {
      * Extends the language pattern matches
      *
      * @param {string} language            name of language
    - * @param {object} patterns            object of patterns to add on
    + * @param {object} languagePatterns    object of patterns to add on
      * @param {string|undefined} inherits  optional language that this language
      *                                     should inherit rules from
      */
    -function extend(...args) {
    -    let [localLanguage, localPatterns, inherits] = args;
    -
    -    // If there is only one argument then we assume that we want to
    -    // extend the default language rules.
    -    if (args.length === 1) {
    -        localPatterns = localLanguage;
    -        localLanguage = 'generic';
    -        inherits = null;
    -    }
    +function extend(language, languagePatterns, inherits) {
     
         // If we extend a language again we shouldn't need to specify the
         // inheritence for it. For example, if you are adding special highlighting
    @@ -326,11 +317,11 @@ function extend(...args) {
         // Rainbow.extend('javascript', [ … ]);
         //
         // Without specifying a language it should inherit (generic in this case)
    -    if (!inheritenceMap[localLanguage]) {
    -        inheritenceMap[localLanguage] = inherits;
    +    if (!inheritenceMap[language]) {
    +        inheritenceMap[language] = inherits;
         }
     
    -    patterns[localLanguage] = localPatterns.concat(patterns[localLanguage] || []);
    +    patterns[language] = languagePatterns.concat(patterns[language] || []);
     }
     
     /**
    diff --git a/test/rainbow-test.js b/test/rainbow-test.js
    index 00c4a7ab..26df3dac 100644
    --- a/test/rainbow-test.js
    +++ b/test/rainbow-test.js
    @@ -35,7 +35,7 @@ describe('Rainbow', () => {
         });
     
         it('Should apply global class', (done) => {
    -        Rainbow.extend([{
    +        Rainbow.extend('generic', [{
                 name: 'name',
                 pattern: /Craig/gm
             }]);
    @@ -47,7 +47,7 @@ describe('Rainbow', () => {
         });
     
         it('Should properly use patterns', (done) => {
    -        Rainbow.extend(genericPatterns);
    +        Rainbow.extend('generic', genericPatterns);
     
             Rainbow.color('here is a test', 'generic', (result) => {
                 expect(result).to.equal('here is a test');
    
    From 602a6e66c636f85e91efbfda8a8371915739f77e Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sat, 2 Jul 2016 01:18:11 -0400
    Subject: [PATCH 141/153] Don't default to all languages
    
    ---
     gulpfile.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/gulpfile.js b/gulpfile.js
    index b4f4a0cc..4e6b2793 100644
    --- a/gulpfile.js
    +++ b/gulpfile.js
    @@ -219,7 +219,7 @@ gulp.task('append-languages', function() {
     
     gulp.task('build', function(callback) {
         if (!argv.languages) {
    -        argv.languages = 'all';
    +        argv.languages = 'java,javascript,csharp,python,c,php,ruby,html,css,json';
         }
     
         argv.ugly = true;
    
    From 22de8a599f36a00c78ea00a20e05502167a3c6f4 Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sat, 2 Jul 2016 01:18:40 -0400
    Subject: [PATCH 142/153] Make sure colorSync works correctly
    
    ---
     src/rainbow.js | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/src/rainbow.js b/src/rainbow.js
    index 0a102cec..ba404d0a 100644
    --- a/src/rainbow.js
    +++ b/src/rainbow.js
    @@ -408,8 +408,9 @@ Rainbow = {
     
     if (isNode) {
         Rainbow.colorSync = function(code, lang) {
    -        const prism = new Prism(_getPrismOptions());
    -        return prism.refract(code, aliases[lang] || lang);
    +        const workerData = _getWorkerData(code, lang);
    +        const prism = new Prism(workerData.options);
    +        return prism.refract(workerData.code, workerData.lang);
         };
     }
     
    
    From 92ea9aa46b841a71db53b66cbfaef6fc077a700f Mon Sep 17 00:00:00 2001
    From: Craig Campbell 
    Date: Sat, 2 Jul 2016 01:19:12 -0400
    Subject: [PATCH 143/153] Update README.md with all documentation
    
    ---
     README.md | 530 +++++++++++++++++++++++++++++++++++++++++++++++++-----
     1 file changed, 483 insertions(+), 47 deletions(-)
    
    diff --git a/README.md b/README.md
    index a9a1a232..a98093f3 100644
    --- a/README.md
    +++ b/README.md
    @@ -2,14 +2,62 @@
     
     Rainbow is a code syntax highlighting library written in Javascript.
     
    -It was designed to be lightweight (1.4kb), easy to use, and extendable.
    +It was designed to be lightweight (~2.5kb), easy to use, and extendable.
     
     It is completely themable via CSS.
     
    -If you would like to donate to help support Rainbow development use [Gittip](https://www.gittip.com/ccampbell).
    +## Demo
    +
    +You can see rainbow in action at [http://rainbowco.de](http://rainbowco.de).
    +
    +You can also build/download custom packages from there.
    +
    +## Contents
    +
    +* [Quick Start](#quick-start)
    +    * [Browser](#browser)
    +    * [Node.js](#nodejs)
    +      * [Install rainbow](#install-rainbow)
    +      * [Highlight some code](#highlight-some-code)
    +  * [Supported Browsers](#supported-browsers)
    +  * [Supported Languages](#supported-languages)
    +  * [Specifying a language](#specifying-a-language)
    +  * [Themes](#themes)
    +    * [Rendering code blocks](#rendering-code-blocks)
    +  * [JavaScript API Documentation](#javascript-api-documentation)
    +    * [Rainbow.color](#rainbowcolor)
    +      * [Preventing automatic highlighting on page load](#preventing-automatic-highlighting-on-page-load)
    +      * [Extra options for color](#extra-options-for-color)
    +        * [globalClass](#globalclass)
    +    * [Rainbow.extend](#rainbowextend)
    +      * [Extending existing languages](#extending-existing-languages)
    +      * [How code is highlighted](#how-code-is-highlighted)
    +        * [Match by name](#match-by-name)
    +        * [Match by group](#match-by-group)
    +        * [Match by array of sub-patterns](#match-by-array-of-sub-patterns)
    +        * [Match using another language](#match-using-another-language)
    +      * [Extending an existing language](#extending-an-existing-language)
    +      * [How Rainbow chooses a match](#how-rainbow-chooses-a-match)
    +      * [Known limitations](#known-limitations)
    +        * [Regular expressions lookbehind assertions](#regular-expressions-lookbehind-assertions)
    +        * [Regular expression subgroup matches](#regular-expression-subgroup-matches)
    +    * [Rainbow.addAlias](#rainbowaddalias)
    +    * [Rainbow.onHighlight](#rainbowonhighlight)
    +  * [Building](#building)
    +    * [Getting a local environment set up](#getting-a-local-environment-set-up)
    +    * [Build commands](#build-commands)
    +      * [gulp build](#gulp-build)
    +      * [gulp lint](#gulp-lint)
    +      * [gulp pack](#gulp-pack)
    +      * [gulp sass](#gulp-sass)
    +      * [gulp test](#gulp-test)
    +      * [gulp watch](#gulp-watch)
    +  * [More Info](#more-info)
     
     ## Quick Start
     
    +### Browser
    +
     1. Include some markup for code you want to be highlighted:
     
         ```html
    @@ -29,29 +77,40 @@ If you would like to donate to help support Rainbow development use [Gittip](htt
     3. Include rainbow.js and whatever languages you want before the closing ````:
     
         ```html
    -    
    +    
         
         
         ```
     
    -## Extending Rainbow
    -If you have a language specific pattern that you want highlighted, but it does not exist in the language syntax rules you can add a rule on your page.
    +By default `dist/rainbow.min.js` comes with some popular languages bundled together with it.
     
    -Let's say for example you want to reference PHP's apc functions.
    -You can include the php language then in the markup on your page add:
    +### Node.js
    +
    +Rainbow 2.0 introduced support for node.js. All of the existing API methods should work, but there is also a new `Rainbow.colorSync` method for synchronous highlighting.
    +
    +#### Install rainbow
     
    -```html
    -
     ```
    +npm install --save rainbow-code
    +```
    +
    +#### Highlight some code
    +
    +```javascript
    +var rainbow = require('rainbow-code');
    +var highlighted = rainbow.colorSync('// So meta\nrainbow.colorSync(\'var helloWorld = true;\');', 'javascript');
    +console.log(highlighted);
    +```
    +
    +## Supported Browsers
    +
    +Rainbow 2.0 should work in the following browsers:
    +
    +| Chrome | Firefox | IE | Safari |
    +| ------ | ------- | --- | ------ |
    +| 20+ | 13+ | 10+ | 6+ |
    +
    +For older browsers you can download the legacy [1.2.0](https://github.com/ccampbell/rainbow/archive/1.2.0.zip) release.
     
     ## Supported Languages
     
    @@ -65,7 +124,8 @@ Currently supported languages are:
     - Haskell
     - HTML
     - Java
    -- Javascript
    +- JavaScript
    +- JSON
     - Lua
     - PHP
     - Python
    @@ -75,60 +135,436 @@ Currently supported languages are:
     - Shell
     - Smalltalk
     
    -## Building
    +## Specifying a language
    +
    +In your markup the `data-language` attribute is used to specify what language to use for highlighting. For example:
    +
    +```html
    +
    var testing = true;
    +``` + +Rainbow also supports the HTML5 style for specifying languages: + +```html +
    var testing = true;
    +``` + +And the Google Prettify style: + +```html +
    var testing = true;
    +``` -Rainbow gets minified with the closure compiler. You can install it on OS X via Homebrew: +## Themes - brew install closure-compiler +Themes are located in the `themes/sass` directory. They are written using sass so that common logic can be shared among all themes without having to duplicate it in each theme file. You should not edit the css files directly. -To build a minified version of your changes, you can run the compile script: +`_base.sass` includes some default styles shared by almost every theme. `_init.sass` contains mixins and initialization logic that is shared by every theme. - ./util/compile.py --core +### Rendering code blocks -In case the compiler cannot be found (which is the case if you installed via Homebrew), -you will have to specify the path to the compiler.jar (see `brew info closure-compiler`) - -here's an example: +As of version 2.0 the themes use a clever trick to display the highlighted code. All code blocks default to `opacity: 0`, but an animation is triggered on page load to happen after a 2 second delay. - CLOSURE_COMPILER=/usr/local/Cellar/closure-compiler/20120710/libexec/build/compiler.jar util/compile.py --core +This means for users who do not have JavaScript enabled the code will fade in after 2 seconds. If JavaScript is enabled, the animation is stopped on load and the delay is reset to `0s`. That ensures that as soon as the code is done being highlighted it will be able to show up instantly. This is used to prevent a flash of unstyled text on page load and ensure that the code blocks only show up after they have been highlighted. -If you want to build a custom version, list the languages you would like to include as -command line arguments: +There is also a preload animation that will show up for any code block that takes longer than 300ms to load. - util/compile.py ruby javascript +## JavaScript API Documentation -## Tests +Rainbow has four public methods: -Unit tests run via mocha. +- [Rainbow.color](#rainbowcolor) +- [Rainbow.extend](#rainbowextend) +- [Rainbow.addAlias](#rainbowaddalias) +- [Rainbow.onHighlight](#rainbowonhighlight) -### Running in browser +### Rainbow.color -Download the repo and go to `tests/rainbow.html` in your browser. +Rainbow.color is used to highlight blocks of code. -### Running with Grunt and PhantomJS +For convenience, this method is called automatically to highlight all code blocks on the page when `DOMContentLoaded` fires. If you would like to highlight stuff that is not in the DOM you can use it on its own. There are three ways to use it. -1. Install grunt-cli +1. The first option is calling the color method on its own: - ```bash - npm install -g grunt-cli + ```javascript + Rainbow.color(); ``` -2. Install npm packages + Each time this is called, Rainbow will look for matching `pre` blocks on the page that have not yet been highlighted and highlight them. + + You can optionally pass a callback function that will fire when all the blocks have been highlighted. - ```bash - cd /path/to/repo - npm install + ```javascript + Rainbow.color(function() { + console.log('The new blocks are now highlighted!'); + }); ``` -3. Run tests +2. The second option is passing a specific element to the color method. - ```bash - grunt mocha + In this example we are creating a code block, highlighting it, then inserting it into the DOM: + + ```javascript + var div = document.createElement('div'); + div.innerHTML = '
    var foo = true;
    '; + Rainbow.color(div, function() { + document.getElementById('something-else').appendChild(div;) + }); ``` +3. The final option is passing in your code as a string to `Rainbow.color`. + + ```javascript + Rainbow.color('var foo = true;', 'javascript', function(highlightedCode) { + console.log(highlightedCode); + }); + ``` + +#### Preventing automatic highlighting on page load + +If you want to prevent code on the page from being highlighted when the page loads you can set the `defer` property to `true`. + +```javascript +Rainbow.defer = true; +``` + +Note that you have to set this before `DOMContentLoaded` fires or else it will not do anything. + +#### Extra options for color + +As of right now there is one extra option for color. + +##### globalClass + +This option allows you to have an extra class added to every span that Rainbow renders. This can be useful if you want to remove the classes in order to trigger a special effect of some sort. + +To apply a global class you can add it in your markup: + +```html +
    var hello = true;
    +``` + +Or you can pass it into a `Rainbow.color` call like this: + +```javascript +Rainbow.color('var hello = true;', { + language: 'javascript', + globalClass: 'animate' +}); +``` + +### Rainbow.extend + +Rainbow.extend is used to define language grammars which are used to highlight the code you pass in. It can be used to define new languages or to extend existing languages. + +A very simple language grammer looks something like this: + +```javascript +Rainbow.extend('example', [ + { + name: 'keyword', + pattern: /function|return|continue|break/g + } +]); +``` + +Any pattern used with extend will take precedence over an existing pattern that matches the same block. It will also take precedence over any pattern that is included as part of the generic patterns. + +For example if you were to call + +```javascript +Rainbow.extend('example', [ + { + name: 'keyword.magic', + pattern: /function/g + } +]); +``` + +This would mean that function will be highlighted as `function`, but `return`, `continue`, and `break` will still be highlighted as just `return`, etc. + +#### Extending existing languages + +By default languages are considered to be standalone, but if you specify an optional third parameter you can have your language inherit from another one. + +For example the python language grammars inherit from the generic ones: + +```javascript +Rainbow.extend('python', [ + { + name: 'constant.language', + pattern: /True|False|None/g + } +], 'generic'); +``` + +If you wanted to remove the default boolean values you should be able to do something like this: + +```javascript +Rainbow.extend('python', [ + { + name: '', + pattern: /true|false/g + } +]); +``` + +#### How code is highlighted + +The `name` value determines what classes will be added to a span that matches the pattern you specify. For example, if you name a pattern `constant.hex-color` the code that matches that pattern will be wrapped in ` +``` + +You see the value class never gets applied. + +To achieve what you really want you would have to use a subpattern like this: + +```javascript +{ + name: 'name.attribute', + matches: [{ + matches: { + 1: 'value' + }, + pattern: /\"(.*?)\"/g + }], + pattern: /(name=\"(.*?)\")/g +} +``` + +This means the entire block is wrapped with `name.attribute` scope and then within that any part in double quotes will be wrapped as `value`. + +That means the entire block will behighlighted as + +```html +name="value" +``` + +In this example you could avoid subpatterns completely by using a regex like this to begin with: + +```javascript +/(name=)\"(.*?)\"/g +``` + +### Rainbow.addAlias + +The addAlias function allows you to map a different name to a language. For example: + +```javascript +Rainbow.addAlias('js', 'javascript'); +``` + +This allows you to highlight javascript code by using the language `js` instead of `javascript`. + +### Rainbow.onHighlight + +This method notifies you as soon as a block of code has been highlighted. + +```javascript +Rainbow.onHighlight(function(block, language) { + console.log(block, 'for language', language, 'was highlighted'); +}); +``` + +The first parameter returns a reference to that code block in the DOM. The second parameter returns a string of the language being highlighted. + +## Building + +Rainbow is compiled using [rollup](https://github.com/rollup/rollup) and [buble](https://gitlab.com/Rich-Harris/buble). + +[Gulp](https://github.com/gulpjs/gulp) is used for all build related tasks. + +### Getting a local environment set up + +```shell +git clone git@github.com:ccampbell/rainbow.git +cd rainbow +npm install +``` + +### Build commands + +#### gulp build + +The build command is used to build a custom version of rainbow.js. If you run + +```shell +gulp build +``` + +A file will be created at `dist/rainbow-custom.min.js` containing rainbow.js as well as popular languages. If you want to specify specific languages you can use: + +```shell +gulp build --languages=html,css,php,javascript +``` + +If you want a minimized version of rainbow without any languages you can pass + +```shell +gulp build --languages=none +``` + +If you want a minimized version with all languages you can pass + +```shell +gulp build --languages=all +``` + +#### gulp lint + +The lint command will check all the javascript files for things that do not match the styleguide from the `.eslintrc` file. + +#### gulp pack + +The pack command will run a buble + rollup build and save the resulting file to `dist/rainbow.js` + +#### gulp sass + +The sass command will compile all the rainbow themes + +#### gulp test + +The test command will run the unit tests. You can pass the `--watch` flag to keep the tests running and have them rerun when you make changes. That is a little buggy though which has something to do with karma + rollup. + +You can also use the `--browsers` flag to specify a browser to run the tests in. Currently only `PhantomJS` and `Chrome` are supported. + +#### gulp watch + +The watch command will look at sass files and src js files and build the css or js (using `gulp sass` and `gulp pack`) every time you make a change. + ## More Info If you are looking for line number support you can try one of the following: - https://github.com/Blender3D/rainbow.linenumbers.js - https://github.com/Sjeiti/rainbow.linenumbers -You can check out additional documentation and build custom packages at [rainbowco.de](http://rainbowco.de). +You can check out demos and build custom packages at [rainbowco.de](http://rainbowco.de). From e62c3a6ffe0d16e6d8182e5a6afe0635220ab226 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:19:50 -0400 Subject: [PATCH 144/153] Clean up file to make things more clear --- themes/sass/_init.sass | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index 455a7b30..94abcc5c 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -50,10 +50,10 @@ pre [data-language], pre [class^="lang"] // IE 10+ and all modern browsers support CSS animations -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)" - animation: 50ms ease-in-out 2000ms forwards fade-in + animation: 50ms ease-in-out 2s forwards fade-in &.rainbow - animation-delay: 0ms + animation-delay: 0s &.loading animation-play-state: paused @@ -74,7 +74,6 @@ pre background: nth($rainbow, $i) animation: fade 1.5s (($i - $start) * $dur / $num + $delay) linear infinite - .preloader position: absolute top: 12px @@ -86,8 +85,6 @@ pre border-radius: 4px display: inline-block margin-right: 4px - opacity: 0 animation-play-state: paused animation-fill-mode: forwards - From ebfc7eec8e040bc4df1bcbf2950658fca2b89505 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:20:03 -0400 Subject: [PATCH 145/153] Add rainbow theme used by rainbowco.de site --- themes/sass/rainbow.sass | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 themes/sass/rainbow.sass diff --git a/themes/sass/rainbow.sass b/themes/sass/rainbow.sass new file mode 100644 index 00000000..5777a5e3 --- /dev/null +++ b/themes/sass/rainbow.sass @@ -0,0 +1,68 @@ +// This is the theme used on the rainbowco.de website +@import "_base.sass" + +code span + transition: color 0.6s ease-in + +pre + background: #010104 + +.animate + color: #fff !important + +// These colors are only needed to highlight the header on the site +.red + color: $red + +.orange + color: $orange + +.yellow + color: $yellow + +.green + color: $green + +.blue + color: $blue + +.indigo + color: $indigo + +.violet + color: $violet + +@include language("custom") + .comment + color: #314CAD + + .integer + color: $yellow + + .keyword + color: $orange + +.comment + color: #535353; + +.keyword, .selector, .operator + color: lighten($violet, 20%) + +.storage, .support + color: lighten($red, 8%) + +.string + color: lighten($yellow, 20%) + +.constant + color: lighten($orange, 20%) + +.entity + color: lighten($blue, 15%) + +.inherited-class + font-style: italic + +@include language("html") + .attribute + color: lighten($red, 15%) From 011e05156f54910329b9e91511a90eb5db09fe2c Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:23:27 -0400 Subject: [PATCH 146/153] Round delay times --- themes/sass/_init.sass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/sass/_init.sass b/themes/sass/_init.sass index 94abcc5c..2dbd1661 100644 --- a/themes/sass/_init.sass +++ b/themes/sass/_init.sass @@ -72,7 +72,7 @@ pre @for $i from $start through $start + $num &:nth-of-type(#{$i}) background: nth($rainbow, $i) - animation: fade 1.5s (($i - $start) * $dur / $num + $delay) linear infinite + animation: fade 1.5s round(($i - $start) * $dur / $num + $delay) linear infinite .preloader position: absolute From 8b4fe9590e56d4200ec517a543e90a9e5457be71 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:23:42 -0400 Subject: [PATCH 147/153] Include latest css copy of all themes --- themes/css/all-hallows-eve.css | 2 +- themes/css/blackboard.css | 2 +- themes/css/dreamweaver.css | 2 +- themes/css/espresso-libre.css | 2 +- themes/css/github.css | 2 +- themes/css/kimbie-dark.css | 2 +- themes/css/kimbie-light.css | 2 +- themes/css/monokai.css | 2 +- themes/css/obsidian.css | 2 +- themes/css/paraiso-dark.css | 2 +- themes/css/paraiso-light.css | 2 +- themes/css/pastie.css | 2 +- themes/css/rainbow.css | 1 + themes/css/solarized-dark.css | 2 +- themes/css/solarized-light.css | 2 +- themes/css/sunburst.css | 2 +- themes/css/tomorrow-night.css | 2 +- themes/css/tricolore.css | 2 +- themes/css/twilight.css | 2 +- themes/css/zenburnesque.css | 2 +- 20 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 themes/css/rainbow.css diff --git a/themes/css/all-hallows-eve.css b/themes/css/all-hallows-eve.css index 346996c3..b593645a 100644 --- a/themes/css/all-hallows-eve.css +++ b/themes/css/all-hallows-eve.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#9933CC}pre .constant{color:#3387CC}pre .storage{color:#CC7833}pre .string{color:#66CC33}pre .keyword,pre .selector{color:#CC7833}pre .inherited-class{font-style:italic}pre .support{color:#C83730} diff --git a/themes/css/blackboard.css b/themes/css/blackboard.css index 210520a3..54be842a 100644 --- a/themes/css/blackboard.css +++ b/themes/css/blackboard.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#0B1022}pre .comment{color:#727272}pre .constant{color:#D8FA3C}pre .storage{color:#FBDE2D}pre .string,pre .comment.docstring{color:#61CE3C}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#FBDE2D}pre .inherited-class{font-style:italic}pre .entity{color:#FF6400}pre .support{color:#8DA6CE}pre .variable.global,pre .variable.class,pre .variable.instance{color:#FF6400}[data-language="c"] .function.call,.lang-c .function.call,.language-c .function.call{color:#8DA6CE} diff --git a/themes/css/dreamweaver.css b/themes/css/dreamweaver.css index da0fe8fe..47a88650 100644 --- a/themes/css/dreamweaver.css +++ b/themes/css/dreamweaver.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre,code{font-family:monospace}pre{background-color:#fff;color:#000;font-size:13px;line-height:16px}pre .comment{color:#888}pre .support{color:#cd57d5}pre .constant.numeric,pre .php.embedded{color:#fa0002;font-weight:bold}pre .keyword,pre .constant.language{color:#000789;font-weight:bold}pre .selector,pre .support.property,pre .entity.name.function{color:#000}pre .storage.function,pre .variable.self,pre .support.function,pre .constant.language{color:#000;font-weight:bold}pre .string{color:#0d43fa;font-weight:normal}pre .css-property+span,pre .keyword.unit,pre .support.css-value{color:#0d43fa !important;font-weight:normal !important}pre .entity.tag.style+.string,pre .php.embedded .constant.language,pre .php.embedded .keyword{color:#37a348 !important}pre .support.method{color:#2bd5bb}pre .entity.name{color:#fd74e0}pre .support.css-property,pre .support.tag-name,pre .support.tag,pre .support.attribute,pre .support.attribute+.operator{color:#000789}pre .storage.module,pre .storage.class{color:#122573;font-weight:bold}pre .css.embedded .support.tag,pre .css.embedded .style.tag{color:#cd57d5}pre .keyword.operator{color:#2852eb;font-weight:normal}pre .php.embedded .variable,pre .php.embedded .storage.function{color:#0d43fa;font-weight:normal}pre .php.embedded .string,pre .js.embedded .tag.script{color:#c4001e}pre .php.embedded .comment{color:#f4b441;font-weight:normal}pre .php.embedded .function.name{color:#000;font-weight:normal} diff --git a/themes/css/espresso-libre.css b/themes/css/espresso-libre.css index 2ddcadc8..84ad0b19 100644 --- a/themes/css/espresso-libre.css +++ b/themes/css/espresso-libre.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2a211c;color:#bdae9d}pre .support.class,pre .support.type{color:#6d79de}pre .support.constant{color:#00af0e}pre .constant.language{color:#585cf6}pre .support.function{font-weight:bold;color:#7290d9}pre .string{color:#049b0a}pre .constant.numeric{color:#44aa43}pre .keyword,pre .storage{color:#43a8ed}pre .entity.function{color:#ff9358}pre .comment{color:#0066ff;font-style:italic}pre .constant.symbol{color:#c5656b}pre .variable.instance,pre .variable.language,pre .constant{color:#318495} diff --git a/themes/css/github.css b/themes/css/github.css index fe4eab4d..dbf8832e 100644 --- a/themes/css/github.css +++ b/themes/css/github.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{border:1px solid #ccc;word-wrap:break-word;padding:6px 10px;line-height:19px;margin-bottom:20px}pre code{border:0;padding:0;margin:0;border-radius:0}code{border:1px solid #eaeaea;margin:0px 2px;padding:0px 5px;font-size:12px}pre,code{font-family:Consolas, 'Liberation Mono', Courier, monospace;color:#333;background:#f8f8f8;border-radius:3px}pre,pre code{font-size:13px}pre .comment{color:#998}pre .support{color:#0086B3}pre .tag,pre .tag-name{color:navy}pre .keyword,pre .css-property,pre .vendor-fix,pre .sass,pre .class,pre .id,pre .css-value,pre .entity.function,pre .storage.function{font-weight:bold}pre .css-property,pre .css-value,pre .vendor-fix,pre .support.namespace{color:#333}pre .constant.numeric,pre .keyword.unit,pre .hex-color{font-weight:normal;color:#099}pre .entity.class{color:#458}pre .entity.id,pre .entity.function{color:#900}pre .attribute,pre .variable{color:teal}pre .string,pre .support.value{font-weight:normal;color:#d14}pre .regexp{color:#009926} diff --git a/themes/css/kimbie-dark.css b/themes/css/kimbie-dark.css index 820e770e..846f1b9b 100644 --- a/themes/css/kimbie-dark.css +++ b/themes/css/kimbie-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#221a0f;color:#fbebd4}pre .comment{color:#a57a4c}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/kimbie-light.css b/themes/css/kimbie-light.css index cff5ff0b..4fc140b3 100644 --- a/themes/css/kimbie-light.css +++ b/themes/css/kimbie-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#fbebd4;color:#221a0f}pre .comment{color:#d6baad}pre .variable.global,pre .variable.class,pre .variable.instance{color:#dc3958}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f79a32}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f06431}pre .constant.symbol,pre .string{color:#889b4a}pre .entity.function,pre .support.css-property,pre .selector{color:#8ab1b0}pre .keyword,pre .storage{color:#98676a} diff --git a/themes/css/monokai.css b/themes/css/monokai.css index d02987dc..c177cd86 100644 --- a/themes/css/monokai.css +++ b/themes/css/monokai.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}*[data-language="html"] .support.operator{color:#fff} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#272822}pre .comment{color:#75715E}pre .constant{color:#AE81FF}pre .storage{color:#66D9EF}pre .string,pre .comment.docstring{color:#E6DB74}pre .support.tag{color:#fff}pre .keyword{color:#F92672}pre .selector,pre .storage.modifier.extends{color:#F92672}pre .inherited-class{font-style:italic}pre .operator,pre .support.tag-name,pre .entity.tag{color:#F92672}pre .entity,pre .support.attribute,pre .entity.attribute{color:#A6E22E}pre .support,pre *[data-language="c"] .function.call{color:#66D9EF}pre .css-property,pre .storage.function{font-style:italic}pre .variable.global,pre .variable.class,pre .variable.instance{color:#A6E22E}[data-language="html"] .support.operator,.lang-html .support.operator,.language-html .support.operator{color:#fff}[data-language="javascript"] .variable.super,.lang-javascript .variable.super,.language-javascript .variable.super{color:#66D9EF}[data-language="js"] .variable.super,.lang-js .variable.super,.language-js .variable.super{color:#66D9EF} diff --git a/themes/css/obsidian.css b/themes/css/obsidian.css index a8384dfa..e84ec91e 100644 --- a/themes/css/obsidian.css +++ b/themes/css/obsidian.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#22282A;color:#F1F2F3}pre .comment{color:#66747B}pre .constant{color:#EC7600}pre .storage{color:#EC7600}pre .string,pre .comment.docstring{color:#EC7600}pre .string.regexp,pre .support.tag.script,pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#93C763}pre .inherited-class{font-style:italic}pre .entity{color:#93C763}pre .integer{color:#FFCD22}pre .variable.global,pre .variable.class,pre .variable.instance{color:#CCC}pre .preprocessor{color:#66747B}pre .support,*[data-language="csharp"] .function.call{color:#FACD22} diff --git a/themes/css/paraiso-dark.css b/themes/css/paraiso-dark.css index 8983b14b..facb287a 100644 --- a/themes/css/paraiso-dark.css +++ b/themes/css/paraiso-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#2f1e2e;color:#e7e9db}pre .comment{color:#776e71}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/paraiso-light.css b/themes/css/paraiso-light.css index 2fb50f2f..8e77bc1b 100644 --- a/themes/css/paraiso-light.css +++ b/themes/css/paraiso-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#e7e9db;color:#2f1e2e}pre .comment{color:#8d8687}pre .variable.global,pre .variable.class,pre .variable.instance{color:#ef6155}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#f99b15}pre .constant,pre .entity,pre .entity.class,pre .support{color:#fec418}pre .constant.symbol,pre .string{color:#48b685}pre .entity.function,pre .support.css-property,pre .selector{color:#06b6ef}pre .keyword,pre .storage{color:#815ba4} diff --git a/themes/css/pastie.css b/themes/css/pastie.css index 4a5896cd..279850d4 100644 --- a/themes/css/pastie.css +++ b/themes/css/pastie.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#F8F8FF;border:1px solid #DEDEDE;color:#000;font-size:13px;line-height:16px}pre,code{font-family:monospace}pre .comment,code .comment{color:#888}pre .keyword,pre .selector,pre .storage.module,pre .storage.class,pre .storage.function,code .keyword,code .selector,code .storage.module,code .storage.class,code .storage.function{color:#080;font-weight:bold}pre .keyword.operator,code .keyword.operator{color:#000;font-weight:normal}pre .constant.language,code .constant.language{color:#038;font-weight:bold}pre .constant.symbol,pre .class,pre .constant,code .constant.symbol,code .class,code .constant{color:#036;font-weight:bold}pre .keyword.namespace,pre .entity.name.class,code .keyword.namespace,code .entity.name.class{color:#B06;font-weight:bold}pre .constant.numeric,code .constant.numeric{color:#00D;font-weight:bold}pre .string,pre .comment.docstring,code .string,code .comment.docstring{color:#D20;background-color:#FFF0F0}pre .string.regexp,code .string.regexp{background-color:#FFF0FF;color:#808}pre .variable.instance,code .variable.instance{color:#33B}pre .entity.name.function,code .entity.name.function{color:#06B;font-weight:bold}pre .support.tag-name,pre .entity.tag.script,pre .entity.tag.style,code .support.tag-name,code .entity.tag.script,code .entity.tag.style{color:#070}pre .support.attribute,code .support.attribute{color:#007;font-style:italic}pre .entity.name.tag,pre .storage.type,code .entity.name.tag,code .storage.type{color:#070;font-weight:bold}pre .variable.self,pre .support.function,code .variable.self,code .support.function{color:#038;font-weight:bold}pre .entity.function,pre .support.magic,pre.support.method,code .entity.function,code .support.magic,code.support.method{color:#C00;font-weight:bold} diff --git a/themes/css/rainbow.css b/themes/css/rainbow.css new file mode 100644 index 00000000..75b0049f --- /dev/null +++ b/themes/css/rainbow.css @@ -0,0 +1 @@ +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}code span{transition:color 0.6s ease-in}pre{background:#010104}.animate{color:#fff !important}.red{color:#f50419}.orange{color:#f57900}.yellow{color:#f5e600}.green{color:#00f50c}.blue{color:#0081f5}.indigo{color:#5000f5}.violet{color:#9000f5}[data-language="custom"] .comment,.lang-custom .comment,.language-custom .comment{color:#314CAD}[data-language="custom"] .integer,.lang-custom .integer,.language-custom .integer{color:#f5e600}[data-language="custom"] .keyword,.lang-custom .keyword,.language-custom .keyword{color:#f57900}.comment{color:#535353}.keyword,.selector,.operator{color:#bc5cff}.storage,.support{color:#fb2639}.string{color:#fff55c}.constant{color:#ffad5c}.entity{color:#43a6ff}.inherited-class{font-style:italic}[data-language="html"] .attribute,.lang-html .attribute,.language-html .attribute{color:#fc4959} diff --git a/themes/css/solarized-dark.css b/themes/css/solarized-dark.css index 1b97e5e8..f7bd3771 100644 --- a/themes/css/solarized-dark.css +++ b/themes/css/solarized-dark.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#002b36;color:#839496}pre .comment{color:#586e75}pre .constant{color:#839496}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#839496}pre .support.property{color:#839496}pre .variable.global,pre .variable.class,pre .variable.instance{color:#839496}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/solarized-light.css b/themes/css/solarized-light.css index b35a52c6..96a29e24 100644 --- a/themes/css/solarized-light.css +++ b/themes/css/solarized-light.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#fdf6e3;color:#657b83}pre .comment{color:#93a1a1}pre .constant{color:#657b83}pre .constant.language{color:#268bd2}pre .constant.regexp{color:#2aa198}pre .storage{color:#268bd2}pre .string,pre .comment.docstring{color:#2aa198}pre .support.tag.script,pre .support.tag.style{color:#2aa198}pre .string.regexp{color:#2aa198}pre .string.regexp.open,pre .string.regexp.close{color:#2aa198}pre .keyword,pre .selector{color:#859900}pre .inherited-class{font-style:italic}pre .entity{color:#b58900}pre .support.method{color:#657b83}pre .support.property{color:#657b83}pre .variable.global,pre .variable.class,pre .variable.instance{color:#657b83}pre .support,*[data-language="c"] .function.call{color:#859900} diff --git a/themes/css/sunburst.css b/themes/css/sunburst.css index 52bac9b5..70bf84a2 100644 --- a/themes/css/sunburst.css +++ b/themes/css/sunburst.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre .comment{color:#AEAEAE;font-style:italic}pre .constant{color:#3387CC}pre .storage{color:#99CF50}pre .string,pre .entity.name.class,pre .comment.docstring{color:#65B042}pre .string.regexp{color:#E9C062}pre .string.constant{color:#DDF2A4}pre .constant.hex-color{color:#DD7B3B}pre .support,pre .tag.script,pre .function.call{color:#dad085}pre .support.css-property{color:#C5AF75}pre .support.tag.style{color:#fff}pre .keyword,pre .selector{color:#E28964}pre .keyword.namespace{color:#3387CC;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity,pre .variable.instance,pre .support.namespace,pre .support.tag,pre .support.tag-name{color:#89BDFF}pre .entity.name.id{color:#8693A5}pre .variable,pre .variable.global{color:#3E87E3}*[data-language="c"] .function.call{color:#8DA6CE} diff --git a/themes/css/tomorrow-night.css b/themes/css/tomorrow-night.css index 27c52765..ff9859b7 100644 --- a/themes/css/tomorrow-night.css +++ b/themes/css/tomorrow-night.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background-color:#1d1f21;color:#c5c8c6}pre .comment{color:#969896}pre .variable.global,pre .variable.class,pre .variable.instance{color:#c66}pre .constant.numeric,pre .constant.language,pre .constant.hex-color,pre .keyword.unit{color:#de935f}pre .constant,pre .entity,pre .entity.class,pre .support{color:#f0c674}pre .constant.symbol,pre .string{color:#b5bd68}pre .entity.function,pre .support.css-property,pre .selector{color:#81a2be}pre .keyword,pre .storage{color:#b294bb} diff --git a/themes/css/tricolore.css b/themes/css/tricolore.css index 8231c929..5519a093 100644 --- a/themes/css/tricolore.css +++ b/themes/css/tricolore.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#FFF;color:#000;font-size:12px;line-height:16px}pre .comment{color:#7E7E7E;font-style:italic}pre .constant{color:#18838A;font-weight:bold}pre .storage{color:#0000A1}pre .string{color:#8E0022}pre .keyword,pre .selector{color:#0000A1;font-weight:bold}pre .inherited-class{font-style:italic}pre .entity{color:#3E853F}pre .support{color:#192140}pre .variable.global,pre .variable.class,pre .variable.instance{color:#3E853F} diff --git a/themes/css/twilight.css b/themes/css/twilight.css index e4b04492..8c67d278 100644 --- a/themes/css/twilight.css +++ b/themes/css/twilight.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#141414;color:#F8F8F8}pre .comment{color:#5F5A60}pre .constant.numeric{color:#D87D50}pre .constant{color:#889AB4}pre .constant.symbol,pre .constant.language{color:#D87D50}pre .storage{color:#F9EE98}pre .string{color:#8F9D6A}pre .string.regexp{color:#E9C062}pre .keyword,pre .selector,pre .storage{color:#CDA869}pre .inherited-class{color:#9B5C2E}pre .entity{color:#FF6400}pre .support{color:#9B859D}pre .support.magic{color:#DAD69A}pre .variable{color:#7587A6}pre .function,pre .entity.class{color:#9B703F}pre .support.class-name,pre .support.type{color:#AB99AC} diff --git a/themes/css/zenburnesque.css b/themes/css/zenburnesque.css index a58cea72..2f614019 100644 --- a/themes/css/zenburnesque.css +++ b/themes/css/zenburnesque.css @@ -1 +1 @@ -@keyframes fade-in{0%{opacity:0}100%{opacity:1}}[data-language] code,pre [data-language]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:40ms ease-in-out 1000ms forwards fade-in}[data-language] code.rainbow,pre [data-language].rainbow{animation-delay:0ms}[data-language] code.stop-animation,pre [data-language].stop-animation{opacity:0;animation-play-state:paused}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} +@keyframes fade-in{0%{opacity:0}100%{opacity:1}}@keyframes fade{10%{transform:scale(1, 1)}35%{transform:scale(1, 1.7)}40%{transform:scale(1, 1.7)}50%{opacity:1}60%{transform:scale(1, 1)}100%{transform:scale(1, 1);opacity:0}}[data-language] code,[class^="lang"] code,pre [data-language],pre [class^="lang"]{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";animation:50ms ease-in-out 2s forwards fade-in}[data-language] code.rainbow,[class^="lang"] code.rainbow,pre [data-language].rainbow,pre [class^="lang"].rainbow{animation-delay:0s}[data-language] code.loading,[class^="lang"] code.loading,pre [data-language].loading,pre [class^="lang"].loading{animation-play-state:paused}pre{position:relative}pre.loading .preloader div{animation-play-state:running}pre.loading .preloader div:nth-of-type(1){background:#0081f5;animation:fade 1.5s 300ms linear infinite}pre.loading .preloader div:nth-of-type(2){background:#5000f5;animation:fade 1.5s 438ms linear infinite}pre.loading .preloader div:nth-of-type(3){background:#9000f5;animation:fade 1.5s 577ms linear infinite}pre.loading .preloader div:nth-of-type(4){background:#f50419;animation:fade 1.5s 715ms linear infinite}pre.loading .preloader div:nth-of-type(5){background:#f57900;animation:fade 1.5s 853ms linear infinite}pre.loading .preloader div:nth-of-type(6){background:#f5e600;animation:fade 1.5s 992ms linear infinite}pre.loading .preloader div:nth-of-type(7){background:#00f50c;animation:fade 1.5s 1130ms linear infinite}pre .preloader{position:absolute;top:12px;left:10px}pre .preloader div{width:12px;height:12px;border-radius:4px;display:inline-block;margin-right:4px;opacity:0;animation-play-state:paused;animation-fill-mode:forwards}pre{background-color:#000;word-wrap:break-word;margin:0px;padding:10px;color:#fff;font-size:14px;margin-bottom:20px}pre,code{font-family:'Monaco', 'Menlo', courier, monospace}pre{background:#404040;color:#dedede}pre .comment{color:#709070;font-style:italic}pre .integer{color:#22C0FF}pre .storage{color:#6080FF}pre .string{color:#FF2020}pre .keyword,pre .selector{color:#ffffa0}pre .inherited-class{font-style:italic}pre .entity{color:#F09040}pre .support{color:#C83730}pre .variable.class{color:#FF8000} From e57023f81101e5f6fb0fed9f9cb9421c91e9d7af Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:30:37 -0400 Subject: [PATCH 148/153] Lowercase prettify --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a98093f3..00f0471a 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ Rainbow also supports the HTML5 style for specifying languages:
    var testing = true;
    ``` -And the Google Prettify style: +And the Google prettify style: ```html
    var testing = true;
    From 635b54b466b1b1d58267471e539599b95f6c4d26 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:48:25 -0400 Subject: [PATCH 149/153] Fix async Rainbow.color in node For some reason node.js does not like the setTimeout inside the web worker. I haven't had a chance to dig into it and see why, but for now this works. --- src/worker.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/worker.js b/src/worker.js index 1f0e6386..a1c3fd52 100644 --- a/src/worker.js +++ b/src/worker.js @@ -6,13 +6,13 @@ export default function rainbowWorker(e) { const prism = new Prism(message.options); const result = prism.refract(message.code, message.lang); - setTimeout(() => { + function _reply(message, result) { self.postMessage({ id: message.id, lang: message.lang, result }); - }, message.options.delay * 1000); + } // I realized down the road I might look at this and wonder what is going on // so probably it is not a bad idea to leave a comment. @@ -26,6 +26,12 @@ export default function rainbowWorker(e) { // block we are highlighting, but in the browser we will keep a single // worker open for all requests. if (message.isNode) { + _reply(message, result); self.close(); + return; } + + setTimeout(() => { + _reply(message, result); + }, message.options.delay * 1000); } From 9241975e050ccb360cc507adf1b82d314a5cb383 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 01:51:56 -0400 Subject: [PATCH 150/153] Do not overwrite outer scope --- src/worker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/worker.js b/src/worker.js index a1c3fd52..38707e38 100644 --- a/src/worker.js +++ b/src/worker.js @@ -6,7 +6,7 @@ export default function rainbowWorker(e) { const prism = new Prism(message.options); const result = prism.refract(message.code, message.lang); - function _reply(message, result) { + function _reply() { self.postMessage({ id: message.id, lang: message.lang, @@ -26,12 +26,12 @@ export default function rainbowWorker(e) { // block we are highlighting, but in the browser we will keep a single // worker open for all requests. if (message.isNode) { - _reply(message, result); + _reply(); self.close(); return; } setTimeout(() => { - _reply(message, result); + _reply(); }, message.options.delay * 1000); } From db535fbd599d3fd12371cbf31793a81414850abe Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 12:42:36 -0400 Subject: [PATCH 151/153] Remove python utils since we use gulp now --- util/builder.py | 153 ------------------------------------------------ util/compile.py | 38 ------------ 2 files changed, 191 deletions(-) delete mode 100644 util/builder.py delete mode 100755 util/compile.py diff --git a/util/builder.py b/util/builder.py deleted file mode 100644 index e39c715c..00000000 --- a/util/builder.py +++ /dev/null @@ -1,153 +0,0 @@ -import os -import subprocess -import zipfile -import hashlib -import re -import glob -import json -from zipfile import ZipFile -from StringIO import StringIO - - -class RainbowBuilder(object): - - def __init__(self, js_path, closure_path, theme_path=None): - - self.versions = { - 'c': '1.0.7', - 'csharp': '1.0.1', - 'coffeescript': '1.0', - 'css': '1.0.9', - 'd': '1.0', - 'generic': '1.0.12', - 'go': '1.0', - 'haskell': '1.0.1', - 'html': '1.0.9', - 'java': '1.0', - 'javascript': '1.0.10', - 'lua': '1.0.1', - 'php': '1.0.8', - 'python': '1.0.9', - 'r': '1.0', - 'ruby': '1.0.6', - 'scheme': '1.0', - 'shell': '1.0.3', - 'smalltalk': '1.0' - } - - self.js_path = js_path - self.closure_path = closure_path - self.js_files_to_include = [] - self.file_name = "" - self.theme_path = theme_path - - def getPathForLanguage(self, language): - return os.path.join(self.js_path, 'language/' + language + '.js') - - def getRainbowPath(self): - return os.path.join(self.js_path, 'rainbow.js') - - def verifyPaths(self): - if not os.path.exists(self.js_path): - raise Exception('directory does not exist at: %s' % self.js_path) - - if not os.path.isfile(self.closure_path): - raise Exception('closure compiler does not exist at: %s' % self.closure_path) - - def getZipForLanguages(self, languages, path=None): - self.verifyPaths() - - # strip out any duplicates - languages = list(set(languages)) - - write_to = StringIO() if path is None else path - zip_file = ZipFile(write_to, 'w') - zip_file.write(self.getRainbowPath(), 'rainbow.js', zipfile.ZIP_DEFLATED) - - # include minimized version even when downloading the dev version - zip_file.write(self.getRainbowPath().replace('.js', '.min.js'), 'rainbow.min.js', zipfile.ZIP_DEFLATED) - - # include themes as well - if self.theme_path: - files = glob.glob(self.theme_path + '/*.css') - for file_name in files: - zip_file.write(file_name, os.path.join('themes', os.path.basename(file_name)), zipfile.ZIP_DEFLATED) - - for language in languages: - zip_file.write(self.getPathForLanguage(language), os.path.join('language', language + '.js'), zipfile.ZIP_DEFLATED) - - zip_file.close() - - return write_to - - def openFile(self, path): - file = open(path, "r") - content = file.read() - file.close() - return content - - def writeFile(self, path, content): - file = open(path, "w") - file.write(content) - file.close() - - def getPackageJSON(self): - contents = self.openFile(os.path.join(self.js_path, '../package.json')) - return json.loads(contents) - - def getLanguageVersions(self, languages): - groups = [] - for language in languages: - if language in self.versions: - groups.append(language + ' v' + self.versions[language]) - - return ', '.join(groups) - - def getFileForLanguages(self, languages, cache=None): - self.verifyPaths() - - # strip out any duplicates - languages = list(set(languages)) - - self.js_files_to_include = [self.getRainbowPath()] - for language in languages: - path = self.getPathForLanguage(language) - if not os.path.exists(path): - continue - - self.js_files_to_include.append(path) - - self.file_name = 'rainbow' + ('-custom' if len(languages) else '') + '.min.js' - - if cache is not None: - version = self.getVersion() - cache_key = 'rainbow_' + hashlib.md5(self.getLanguageVersions(languages)).hexdigest() + '_' + version - cached_version = cache.get(cache_key) - if cached_version: - return cached_version - - command = ['java', '-jar', self.closure_path, '--compilation_level', 'SIMPLE_OPTIMIZATIONS'] + self.js_files_to_include - proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - output, err = proc.communicate() - - if err: - print err - - lines = output.splitlines() - - data = self.getPackageJSON() - - new_comment = "/* Rainbow v%s %s | included languages: %s */" % ( - data['version'], - data['homepage'].replace('http://', ''), - ', '.join(languages) - ) - - lines.insert(0, new_comment) - - output = '\n'.join(lines) - - if cache is not None: - cache.set(cache_key, output, 14400) # 4 hours - - return output diff --git a/util/compile.py b/util/compile.py deleted file mode 100755 index e0540845..00000000 --- a/util/compile.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -import sys -import os -from builder import RainbowBuilder - -sys.argv.pop(0) -languages = sys.argv -languages.sort() - -no_language_args = ['--alone', '--forever-alone', '--core', '--no-languages', '--without-languages', '--none'] -rainbow_only = len(set(no_language_args) - set(sys.argv)) < len(no_language_args) - -if not rainbow_only: - languages.insert(0, 'generic') - -js_path = os.path.dirname(__file__) + '/../js/' - -for language in languages[:]: - if language.startswith('--'): - languages.remove(language) - -builder = RainbowBuilder(js_path, os.environ.get('CLOSURE_COMPILER', '/usr/local/compiler-latest/compiler.jar')) - -print 'waiting for closure compiler...' -contents = builder.getFileForLanguages(languages) - -print "\nincluded:" -for file in builder.js_files_to_include: - print " ", os.path.basename(file) -print "" - -print 'writing to file:', builder.file_name - -new_file = os.path.join(js_path, builder.file_name) - -file = open(new_file, "w") -file.write(contents) -file.close() From c68098eee0123d0b1f3bec5a326eb94fe20fbe59 Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 16:04:54 -0400 Subject: [PATCH 152/153] Add note about language sass mixin --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 00f0471a..cdda7556 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ You can also build/download custom packages from there. * [Specifying a language](#specifying-a-language) * [Themes](#themes) * [Rendering code blocks](#rendering-code-blocks) + * [Adding custom rules for specific languages](#adding-custom-rules-for-specific-languages) * [JavaScript API Documentation](#javascript-api-documentation) * [Rainbow.color](#rainbowcolor) * [Preventing automatic highlighting on page load](#preventing-automatic-highlighting-on-page-load) @@ -169,6 +170,22 @@ This means for users who do not have JavaScript enabled the code will fade in af There is also a preload animation that will show up for any code block that takes longer than 300ms to load. +### Adding custom rules for specific languages + +A SASS mixin was added to simplify defining styles that should only apply for a specific language. Using it looks like this: + +```sass +@include language("html") + .support.operator + color: #fff + +@include language(("javascript", "js")) + .variable.super + color: #66D9EF +``` + +You can pass a single language or a list of languages. + ## JavaScript API Documentation Rainbow has four public methods: From 5063ffe6de8d196a556ae1303c0c16d3cd9b1a7e Mon Sep 17 00:00:00 2001 From: Craig Campbell Date: Sat, 2 Jul 2016 16:08:25 -0400 Subject: [PATCH 153/153] Remove directories from package.json --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 9bedb2b0..8391125f 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,6 @@ "description": "Simple library for code syntax highlighting", "main": "./src/rainbow-node.js", "homepage": "http://rainbowco.de", - "directories": { - "test": "tests" - }, "scripts": { "test": "gulp test" },