bluetext
v0.0.2
Published
Blueprints for text! Parses text to a tree according to your rules.
Downloads
7
Readme
bluetext
Blueprints for text! Parses text to a tree according to your rules.
Installation
Browser
<script src="https://cdn.jsdelivr.net/npm/bluetext"></script>
Node
npm install bluetext
const BlueText = require("bluetext");
Usage
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);