Package Exports
- unist-util-source
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 (unist-util-source) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
unist-util-source

Unist utility to get the source of a Node or Location.
Installation
npm:
npm install unist-util-source
Usage
Say we have the following file, example.md
:
> + **[Hello](./example)**
> world.
And our script, example.js
, looks as follows:
var vfile = require('to-vfile');
var unified = require('unified');
var parse = require('remark-parse');
var source = require('unist-util-source');
var file = vfile.readSync('example.md');
var tree = unified().use(parse).parse(file);
var list = tree.children[0].children[0];
console.log(source(list, file));
Now, running node example
yields:
+ **[Hello](./example)**
world.
API
source(value, doc)
Parameters
Returns
string?
— Source of value
in file
, if available.