Package Exports
- source-fragment
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (source-fragment) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
source-fragment
Fetch source file fragment with highlighting
Install
npm install source-fragmentExample
Suppose we have the code (example.js):
function hello() {
return (
'world' +
'!!!'
);
}To get colored fragment of this code:
var sf = require('source-fragment');
console.log(fs.getColoredSourceFragment('example.js:2:12:5:6', { format: 'tty' }));You'll see in console:

The same but in HTML format:
fs.getColoredSourceFragment('example.js:2:12:5:6', { format: 'html' });
// <div class="j5as83pdmd85mv2c-source">
// <style>...</style>
// <div class="j5as83pdmd85mv2c-line"><span class="j5as83pdmd85mv2c-num"> 2</span>...</div>
// ...
// </div>When pasted on HTML page looks like:

License
MIT