Closed alanhamlett closed 5 months ago
Alternatively we can use this method signature, maybe it's better?
matchers: [matcher: RegExp | ((_: string) => boolean), style: StyleOrRender][],
matchers: [matcher: RegExp | ((_: string) => boolean), style: StyleOrRender][],
It seems better. Thank you for the suggestion!
Oh... so how can we tokenize the text with the alternative method signature without regex?
I think your first suggestion is OK so anyway I'll merge this PR. Could you send a PR if you found a better way? Thank you!
Released in 0.26.1
.
Thanks! Very quick ❤️
Oops, should have added the regex result too. Adding in #149.
In some cases we need the ability to run custom code when rendering, more than a regex can do. This adds an optional callback function that when provided, should return
true
orfalse
on the given input textstring
. It's backwards compatible with currentcreateRegexRenderer
usages, but allows overwriting the regex using custom code to prevent matching when necessary.