node package manager



npm package

Build Status Dependency Status Coverage Status Known Vulnerabilities XO code style Gitter

Script to replace a plain text link (ie http://whatever) with a linked title to the link's webpage in markdown. Source: would become Source: "[Google](", **, although a template can used if desired.


Installation is easiest through npm:

npm install markdown-plain-link-replacer --save


markdown-plain-link-replacer can be included as reference.

var linkReplacer = require('markdown-plain-link-replacer')
  , input = "  "
linkReplacer.replacePlainLinks(input, function(newMarkdown){
  //newMarkdown: '  "[Bespin](", **  '

The replacePlainLinks method has the following signature replacePlainLinks(inputMarkdown, calllback, [hoganTemplate]). The hogan template is optional and uses the hogan.js templating engine to style the new markdown. For example, a template = [{{title}}]({{url}}) from {{source}} will produce [Google]( from for url The default template is "[{{title}}]({{url}})", *{{source}}*


$ npm install --global markdown-plain-link-replacer
$ markdown-plain-link-replacer --help
    $ markdown-plain-link-replacer "<markdown>"
    $ markdown-plain-link-replacer "  "
  File input example with custom template
    $ markdown-plain-link-replacer -i "" -t "[{{title}}]({{url}}) from {{source}}"

The cli can take a -i argument for file input, and -t argument for passing in a hogan template string.


MIT © Mark Rogers