A markdown-it plugin to configure the attributes for links
MIT License
Bot releases are visible (Hide)
Attributes are now nested under an attrs
property.
v1.0.0:
md.use(mila, {
target: '_blank',
rel: 'noopener'
})
v2.0.0:
md.use(mila, {
attrs: {
target: '_blank',
rel: 'noopener'
}
})
This allows us to support things like pattern
Add pattern
property to specify a regex to apply config to links conditionally if the href of the link matches it
md.use(mila, {
pattern: /^https?:\/\//,
attrs: {
target: '_blank',
rel: 'noopener'
}
})
Add an array of configs for multiple config options, the first pattern to match will use that config
md.use(mila, [{
pattern: /^https?:\/\//, // apply target and rel properties for external links
attrs: {
target: '_blank',
rel: 'noopener'
}, {
attrs: { // otherwise, apply a class to internal links
className: 'internal-link'
}
})