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
unicode-baseby default; how can I add
I've tried adding
../../public/vendor/xregexp/unicode/unicode-categories.jsto 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
How have you tried adding
public/vendor/xregexp/unicode/unicode-categories.jsto the plugin? You should be able to append it by adding the entry into the plugin's
Just to clarify, I believe Julian is talking about copying the script file into your plugin, and trying it that way.
Oh, yeah that'd work. I'm not sure if you could link back via relative path to the script in core, though. Worth trying.
No luck trying
clientScripts(neither the base path as you have it, nor prefixed with "../.."). I don't see
clientScriptsin the docs... how is that different from
Copying the script into my plugin is an acceptable workaround, I suppose.
JavadocMD last edited by JavadocMD
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!
To date you're the only other person who needed XRegExp, so feel special I guess?
Attempting to do Unicode-friendly text manipulation is the worst kind of special.
Ha! Yeah I hear you. Every time I load up a regex library I feel like there ought to be a better way... luckily I'm at least semi-proficient at writing a regular expression, but don't ask me to make sense of one after a week's time LOL