The Wayback Machine - https://web.archive.org/web/20200910231147/https://github.com/syntax-tree/unist-util-position
Skip to content
main
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

readme.md

unist-util-position

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to get the positional info of nodes.

Install

npm:

npm install unist-util-position

Use

var remark = require('remark')
var position = require('unist-util-position')

var tree = remark().parse('# foo\n\n* bar\n')

console.log(position(tree))
console.log(position.start(tree))
console.log(position.end(tree))

console.log(position())
console.log(position.start())
console.log(position.end())

Yields:

{start: {line: 1, column: 1, offset: 0}, end: {line: 4, column: 1, offset: 13}}
{line: 1, column: 1, offset: 0}
{line: 4, column: 1, offset: 13}
{start: {line: null, column: null, offset: null}, end: {line: null, column: null, offset: null}}
{line: null, column: null, offset: null}
{line: null, column: null, offset: null}

API

position(node?)

Get the positional info of node (Node?). Returns Position.

position.start(node?)

position.end(node?)

Get the start or end points in the positional info of node (Node?). Returns Point.

Contribute

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

You can’t perform that action at this time.