Skip to content

syntax-tree/unist-util-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unist-util-source Build Status Coverage Status

Unist utility to get the source of a Node or Location.

Installation

npm:

npm install unist-util-source

Usage

var remark = require('remark');
var source = require('./');

remark()
  .use(function () {
    return transformer;
    function transformer(tree, file) {
      var list = tree.children[0].children[0];
      console.log(source(list, file));
    }
  })
  .process('> + **[Hello](./example)**\n> world.');

Yields:

+ **[Hello](./example)**
world.

API

source(value, doc)

Parameters
  • value (Node or Location) — Value to get.
  • doc (VFile or string) — Document in which value exists.
Returns

string? — Source of value in file, if available.

License

MIT © Titus Wormer

About

utility to get the source of a node or position

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •