mansplain
v3.0.1
Published
convert npm man links to html
Downloads
16
Readme
mansplain
convert npm man links to html anchor elements
a tool for converting man-style links to clickable html anchor elements. made p specifically for the npm cli reference
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 convertedskip
: a boolean, if set totrue
,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