https://github.com/weisrc/bluetext
Blueprints for text! Parses text to a tree according to your rules.
https://github.com/weisrc/bluetext
Last synced: about 1 month ago
JSON representation
Blueprints for text! Parses text to a tree according to your rules.
- Host: GitHub
- URL: https://github.com/weisrc/bluetext
- Owner: weisrc
- License: mit
- Created: 2020-11-16T17:00:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-18T18:39:39.000Z (over 4 years ago)
- Last Synced: 2025-04-01T19:38:55.730Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bluetext
Blueprints for text! Parses text to a tree according to your rules.
## Installation
### Browser
```html
```
### Node
```sh
npm install bluetext
``````js
const BlueText = require("bluetext");
```## Usage
```js
let strings = new BlueText("strings", {
escape: "\\", // escape character
start: '"',
end: '"',
alter: (res) => res.match,
});let comments = new BlueText("comments", {
start: "/\\*",
end: "\\*/",
alter: () => BlueText.NONE, // do not add to parent inner.
});let brackets = new BlueText("brackets", {
start: "[", // or just use JS regex
end: "]", // this will get compiled to regex
alter: (res) => res.match, // alter the result
rules: [BlueText.SELF, strings, comments],
});let res = brackets.match('[["Hello"]]');
console.log(res);
```