zotero/resource/csl-validator.js

58 lines
648 KiB
JavaScript
Raw Normal View History

2012-07-11 00:00:16 +00:00
/*
Copyright (c) 2003, 2004 David Tolpin, Davidashen
http://davidashen.net/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of Davidashen nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS", AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
and Clark Cooper
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
2013-03-23 21:30:21 +00:00
function da(b){throw b}var ea=void 0,ia=!0,ja=null,ka=!1,qa,ta,Ca,a={arguments:["csl.rnc"],stdin:(function(){return ta<qa.length?qa[ta++]:ja}),stdout:(function(b){Ca+=String.fromCharCode(b)}),stderr:(function(b){Ca+=String.fromCharCode(b)}),noInitialRun:ia};validate=(function(b){for(var c=0,d=b.length,e=0;e<d;e++){var f=b.charCodeAt(e),c=128<=f?2048<=f?c+3:c+2:c+1}qa=new Uint8Array(c);var g,c=qa;g||(g=0);d=b.length;for(e=0;e<d;e++){f=b.charCodeAt(e),128<=f?2048<=f?(c[g]=f>>>12|224,c[g+1]=f>>>6&63|128,c[g+2]=f&63|128,g+=3):(c[g]=f>>>6|192,c[g+1]=f&63|128,g+=2):c[g++]=f}ta=0;Ca="";Da[0]=Da[1];Fa();return Ca});"undefined"===typeof window&&(onmessage=(function(b){postMessage(validate(b.data))}));try{this.Module=a}catch(Ga){this.Module=a={}}var Ia="object"===typeof process&&"function"===typeof require,La="object"===typeof window,Ma="function"===typeof importScripts,Sa=!La&&!Ia&&!Ma;if(Ia){a.print=(function(b){process.stdout.write(b+"\n")});a.printErr=(function(b){process.stderr.write(b+"\n")});var Ta=require("fs"),Va=require("path");a.read=(function(b){var b=Va.normalize(b),c=Ta.readFileSync(b).toString();!c&&b!=Va.resolve(b)&&(b=path.join(__dirname,"..","src",b),c=Ta.readFileSync(b).toString());return c});a.load=(function(b){gb(read(b))});a.arguments||(a.arguments=process.argv.slice(2))}Sa&&(a.print=print,"undefined"!=typeof printErr&&(a.printErr=printErr),a.read="undefined"!=typeof read?read:(function(b){snarf(b)}),a.arguments||("undefined"!=typeof scriptArgs?a.arguments=scriptArgs:"undefined"!=typeof arguments&&(a.arguments=arguments)));La&&!Ma&&(a.print||(a.print=(function(b){console.log(b)})),a.printErr||(a.printErr=(function(b){console.log(b)})));if(La||Ma){a.read=(function(b){var c=new XMLHttpRequest;c.open("GET",b,ka);c.send(ja);return c.responseText}),a.arguments||"undefined"!=typeof arguments&&(a.arguments=arguments)}Ma&&(a.print||(a.print=(function(){})),a.load=importScripts);!Ma&&!La&&!Ia&&!Sa&&da("Unknown runtime environment. Where are we?");function gb(b){eval.call(ja,b)}"undefined"==!a.load&&a.read&&(a.load=(function(b){gb(a.read(b))}));a.print||(a.print=(function(){}));a.printErr||(a.printErr=a.print);a.arguments||(a.arguments=[]);a.print=a.print;a.f=a.printErr;a.preRun||(a.preRun=[]);a.postRun||(a.postRun=[]);function hb(b){if(1==ib){return 1}var c={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+b];c||("*"==b.charAt(b.length-1)?c=ib:"i"==b[0]&&(b=parseInt(b.substr(1)),pb(0==b%8),c=b/8));return c}var qb;function zb(){var b=[],c=0;this.F=(function(d){d&=255;c&&(b.push(d),c--);if(0==b.length){if(128>d){return String.fromCharCode(d)}b.push(d);c=191<d&&224>d?1:2;return""}if(0<c){return""}var d=b[0],e=b[1],f=b[2],d=191<d&&224>d?String.fromCharCode((d&31)<<6|e&63):String.fromCharCode((d&15)<<12|(e&63)<<6|f&63);b.length=0;return d});this.M=(function(b){for(var b=unescape(encodeURIComponent(b)),c=[],f=0;f<b.length;f++){c.push(b.charCodeAt(f))}return c})}function Fb(b){var c=k;k=k+b|0;k=k+3>>2<<2;return c}function Ib(b){var c=Mb;Mb=Mb+b|0;Mb=Mb+3>>2<<2;Mb>=Ob&&Sb("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.");return c}var ib=4,Tb={},p,Ub,Wb;function Sb(b){a.print(b+":\n"+Error().stack);da("Assertion: "+b)}function pb(b,c){b||Sb("Assertion failed: "+c)}var Xb=this;a.ccall=(function(b,c,d,e){return Yb(ac(b),c,d,e)});function ac(b){try{var c=Xb.Module["_"+b];c||(c=eval("_"+b))}catch(d){}pb(c,"Cannot call unknown function "+b+" (perhaps LLVM optimizations or closure removed it?)");return c}function Yb(b,c,d,e){function f(b,c){if("string"==c){if(b===ja||b===ea||0===b){return 0}g||(g=k);var d=Fb(b.length+1);bc(b,d);return d}return"array"==c?(g||(g=k),d=Fb(b.length),cc(b,d),d):b}var g=0,h=0,e=e?e.map((function(b){return f(b,d[h++])})):[];b=b.apply(ja,e);"string"==c?c=dc(b):(pb("array"!=c),c=b);g&&(k=g);return c}a.cwrap=(function(b,c,d){var e=ac(b);return(function(){return Yb(e,c,
a.run=a.U=Fa;a.FS_createDataFile("/","csl-categories.rnc",[10,35,35,32,67,97,116,101,103,111,114,105,101,115,32,102,111,114,32,115,116,121,108,101,32,109,101,116,97,100,97,116,97,10,100,105,118,32,123,10,32,32,99,97,116,101,103,111,114,121,46,99,105,116,97,116,105,111,110,45,102,111,114,109,97,116,32,61,10,32,32,32,32,34,97,117,116,104,111,114,34,32,124,32,34,97,117,116,104,111,114,45,100,97,116,101,34,32,124,32,34,108,97,98,101,108,34,32,124,32,34,110,111,116,101,34,32,124,32,34,110,117,109,101,114,105,99,34,10,32,32,10,32,32,35,35,32,85,115,101,32,34,103,101,110,101,114,105,99,45,98,97,115,101,34,32,102,111,114,32,115,116,121,108,101,115,32,116,104,97,116,32,97,114,101,32,110,111,110,45,100,105,115,99,105,112,108,105,110,101,32,115,112,101,99,105,102,105,99,44,32,115,117,99,104,32,97,115,10,32,32,35,35,32,65,80,65,44,32,72,97,114,118,97,114,100,44,32,101,116,99,46,10,32,32,99,97,116,101,103,111,114,121,46,102,105,101,108,100,32,61,10,32,32,32,32,34,97,110,116,104,114,111,112,111,108,111,103,121,34,10,32,32,32,32,124,32,34,97,115,116,114,111,110,111,109,121,34,10,32,32,32,32,124,32,34,98,105,111,108,111,103,121,34,10,32,32,32,32,124,32,34,98,111,116,97,110,121,34,10,32,32,32,32,124,32,34,99,104,101,109,105,115,116,114,121,34,10,32,32,32,32,124,32,34,99,111,109,109,117,110,105,99,97,116,105,111,110,115,34,10,32,32,32,32,124,32,34,101,110,103,105,110,101,101,114,105,110,103,34,10,32,32,32,32,124,32,34,103,101,110,101,114,105,99,45,98,97,115,101,34,10,32,32,32,32,124,32,34,103,101,111,103,114,97,112,104,121,34,10,32,32,32,32,124,32,34,103,101,111,108,111,103,121,34,10,32,32,32,32,124,32,34,104,105,115,116,111,114,121,34,10,32,32,32,32,124,32,34,104,117,109,97,110,105,116,105,101,115,34,10,32,32,32,32,124,32,34,108,97,119,34,10,32,32,32,32,124,32,34,108,105,110,103,117,105,115,116,105,99,115,34,10,32,32,32,32,124,32,34,108,105,116,101,114,97,116,117,114,101,34,10,32,32,32,32,124,32,34,109,97,116,104,34,10,32,32,32,32,124,32,34,109,101,100,105,99,105,110,101,34,10,32,32,32,32,124,32,34,112,104,105,108,111,115,111,112,104,121,34,10,32,32,32,32,124,32,34,112,104,121,115,105,99,115,34,10,32,32,32,32,124,32,34,112,111,108,105,116,105,99,97,108,95,115,99,105,101,110,99,101,34,10,32,32,32,32,124,32,34,112,115,121,99,104,111,108,111,103,121,34,10,32,32,32,32,124,32,34,115,99,105,101,110,99,101,34,10,32,32,32,32,124,32,34,115,111,99,105,97,108,95,115,99,105,101,110,99,101,34,10,32,32,32,32,124,32,34,115,111,99,105,111,108,111,103,121,34,10,32,32,32,32,124,32,34,116,104,101,111,108,111,103,121,34,10,32,32,32,32,124,32,34,122,111,111,108,111,103,121,34,10,125,10],ia,ia);a.FS_createDataFile("/","csl-data.rnc",[110,97,109,101,115,112,97,99,101,32,100,99,32,61,32,34,104,116,116,112,58,47,47,112,117,114,108,46,111,114,103,47,100,99,47,101,108,101,109,101,110,116,115,47,49,46,49,47,34,10,10,100,99,58,116,105,116,108,101,32,91,32,34,67,105,116,97,116,105,111,110,32,83,116,121,108,101,32,76,97,110,103,117,97,103,101,32,68,97,116,97,34,32,93,10,100,99,58,99,114,101,97,116,111,114,32,91,32,34,66,114,117,99,101,32,68,39,65,114,99,117,115,34,32,93,10,100,99,58,99,111,112,121,114,105,103,104,116,32,91,32,34,66,114,117,99,101,32,68,39,65,114,99,117,115,44,32,50,48,48,57,34,32,93,10,100,99,58,100,101,115,99,114,105,112,116,105,111,110,32,91,32,34,65,32,115,99,104,101,109,97,32,102,111,114,32,116,104,101,32,67,83,76,32,100,97,116,97,32,109,111,100,101,108,46,34,32,93,10,105,110,99,108,117,100,101,32,34,99,115,108,45,116,121,112,101,115,46,114,110,99,34,10,105,110,99,108,117,100,101,32,34,99,115,108,45,118,97,114,105,97,98,108,101,115,46,114,110,99,34,10,115,116,97,114,116,32,61,32,101,108,101,109,101,110,116,32,114,101,102,101,114,101,110,99,101,115,32,123,32,114,101,102,101,114,101,110,99,101,43,32,125,10,114,101,102,101,114,101,110,99,101,32,61,32,101,108,101,109,101,110,116,32,114,101,102,101,114,101,110,99,101,32,123,32,116,121,112,101,44,32,105,100,44,32,117,114,105,63,44,32,99,111,110,116,97,105,110,101,114,45,117,114,105,63,44,32,40,99,111,110,116,114,105,98,117,116,111,114,42,32,38,32,100,97,116,101,42,32,38,32,118,97,114,105,97,98,108,101,