posthtml-url-attrs
PostHTML plugin for transforming URL attributes.
Usage
const posthtml = require('posthtml');
const urlAttrs = require('posthtml-url-attrs');
const options = {
eachURL: function(url) {
return `http://domain.com/${url}`;
}
};
posthtml()
.use( urlAttrs(options) )
.process('<a href="link.html">link</a>')
.then(result => console.log(result.html));
//-> <a href="http://domain.com/link.html">link</a>
Options
options.eachURL
Type: Function
Default value: undefined
A callback function ran for each URL value found. You can return either a synchronous value or a Promise
.
options.filter
Type: Object
Default value: …
The elements and attributes for which to search.
options.filterCSS
Type: Boolean
Default value: true
When true, the contents of <style>
elements and style
attributes will be checked for property values containing URLs.