commit b1cc6e260e1d0fb42fe181f979037581453b7ec9
parent 4b13987c7e83110ff0a3c479a350b4943a7c273a
Author: aurimasv <aurimas.dev@gmail.com>
Date: Wed, 19 Dec 2012 06:36:08 -0600
Load XRegExp into Zotero.XRegExp and Zotero.Utilities.XRegExp and make it accessible from translators.
Diffstat:
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -1668,5 +1668,11 @@ Zotero.Utilities = {
}
}
return length;
- }
+ },
+
+ /**
+ * Provides unicode support and other additional features for regular expressions
+ * See https://github.com/slevithan/xregexp for usage
+ */
+ "XRegExp": Zotero.XRegExp
}
diff --git a/chrome/content/zotero/xpcom/xregexp/init.js b/chrome/content/zotero/xpcom/xregexp/init.js
@@ -0,0 +1,17 @@
+//List of files to be loaded by Zotero
+var load = [
+ /**Core functions**/
+ 'xregexp',
+
+ /**Addons**/
+ 'addons/build', //adds ability to "build regular expressions using named subpatterns, for readability and pattern reuse"
+ 'addons/matchrecursive', //adds ability to "match recursive constructs using XRegExp pattern strings as left and right delimiters"
+
+ /**Unicode support**/
+ 'addons/unicode/unicode-base', //required for all other unicode packages. Adds \p{Letter} category
+
+ 'addons/unicode/unicode-blocks', //adds support for all Unicode blocks (e.g. InArabic, InCyrillic_Extended_A, etc.)
+ 'addons/unicode/unicode-categories', //adds support for all Unicode categories (e.g. Punctuation, Lowercase_Letter, etc.)
+ 'addons/unicode/unicode-properties', //adds Level 1 Unicode properties (e.g. Uppercase, White_Space, etc.)
+ 'addons/unicode/unicode-scripts' //adds support for all Unicode scripts (e.g. Gujarati, Cyrillic, etc.)
+];
+\ No newline at end of file
diff --git a/components/zotero-service.js b/components/zotero-service.js
@@ -206,6 +206,20 @@ function makeZoteroContext(isConnector) {
.getService(Ci.mozIJSSubScriptLoader)
.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
+ //Load XRegExp object into Zotero.XRegExp
+ //This needs to be loaded before Zotero.Utilities so it gets included in Zotero.Utilities.Translate
+ //The files that need to be loaded are defined in the init.js file
+ var xregexpContext = {};
+ Cc["@mozilla.org/moz/jssubscript-loader;1"]
+ .getService(Ci.mozIJSSubScriptLoader)
+ .loadSubScript("chrome://zotero/content/xpcom/xregexp/init.js", xregexpContext);
+ for(var i=0; i<xregexpContext.load.length; i++) {
+ Cc["@mozilla.org/moz/jssubscript-loader;1"]
+ .getService(Ci.mozIJSSubScriptLoader)
+ .loadSubScript("chrome://zotero/content/xpcom/xregexp/" + xregexpContext.load[i] + ".js", xregexpContext);
+ }
+ zContext.Zotero.XRegExp = xregexpContext.XRegExp;
+
// Load remaining xpcomFiles
for (var i=1; i<xpcomFilesAll.length; i++) {
try {