dist/plugin.js
/** Build processor function from a path map. The processor takes a node and an attribute name, and
 * tests the attribute value against all of the paths in the path map. The first match either
 * replaces the attribute value, or removes the attribute. */
Build processor function from a path map. The processor takes a node and an attribute name, and
tests the attribute value against all of the paths in the path map. The first match either
replaces the attribute value, or removes the attribute.
Build processor function from a path map . The processor takes a node and an attribute name and tests the attribute value against all of the paths in the path map . The first match either replaces the attribute value or removes the attribute .
function buildProcessor(pathMap) {
    const rewriters = Object
        .keys(pathMap)
        .map(from => createPathRewriter(from, pathMap[from]));
    return function process(node, attrName) {
        if (node.attrs) {
            const attrValue = node.attrs[attrName];
            if (attrValue) {
                const rewriter = rewriters.find(function (r) { return r.test(this); }, attrValue);
                if (rewriter) {
                    if (rewriter.replace) {
                        node.attrs[attrName] = rewriter.replace;
                    }
                    else {
                        delete node.attrs[attrName];
                    }
                }
            }
        }
    };
}
function buildProcessor ( pathMap ) { const rewriters = Object . keys ( pathMap ) . map ( from => createPathRewriter ( from , pathMap [ from ] ) ) ; return function process ( node , attrName ) { if ( node . attrs ) { const attrValue = node . attrs [ attrName ] ; if ( attrValue ) { const rewriter = rewriters . find ( function ( r ) { return r . test ( this ) ; } , attrValue ) ; if ( rewriter ) { if ( rewriter . replace ) { node . attrs [ attrName ] = rewriter . replace ; } else { delete node . attrs [ attrName ] ; } } } } } ; }
Build processor function from a path map.
Build processor function from a path map .