showdown-transform-anchor-href
v0.0.1
Published
Transform href attribute of archor tags by given function
Readme
Showdown's transform anchor href extension
Showdown's transform anchor href extension adds support for modifying user provided href.
Working on:
currently only working on node.js
Installation
With npm
npm install showdown-transform-anchor-hrefUsage
const Showdown = require('showdown');
const ShowdownTransformAnchorHref = require('showdown-transform-anchor-href');
// setup a transformation function to do whatever you need with the href attr
ShowdownTransformAnchorHref.addTransformation(function(href) {
return ('http://www.myrwebsite.com/redirect?url='+ new Buffer(href).toString('base64'));
})
showdown.extension('ShowdownTransformAnchorHref', ShowdownTransformAnchorHref);
const converter = new Showdown.Converter({ extensions: ['ShowdownTransformAnchorHref'] });
const input = '[link](example.com)';
const html = converter.makeHtml(input);
console.log(html);