https://drafts.csswg.org/css-syntax-3/#urange
519161
function scanUnicodeRange(scanner) {
    var hexStart = scanner.tokenStart + 1; // skip +
    var hexLength = 0;

    scan: {
        if (scanner.tokenType === NUMBER) {
            if (scanner.source.charCodeAt(scanner.tokenStart) !== FULLSTOP && scanUnicodeNumber(scanner)) {
                scanner.next();
            } else if (scanner.source.charCodeAt(scanner.tokenStart) !== HYPHENMINUS) {
                break scan;
            }
        } else {
            scanner.next(); // PLUSSIGN
        }

        if (scanner.tokenType === HYPHENMINUS) {
            scanner.next();
        }

        if (scanner.tokenType === NUMBER) {
            scanner.next();
        }

        if (scanner.tokenType === IDENTIFIER) {
            scanner.next();
        }

        if (scanner.tokenStart === hexStart) {
            scanner.error('Unexpected input', hexStart);
        }
    }

    // validate for U+x{1,6} or U+x{1,6}-x{1,6}
    // where x is [0-9a-fA-F]
    for (var i = hexStart, wasHyphenMinus = false; i < scanner.tokenStart; i++) {
        var code = scanner.source.charCodeAt(i);

        if (isHex(code) === false && (code !== HYPHENMINUS || wasHyphenMinus)) {
            scanner.error('Unexpected input', i);
        }

        if (code === HYPHENMINUS) {
            // hex sequence shouldn't be an empty
            if (hexLength === 0) {
                scanner.error('Unexpected input', i);
            }

            wasHyphenMinus = true;
            hexLength = 0;
        } else {
            hexLength++;

            // too long hex sequence
            if (hexLength > 6) {
                scanner.error('Too long hex sequence', i);
            }
        }

    }

    // check we have a non-zero sequence
    if (hexLength === 0) {
        scanner.error('Unexpected input', i - 1);
    }

    // U+abc???
    if (!wasHyphenMinus) {
        // consume as many U+003F QUESTION MARK (?) code points as possible
        for (; hexLength < 6 && !scanner.eof; scanner.next()) {
            if (scanner.tokenType !== QUESTIONMARK) {
                break;
            }

            hexLength++;
        }
    }
}
130083
def optimize_svg_for_uri_escaping!(svg)
      # Remove comments, xml meta, and doctype
      svg.gsub!(/<!--.*?-->|<\?.*?\?>|<!.*?>/m, '')
      # Replace consecutive whitespace and newlines with a space
      svg.gsub!(/\s+/, ' ')
      # Collapse inter-tag whitespace
      svg.gsub!('> <', '><')
      # Replace " with '
      svg.gsub!(/([\w:])="(.*?)"/, "\\1='\\2'")
      svg.strip!
    end
