markdown-it-replace-link
markdown-it plugin for replacing links (image & text) in the markdown document.
Last updated 10 years ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install markdown-it-replace-link 
SYNC missed versions from official npm registry.

markdown-it-replace-link

markdown-it plugin for replacing links (image & text) in the markdown document.

Usage

Enable plugin

var md = require('markdown-it')({
    html: true,
    linkify: true
})
.use(require('markdown-it-replace-link'), {
    processHTML: true, // defaults to false for backwards compatibility
    replaceLink: function (link, env, token, htmlToken) {
        return link + "?c=" + Date.now();
    }
})

Example

[Hello](test)

and use this

var md = require('markdown-it')({
    replaceLink: function (link, env, token, htmlToken) {
        return "http://me.com/" + link;
    }
}).use(require('markdown-it-replace-link'));

This will result in the link prefixed with the http://me.com/ like:

<p><a href="http://me.com/test">Hello</a></p>

Both images and html links will be processed.

If using this in a browser, the script will create a variable window.markdownitReplaceLink that can be passed to .use().

Testing

To run the tests use:

npm run test

License

MIT

Current Tags

  • 1.2.2                                ...           latest (2 years ago)

6 Versions

  • 1.2.2                                ...           2 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 32
Today 0
This Week 0
This Month 15
Last Day 0
Last Week 14
Last Month 7
Dependencies (0)
None
Dev Dependencies (8)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE