Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2
utility to serialize a node, position, or point as a human readable location
License
syntax-tree/unist-util-stringify-position
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
unist utility to pretty print the positional info of a node.
This package is a utility that takes anyunist (whether mdast, hast, etc)node, position, or point, and serializes its positional info.
This utility is useful to display where something occurred in the originaldocument, in one standard way, for humans.For example, when throwing errors or warning messages about something.
This package isESM only.In Node.js (version 16+), install withnpm:
npm install unist-util-stringify-position
In Deno withesm.sh:
import{stringifyPosition}from'https://esm.sh/unist-util-stringify-position@4'
In browsers withesm.sh:
<scripttype="module">import{stringifyPosition}from'https://esm.sh/unist-util-stringify-position@4?bundle'</script>
import{stringifyPosition}from'unist-util-stringify-position'stringifyPosition({line:2,column:3})// => '2:3' (point)stringifyPosition({start:{line:2},end:{line:3}})// => '2:1-3:1' (position)stringifyPosition({type:'text',value:'!',position:{start:{line:5,column:11},end:{line:5,column:12}}})// => '5:11-5:12' (node)
This package exports the identifierstringifyPosition.There is no default export.
Serialize the positional info of a point, position (start and end points), ornode.
node(Node)— node whosepositionfields to serializeposition(Position)— position whosestartandendpoints to serializepoint(Point)— point whoselineandcolumnfields to serialize
Pretty printed positional info of a node (string).
In the format of a rangels:cs-le:ce (when givennode orposition) or apointl:c (when givenpoint), wherel stands for line,c for column,sforstart, ande for end.An empty string ('') is returned if the given value is neithernode,position, norpoint.
This package is fully typed withTypeScript.It exports no additional types.
Projects maintained by the unified collective are compatible with maintainedversions of Node.js.
When we cut a new major release, we drop support for unmaintained versions ofNode.This means we try to keep the current release line,unist-util-stringify-position@^4, compatible with Node.js 16.
This project is safe.
unist-util-generated— check if a node is generatedunist-util-position— get positional info of nodesunist-util-remove-position— remove positional info from treesunist-util-source— get the source of a value (node or position) in a file
Seecontributing.md insyntax-tree/.github for ways to getstarted.Seesupport.md for ways to get help.
This project has acode of conduct.By interacting with this repository, organization, or community you agree toabide by its terms.
About
utility to serialize a node, position, or point as a human readable location
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.