vscode-region-parser
v1.0.1
Published
A VSCode region parser following the region-ast specification
Maintainers
Readme
vscode-region-parser
Table of contents
🍵 Introduction
This library is a VSCode regions parser. It implements the region-ast specification.
This library provides a unified plugin and some utils.
🚀 Get started
This package is published on NPM.
npm install vscode-region-parser🛠️ Usage
Unified plugin
To use with unified, just use the parser plugin:
import { unified } from 'unified'
import { parse } from 'vscode-region-parser'
unified().use(parse)
// Now the processor can parse regionsIf you want to compile (stringify), you should use the region-ast compiler plugin:
import { unified } from 'unified'
import { parse } from 'vscode-region-parser'
import { stringify } from 'region-ast'
unified()
.use(parse)
.use(stringify)
// Now the processor can stringify region ASTExtract regions
You can use extractRegions & extractRegion utils to find all regions
in text content or find region by name:
import { extractRegions, extractRegion } from 'vscode-region-parser'
const content = `
// #region Example
const example = 'example'
// #endregion
// #region Foo
const foo = 'foo'
// #endregion
`
extractRegions(content) // => VSCodeRegion[]
// By name
extractRegion('Example', content) // => VSCodeRegion { name: 'Example' ... }💡 Please check the API documentation.
🤝 Contribute
You would like to contribute to this project? You are welcome!
First, please check:
👑 Author
Made with ❤ by Hervé Perchec
⚖️ License
📰 Changelog
See all changes to this project in the CHANGELOG.md file.
🧱 Related packages
README.md - this file was auto generated with juisy README templater. Don't edit it.
