styledoc.js
function selectorToId(selector) {
        var id = selector.replace(/[^a-z0-9_-]/ig, "_");

        if (styledoc.item_id_trim_underscores) {
            id = id.replace(/_{2,}/g, "_").replace(/^_/, "").replace(/_$/, "");
        }

        return id;
    }
function selectorToId(selector) {
        var id = selector.replace(/[^a-z0-9_-]/ig, "_");

        if (styledoc.item_id_trim_underscores) {
            id = id.replace(/_{2,}/g, "_").replace(/^_/, "").replace(/_$/, "");
        }

        return id;
    }
function selectorToId ( selector ) { var id = selector . replace ( / [^a-z0-9_-] / ig , "_" ) ; if ( styledoc . item_id_trim_underscores ) { id = id . replace ( / _{2,} / g , "_" ) . replace ( / ^_ / , "" ) . replace ( / _$ / , "" ) ; } return id ; }
Replace any char other than latin letters, digits, hyphens and underscores with underscore char
Also wipes out the first underscore char (@todo is it really good and safe idea?)
E.g.: .my-class => my-class
.my-class.subclass#id #otherid => my-class_subclass_id__otherid
@param {string} selector
@returns {string}
Replace any char other than latin letters digits hyphens and underscores with underscore char Also wipes out the first underscore char (