Include XRegExp unicode-categories.js client-side
-
I need additional XRegExp addons for my plugin's client script (to support character categories like \pN). It appears NodeBB includes
xregexp
(core) andunicode-base
by default; how can I addunicode-categories
?I've tried adding
../../public/vendor/xregexp/unicode/unicode-categories.js
to my plugin's scripts as well as modules to no avail (my understanding of what modules is used for is a little fuzzy). In any case, I get "SyntaxError: Unknown Unicode token \pN" when the script runs.\pL works fine, presumably because that's provided in
unicode-base
.Thanks!
-
Just to clarify, I believe Julian is talking about copying the script file into your plugin, and trying it that way.
-
-
Oh wait! Fixed it. It appears the issue was simply script initialization order. My plugin.json now has this:
"scripts": [ "../../public/vendor/xregexp/unicode/unicode-categories.js", "public/main.js" ],
(Where main.js is my script that uses XRegExp.) And it works fine. The first time I tried this, the scripts were in reverse order. No need to copy the script into my plugin, though that did help me figure out the issue. Thanks for the suggestion!
-