Parse text for keywords and replace with links for documentation
link-injection parses arbitrary text and replaces all keywords with an anchor link to the keyword's reference. Excellent for creating hyperlinks in documentation to other parts of the documentation and who knows what else. What is supported:
Arrayis a keyword, it will not transpose
Float32Arrayinto an anchor
npm install link-injection
parse( text, map, options )Parses string
textreplacing instances of
map's keys with an anchor with an href to the key's value.
caseSensitive: Whether or not the keyword match should be case-sensitive. (default:
varinject =html = '<div>Modern browsers are now implementing a Float32Array type, ' +'which is a typed array version of an Array, except it only holds 32-bit ' +'floating point numbers. The <a href="#Float32Array">Float32Array</a> is ' +'frequently used in 3D WebGL applications and audio processing.</div>';// Using local links, but can be anything -- the keys' values are put into the href attributemap ='Array' : '#Array''Float32Array' : '#Float32Array';var output = inject;console;
Outputs (spacing added for viewing):
Modern browsers are now implementing a Float32Arraytype, which is a typed array version of an Array, except itonly holds 32-bit floating point numbers. The Float32Arrayis frequently used in 3D WebGL applications and audio processing.
npm test from project root -- requires
mocha to be installed globally