all files / lib/languages/ markup.js

90.91% Statements 10/11
50% Branches 1/2
100% Functions 1/1
90.91% Lines 10/11
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                                                                                               
"use strict";
 
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.svg = exports.html = exports.xml = exports.markup = undefined;
 
var _hooks = require("../hooks");
 
var markup = {
    comment: /<!--[\w\W]*?-->/,
    prolog: /<\?[\w\W]+?\?>/,
    doctype: /<!DOCTYPE[\w\W]+?>/,
    cdata: /<!\[CDATA\[[\w\W]*?]]>/i,
    tag: {
        pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
        inside: {
            tag: {
                pattern: /^<\/?[^\s>\/]+/i,
                inside: {
                    punctuation: /^<\/?/,
                    namespace: /^[^\s>\/:]+:/,
                    _order: ["punctuation", "namespace"]
                }
            },
            "attr-value": {
                pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,
                inside: {
                    punctuation: /[=>"']/,
                    _order: ["punctuation"]
                }
            },
            punctuation: /\/?>/,
            "attr-name": {
                pattern: /[^\s>\/]+/,
                inside: {
                    "namespace": /^[^\s>\/:]+:/,
                    _order: ["namespace"]
                }
            },
            _order: ["tag", "attr-value", "punctuation", "attr-name"]
        }
    },
    "entity": /&#?[\da-z]{1,8};/i,
    "_order": ["comment", "prolog", "doctype", "cdata", "tag", "entity"]
};
 
// Plugin to make entity title show the real entity, idea by Roman Komarov
(0, _hooks.add)("wrap", function (env) {
    Iif (env.type === "entity") {
        env.attributes.title = env.content.replace(/&amp;/, "&");
    }
});
 
exports.markup = markup;
exports.xml = markup;
exports.html = markup;
exports.svg = markup;