$.fn.highlight = function (b, k) {
    var minlengthToHLseparate = 1; // change to get filtered highlits
    function l() {
        $("." + c.className).each(function (c, e) {
            var a = e.previousSibling,
                d = e.nextSibling,
                b = $(e),
                f = "";
            a && 3 == a.nodeType && (f += a.data, a.parentNode.removeChild(a));
            e.firstChild && (f += e.firstChild.data);
            d && 3 == d.nodeType && (f += d.data, d.parentNode.removeChild(d));
            b.replaceWith(f)
        })
    }

    function h(b) {
        b = b.childNodes;
        for (var e = b.length, a; a = b[--e];)
            if (3 == a.nodeType) {

                if (!/^\s+$/.test(a.data)) {
                    var d = a.data;
                    if (pt.length < minlengthToHLseparate) {
                        var d = d.replace(m, '$1<span class="' + c.className + '">$2</span>$3');
                    } else {
                        var d = d.replace(m, '<span class="' + c.className + '">$1</span>');
                    }
                    $(a).replaceWith(d)
                }
            } else 1 == a.nodeType && a.childNodes && a.className != "hide-highlight" && (!/(script|style|svg)/i.test(a.tagName) && a.className != c.className) && h(a)
    }
    var c = {
        split: "\\s+",
        className: "highlight",
        caseSensitive: !1,
        strictly: !1,
        remove: !0
    }, c = $.extend(c, k);
    c.remove && l();

    b = $.trim(b);
    var g = c.strictly ? "" : "\\S*";
    if (b.length < minlengthToHLseparate) {
        var m = RegExp("(^|[^а-яё])(" + b + (c.full ? (b.slice(-1) == "." ? "" : " ") : "") + ")([^а-яё]|$)", (c.caseSensitive ? "" : "i") + "g");
    } else {
        var m = RegExp("(" + b + (c.full ? (b.slice(-1) == "." ? "" : " ") : "") + ")", (c.caseSensitive ? "" : "i") + "g");
    }
    var pt = b;
    return this.each(function () {
        b && h(this)
    })
};