All Projects → martinheidegger → Markdown It Replace Link

martinheidegger / Markdown It Replace Link

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

Programming Languages

javascript
184084 projects - #8 most used programming language

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].