all files / lib/languages/ css.js

100% Statements 9/9
100% Branches 0/0
100% Functions 0/0
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76                                                                                                                                     
"use strict";
 
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.css = undefined;
 
var _utils = require("../utils");
 
var _markup = require("./markup");
 
var css = {
    comment: /\/\*[\w\W]*?\*\//,
    atrule: {
        pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
        inside: {
            rule: /@[\w-]+/,
            _order: ["rule"]
        }
    },
    url: /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
    selector: {
        pattern: /[^\{\}\s][^\{\}]*(?=\s*\{)/,
        inside: {
            "pseudo-element": /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/,
            "pseudo-class": /:[-\w]+(?:\(.*\))?/,
            "class": /\.[-:\.\w]+/,
            id: /#[-:\.\w]+/,
            _order: ["pseudo-element", "pseudo-class", "class", "id"]
        }
    },
    string: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
    property: /(\b|\B)[\w-]+(?=\s*:)/i,
    important: /\B!important\b/i,
    hexcode: /#[\da-f]{3,6}/i,
    entity: /\\[\da-f]{1,8}/i,
    number: /[\d%\.]+/,
    "function": /[-a-z0-9]+(?=\()/i,
    punctuation: /[(){};:]/,
    _order: ["comment", "atrule", "url", "selector", "string", "property", "important", "hexcode", "entity", "number", "function", "punctuation"]
};
// import hooks from "../hooks";
 
_utils.lang.insertAfter(css.atrule.inside, "rule", _utils.lang.clone(css));
 
_utils.lang.insertBefore(_markup.markup, "tag", {
    "style": {
        pattern: /(<style[\w\W]*?>)[\w\W]*?(?=<\/style>)/i,
        lookbehind: true,
        inside: _utils.lang.clone(css),
        alias: "language-css"
    },
    _order: ["style"]
});
 
_utils.lang.insertBefore(_markup.markup.tag.inside, "attr-value", {
    "style-attr": {
        pattern: /\s*style=("|").*?\1/i,
        inside: {
            "attr-name": {
                pattern: /^\s*style/i,
                inside: _utils.lang.clone(_markup.markup.tag.inside)
            },
            "punctuation": /^\s*=\s*['"]|['"]\s*$/,
            "attr-value": {
                pattern: /.+/i,
                inside: _utils.lang.clone(css)
            },
            _order: ["attr-name", "punctuation", "attr-value"]
        },
        alias: "language-css"
    },
    _order: ["style-attr"]
});
 
exports.css = css;