mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-14 06:04:22 +08:00
14 lines
440 B
JavaScript
14 lines
440 B
JavaScript
// Names used by renderers are technical tokens, including inside raw examples.
|
|
export function messageContractTokens(message) {
|
|
return [
|
|
...message.matchAll(
|
|
/\$[\p{L}_][\p{L}\p{N}_]*(?:\.[\p{L}_][\p{L}\p{N}_]*)*/gu,
|
|
),
|
|
...message.matchAll(/<\/?[\p{L}][\p{L}\p{N}_-]*(?:\s[^<>]*?)?\s*\/?>/gu),
|
|
]
|
|
.map(([token]) =>
|
|
token.startsWith('<') ? token.match(/^<\/?[^\s/>]+/u)[0] + '>' : token,
|
|
)
|
|
.sort();
|
|
}
|