fretted-strings

Marks on your strings and get it's position.
npm i fretted-strings
Basic usage
import assert from 'node:assert';
import { extract } from 'fretted-strings';
const [content, frets] = extract(
`
hogehoge
%%% ^ ^ %%%
%%% p1 p2 %%%
fooo`,
);
assert.equal(
content,
`
hogehoge
fooo`,
);
assert.equal(frets.p1.pos, 7);
assert.equal(frets.p1.line, 1);
assert.equal(frets.p1.character, 6);
assert.equal(frets.p2.pos, 14);
assert.equal(frets.p2.line, 1);
assert.equal(frets.p2.character, 13);
Use custom tag
import { createExtractFn } from 'fretted-strings';
const extract = createExtractFn('<!--%%', '%%-->');
const [content, frets] = extract(
`
<html>
<div>hogehoge</div>
<!--%% ^ %%-->
<!--%% p %%-->
</html>
`,
);
LICENSE
MIT