185666
function cssParseUri(candidate) {
      var string1 = /^\s*["]([^"]*)["]\s*$/;
      var string2 = /^\s*[']([^']*)[']\s*$/;
      var url1 = /^\s*url\s*[(]["]([^"]*)["][)]\s*$/;
      var url2 = /^\s*url\s*[(][']([^']*)['][)]\s*$/;
      // Not officially part of the CSS2.1 grammar
      // but supported by Chrome
      var url3 = /^\s*url\s*[(]([^)]*)[)]\s*$/;
      var match;
      if ((match = string1.exec(candidate))) {
        return match[1];
      } else if ((match = string2.exec(candidate))) {
        return match[1];
      } else if ((match = url1.exec(candidate))) {
        return match[1];
      } else if ((match = url2.exec(candidate))) {
        return match[1];
      } else if ((match = url3.exec(candidate))) {
        return match[1];
      }
      return null;
    }
283712
function cssTemplate(params) {
    // Localize parameters
    var items = params.items,
    options = params.options;

    params.options.retina = params.options.image.indexOf('@2x') !== -1;
    if (params.options.retina) {
        params.options.bgWidth = Math.round(options.size.width / 2);
        params.options.bgHeight = Math.round(options.size.height / 2);
        params.options.className = params.options.className.replace('@2x', '');
        params.options.image2x = params.options.image;
        params.options.image = params.options.image.replace('@2x', '');
    }

    items.forEach(function (item) {
        if (item.x === -99999) {
            item.px.offset_x = 'right';
        }

        if (params.options.retina) {
            if (item.px.offset_x !== 'right') {
                item.px.offset_x = Math.round(parseFloat(item.px.offset_x) / 2) + 'px';
            }
            item.px.offset_y = Math.round(parseFloat(item.px.offset_y) / 2) + 'px';
            item.px.width = Math.round(parseFloat(item.px.width) / 2) + 'px';
            item.px.height = Math.round(parseFloat(item.px.height) / 2) + 'px';
        }
    });

    // Render and return CSS
    var css = mustache.render(tmpl, params);
    return css;
}
1270795
function fixRelativeCssUrls(cssText, baseUrl) {
    const cssUrls = cssText
        // Remove comments
        .replace(regex.cssComments, '')
        // Match url(...) values
        .match(regex.cssUrls) || [];

    cssUrls.forEach(cssUrl => {
        const oldUrl = cssUrl.replace(regex.cssUrls, '$1');
        const newUrl = getFullUrl(oldUrl, baseUrl);

        cssText = cssText.replace(cssUrl, cssUrl.replace(oldUrl, newUrl));
    });

    return cssText;
}
967777
function getTokens(css) {
    // Parse string, character by character:
    for (pos = 0; pos < css.length; col++, pos++) {
      c = css.charAt(pos);
      cn = css.charAt(pos + 1);

      // If we meet `/*`, it's a start of a multiline comment.
      // Parse following characters as a multiline comment:
      if (c === '/' && cn === '*') {
        parseMLComment(css);
      }

      // If we meet `//` and it is not a part of url:
      else if (!urlMode && c === '/' && cn === '/') {
        // If we're currently inside a block, treat `//` as a start
        // of identifier. Else treat `//` as a start of a single-line
        // comment:
        parseSLComment(css);
      }

      // If current character is a double or single quote, it's a start
      // of a string:
      else if (c === '"' || c === "'") {
        parseString(css, c);
      }

      // If current character is a space:
      else if (c === ' ') {
        parseSpaces(css);
      }

      // If current character is `=`, it must be combined with next `=`
      else if (c === '=' && cn === '=') {
        parseEquality(css);
      }

      // If we meet `!=`, this must be inequality
      else if (c === '!' && cn === '=') {
        parseInequality(css);
      }

      // If current character is a punctuation mark:
      else if (c in Punctuation) {
        // Check for CRLF here or just LF
        if (c === '\r' && cn === '\n' || c === '\n') {
          // If \r we know the next character is \n due to statement above
          // so we push a CRLF token type to the token list and importantly
          // skip the next character so as not to double count newlines or
          // columns etc
          if (c === '\r') {
            pushToken(TokenType.Newline, '\r\n', col);
            pos++; // If CRLF skip the next character and push crlf token
          } else if (c === '\n') {
            // If just a LF newline and not part of CRLF newline we can just
            // push punctuation as usual
            pushToken(Punctuation[c], c, col);
          }

          ln++; // Go to next line
          col = 0; // Reset the column count
        } else if (c !== '\r' && c !== '\n') {
          // Handle all other punctuation and add to list of tokens
          pushToken(Punctuation[c], c, col);
        }// Go to next line
        if (c === ')') urlMode = false; // Exit url mode
        else if (c === '\t' && tabSize > 1) col += (tabSize - 1);
      }

      // If current character is a decimal digit:
      else if (isDecimalDigit(c)) {
        parseDecimalNumber(css);
      }

      // If current character is anything else:
      else {
        parseIdentifier(css);
      }
    }

    return tokens;
  }
660440
function css(prefix, escape) {
		var mw = core.base();
		mw.prefix = (typeof prefix !== 'undefined' ? prefix : 'mw-');
		mw.error = function (str) {
			return mw.wrap(str, 'error');
		};
		mw.warning = function (str) {
			return mw.wrap(str, 'warning');
		};
		mw.success = function (str) {
			return mw.wrap(str, 'success');
		};
		mw.accent = function (str) {
			return mw.wrap(str, 'accent');
		};
		mw.signal = function (str) {
			return mw.wrap(str, 'signal');
		};
		mw.muted = function (str) {
			return mw.wrap(str, 'muted');
		};
		mw.plain = function (str) {
			return mw.wrap(str, 'plain');
		};
		// html encode?
		if (escape) {
			mw.wrap = function (str, style) {
				return '<span class="' + mw.prefix + style + '">' + escapeHTML(str) + '</span>';
			};
		} else {
			mw.wrap = function (str, style) {
				return '<span class="' + mw.prefix + style + '">' + str + '</span>';
			};
		}
		mw.toString = function () {
			return '<ministyle-css>';
		};
		return mw;
	}
217808
function parseURL(url, instanceOptions) {
	    var holder = {
	        theme: extend(App.settings.themes.gray, null),
	        stylesheets: instanceOptions.stylesheets,
	        instanceOptions: instanceOptions
	    };

	    var firstQuestionMark = url.indexOf('?');
	    var parts = [url];

	    if (firstQuestionMark !== -1) {
	        parts = [url.slice(0, firstQuestionMark), url.slice(firstQuestionMark + 1)];
	    }

	    var basics = parts[0].split('/');

	    holder.holderURL = url;

	    var dimensions = basics[1];
	    var dimensionData = dimensions.match(/([\d]+p?)x([\d]+p?)/);

	    if (!dimensionData) return false;

	    holder.fluid = dimensions.indexOf('p') !== -1;

	    holder.dimensions = {
	        width: dimensionData[1].replace('p', '%'),
	        height: dimensionData[2].replace('p', '%')
	    };

	    if (parts.length === 2) {
	        var options = querystring.parse(parts[1]);

	        // Dimensions

	        if (utils.truthy(options.ratio)) {
	            holder.fluid = true;
	            var ratioWidth = parseFloat(holder.dimensions.width.replace('%', ''));
	            var ratioHeight = parseFloat(holder.dimensions.height.replace('%', ''));

	            ratioHeight = Math.floor(100 * (ratioHeight / ratioWidth));
	            ratioWidth = 100;

	            holder.dimensions.width = ratioWidth + '%';
	            holder.dimensions.height = ratioHeight + '%';
	        }

	        holder.auto = utils.truthy(options.auto);

	        // Colors

	        if (options.bg) {
	            holder.theme.bg = utils.parseColor(options.bg);
	        }

	        if (options.fg) {
	            holder.theme.fg = utils.parseColor(options.fg);
	        }

	        //todo: add automatic foreground to themes without foreground
	        if (options.bg && !options.fg) {
	            holder.autoFg = true;
	        }

	        if (options.theme && holder.instanceOptions.themes.hasOwnProperty(options.theme)) {
	            holder.theme = extend(holder.instanceOptions.themes[options.theme], null);
	        }

	        // Text

	        if (options.text) {
	            holder.text = options.text;
	        }

	        if (options.textmode) {
	            holder.textmode = options.textmode;
	        }

	        if (options.size && parseFloat(options.size)) {
	            holder.size = parseFloat(options.size);
	        }

	        if (options.font) {
	            holder.font = options.font;
	        }

	        if (options.align) {
	            holder.align = options.align;
	        }

	        if (options.lineWrap) {
	            holder.lineWrap = options.lineWrap;
	        }

	        holder.nowrap = utils.truthy(options.nowrap);

	        // Miscellaneous

	        holder.outline = utils.truthy(options.outline);

	        if (utils.truthy(options.random)) {
	            App.vars.cache.themeKeys = App.vars.cache.themeKeys || Object.keys(holder.instanceOptions.themes);
	            var _theme = App.vars.cache.themeKeys[0 | Math.random() * App.vars.cache.themeKeys.length];
	            holder.theme = extend(holder.instanceOptions.themes[_theme], null);
	        }
	    }

	    return holder;
	}
160255
function getImageSrcCSS(token) {
	// A stylesheet token may contain either quoted ('string') or unquoted URL
	let urlValue = token.item(0);
	if (urlValue && urlValue.type === 'string') {
		urlValue = urlValue.item(0);
	}

	return urlValue && urlValue.valueOf();
}
938030
function _fnStringToCss( s )
	{
		if ( s === null ) {
			return '0px';
		}
	
		if ( typeof s == 'number' ) {
			return s < 0 ?
				'0px' :
				s+'px';
		}
	
		// Check it has a unit character already
		return s.match(/\d$/) ?
			s+'px' :
			s;
	}
1144601
function(path) {
  if (path.indexOf('url') === 0) return path;

  var options_ = options
    , token_ = token
    , tokens_ = tokens
    , variables_ = variables
    , traits_ = traits
    , depth_ = depth;

  var path = path.replace(/['"]/g, '')
    , css = fs.readFileSync(path, 'utf8');

  path = join(options.dir, path);

  css = parse(lex(css), {
    __proto__: options,
    dir: dirname(path)
  });

  options = options_;
  token = token_;
  tokens = tokens_;
  variables = variables_;
  traits = traits_;
  depth = depth_;

  return css;
}
738172
static void dataUri( CssFormatter formatter, byte[] bytes, String urlStr, String type ) {
        if( type == null ) {
            switch( urlStr.substring( urlStr.lastIndexOf( '.' ) + 1 ) ) {
                case "gif": 
                    type = "image/gif;base64";
                    break;
                case "png": 
                    type = "image/png;base64";
                    break;
                case "jpg":
                case "jpeg":
                    type = "image/jpeg;base64";
                    break;
                default: 
                    type = "text/html";
            }
        } else {
            type = removeQuote( type );
        }

        if( type.endsWith( "base64" ) ) {
            formatter.append( "url(\"data:" ).append( type ).append( ',' );
            formatter.append( toBase64( bytes ) );
            formatter.append( "\")" );
        } else {
            formatter.append( "url(\"data:" ).append( type ).append( ',' );
            appendEncode( formatter, bytes );
            formatter.append( "\")" );
        }
    }
686954
function syntaxHighlight(json) {
  json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
    var cls = 'number',
        url = false;
    if (/^"/.test(match)) {
        if (/:$/.test(match)) {
          cls = 'key';
        } else {
          cls = 'string';
          if(match.indexOf('"https://') === 0){
            // url = true;
            cls += ' link';
          }
        }
    } else if (/true|false/.test(match)) {
      cls = 'boolean';
    } else if (/null/.test(match)) {
      cls = 'null';
    }
    var html = '<span class="' + cls + '">' + match + '</span>';
    if(url){
      html = '<a href>' + html + '</a>';
    }
    return html;
  });
}
1034960
function (domElt) {
            // work-around for http://crbug.com/240772
            var values = [];
            var parent = domElt;
            while (parent && parent.style) {
                values.push(parent.style.cssText);
                parent.style.overflow = "hidden";
                parent = parent.parentNode;
            }
            domElt.getBoundingClientRect(); // making sure Chrome updates the display
            parent = domElt;
            while (parent && parent.style) {
                parent.style.cssText = values.shift();
                parent = parent.parentNode;
            }
        }
306721
function (char) {
                var
                    linkState = this._linkState;
                if ("]" === char && 0 === linkState) {
                    ++this._linkState;
                } else if ("(" === char && 1 === linkState) {
                    ++this._linkState;
                } else if (")" === char && 2 === linkState) {
                    return this._finishLink();
                } else if (0 === linkState) {
                    this._linkText.push(char);
                } else if (2 === linkState) {
                    /*
                     * https://github.com/ArnaudBuchholz/gpf-js/issues/33
                     * Filter out tabs and carriage returns
                     */
                    if (-1 === "\t\n".indexOf(char)) {
                        this._linkUrl.push(char);
                    }
                }
                // Else... nothing. do some kind of error handling?
            }
455528
function compatibleStyleSheetInsertRule(rule, index){
    // fetch selector and style from rule description
    var m = rule.match(/^([^{]+)\{(.*)\}\s*$/);
    if (m)
    {
      var selectors = m[1].trim().split(/\s*,\s*/);
      for (var i = 0; i < selectors.length; i++)
        this.addRule(selectors[i], m[2] || null, index++);
      return index - 1;
    }

    /** @cut */ throw new Error('Syntax error in CSS rule to be added');
  }
868428
function getUri1() {
  const startPos = pos;
  let content = [];

  if (checkSC(pos)) content = content.concat(getSC());

  while (pos < tokens[startPos].uri_end) {
    if (checkInterpolation(pos)) content.push(getInterpolation());
    else if (checkUriRaw(pos)) content.push(getUriRaw());
    else break;
  }

  if (checkSC(pos)) content = content.concat(getSC());

  return content;
}