markdown-it-link-attributes
Link attributes plugin for markdown-it markdown parser.
Install
node.js, browser:
npm install markdown-it-link-attributes --save
bower install markdown-it-link-attributes --save
Use
var md = require('markdown-it')()
var mila = require('markdown-it-link-attributes')
md.use(mila, {
target: '_blank',
rel: 'noopener'
})
var html = md.render('[link](https://google.com)')
html
If the linkify
optoon is set to true
on markdown-it
, then the attributes will be applied to plain links as well.
var md = require('markdown-it')({
linkify: true
})
md.use(mila, {
target: '_blank',
rel: 'noopener'
})
var html = md.render('foo https://google.com bar')
html
Differences in browser. If you load script directly into the page, without a package system, the module will add itself globally as window.markdownitLinkAttributes
.
License
MIT