1.3.7 • Published 1 year ago
tagged-comment-parser v1.3.7
tagged-comment-parser
This is a simple parser for tagged comments.
import { parse, tryParse } from "tagged-comment-parser";
const result = parse("@cached @alias:foo this comment is tagged!");
/*
result:
{
"comment": "this comment is tagged!",
"tags": {
"cached": true,
"alias": "foo"
}
}
*/
// If you want to avoid exceptions, use tryParse
const result = tryParse(null);
/*
result:
{
"comment": undefined,
"tags": {}
}
*/The tags can appear as the first xor last part of the string.
Syntax
'@tag'(no value specified):tagwill have a value oftrue'@tag:something'(value after colon):tagwill be the string'something''@tag(12, "some string")'(parentheses with multiple values):tagwill be the array["12", "some string"]