3.0.1 • Published 10 years ago

mansplain v3.0.1

Weekly downloads
37
License
ISC
Repository
github
Last release
10 years ago

mansplain

convert npm man links to html anchor elements

Build Status Code Climate npm version

a tool for converting man-style links to clickable html anchor elements. made p specifically for the npm cli reference

man-explain

installation

npm install mansplain

usage

default usage:

const mansplain = require('mansplain');

var input = "<li>npm-cmd(9)</li>";
var result = mansplain({ input: input });
console.log(result);

//=> '<li><a href="cmd">cmd</a></li>'

opts:

mansplain can take 3 arguments:

  • input: a string to be converted
  • skip: a boolean, if set to true, mansplain will skip the first match, e.g.:

    var input = '<li>npm-cmd(9)</li><li>npm-install(1)</li>'
    var result = mansplain({ input: input, skip: true});
    console.log(result);    
    
    //=> '<li>npm-cmd</li><li><a href="install">npm-install</a></li>'
  • prefix: a hash, serves as a prefix for href value. DO NOT INCLUDE A TRAILING OR LEADING SLASH

    var input = "<li>npm-cmd(1)</li>";
    var result = mansplain({ input: input, prefix: { 1:'cli'}});
    console.log(result);
    
    //=> '<li><a href="cli/cmd">cmd</a></li>'

testing

this package uses mocha framework and the chai assertion library for testing.

npm test

notes

  • matches on a word with digits, hypens, or periods followed by (n), where n is a single digit
  • will remove npm- prefix
3.0.1

10 years ago

3.0.0

10 years ago

2.2.0

10 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.4.0

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago