Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including markdown-it-replace-link with all npm packages installed. Try it out:

var markdownItReplaceLink = require("markdown-it-replace-link")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

markdown-it-replace-link v1.1.0

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

markdown-it-replace-link

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

Usage

Enable plugin

var md = require('markdown-it')({
    replaceLink: function (link, env) {
        return link + "?c=" + Date.now();
    }
}).use(require('markdown-it-replace-link')); // <-- this use(package_name) is required

Example

[Hello](test)

and use this

var md = require('markdown-it')({
    replaceLink: function (link, env) {
        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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free