unist-util-position
unist utility to get the position of a node
Last updated 4 years ago by wooorm .
MIT · Repository · Bugs · Original npm
$ cnpm install unist-util-position 
SYNC missed versions from official npm registry.

unist-util-position

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to get the positional info of nodes.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install unist-util-position

Use

import remark from 'remark'
import {position, pointStart, pointEnd} from 'unist-util-position'

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

console.log(position(tree))
console.log(pointStart(tree))
console.log(pointEnd(tree))

console.log(position())
console.log(pointStart())
console.log(pointEnd())

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

This package exports the following identifiers: position, pointStart, and pointEnd. There is no default export.

position(node?)

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

pointStart(node?)

pointEnd(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

Current Tags

  • 4.0.4                                ...           latest (3 years ago)

5 Versions

  • 4.0.4                                ...           3 years ago
  • 4.0.3                                ...           3 years ago
  • 4.0.2                                ...           3 years ago
  • 4.0.1                                ...           4 years ago
  • 3.1.0                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (10)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org