1.1.16 • Published 6 years ago

markdown-plain-link-replacer v1.1.16

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

markdown-plain-link-replacer

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: http://www.google.com would become Source: "[Google](http://www.google.com)", *google.com*, although a template can be used if desired.

Installation

Installation is easiest through npm:

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

Usage

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

var linkReplacer = require('markdown-plain-link-replacer')
  , input = "  http://starwars.wikia.com/wiki/Bespin  "
  ;

linkReplacer.replacePlainLinks(input, function(newMarkdown){
  //newMarkdown: '  "[Bespin](http://starwars.wikia.com/wiki/Bespin)", *wikia.com*  '
	console.log(newMarkdown);
});

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](http://www.google.com) from google.com for url http://www.google.com. The default template is "[{{title}}]({{url}})", *{{source}}*

CLI

$ npm install --global markdown-plain-link-replacer
$ markdown-plain-link-replacer --help

  Usage
    $ markdown-plain-link-replacer "<markdown>"

  Example
    $ markdown-plain-link-replacer "  http://starwars.wikia.com/wiki/Bespin  "
  
  File input example with custom template
    $ markdown-plain-link-replacer -i "sample.md" -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.

License

MIT © Mark Rogers

1.1.16

6 years ago

1.1.14

6 years ago

1.1.12

6 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

8 years ago

1.0.19

8 years ago

1.0.18

8 years ago

1.0.17

8 years ago

1.0.16

8 years ago

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago