trainbbcode 0.2.7 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/Manifest +44 -0
  2. data/Rakefile +2 -1
  3. data/init.rb +1 -0
  4. data/lib/trainbbcode.rb +66 -29
  5. data/rails_generators/syntaxhighlighter/syntaxhighlighter_generator.rb +30 -0
  6. data/rails_generators/syntaxhighlighter/templates/scripts/clipboard.swf +0 -0
  7. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushAS3.js +61 -0
  8. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushBash.js +66 -0
  9. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushCSharp.js +67 -0
  10. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushColdFusion.js +102 -0
  11. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushCpp.js +99 -0
  12. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushCss.js +93 -0
  13. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushDelphi.js +57 -0
  14. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushDiff.js +43 -0
  15. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushErlang.js +54 -0
  16. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushGroovy.js +69 -0
  17. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushJScript.js +52 -0
  18. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushJava.js +59 -0
  19. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushJavaFX.js +60 -0
  20. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushPerl.js +74 -0
  21. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushPhp.js +91 -0
  22. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushPlain.js +35 -0
  23. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushPowerShell.js +76 -0
  24. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushPython.js +66 -0
  25. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushRuby.js +57 -0
  26. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushScala.js +53 -0
  27. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushSql.js +68 -0
  28. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushVb.js +58 -0
  29. data/rails_generators/syntaxhighlighter/templates/scripts/shBrushXml.js +71 -0
  30. data/rails_generators/syntaxhighlighter/templates/scripts/shCore.js +30 -0
  31. data/rails_generators/syntaxhighlighter/templates/scripts/shLegacy.js +30 -0
  32. data/rails_generators/syntaxhighlighter/templates/src/shCore.js +2077 -0
  33. data/rails_generators/syntaxhighlighter/templates/src/shLegacy.js +172 -0
  34. data/rails_generators/syntaxhighlighter/templates/styles/help.png +0 -0
  35. data/rails_generators/syntaxhighlighter/templates/styles/magnifier.png +0 -0
  36. data/rails_generators/syntaxhighlighter/templates/styles/page_white_code.png +0 -0
  37. data/rails_generators/syntaxhighlighter/templates/styles/page_white_copy.png +0 -0
  38. data/rails_generators/syntaxhighlighter/templates/styles/printer.png +0 -0
  39. data/rails_generators/syntaxhighlighter/templates/styles/shCore.css +330 -0
  40. data/rails_generators/syntaxhighlighter/templates/styles/shThemeDefault.css +173 -0
  41. data/rails_generators/syntaxhighlighter/templates/styles/shThemeDjango.css +176 -0
  42. data/rails_generators/syntaxhighlighter/templates/styles/shThemeEclipse.css +190 -0
  43. data/rails_generators/syntaxhighlighter/templates/styles/shThemeEmacs.css +175 -0
  44. data/rails_generators/syntaxhighlighter/templates/styles/shThemeFadeToGrey.css +177 -0
  45. data/rails_generators/syntaxhighlighter/templates/styles/shThemeMidnight.css +175 -0
  46. data/rails_generators/syntaxhighlighter/templates/styles/shThemeRDark.css +175 -0
  47. data/trainbbcode.gemspec +6 -3
  48. metadata +56 -4
@@ -0,0 +1,57 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ SyntaxHighlighter.brushes.Ruby = function()
31
+ {
32
+ // Contributed by Erik Peterson.
33
+
34
+ var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' +
35
+ 'END end ensure false for if in module new next nil not or raise redo rescue retry return ' +
36
+ 'self super then throw true undef unless until when while yield';
37
+
38
+ var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' +
39
+ 'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' +
40
+ 'ThreadGroup Thread Time TrueClass';
41
+
42
+ this.regexList = [
43
+ { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
44
+ { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
45
+ { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
46
+ { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants
47
+ { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols
48
+ { regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables
49
+ { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
50
+ { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins
51
+ ];
52
+
53
+ this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
54
+ };
55
+
56
+ SyntaxHighlighter.brushes.Ruby.prototype = new SyntaxHighlighter.Highlighter();
57
+ SyntaxHighlighter.brushes.Ruby.aliases = ['ruby', 'rails', 'ror', 'rb'];
@@ -0,0 +1,53 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ SyntaxHighlighter.brushes.Scala = function()
31
+ {
32
+ // Contributed by Yegor Jbanov and David Bernard.
33
+
34
+ var keywords = 'val sealed case def true trait implicit forSome import match object null finally super ' +
35
+ 'override try lazy for var catch throw type extends class while with new final yield abstract ' +
36
+ 'else do if return protected private this package false';
37
+
38
+ var keyops = '[_:=><%#@]+';
39
+
40
+ this.regexList = [
41
+ { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
42
+ { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
43
+ { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // multi-line strings
44
+ { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double-quoted string
45
+ { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
46
+ { regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // numbers
47
+ { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
48
+ { regex: new RegExp(keyops, 'gm'), css: 'keyword' } // scala keyword
49
+ ];
50
+ }
51
+
52
+ SyntaxHighlighter.brushes.Scala.prototype = new SyntaxHighlighter.Highlighter();
53
+ SyntaxHighlighter.brushes.Scala.aliases = ['scala'];
@@ -0,0 +1,68 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ SyntaxHighlighter.brushes.Sql = function()
31
+ {
32
+ var funcs = 'abs avg case cast coalesce convert count current_timestamp ' +
33
+ 'current_user day isnull left lower month nullif replace right ' +
34
+ 'session_user space substring sum system_user upper user year';
35
+
36
+ var keywords = 'absolute action add after alter as asc at authorization begin bigint ' +
37
+ 'binary bit by cascade char character check checkpoint close collate ' +
38
+ 'column commit committed connect connection constraint contains continue ' +
39
+ 'create cube current current_date current_time cursor database date ' +
40
+ 'deallocate dec decimal declare default delete desc distinct double drop ' +
41
+ 'dynamic else end end-exec escape except exec execute false fetch first ' +
42
+ 'float for force foreign forward free from full function global goto grant ' +
43
+ 'group grouping having hour ignore index inner insensitive insert instead ' +
44
+ 'int integer intersect into is isolation key last level load local max min ' +
45
+ 'minute modify move name national nchar next no numeric of off on only ' +
46
+ 'open option order out output partial password precision prepare primary ' +
47
+ 'prior privileges procedure public read real references relative repeatable ' +
48
+ 'restrict return returns revoke rollback rollup rows rule schema scroll ' +
49
+ 'second section select sequence serializable set size smallint static ' +
50
+ 'statistics table temp temporary then time timestamp to top transaction ' +
51
+ 'translation trigger true truncate uncommitted union unique update values ' +
52
+ 'varchar varying view when where with work';
53
+
54
+ var operators = 'all and any between cross in join like not null or outer some';
55
+
56
+ this.regexList = [
57
+ { regex: /--(.*)$/gm, css: 'comments' }, // one line and multiline comments
58
+ { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings
59
+ { regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // single quoted strings
60
+ { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'color2' }, // functions
61
+ { regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such
62
+ { regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
63
+ ];
64
+ };
65
+
66
+ SyntaxHighlighter.brushes.Sql.prototype = new SyntaxHighlighter.Highlighter();
67
+ SyntaxHighlighter.brushes.Sql.aliases = ['sql'];
68
+
@@ -0,0 +1,58 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ SyntaxHighlighter.brushes.Vb = function()
31
+ {
32
+ var keywords = 'AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto ' +
33
+ 'Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate ' +
34
+ 'CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType ' +
35
+ 'Date Decimal Declare Default Delegate Dim DirectCast Do Double Each ' +
36
+ 'Else ElseIf End Enum Erase Error Event Exit False Finally For Friend ' +
37
+ 'Function Get GetType GoSub GoTo Handles If Implements Imports In ' +
38
+ 'Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module ' +
39
+ 'MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing ' +
40
+ 'NotInheritable NotOverridable Object On Option Optional Or OrElse ' +
41
+ 'Overloads Overridable Overrides ParamArray Preserve Private Property ' +
42
+ 'Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume ' +
43
+ 'Return Select Set Shadows Shared Short Single Static Step Stop String ' +
44
+ 'Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until ' +
45
+ 'Variant When While With WithEvents WriteOnly Xor';
46
+
47
+ this.regexList = [
48
+ { regex: /'.*$/gm, css: 'comments' }, // one line comments
49
+ { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
50
+ { regex: /^\s*#.*$/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
51
+ { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // vb keyword
52
+ ];
53
+
54
+ this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
55
+ };
56
+
57
+ SyntaxHighlighter.brushes.Vb.prototype = new SyntaxHighlighter.Highlighter();
58
+ SyntaxHighlighter.brushes.Vb.aliases = ['vb', 'vbnet'];
@@ -0,0 +1,71 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ SyntaxHighlighter.brushes.Xml = function()
31
+ {
32
+ function process(match, regexInfo)
33
+ {
34
+ var constructor = SyntaxHighlighter.Match,
35
+ code = match[0],
36
+ tag = new XRegExp('(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
37
+ result = []
38
+ ;
39
+
40
+ if (match.attributes != null)
41
+ {
42
+ var attributes,
43
+ regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
44
+ '\\s*=\\s*' +
45
+ '(?<value> ".*?"|\'.*?\'|\\w+)',
46
+ 'xg');
47
+
48
+ while ((attributes = regex.exec(code)) != null)
49
+ {
50
+ result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
51
+ result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
52
+ }
53
+ }
54
+
55
+ if (tag != null)
56
+ result.push(
57
+ new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
58
+ );
59
+
60
+ return result;
61
+ }
62
+
63
+ this.regexList = [
64
+ { regex: new XRegExp('(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)', 'gm'), css: 'color2' }, // <![ ... [ ... ]]>
65
+ { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // <!-- ... -->
66
+ { regex: new XRegExp('(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)', 'sg'), func: process }
67
+ ];
68
+ };
69
+
70
+ SyntaxHighlighter.brushes.Xml.prototype = new SyntaxHighlighter.Highlighter();
71
+ SyntaxHighlighter.brushes.Xml.aliases = ['xml', 'xhtml', 'xslt', 'html'];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('c(!1q.2X){h 2X=l(){h p={6b:{"1s-R":"","84-2y":1,"83-2y-7W":I,"1I":v,"8d-89":I,"1H-2Q":4,"3g":I,"1w":I,"66":N,"8k-8l":I,"88":N,"5h-1p":I,"1L-1l":N},M:{4T:I,69:v,5l:16,5k:16,8B:N,8f:N,8s:"54",1f:{5q:"53 1g",5d:"9N 1g",5i:"9O 6q 6p",78:"9M C 9L 1V 9I 6p 9J",3t:"3t",6C:"?",1A:"2X\\n\\n",6T:"9K\'t 9P 2O D: ",7x:"9Q 9W\'t 9X D 1L-1l 9V: ",77:"<!9U 1L 9R \\"-//9S//6H 9T 1.0 9H//9G\\" \\"2s://5x.6x.6B/9v/6D/6H/6D-9w.9u\\"><1L 9t=\\"2s://5x.6x.6B/9s/9x\\"><6z><9y 2s-9E=\\"9F-9D\\" 63=\\"1X/1L; 9C=9z-8\\" /><3i>9A 2X</3i></6z><33 1m=\\"39-9Y:9Z,an,ao,am-al;ai-3f:#aj;3f:#ak;39-2Q:ap;1X-6G:6u;\\"><A 1m=\\"1X-6G:6u;6w-4w:aw;\\"><A 1m=\\"39-2Q:au-at;\\">2X</A><A 1m=\\"39-2Q:.as;6w-9p:ah;\\"><A>6O 2.1.ag (a5 15 6h)</A><A><a 27=\\"2s://6I.3k\\" a6=\\"4k\\" 1m=\\"3f:#6F;1X-6t:6L;\\">2s://6I.3k</a></A><A>a3 a0 a1 f 1l, a2 <a 27=\\"a7://5x.a8.3k/ae-af/ad?ac=a9-aa&ab=ax\\" 1m=\\"3f:#6F;1X-6t:6L;\\">8R</a> 6q 8Q 8O 8W!</A></A><A>8V C 8U 8X.</A><A>8K 8N-6h 8M 8S.</A></A></33></1L>"},8u:N},1r:{4Z:v,9o:v,3m:v,6f:{}},2d:{},8h:{9g:/\\/\\*[\\s\\S]*?\\*\\//3b,9d:/\\/\\/.*$/3b,9e:/#.*$/3b,9j:/"([^\\\\"\\n]|\\\\.)*"/g,9n:/\'([^\\\\\'\\n]|\\\\.)*\'/g,9m:/"([^\\\\"]|\\\\.)*"/g,8Y:/\'([^\\\\\']|\\\\.)*\'/g,9k:/(&X;|<)!--[\\s\\S]*?--(&Z;|>)/3b,43:/&X;\\w+:\\/\\/[\\w-.\\/?%&=@:;]*&Z;|\\w+:\\/\\/[\\w-.\\/?%&=@:;]*/g,9c:{G:/(&X;|<)\\?=?/g,1d:/\\?(&Z;|>)/g},93:{G:/(&X;|<)%=?/g,1d:/%(&Z;|>)/g},92:{G:/(&X;|<)\\s*1l.*?(&Z;|>)/4e,1d:/(&X;|<)\\/\\s*1l\\s*(&Z;|>)/4e}},1w:{1c:l(3O){h 3T=Q.22("3Y"),5s=p.1w.7d;3T.L="1w";D(h 30 1V 5s){h 6i=5s[30],5t=W 6i(3O),1Y=5t.1c();3O.6g[30]=5t;c(1Y==v){1J}c(7X(1Y)=="91"){1Y=p.1w.6m(1Y,3O.1k,30)}1Y.L+="5v "+30;3T.2p(1Y)}q 3T},6m:l(5L,7j,5K){h a=Q.22("a"),5N=a.1m,5D=p.M,5M=5D.5l,5J=5D.5k;a.27="#"+5K;a.3i=5L;a.5j=7j;a.76=5K;a.1Q=5L;c(40(5M)==N){5N.26=5M+"75"}c(40(5J)==N){5N.2e=5J+"75"}a.9l=l(e){97{p.1w.6M(f,e||1q.6Y,f.5j,f.76)}98(e){p.B.1A(e.6n)}q N};q a},6M:l(7i,7g,7b,7h,7f){h 5G=p.1r.6f[7b],5H;c(5G==v||(5H=5G.6g[7h])==v){q v}q 5H.2z(7i,7g,7f)},7d:{5q:l(5b){f.1c=l(){c(5b.V("66")!=I){q}q p.M.1f.5q};f.2z=l(5c,8T,8P){h A=5b.A;5c.7y.4p(5c);A.L=A.L.E("5O","")}},5d:l(6R){f.1c=l(){q p.M.1f.5d};f.2z=l(b1,bU,bV){h 3J=p.B.3d(6R.5g).E(/</g,"&X;"),2A=p.B.4z("","4k",bT,bS,"bQ=0, bR=1, bW=0, 7a=1");3J=p.B.2T(3J);2A.Q.3D("<54>"+3J+"</54>");2A.Q.4o()}},5i:l(64){h 3C,c2,6a=64.1k;f.1c=l(){h 2V=p.M;c(2V.69==v){q v}l 1E(56){h 5m="";D(h 5f 1V 56){5m+="<c1 R=\'"+5f+"\' 24=\'"+56[5f]+"\'/>"}q 5m};l 2i(5n){h 5p="";D(h 5o 1V 5n){5p+=" "+5o+"=\'"+5n[5o]+"\'"}q 5p};h 67={26:2V.5l,2e:2V.5k,1k:6a+"bY",4r:"bZ/x-71-6V",3i:p.M.1f.5i},5V={bE:"ay",bD:"bC",bA:"5j="+6a,c4:"N"},5U=2V.69,3x;c(/bG/i.1R(6K.7k)){3x="<4h"+2i({bH:"bM:bN-bL-bK-bI-bJ",c3:"2s://ck.cj.3k/cm/71/c9/6V/c8.c7#6O=9,0,0,0"})+2i(67)+">"+1E(5V)+1E({c6:5U})+"</4h>"}F{3x="<ca"+2i(67)+2i(5V)+2i({cg:5U})+"/>"}3C=Q.22("A");3C.1Q=3x;q 3C};f.2z=l(cf,ce,62){h 7c=62.cd;6U(7c){2K"7q":h 61=p.B.2T(p.B.3d(64.5g).E(/&X;/g,"<").E(/&Z;/g,">").E(/&aT;/g,"&"));c(1q.74){1q.74.aU("1X",61)}F{q p.B.2T(61)}2K"aR":p.B.1A(p.M.1f.78);2h;2K"aP":p.B.1A(62.6n);2h}}},aV:l(65){f.1c=l(){q p.M.1f.3t};f.2z=l(aW,bz,b0){h 1Z=Q.22("aZ"),1N=v;c(p.1r.3m!=v){Q.33.4p(p.1r.3m)}p.1r.3m=1Z;1Z.1m.aX="aY:aO;26:6r;2e:6r;G:-6j;4w:-6j;";Q.33.2p(1Z);1N=1Z.5Q.Q;6J(1N,1q.Q);1N.3D("<A 1s=\\""+65.A.L.E("5O","")+" aD\\">"+65.A.1Q+"</A>");1N.4o();1Z.5Q.4F();1Z.5Q.3t();l 6J(6N,6E){h 2I=6E.4O("4n");D(h i=0;i<2I.u;i++){c(2I[i].6y.6P()=="6A"&&/aE\\.1a$/.1R(2I[i].27)){6N.3D("<4n 4r=\\"1X/1a\\" 6y=\\"6A\\" 27=\\""+2I[i].27+"\\"></4n>")}}}}},az:l(aA){f.1c=l(){q p.M.1f.6C};f.2z=l(aF,aG){h 2A=p.B.4z("","4k",aM,aK,"7a=0"),1N=2A.Q;1N.3D(p.M.1f.77);1N.4o();2A.4F()}}}},B:{Y:l(49,73,3y){3y=3e.aH(3y||0,0);D(h i=3y;i<49.u;i++){c(49[i]==73){q i}}q-1},6d:l(72){q 72+3e.aI(3e.b2()*b3).2u()},6c:l(51,4L){h 3h={},1W;D(1W 1V 51){3h[1W]=51[1W]}D(1W 1V 4L){3h[1W]=4L[1W]}q 3h},80:l(4J){6U(4J){2K"I":q I;2K"N":q N}q 4J},4z:l(43,6W,4B,4H,2N){h x=(6X.26-4B)/2,y=(6X.2e-4H)/2;2N+=", G="+x+", 4w="+y+", 26="+4B+", 2e="+4H;2N=2N.E(/^,/,"");h 4E=1q.bk(43,6W,2N);4E.4F();q 4E},7C:l(1G,1T,1U){c(1G.6Z){1G["e"+1T+1U]=1U;1G[1T+1U]=l(){1G["e"+1T+1U](1q.6Y)};1G.6Z("bw"+1T,1G[1T+1U])}F{1G.bv(1T,1U,N)}},1A:l(z){1A(p.M.1f.1A+z)},4u:l(4N,6Q){h 2r=p.1r.4Z,3V=v;c(2r==v){2r={};D(h 2L 1V p.2d){h 42=p.2d[2L].bu;c(42==v){1J}p.2d[2L].R=2L.6P();D(h i=0;i<42.u;i++){2r[42[i]]=2L}}p.1r.4Z=2r}3V=p.2d[2r[4N]];c(3V==v&&6Q!=N){p.B.1A(p.M.1f.6T+4N)}q 3V},46:l(z,6S){h 2E=z.1P("\\n");D(h i=0;i<2E.u;i++){2E[i]=6S(2E[i])}q 2E.5A("\\n")},8C:l(z){q z.E(/^[ ]*[\\n]+|[\\n]*[ ]*$/g,"")},8H:l(z){h 3X,45={},4P=W U("^\\\\[(?<4c>(.*?))\\\\]$"),7e=W U("(?<R>[\\\\w-]+)"+"\\\\s*:\\\\s*"+"(?<24>"+"[\\\\w-%#]+|"+"\\\\[.*?\\\\]|"+"\\".*?\\"|"+"\'.*?\'"+")\\\\s*;?","g");2j((3X=7e.T(z))!=v){h 2f=3X.24.E(/^[\'"]|[\'"]$/g,"");c(2f!=v&&4P.1R(2f)){h m=4P.T(2f);2f=m.4c.u>0?m.4c.1P(/\\s*,\\s*/):[]}45[3X.R]=2f}q 45},7K:l(z,1a){c(z==v||z.u==0||z=="\\n"){q z}z=z.E(/</g,"&X;");z=z.E(/ {2,}/g,l(m){h 4t="";D(h i=0;i<m.u-1;i++){4t+="&2B;"}q 4t+" "});c(1a!=v){z=p.B.46(z,l(2l){c(2l.u==0){q""}h 3W="";2l=2l.E(/^(&2B;| )+/,l(s){3W=s;q""});c(2l.u==0){q 3W}q 3W+"<C 1s=\\""+1a+"\\">"+2l+"</C>"})}q z},7V:l(6l,6o){h 32=6l.2u();2j(32.u<6o){32="0"+32}q 32},6k:l(){h 3w=Q.22("A"),3B,3o=0,44=Q.33,1k=p.B.6d("6k"),36="<A 1s=\\"",2Y="</A>",4U="</4G>";3w.1Q=36+"6e\\">"+36+"1p\\">"+36+"2y\\">"+36+"63"+"\\"><4G 1s=\\"b5\\"><4G 1k=\\""+1k+"\\">&2B;"+4U+4U+2Y+2Y+2Y+2Y;44.2p(3w);3B=Q.bb(1k);c(/bg/i.1R(6K.7k)){h 6v=1q.be(3B,v);3o=85(6v.bc("26"))}F{3o=3B.bd}44.4p(3w);q 3o},8b:l(79,6s){h 1H="";D(h i=0;i<6s;i++){1H+=" "}q 79.E(/\\t/g,1H)},8a:l(2Z,4f){h bF=2Z.1P("\\n"),1H="\\t",4d="";D(h i=0;i<50;i++){4d+=" "}l 8x(3s,18,8A){q 3s.29(0,18)+4d.29(0,8A)+3s.29(18+1,3s.u)};2Z=p.B.46(2Z,l(20){c(20.Y(1H)==-1){q 20}h 18=0;2j((18=20.Y(1H))!=-1){h 8w=4f-18%4f;20=8x(20,18,8w)}q 20});q 2Z},3d:l(z){h br=/<br\\s*\\/?>|&X;br\\s*\\/?&Z;/4e;c(p.M.8B==I){z=z.E(br,"\\n")}c(p.M.8f==I){z=z.E(br,"")}q z},2G:l(z){q z.E(/^\\s+|\\s+$/g,"")},2T:l(z){h 21=p.B.3d(z).1P("\\n"),bf=W bh(),8D=/^\\s*/,2a=ba;D(h i=0;i<21.u&&2a>0;i++){h 4x=21[i];c(p.B.2G(4x).u==0){1J}h 4I=8D.T(4x);c(4I==v){q z}2a=3e.2a(4I[0].u,2a)}c(2a>0){D(h i=0;i<21.u;i++){21[i]=21[i].29(2a)}}q 21.5A("\\n")},82:l(35,31){c(35.H<31.H){q-1}F{c(35.H>31.H){q 1}F{c(35.u<31.u){q-1}F{c(35.u>31.u){q 1}}}}q 0},2D:l(8q,34){l 8n(4D,8r){q[W p.4v(4D[0],4D.H,8r.1a)]};h b4=0,4s=v,3L=[],8p=34.4X?34.4X:8n;2j((4s=34.3K.T(8q))!=v){3L=3L.2t(8p(4s,34))}q 3L},8m:l(8o){h X="&X;",Z="&Z;";q 8o.E(p.8h.43,l(m){h 4j="",47="";c(m.Y(X)==0){47=X;m=m.3U(X.u)}c(m.Y(Z)==m.u-Z.u){m=m.3U(0,m.u-Z.u);4j=Z}q 47+"<a 27=\\""+m+"\\">"+m+"</a>"+4j})},8v:l(){h 3N=Q.4O("1l"),4i=[];D(h i=0;i<3N.u;i++){c(3N[i].4r=="6e"){4i.K(3N[i])}}q 4i},8I:l(4b){h 4q="<![b6[",3S="]]>",1v=p.B.2G(4b),3R=N;c(1v.Y(4q)==0){1v=1v.3U(4q.u);3R=I}c(1v.Y(3S)==1v.u-3S.u){1v=1v.3U(0,1v.u-3S.u);3R=I}q 3R?1v:4b}},1I:l(8E,4R){l 8e(4g){h 4Q=[];D(h i=0;i<4g.u;i++){4Q.K(4g[i])}q 4Q};h 2q=4R?[4R]:8e(Q.4O(p.M.8s)),8J="1Q",2k=v,4S=p.M;c(4S.4T){2q=2q.2t(p.B.8v())}c(2q.u===0){q}D(h i=0;i<2q.u;i++){h 2M=2q[i],28=p.B.8H(2M.L),1D,2W,25;28=p.B.6c(8E,28);1D=28["2O"];c(1D==v){1J}c(28["1L-1l"]=="I"||p.6b["1L-1l"]==I){2k=W p.4a(1D);1D="b9"}F{h 3P=p.B.4u(1D);c(3P){1D=3P.R;2k=W 3P()}F{1J}}2W=2M[8J];c(4S.4T){2W=p.B.8I(2W)}28["2O-R"]=1D;2k.1I(2W,28);25=2k.A;c(p.M.8u){25=Q.22("bj");25.24=2k.A.1Q;25.1m.26="bt";25.1m.2e="bx"}2M.7y.bs(25,2M)}},bq:l(7H){p.B.7C(1q,"bl",l(){p.1I(7H)})}};p.4v=l(4A,7G,1a){f.24=4A;f.H=7G;f.u=4A.u;f.1a=1a;f.5Y=v};p.4v.14.2u=l(){q f.24};p.4a=l(4K){h 3z=p.B.4u(4K),2g,4W=W p.2d.bm(),bn=v;c(3z==v){q}2g=W 3z();f.4m=4W;c(2g.3I==v){p.B.1A(p.M.1f.7x+4K);q}4W.59.K({3K:2g.3I.C,4X:7p});l 3A(4Y,7w){D(h j=0;j<4Y.u;j++){4Y[j].H+=7w}};l 7p(19,bp){h 7n=19.C,1o=[],4M=2g.59,7l=19.H+19.G.u,2U=2g.3I,1n;D(h i=0;i<4M.u;i++){1n=p.B.2D(7n,4M[i]);3A(1n,7l);1o=1o.2t(1n)}c(2U.G!=v&&19.G!=v){1n=p.B.2D(19.G,2U.G);3A(1n,19.H);1o=1o.2t(1n)}c(2U.1d!=v&&19.1d!=v){1n=p.B.2D(19.1d,2U.1d);3A(1n,19.H+19[0].bo(19.1d));1o=1o.2t(1n)}D(h j=0;j<1o.u;j++){1o[j].5Y=3z.R}q 1o}};p.4a.14.1I=l(7t,7s){f.4m.1I(7t,7s);f.A=f.4m.A};p.7I=l(){};p.7I.14={V:l(7J,7Z){h 4l=f.1E[7J];q p.B.80(4l==v?7Z:4l)},1c:l(7Y){q Q.22(7Y)},8i:l(2F,81){h 3u=[];c(2F!=v){D(h i=0;i<2F.u;i++){c(7X(2F[i])=="4h"){3u=3u.2t(p.B.2D(81,2F[i]))}}}q 3u.aB(p.B.82)},86:l(){h 23=f.2C;D(h i=0;i<23.u;i++){c(23[i]===v){1J}h 2x=23[i],4V=2x.H+2x.u;D(h j=i+1;j<23.u&&23[i]!==v;j++){h 1S=23[j];c(1S===v){1J}F{c(1S.H>4V){2h}F{c(1S.H==2x.H&&1S.u>2x.u){f.2C[i]=v}F{c(1S.H>=2x.H&&1S.H<4V){f.2C[j]=v}}}}}}},8t:l(2H){h 3r=2H.1P(/\\n/g),3n=85(f.V("84-2y")),2v=f.V("83-2y-7W"),7N=f.V("1I",[]),7U=f.V("3g");2H="";c(2v==I){2v=(3n+3r.u-1).2u().u}F{c(40(2v)==I){2v=0}}D(h i=0;i<3r.u;i++){h 1x=3r[i],60=/^(&2B;|\\s)+/.T(1x),52="aN"+(i%2==0?1:2),7F=p.B.7V(3n+i,2v),7P=p.B.Y(7N,(3n+i).2u())!=-1,2S=v;c(60!=v){2S=60[0].2u();1x=1x.29(2S.u)}1x=p.B.2G(1x);c(1x.u==0){1x="&2B;"}c(7P){52+=" aQ"}2H+="<A 1s=\\"2y "+52+"\\">"+"<7L>"+"<7T>"+(7U?"<3F 1s=\\"aS\\"><C>"+7F+"</C></3F>":"")+"<3F 1s=\\"63\\">"+(2S!=v?"<C 1s=\\"by\\">"+2S.E(" ","&2B;")+"</C>":"")+1x+"</3F>"+"</7T>"+"</7L>"+"</A>"}q 2H},8y:l(5X,5T){h 18=0,3c="",3a=p.B.7K,5S=f.V("2O-R","");l 5W(5Z){h 5R=5Z?(5Z.5Y||5S):5S;q 5R?5R+" ":""};D(h i=0;i<5T.u;i++){h 1y=5T[i],3G;c(1y===v||1y.u===0){1J}3G=5W(1y);3c+=3a(5X.29(18,1y.H-18),3G+"7O")+3a(1y.24,3G+1y.1a);18=1y.H+1y.u}3c+=3a(5X.29(18),5W()+"7O");q 3c},1I:l(C,7E){h cb=p.M,1r=p.1r,A,ci,3Z,ch="cn";f.1E={};f.A=v;f.1p=v;f.C=v;f.1i=v;f.6g={};f.1k=p.B.6d("cl");1r.6f[f.1k]=f;c(C===v){C=""}f.1E=p.B.6c(p.6b,7E||{});c(f.V("88")==I){f.1E.1w=f.1E.3g=N}f.A=A=f.1c("3Y");f.1p=f.1c("3Y");f.1p.L="1p";L="6e";A.1k=f.1k;c(f.V("66")){L+=" 5O"}c(f.V("3g")==N){L+=" bB"}c(f.V("5h-1p")==N){f.1p.L+=" bO-5h"}L+=" "+f.V("1s-R");L+=" "+f.V("2O-R");A.L=L;f.5g=C;f.C=p.B.8C(C).E(/\\r/g," ");3Z=f.V("1H-2Q");f.C=f.V("8d-89")==I?p.B.8a(f.C,3Z):p.B.8b(f.C,3Z);f.C=p.B.2T(f.C);c(f.V("1w")){f.1i=f.1c("3Y");f.1i.L="1i";f.1i.2p(p.1w.1c(f));A.2p(f.1i);h 1i=f.1i;l 58(){1i.L=1i.L.E("53","")};A.c0=l(){58();1i.L+=" 53"};A.bX=l(){58()}}A.2p(f.1p);f.2C=f.8i(f.59,f.C);f.86();C=f.8y(f.C,f.2C);C=f.8t(p.B.2G(C));c(f.V("8k-8l")){C=p.B.8m(C)}f.1p.1Q=C},9f:l(z){z=z.E(/^\\s+|\\s+$/g,"").E(/\\s+/g,"|");q"\\\\b(?:"+z+")\\\\b"},9i:l(2J){f.3I={G:{3K:2J.G,1a:"1l"},1d:{3K:2J.1d,1a:"1l"},C:W U("(?<G>"+2J.G.1g+")"+"(?<C>.*?)"+"(?<1d>"+2J.1d.1g+")","96")}}};q p}()}c(!1q.U){(l(){h 2w={T:10.14.T,87:5I.14.87,E:5I.14.E,1P:5I.14.1P},1F={13:/(?:[^\\\\([#\\s.]+|\\\\(?!k<[\\w$]+>|[7z]{[^}]+})[\\S\\s]?|\\((?=\\?(?!#|<[\\w$]+>)))+|(\\()(?:\\?(?:(#)[^)]*\\)|<([$\\w]+)>))?|\\\\(?:k<([\\w$]+)>|[7z]{([^}]+)})|(\\[\\^?)|([\\S\\s])/g,99:/(?:[^$]+|\\$(?![1-9$&`\']|{[$\\w]+}))+|\\$(?:([1-9]\\d*|[$&`\'])|{([$\\w]+)})/g,37:/^(?:\\s+|#.*)+/,5B:/^(?:[?*+]|{\\d+(?:,\\d*)?})/,7Q:/&&\\[\\^?/g,7S:/]/g},7o=l(5C,5v,5u){D(h i=5u||0;i<5C.u;i++){c(5C[i]===5v){q i}}q-1},8G=/()??/.T("")[1]!==3j,3q={};U=l(1e,1O){c(1e 68 10){c(1O!==3j){3H 7r("4y\'t 4C 9a 8z 95 7u 10 5u 94")}q 1e.3E()}h 1O=1O||"",7R=1O.Y("s")>-1,7M=1O.Y("x")>-1,5z=N,3v=[],1b=[],13=1F.13,J,cc,38,3M,3p;13.O=0;2j(J=2w.T.2n(13,1e)){c(J[2]){c(!1F.5B.1R(1e.17(13.O))){1b.K("(?:)")}}F{c(J[1]){3v.K(J[3]||v);c(J[3]){5z=I}1b.K("(")}F{c(J[4]){3M=7o(3v,J[4]);1b.K(3M>-1?"\\\\"+(3M+1)+(40(1e.5w(13.O))?"":"(?:)"):J[0])}F{c(J[5]){1b.K(3q.7m?3q.7m.7q(J[5],J[0].5w(1)==="P"):J[0])}F{c(J[6]){c(1e.5w(13.O)==="]"){1b.K(J[6]==="["?"(?!)":"[\\\\S\\\\s]");13.O++}F{cc=U.8g("&&"+1e.17(J.H),1F.7Q,1F.7S,"",{7D:"\\\\"})[0];1b.K(J[6]+cc+"]");13.O+=cc.u+1}}F{c(J[7]){c(7R&&J[7]==="."){1b.K("[\\\\S\\\\s]")}F{c(7M&&1F.37.1R(J[7])){38=2w.T.2n(1F.37,1e.17(13.O-1))[0].u;c(!1F.5B.1R(1e.17(13.O-1+38))){1b.K("(?:)")}13.O+=38-1}F{1b.K(J[7])}}}F{1b.K(J[0])}}}}}}}3p=10(1b.5A(""),2w.E.2n(1O,/[9B]+/g,""));3p.1C={1g:1e,2m:5z?3v:v};q 3p};U.9q=l(R,o){3q[R]=o};10.14.T=l(z){h 1h=2w.T.2n(f,z),R,i,5y;c(1h){c(8G&&1h.u>1){5y=W 10("^"+f.1g+"$(?!\\\\s)",f.5E());2w.E.2n(1h[0],5y,l(){D(i=1;i<8j.u-2;i++){c(8j[i]===3j){1h[i]=3j}}})}c(f.1C&&f.1C.2m){D(i=1;i<1h.u;i++){R=f.1C.2m[i-1];c(R){1h[R]=1h[i]}}}c(f.3l&&f.O>(1h.H+1h[0].u)){f.O--}}q 1h}})()}10.14.5E=l(){q(f.3l?"g":"")+(f.av?"i":"")+(f.8F?"m":"")+(f.37?"x":"")+(f.a4?"y":"")};10.14.3E=l(7A){h 5F=W U(f.1g,(7A||"")+f.5E());c(f.1C){5F.1C={1g:f.1C.1g,2m:f.1C.2m?f.1C.2m.17(0):v}}q 5F};10.14.2n=l(90,z){q f.T(z)};10.14.9b=l(9h,8c){q f.T(8c[0])};U.5P=l(57,5e){h 55="/"+57+"/"+(5e||"");q U.5P[55]||(U.5P[55]=W U(57,5e))};U.41=l(z){q z.E(/[-[\\]{}()*+?.\\\\^$|,#\\s]/g,"\\\\$&")};U.8g=l(z,G,11,1j,2R){h 2R=2R||{},2P=2R.7D,12=2R.c5,1j=1j||"",5r=1j.Y("g")>-1,70=1j.Y("i")>-1,7v=1j.Y("m")>-1,5a=1j.Y("y")>-1,1j=1j.E(/y/g,""),G=G 68 10?(G.3l?G:G.3E("g")):W U(G,"g"+1j),11=11 68 10?(11.3l?11:11.3E("g")):W U(11,"g"+1j),1M=[],2o=0,1u=0,1t=0,1z=0,2b,2c,1B,1K,3Q,48;c(2P){c(2P.u>1){3H aC("4y\'t 4C aL aJ 7u 41 7B")}c(7v){3H 7r("4y\'t 4C 41 7B 8z bi b8 8F b7")}3Q=U.41(2P);48=W 10("^(?:"+3Q+"[\\\\S\\\\s]|(?:(?!"+G.1g+"|"+11.1g+")[^"+3Q+"])+)+",70?"i":"")}2j(I){G.O=11.O=1t+(2P?(48.T(z.17(1t))||[""])[0].u:0);1B=G.T(z);1K=11.T(z);c(1B&&1K){c(1B.H<=1K.H){1K=v}F{1B=v}}c(1B||1K){1u=(1B||1K).H;1t=(1B?G:11).O}F{c(!2o){2h}}c(5a&&!2o&&1u>1z){2h}c(1B){c(!2o++){2b=1u;2c=1t}}F{c(1K&&2o){c(!--2o){c(12){c(12[0]&&2b>1z){1M.K([12[0],z.17(1z,2b),1z,2b])}c(12[1]){1M.K([12[1],z.17(2b,2c),2b,2c])}c(12[2]){1M.K([12[2],z.17(2c,1u),2c,1u])}c(12[3]){1M.K([12[3],z.17(1u,1t),1u,1t])}}F{1M.K(z.17(2c,1u))}1z=1t;c(!5r){2h}}}F{G.O=11.O=0;3H bP("8L aq 9r ar 8Z")}}c(1u===1t){1t++}}c(5r&&!5a&&12&&12[0]&&z.u>1z){1M.K([12[0],z.17(1z),1z,z.u])}G.O=11.O=0;q 1M};',62,768,'||||||||||||if|||this||var||||function||||sh|return||||length|null||||str|div|utils|code|for|replace|else|left|index|true|_121|push|className|config|false|lastIndex||document|name||exec|XRegExp|getParam|new|lt|indexOf|gt|RegExp|_139|vN|part|prototype|||slice|pos|_d3|css|_11f|create|right|_119|strings|source|_129|bar|_13a|id|script|style|_da|_d6|lines|window|vars|class|_145|_144|_b5|toolbar|_f4|_103|_146|alert|_149|_x|_c3|params|lib|obj|tab|highlight|continue|_14a|html|_142|doc|_11a|split|innerHTML|test|_ec|_5a|_5b|in|_4f|text|_8|_3c|_91|_98|createElement|_e7|value|_c5|width|href|_c2|substr|min|_147|_148|brushes|height|_6e|_cd|break|attributes|while|_be|_75|captureNames|call|_143|appendChild|_bc|_5f|http|concat|toString|_f0|real|_e9|line|execute|wnd|nbsp|matches|getMatches|_66|_e3|trim|_ed|_40|_10f|case|_61|_c1|_55|brush|_13c|size|_13b|_f9|unindent|_d9|_28|_c4|SyntaxHighlighter|_81|_88|_5|m2|_7a|body|_a2|m1|_80|extended|len|font|_fe|gm|_fd|fixInputString|Math|color|gutter|_4e|title|undefined|com|global|printFrame|_ef|_7d|_125|_118|_ee|_8e|print|_e5|_11e|_7b|_32|_49|_cc|offsetMatches|_7c|_25|write|addFlags|td|_104|throw|htmlScript|_22|regex|_a7|_124|_af|_2|_c6|_14b|_b6|_b4|_3|substring|_60|_76|_6a|DIV|_10b|isNaN|escape|_62|url|_7e|_6b|eachLine|_ae|esc|_47|HtmlScript|_b2|values|_8c|gi|_89|_b9|object|_b0|_ad|_blank|_e1|xmlBrush|link|close|removeChild|_b3|type|_a6|_73|findBrush|Match|top|_9d|can|popup|_c8|_53|supply|_a3|win|focus|span|_54|_9e|_50|_cb|_4d|_d7|_5d|getElementsByTagName|_6c|_ba|_b8|_bf|useScriptTags|_82|_ea|_ce|func|_d0|discoveredBrushes||_4c|_f6|show|pre|key|_29|_133|hide|regexList|_141|_19|_1a|viewSource|_134|_2b|originalCode|wrap|copyToClipboard|highlighterId|toolbarItemHeight|toolbarItemWidth|_2a|_2c|_2e|_2d|expandSource|_13e|_4|_7|from|item|charAt|www|r2|_11d|join|quantifier|_113|_e|getNativeFlags|_12e|_17|_18|String|_10|_b|_9|_f|_d|collapsed|cache|contentWindow|_101|_ff|_fb|swf|_30|getBrushNameCss|_fa|brushName|_100|_f5|_37|_35|content|_24|_38|collapse|_2f|instanceof|clipboardSwf|_27|defaults|merge|guid|syntaxhighlighter|highlighters|toolbarCommands|2009|_6|500px|measureSpace|_78|createButton|message|_79|clipboard|to|0px|_85|decoration|center|_83|margin|w3|rel|head|stylesheet|org|help|xhtml1|_3f|0099FF|align|DTD|alexgorbatchev|copyStyles|navigator|none|executeCommand|_3e|version|toLowerCase|_5e|_1e|_65|noBrush|switch|flash|_52|screen|event|attachEvent|_13f|shockwave|_4b|_48|clipboardData|px|commandName|aboutDialog|copyToClipboardConfirmation|_84|scrollbars|_14|_36|items|_6d|_16|_13|_15|_12|_a|userAgent|_d8|unicode|_d5|_112|process|get|TypeError|_de|_dd|one|_140|_d1|brushNotHtmlScript|parentNode|pP|_12d|character|addEvent|escapeChar|_106|_f7|_c9|_c7|Highlighter|_df|decorate|table|_11c|_f1|plain|_f8|classLeft|_11b|classRight|tr|_f2|padNumber|numbers|typeof|_e2|_e0|toBoolean|_e4|matchesSortCallback|pad|first|parseInt|removeNestedMatches|match|light|tabs|processSmartTabs|processTabs|args|smart|toArray|stripBrs|matchRecursive|regexLib|findMatches|arguments|auto|links|processUrls|defaultAdd|_a9|_a8|_a1|_a4|tagName|createDisplayLines|debug|getSyntaxHighlighterScriptTags|_93|insertSpaces|processMatches|when|_90|bloggerMode|trimFirstAndLastLines|_9a|_b7|multiline|_117|parseParams|stripCData|_bd|Copyright|subject|Alex|2004|development|_1c|keep|donate|Gorbatchev|_1b|syntax|JavaScript|active|highlighter|multiLineSingleQuotedString|delimiters|_12f|string|scriptScriptTags|aspScriptTags|another|constructing|sgi|try|catch|replaceVar|flags|apply|phpScriptTags|singleLineCComments|singleLinePerlComments|getKeywords|multiLineCComments|_131|forHtmlScript|doubleQuotedString|xmlComments|onclick|multiLineDoubleQuotedString|singleQuotedString|spaceWidth|bottom|addPlugin|contains|1999|xmlns|dtd|TR|transitional|xhtml|meta|utf|About|sx|charset|Type|equiv|Content|EN|Transitional|your|now|Can|is|The|view|copy|find|Brush|PUBLIC|W3C|XHTML|DOCTYPE|option|wasn|configured|family|Geneva|you|like|please|If|sticky|October|target|https|paypal|_s|xclick|hosted_button_id|cmd|webscr|cgi|bin|364|4em|background|fff|000|serif|sans|Arial|Helvetica|1em|data|unbalanced|75em|large|xx|ignoreCase|3em|2930402|always|about|_42|sort|SyntaxError|printing|shCore|_43|_44|max|round|than|250|more|500|alt|absolute|error|highlighted|ok|number|amp|setData|printSource|_39|cssText|position|IFRAME|_3b|_1f|random|1000000|_a5|block|CDATA|flag|the|htmlscript|1000|getElementById|getPropertyValue|offsetWidth|getComputedStyle|_99|opera|Array|using|textarea|open|load|Xml|_cf|lastIndexOf|_d4|all||replaceChild|70em|aliases|addEventListener|on|30em|spaces|_3a|flashVars|nogutter|transparent|wmode|allowScriptAccess|_8a|msie|classid|96b8|444553540000|11cf|ae6d|clsid|d27cdb6e|no|Error|location|resizable|400|750|_20|_21|menubar|onmouseout|_clipboard|application|onmouseover|param|_26|codebase|menu|valueNames|movie|cab|swflash|cabs|embed|conf||command|_34|_33|src|_10c|_10a|macromedia|download|highlighter_|pub|important'.split('|'),0,{}))
@@ -0,0 +1,30 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1 y={d:{}};y.d={F:6(S,l,q,k,m,n){6 J(z,Y){1 V=16 15("^"+Y+"\\\\[(?<o>\\\\w+)\\\\]$","14"),x=2;h(1 i=0;i<z.g;i++){7((x=V.17(z[i]))!=2){4 x.o}}4 2};6 3(r,U){4 r!=2?r:U};6 9(s){4 s!=2?s.13():2};1 f=S.18(":"),E=f[0],c={},u={"p":"p"};C={"p":"1a"},v=2,5=d.5;h(1 i 19 f){c[f[i]]="p"}l=9(3(l,5.O));q=9(3(q,5.T));k=9(3(k,5.A));n=9(3(n,5.W));m=9(3(m,5["K-L"]));v={1b:E,O:3(C[c.12],l),T:3(C[c.1g],q),A:3(u[c.A],k),W:3(u[c.1t],n),"K-L":3(J(f,"1q"),m)};4 v},1x:6(B,I,D,H,N,M){6 Z(){1 a=1r;h(1 i=0;i<a.g;i++){7(a[i]===2){10}7(G(a[i])=="1s"&&a[i]!=""){4 a[i]+""}7(G(a[i])=="1c"&&a[i].o!=""){4 a[i].o+""}}4 2};6 t(Q,R,11){1 j=1w.1v(11);h(1 i=0;i<j.g;i++){7(j[i].1u("1p")==R){Q.1n(j[i])}}};1 b=[],1o=2,1f={},1e="1d";t(b,B,"1h");t(b,B,"1i");7(b.g===0){4}h(1 i=0;i<b.g;i++){1 8=b[i],e=Z(8.X["1m"],8.1l,8.X["P"],8.P),1k="";7(e===2){10}e=y.d.F(e,I,D,H,N,M);d.1j(e,8)}}};',62,96,'|var|null|defaultValue|return|defaults|function|if|_26|asString||_21|_11|SyntaxHighlighter|_27|_f|length|for||_1f|_4|_2|_5|_6|value|true|_3|_c|_e|findTagsByName|_12|result||_a|dp|_7|collapse|_14|reverse|_16|_10|parseParams|typeof|_17|_15|getValue|first|line|_19|_18|gutter|language|_1c|_1d|_1|toolbar|_d|_9|ruler|attributes|_8|findValue|continue|_1e|nogutter|toString|gi|XRegExp|new|exec|split|in|false|brush|object|innerHTML|_24|_23|nocontrols|pre|textarea|highlight|_28|className|class|push|_22|name|firstline|arguments|string|showcolumns|getAttribute|getElementsByTagName|document|HighlightAll'.split('|'),0,{}))
@@ -0,0 +1,2077 @@
1
+ /**
2
+ * SyntaxHighlighter
3
+ * http://alexgorbatchev.com/
4
+ *
5
+ * SyntaxHighlighter is donationware. If you are using it, please donate.
6
+ * http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
7
+ *
8
+ * @version
9
+ * 2.1.364 (October 15 2009)
10
+ *
11
+ * @copyright
12
+ * Copyright (C) 2004-2009 Alex Gorbatchev.
13
+ *
14
+ * @license
15
+ * This file is part of SyntaxHighlighter.
16
+ *
17
+ * SyntaxHighlighter is free software: you can redistribute it and/or modify
18
+ * it under the terms of the GNU Lesser General Public License as published by
19
+ * the Free Software Foundation, either version 3 of the License, or
20
+ * (at your option) any later version.
21
+ *
22
+ * SyntaxHighlighter is distributed in the hope that it will be useful,
23
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ * GNU General Public License for more details.
26
+ *
27
+ * You should have received a copy of the GNU General Public License
28
+ * along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
29
+ */
30
+ //
31
+ // Begin anonymous function. This is used to contain local scope variables without polutting global scope.
32
+ //
33
+ if (!window.SyntaxHighlighter) var SyntaxHighlighter = function() {
34
+
35
+ // Shortcut object which will be assigned to the SyntaxHighlighter variable.
36
+ // This is a shorthand for local reference in order to avoid long namespace
37
+ // references to SyntaxHighlighter.whatever...
38
+ var sh = {
39
+ defaults : {
40
+ /** Additional CSS class names to be added to highlighter elements. */
41
+ 'class-name' : '',
42
+
43
+ /** First line number. */
44
+ 'first-line' : 1,
45
+
46
+ /**
47
+ * Pads line numbers. Possible values are:
48
+ *
49
+ * false - don't pad line numbers.
50
+ * true - automaticaly pad numbers with minimum required number of leading zeroes.
51
+ * [int] - length up to which pad line numbers.
52
+ */
53
+ 'pad-line-numbers' : true,
54
+
55
+ /** Lines to highlight. */
56
+ 'highlight' : null,
57
+
58
+ /** Enables or disables smart tabs. */
59
+ 'smart-tabs' : true,
60
+
61
+ /** Gets or sets tab size. */
62
+ 'tab-size' : 4,
63
+
64
+ /** Enables or disables gutter. */
65
+ 'gutter' : true,
66
+
67
+ /** Enables or disables toolbar. */
68
+ 'toolbar' : true,
69
+
70
+ /** Forces code view to be collapsed. */
71
+ 'collapse' : false,
72
+
73
+ /** Enables or disables automatic links. */
74
+ 'auto-links' : true,
75
+
76
+ /** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
77
+ 'light' : false,
78
+
79
+ /** Enables or disables automatic line wrapping. */
80
+ 'wrap-lines' : true,
81
+
82
+ 'html-script' : false
83
+ },
84
+
85
+ config : {
86
+ /** Enables use of <SCRIPT type="syntaxhighlighter" /> tags. */
87
+ useScriptTags : true,
88
+
89
+ /** Path to the copy to clipboard SWF file. */
90
+ clipboardSwf : null,
91
+
92
+ /** Width of an item in the toolbar. */
93
+ toolbarItemWidth : 16,
94
+
95
+ /** Height of an item in the toolbar. */
96
+ toolbarItemHeight : 16,
97
+
98
+ /** Blogger mode flag. */
99
+ bloggerMode : false,
100
+
101
+ stripBrs : false,
102
+
103
+ /** Name of the tag that SyntaxHighlighter will automatically look for. */
104
+ tagName : 'pre',
105
+
106
+ strings : {
107
+ expandSource : 'show source',
108
+ viewSource : 'view source',
109
+ copyToClipboard : 'copy to clipboard',
110
+ copyToClipboardConfirmation : 'The code is in your clipboard now',
111
+ print : 'print',
112
+ help : '?',
113
+ alert: 'SyntaxHighlighter\n\n',
114
+ noBrush : 'Can\'t find brush for: ',
115
+ brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ',
116
+
117
+ // this is populated by the build script
118
+ aboutDialog : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>About SyntaxHighlighter</title></head><body style="font-family:Geneva,Arial,Helvetica,sans-serif;background-color:#fff;color:#000;font-size:1em;text-align:center;"><div style="text-align:center;margin-top:3em;"><div style="font-size:xx-large;">SyntaxHighlighter</div><div style="font-size:.75em;margin-bottom:4em;"><div>version 2.1.364 (October 15 2009)</div><div><a href="http://alexgorbatchev.com" target="_blank" style="color:#0099FF;text-decoration:none;">http://alexgorbatchev.com</a></div><div>If you like this script, please <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2930402" style="color:#0099FF;text-decoration:none;">donate</a> to keep development active!</div></div><div>JavaScript code syntax highlighter.</div><div>Copyright 2004-2009 Alex Gorbatchev.</div></div></body></html>'
119
+ },
120
+
121
+ /** If true, output will show HTML produces instead. */
122
+ debug : false
123
+ },
124
+
125
+ /** Internal 'global' variables. */
126
+ vars : {
127
+ discoveredBrushes : null,
128
+ spaceWidth : null,
129
+ printFrame : null,
130
+ highlighters : {}
131
+ },
132
+
133
+ /** This object is populated by user included external brush files. */
134
+ brushes : {},
135
+
136
+ /** Common regular expressions. */
137
+ regexLib : {
138
+ multiLineCComments : /\/\*[\s\S]*?\*\//gm,
139
+ singleLineCComments : /\/\/.*$/gm,
140
+ singleLinePerlComments : /#.*$/gm,
141
+ doubleQuotedString : /"([^\\"\n]|\\.)*"/g,
142
+ singleQuotedString : /'([^\\'\n]|\\.)*'/g,
143
+ multiLineDoubleQuotedString : /"([^\\"]|\\.)*"/g,
144
+ multiLineSingleQuotedString : /'([^\\']|\\.)*'/g,
145
+ xmlComments : /(&lt;|<)!--[\s\S]*?--(&gt;|>)/gm,
146
+ url : /&lt;\w+:\/\/[\w-.\/?%&=@:;]*&gt;|\w+:\/\/[\w-.\/?%&=@:;]*/g,
147
+
148
+ /** <?= ?> tags. */
149
+ phpScriptTags : { left: /(&lt;|<)\?=?/g, right: /\?(&gt;|>)/g },
150
+
151
+ /** <%= %> tags. */
152
+ aspScriptTags : { left: /(&lt;|<)%=?/g, right: /%(&gt;|>)/g },
153
+
154
+ /** <script></script> tags. */
155
+ scriptScriptTags : { left: /(&lt;|<)\s*script.*?(&gt;|>)/gi, right: /(&lt;|<)\/\s*script\s*(&gt;|>)/gi }
156
+ },
157
+
158
+ toolbar : {
159
+ /**
160
+ * Creates new toolbar for a highlighter.
161
+ * @param {Highlighter} highlighter Target highlighter.
162
+ */
163
+ create : function(highlighter)
164
+ {
165
+ var div = document.createElement('DIV'),
166
+ items = sh.toolbar.items
167
+ ;
168
+
169
+ div.className = 'toolbar';
170
+
171
+ for (var name in items)
172
+ {
173
+ var constructor = items[name],
174
+ command = new constructor(highlighter),
175
+ element = command.create()
176
+ ;
177
+
178
+ highlighter.toolbarCommands[name] = command;
179
+
180
+ if (element == null)
181
+ continue;
182
+
183
+ if (typeof(element) == 'string')
184
+ element = sh.toolbar.createButton(element, highlighter.id, name);
185
+
186
+ element.className += 'item ' + name;
187
+ div.appendChild(element);
188
+ }
189
+
190
+ return div;
191
+ },
192
+
193
+ /**
194
+ * Create a standard anchor button for the toolbar.
195
+ * @param {String} label Label text to display.
196
+ * @param {String} highlighterId Highlighter ID that this button would belong to.
197
+ * @param {String} commandName Command name that would be executed.
198
+ * @return {Element} Returns an 'A' element.
199
+ */
200
+ createButton : function(label, highlighterId, commandName)
201
+ {
202
+ var a = document.createElement('a'),
203
+ style = a.style,
204
+ config = sh.config,
205
+ width = config.toolbarItemWidth,
206
+ height = config.toolbarItemHeight
207
+ ;
208
+
209
+ a.href = '#' + commandName;
210
+ a.title = label;
211
+ a.highlighterId = highlighterId;
212
+ a.commandName = commandName;
213
+ a.innerHTML = label;
214
+
215
+ if (isNaN(width) == false)
216
+ style.width = width + 'px';
217
+
218
+ if (isNaN(height) == false)
219
+ style.height = height + 'px';
220
+
221
+ a.onclick = function(e)
222
+ {
223
+ try
224
+ {
225
+ sh.toolbar.executeCommand(
226
+ this,
227
+ e || window.event,
228
+ this.highlighterId,
229
+ this.commandName
230
+ );
231
+ }
232
+ catch(e)
233
+ {
234
+ sh.utils.alert(e.message);
235
+ }
236
+
237
+ return false;
238
+ };
239
+
240
+ return a;
241
+ },
242
+
243
+ /**
244
+ * Executes a toolbar command.
245
+ * @param {Element} sender Sender element.
246
+ * @param {MouseEvent} event Original mouse event object.
247
+ * @param {String} highlighterId Highlighter DIV element ID.
248
+ * @param {String} commandName Name of the command to execute.
249
+ * @return {Object} Passes out return value from command execution.
250
+ */
251
+ executeCommand : function(sender, event, highlighterId, commandName, args)
252
+ {
253
+ var highlighter = sh.vars.highlighters[highlighterId],
254
+ command
255
+ ;
256
+
257
+ if (highlighter == null || (command = highlighter.toolbarCommands[commandName]) == null)
258
+ return null;
259
+
260
+ return command.execute(sender, event, args);
261
+ },
262
+
263
+ /** Collection of toolbar items. */
264
+ items : {
265
+ expandSource : function(highlighter)
266
+ {
267
+ this.create = function()
268
+ {
269
+ if (highlighter.getParam('collapse') != true)
270
+ return;
271
+
272
+ return sh.config.strings.expandSource;
273
+ };
274
+
275
+ this.execute = function(sender, event, args)
276
+ {
277
+ var div = highlighter.div;
278
+
279
+ sender.parentNode.removeChild(sender);
280
+ div.className = div.className.replace('collapsed', '');
281
+ };
282
+ },
283
+
284
+ /**
285
+ * Command to open a new window and display the original unformatted source code inside.
286
+ */
287
+ viewSource : function(highlighter)
288
+ {
289
+ this.create = function()
290
+ {
291
+ return sh.config.strings.viewSource;
292
+ };
293
+
294
+ this.execute = function(sender, event, args)
295
+ {
296
+ var code = sh.utils.fixInputString(highlighter.originalCode).replace(/</g, '&lt;'),
297
+ wnd = sh.utils.popup('', '_blank', 750, 400, 'location=0, resizable=1, menubar=0, scrollbars=1')
298
+ ;
299
+
300
+ code = sh.utils.unindent(code);
301
+
302
+ wnd.document.write('<pre>' + code + '</pre>');
303
+ wnd.document.close();
304
+ };
305
+ },
306
+
307
+ /**
308
+ * Command to copy the original source code in to the clipboard.
309
+ * Uses Flash method if <code>clipboardSwf</code> is configured.
310
+ */
311
+ copyToClipboard : function(highlighter)
312
+ {
313
+ var flashDiv, flashSwf,
314
+ highlighterId = highlighter.id
315
+ ;
316
+
317
+ this.create = function()
318
+ {
319
+ var config = sh.config;
320
+
321
+ // disable functionality if running locally
322
+ if (config.clipboardSwf == null)
323
+ return null;
324
+
325
+ function params(list)
326
+ {
327
+ var result = '';
328
+
329
+ for (var name in list)
330
+ result += "<param name='" + name + "' value='" + list[name] + "'/>";
331
+
332
+ return result;
333
+ };
334
+
335
+ function attributes(list)
336
+ {
337
+ var result = '';
338
+
339
+ for (var name in list)
340
+ result += " " + name + "='" + list[name] + "'";
341
+
342
+ return result;
343
+ };
344
+
345
+ var args1 = {
346
+ width : config.toolbarItemWidth,
347
+ height : config.toolbarItemHeight,
348
+ id : highlighterId + '_clipboard',
349
+ type : 'application/x-shockwave-flash',
350
+ title : sh.config.strings.copyToClipboard
351
+ },
352
+
353
+ // these arguments are used in IE's <param /> collection
354
+ args2 = {
355
+ allowScriptAccess : 'always',
356
+ wmode : 'transparent',
357
+ flashVars : 'highlighterId=' + highlighterId,
358
+ menu : 'false'
359
+ },
360
+ swf = config.clipboardSwf,
361
+ html
362
+ ;
363
+
364
+ if (/msie/i.test(navigator.userAgent))
365
+ {
366
+ html = '<object'
367
+ + attributes({
368
+ classid : 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
369
+ codebase : 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0'
370
+ })
371
+ + attributes(args1)
372
+ + '>'
373
+ + params(args2)
374
+ + params({ movie : swf })
375
+ + '</object>'
376
+ ;
377
+ }
378
+ else
379
+ {
380
+ html = '<embed'
381
+ + attributes(args1)
382
+ + attributes(args2)
383
+ + attributes({ src : swf })
384
+ + '/>'
385
+ ;
386
+ }
387
+
388
+ flashDiv = document.createElement('div');
389
+ flashDiv.innerHTML = html;
390
+
391
+ return flashDiv;
392
+ };
393
+
394
+ this.execute = function(sender, event, args)
395
+ {
396
+ var command = args.command;
397
+
398
+ switch (command)
399
+ {
400
+ case 'get':
401
+ var code = sh.utils.unindent(
402
+ sh.utils.fixInputString(highlighter.originalCode)
403
+ .replace(/&lt;/g, '<')
404
+ .replace(/&gt;/g, '>')
405
+ .replace(/&amp;/g, '&')
406
+ );
407
+
408
+ if(window.clipboardData)
409
+ // will fall through to the confirmation because there isn't a break
410
+ window.clipboardData.setData('text', code);
411
+ else
412
+ return sh.utils.unindent(code);
413
+
414
+ case 'ok':
415
+ sh.utils.alert(sh.config.strings.copyToClipboardConfirmation);
416
+ break;
417
+
418
+ case 'error':
419
+ sh.utils.alert(args.message);
420
+ break;
421
+ }
422
+ };
423
+ },
424
+
425
+ /** Command to print the colored source code. */
426
+ printSource : function(highlighter)
427
+ {
428
+ this.create = function()
429
+ {
430
+ return sh.config.strings.print;
431
+ };
432
+
433
+ this.execute = function(sender, event, args)
434
+ {
435
+ var iframe = document.createElement('IFRAME'),
436
+ doc = null
437
+ ;
438
+
439
+ // make sure there is never more than one hidden iframe created by SH
440
+ if (sh.vars.printFrame != null)
441
+ document.body.removeChild(sh.vars.printFrame);
442
+
443
+ sh.vars.printFrame = iframe;
444
+
445
+ // this hides the iframe
446
+ iframe.style.cssText = 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;';
447
+
448
+ document.body.appendChild(iframe);
449
+ doc = iframe.contentWindow.document;
450
+
451
+ copyStyles(doc, window.document);
452
+ doc.write('<div class="' + highlighter.div.className.replace('collapsed', '') + ' printing">' + highlighter.div.innerHTML + '</div>');
453
+ doc.close();
454
+
455
+ iframe.contentWindow.focus();
456
+ iframe.contentWindow.print();
457
+
458
+ function copyStyles(destDoc, sourceDoc)
459
+ {
460
+ var links = sourceDoc.getElementsByTagName('link');
461
+
462
+ for(var i = 0; i < links.length; i++)
463
+ if(links[i].rel.toLowerCase() == 'stylesheet' && /shCore\.css$/.test(links[i].href))
464
+ destDoc.write('<link type="text/css" rel="stylesheet" href="' + links[i].href + '"></link>');
465
+ };
466
+ };
467
+ },
468
+
469
+ /** Command to display the about dialog window. */
470
+ about : function(highlighter)
471
+ {
472
+ this.create = function()
473
+ {
474
+ return sh.config.strings.help;
475
+ };
476
+
477
+ this.execute = function(sender, event)
478
+ {
479
+ var wnd = sh.utils.popup('', '_blank', 500, 250, 'scrollbars=0'),
480
+ doc = wnd.document
481
+ ;
482
+
483
+ doc.write(sh.config.strings.aboutDialog);
484
+ doc.close();
485
+ wnd.focus();
486
+ };
487
+ }
488
+ }
489
+ },
490
+
491
+ utils : {
492
+ /**
493
+ * Finds an index of element in the array.
494
+ * @ignore
495
+ * @param {Object} searchElement
496
+ * @param {Number} fromIndex
497
+ * @return {Number} Returns index of element if found; -1 otherwise.
498
+ */
499
+ indexOf : function(array, searchElement, fromIndex)
500
+ {
501
+ fromIndex = Math.max(fromIndex || 0, 0);
502
+
503
+ for (var i = fromIndex; i < array.length; i++)
504
+ if(array[i] == searchElement)
505
+ return i;
506
+
507
+ return -1;
508
+ },
509
+
510
+ /**
511
+ * Generates a unique element ID.
512
+ */
513
+ guid : function(prefix)
514
+ {
515
+ return prefix + Math.round(Math.random() * 1000000).toString();
516
+ },
517
+
518
+ /**
519
+ * Merges two objects. Values from obj2 override values in obj1.
520
+ * Function is NOT recursive and works only for one dimensional objects.
521
+ * @param {Object} obj1 First object.
522
+ * @param {Object} obj2 Second object.
523
+ * @return {Object} Returns combination of both objects.
524
+ */
525
+ merge: function(obj1, obj2)
526
+ {
527
+ var result = {}, name;
528
+
529
+ for (name in obj1)
530
+ result[name] = obj1[name];
531
+
532
+ for (name in obj2)
533
+ result[name] = obj2[name];
534
+
535
+ return result;
536
+ },
537
+
538
+ /**
539
+ * Attempts to convert string to boolean.
540
+ * @param {String} value Input string.
541
+ * @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
542
+ */
543
+ toBoolean: function(value)
544
+ {
545
+ switch (value)
546
+ {
547
+ case "true":
548
+ return true;
549
+
550
+ case "false":
551
+ return false;
552
+ }
553
+
554
+ return value;
555
+ },
556
+
557
+ /**
558
+ * Opens up a centered popup window.
559
+ * @param {String} url URL to open in the window.
560
+ * @param {String} name Popup name.
561
+ * @param {int} width Popup width.
562
+ * @param {int} height Popup height.
563
+ * @param {String} options window.open() options.
564
+ * @return {Window} Returns window instance.
565
+ */
566
+ popup: function(url, name, width, height, options)
567
+ {
568
+ var x = (screen.width - width) / 2,
569
+ y = (screen.height - height) / 2
570
+ ;
571
+
572
+ options += ', left=' + x +
573
+ ', top=' + y +
574
+ ', width=' + width +
575
+ ', height=' + height
576
+ ;
577
+ options = options.replace(/^,/, '');
578
+
579
+ var win = window.open(url, name, options);
580
+ win.focus();
581
+ return win;
582
+ },
583
+
584
+ /**
585
+ * Adds event handler to the target object.
586
+ * @param {Object} obj Target object.
587
+ * @param {String} type Name of the event.
588
+ * @param {Function} func Handling function.
589
+ */
590
+ addEvent: function(obj, type, func)
591
+ {
592
+ if (obj.attachEvent)
593
+ {
594
+ obj['e' + type + func] = func;
595
+ obj[type + func] = function()
596
+ {
597
+ obj['e' + type + func](window.event);
598
+ }
599
+ obj.attachEvent('on' + type, obj[type + func]);
600
+ }
601
+ else
602
+ {
603
+ obj.addEventListener(type, func, false);
604
+ }
605
+ },
606
+
607
+ /**
608
+ * Displays an alert.
609
+ * @param {String} str String to display.
610
+ */
611
+ alert: function(str)
612
+ {
613
+ alert(sh.config.strings.alert + str)
614
+ },
615
+
616
+ /**
617
+ * Finds a brush by its alias.
618
+ *
619
+ * @param {String} alias Brush alias.
620
+ * @param {Boolean} alert Suppresses the alert if false.
621
+ * @return {Brush} Returns bursh constructor if found, null otherwise.
622
+ */
623
+ findBrush: function(alias, alert)
624
+ {
625
+ var brushes = sh.vars.discoveredBrushes,
626
+ result = null
627
+ ;
628
+
629
+ if (brushes == null)
630
+ {
631
+ brushes = {};
632
+
633
+ // Find all brushes
634
+ for (var brush in sh.brushes)
635
+ {
636
+ var aliases = sh.brushes[brush].aliases;
637
+
638
+ if (aliases == null)
639
+ continue;
640
+
641
+ // keep the brush name
642
+ sh.brushes[brush].name = brush.toLowerCase();
643
+
644
+ for (var i = 0; i < aliases.length; i++)
645
+ brushes[aliases[i]] = brush;
646
+ }
647
+
648
+ sh.vars.discoveredBrushes = brushes;
649
+ }
650
+
651
+ result = sh.brushes[brushes[alias]];
652
+
653
+ if (result == null && alert != false)
654
+ sh.utils.alert(sh.config.strings.noBrush + alias);
655
+
656
+ return result;
657
+ },
658
+
659
+ /**
660
+ * Executes a callback on each line and replaces each line with result from the callback.
661
+ * @param {Object} str Input string.
662
+ * @param {Object} callback Callback function taking one string argument and returning a string.
663
+ */
664
+ eachLine: function(str, callback)
665
+ {
666
+ var lines = str.split('\n');
667
+
668
+ for (var i = 0; i < lines.length; i++)
669
+ lines[i] = callback(lines[i]);
670
+
671
+ return lines.join('\n');
672
+ },
673
+
674
+ /**
675
+ * This is a special trim which only removes first and last empty lines
676
+ * and doesn't affect valid leading space on the first line.
677
+ *
678
+ * @param {String} str Input string
679
+ * @return {String} Returns string without empty first and last lines.
680
+ */
681
+ trimFirstAndLastLines: function(str)
682
+ {
683
+ return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
684
+ },
685
+
686
+ /**
687
+ * Parses key/value pairs into hash object.
688
+ *
689
+ * Understands the following formats:
690
+ * - name: word;
691
+ * - name: [word, word];
692
+ * - name: "string";
693
+ * - name: 'string';
694
+ *
695
+ * For example:
696
+ * name1: value; name2: [value, value]; name3: 'value'
697
+ *
698
+ * @param {String} str Input string.
699
+ * @return {Object} Returns deserialized object.
700
+ */
701
+ parseParams: function(str)
702
+ {
703
+ var match,
704
+ result = {},
705
+ arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),
706
+ regex = new XRegExp(
707
+ "(?<name>[\\w-]+)" +
708
+ "\\s*:\\s*" +
709
+ "(?<value>" +
710
+ "[\\w-%#]+|" + // word
711
+ "\\[.*?\\]|" + // [] array
712
+ '".*?"|' + // "" string
713
+ "'.*?'" + // '' string
714
+ ")\\s*;?",
715
+ "g"
716
+ )
717
+ ;
718
+
719
+ while ((match = regex.exec(str)) != null)
720
+ {
721
+ var value = match.value
722
+ .replace(/^['"]|['"]$/g, '') // strip quotes from end of strings
723
+ ;
724
+
725
+ // try to parse array value
726
+ if (value != null && arrayRegex.test(value))
727
+ {
728
+ var m = arrayRegex.exec(value);
729
+ value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : [];
730
+ }
731
+
732
+ result[match.name] = value;
733
+ }
734
+
735
+ return result;
736
+ },
737
+
738
+ /**
739
+ * Wraps each line of the string into <code/> tag with given style applied to it.
740
+ *
741
+ * @param {String} str Input string.
742
+ * @param {String} css Style name to apply to the string.
743
+ * @return {String} Returns input string with each line surrounded by <span/> tag.
744
+ */
745
+ decorate: function(str, css)
746
+ {
747
+ if (str == null || str.length == 0 || str == '\n')
748
+ return str;
749
+
750
+ str = str.replace(/</g, '&lt;');
751
+
752
+ // Replace two or more sequential spaces with &nbsp; leaving last space untouched.
753
+ str = str.replace(/ {2,}/g, function(m)
754
+ {
755
+ var spaces = '';
756
+
757
+ for (var i = 0; i < m.length - 1; i++)
758
+ spaces += '&nbsp;';
759
+
760
+ return spaces + ' ';
761
+ });
762
+
763
+ // Split each line and apply <span class="...">...</span> to them so that
764
+ // leading spaces aren't included.
765
+ if (css != null)
766
+ str = sh.utils.eachLine(str, function(line)
767
+ {
768
+ if (line.length == 0)
769
+ return '';
770
+
771
+ var spaces = '';
772
+
773
+ line = line.replace(/^(&nbsp;| )+/, function(s)
774
+ {
775
+ spaces = s;
776
+ return '';
777
+ });
778
+
779
+ if (line.length == 0)
780
+ return spaces;
781
+
782
+ return spaces + '<code class="' + css + '">' + line + '</code>';
783
+ });
784
+
785
+ return str;
786
+ },
787
+
788
+ /**
789
+ * Pads number with zeros until it's length is the same as given length.
790
+ *
791
+ * @param {Number} number Number to pad.
792
+ * @param {Number} length Max string length with.
793
+ * @return {String} Returns a string padded with proper amount of '0'.
794
+ */
795
+ padNumber : function(number, length)
796
+ {
797
+ var result = number.toString();
798
+
799
+ while (result.length < length)
800
+ result = '0' + result;
801
+
802
+ return result;
803
+ },
804
+
805
+ /**
806
+ * Measures width of a single space character.
807
+ * @return {Number} Returns width of a single space character.
808
+ */
809
+ measureSpace : function()
810
+ {
811
+ var container = document.createElement('div'),
812
+ span,
813
+ result = 0,
814
+ body = document.body,
815
+ id = sh.utils.guid('measureSpace'),
816
+
817
+ // variable names will be compressed, so it's better than a plain string
818
+ divOpen = '<div class="',
819
+ closeDiv = '</div>',
820
+ closeSpan = '</span>'
821
+ ;
822
+
823
+ // we have to duplicate highlighter nested structure in order to get an acurate space measurment
824
+ container.innerHTML =
825
+ divOpen + 'syntaxhighlighter">'
826
+ + divOpen + 'lines">'
827
+ + divOpen + 'line">'
828
+ + divOpen + 'content'
829
+ + '"><span class="block"><span id="' + id + '">&nbsp;' + closeSpan + closeSpan
830
+ + closeDiv
831
+ + closeDiv
832
+ + closeDiv
833
+ + closeDiv
834
+ ;
835
+
836
+ body.appendChild(container);
837
+ span = document.getElementById(id);
838
+
839
+ if (/opera/i.test(navigator.userAgent))
840
+ {
841
+ var style = window.getComputedStyle(span, null);
842
+ result = parseInt(style.getPropertyValue("width"));
843
+ }
844
+ else
845
+ {
846
+ result = span.offsetWidth;
847
+ }
848
+
849
+ body.removeChild(container);
850
+
851
+ return result;
852
+ },
853
+
854
+ /**
855
+ * Replaces tabs with spaces.
856
+ *
857
+ * @param {String} code Source code.
858
+ * @param {Number} tabSize Size of the tab.
859
+ * @return {String} Returns code with all tabs replaces by spaces.
860
+ */
861
+ processTabs : function(code, tabSize)
862
+ {
863
+ var tab = '';
864
+
865
+ for (var i = 0; i < tabSize; i++)
866
+ tab += ' ';
867
+
868
+ return code.replace(/\t/g, tab);
869
+ },
870
+
871
+ /**
872
+ * Replaces tabs with smart spaces.
873
+ *
874
+ * @param {String} code Code to fix the tabs in.
875
+ * @param {Number} tabSize Number of spaces in a column.
876
+ * @return {String} Returns code with all tabs replaces with roper amount of spaces.
877
+ */
878
+ processSmartTabs : function(code, tabSize)
879
+ {
880
+ var lines = code.split('\n'),
881
+ tab = '\t',
882
+ spaces = ''
883
+ ;
884
+
885
+ // Create a string with 1000 spaces to copy spaces from...
886
+ // It's assumed that there would be no indentation longer than that.
887
+ for (var i = 0; i < 50; i++)
888
+ spaces += ' '; // 20 spaces * 50
889
+
890
+ // This function inserts specified amount of spaces in the string
891
+ // where a tab is while removing that given tab.
892
+ function insertSpaces(line, pos, count)
893
+ {
894
+ return line.substr(0, pos)
895
+ + spaces.substr(0, count)
896
+ + line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
897
+ ;
898
+ };
899
+
900
+ // Go through all the lines and do the 'smart tabs' magic.
901
+ code = sh.utils.eachLine(code, function(line)
902
+ {
903
+ if (line.indexOf(tab) == -1)
904
+ return line;
905
+
906
+ var pos = 0;
907
+
908
+ while ((pos = line.indexOf(tab)) != -1)
909
+ {
910
+ // This is pretty much all there is to the 'smart tabs' logic.
911
+ // Based on the position within the line and size of a tab,
912
+ // calculate the amount of spaces we need to insert.
913
+ var spaces = tabSize - pos % tabSize;
914
+ line = insertSpaces(line, pos, spaces);
915
+ }
916
+
917
+ return line;
918
+ });
919
+
920
+ return code;
921
+ },
922
+
923
+ /**
924
+ * Performs various string fixes based on configuration.
925
+ */
926
+ fixInputString : function(str)
927
+ {
928
+ var br = /<br\s*\/?>|&lt;br\s*\/?&gt;/gi;
929
+
930
+ if (sh.config.bloggerMode == true)
931
+ str = str.replace(br, '\n');
932
+
933
+ if (sh.config.stripBrs == true)
934
+ str = str.replace(br, '');
935
+
936
+ return str;
937
+ },
938
+
939
+ /**
940
+ * Removes all white space at the begining and end of a string.
941
+ *
942
+ * @param {String} str String to trim.
943
+ * @return {String} Returns string without leading and following white space characters.
944
+ */
945
+ trim: function(str)
946
+ {
947
+ return str.replace(/^\s+|\s+$/g, '');
948
+ },
949
+
950
+ /**
951
+ * Unindents a block of text by the lowest common indent amount.
952
+ * @param {String} str Text to unindent.
953
+ * @return {String} Returns unindented text block.
954
+ */
955
+ unindent: function(str)
956
+ {
957
+ var lines = sh.utils.fixInputString(str).split('\n'),
958
+ indents = new Array(),
959
+ regex = /^\s*/,
960
+ min = 1000
961
+ ;
962
+
963
+ // go through every line and check for common number of indents
964
+ for (var i = 0; i < lines.length && min > 0; i++)
965
+ {
966
+ var line = lines[i];
967
+
968
+ if (sh.utils.trim(line).length == 0)
969
+ continue;
970
+
971
+ var matches = regex.exec(line);
972
+
973
+ // In the event that just one line doesn't have leading white space
974
+ // we can't unindent anything, so bail completely.
975
+ if (matches == null)
976
+ return str;
977
+
978
+ min = Math.min(matches[0].length, min);
979
+ }
980
+
981
+ // trim minimum common number of white space from the begining of every line
982
+ if (min > 0)
983
+ for (var i = 0; i < lines.length; i++)
984
+ lines[i] = lines[i].substr(min);
985
+
986
+ return lines.join('\n');
987
+ },
988
+
989
+ /**
990
+ * Callback method for Array.sort() which sorts matches by
991
+ * index position and then by length.
992
+ *
993
+ * @param {Match} m1 Left object.
994
+ * @param {Match} m2 Right object.
995
+ * @return {Number} Returns -1, 0 or -1 as a comparison result.
996
+ */
997
+ matchesSortCallback: function(m1, m2)
998
+ {
999
+ // sort matches by index first
1000
+ if(m1.index < m2.index)
1001
+ return -1;
1002
+ else if(m1.index > m2.index)
1003
+ return 1;
1004
+ else
1005
+ {
1006
+ // if index is the same, sort by length
1007
+ if(m1.length < m2.length)
1008
+ return -1;
1009
+ else if(m1.length > m2.length)
1010
+ return 1;
1011
+ }
1012
+
1013
+ return 0;
1014
+ },
1015
+
1016
+ /**
1017
+ * Executes given regular expression on provided code and returns all
1018
+ * matches that are found.
1019
+ *
1020
+ * @param {String} code Code to execute regular expression on.
1021
+ * @param {Object} regex Regular expression item info from <code>regexList</code> collection.
1022
+ * @return {Array} Returns a list of Match objects.
1023
+ */
1024
+ getMatches: function(code, regexInfo)
1025
+ {
1026
+ function defaultAdd(match, regexInfo)
1027
+ {
1028
+ return [new sh.Match(match[0], match.index, regexInfo.css)];
1029
+ };
1030
+
1031
+ var index = 0,
1032
+ match = null,
1033
+ result = [],
1034
+ func = regexInfo.func ? regexInfo.func : defaultAdd
1035
+ ;
1036
+
1037
+ while((match = regexInfo.regex.exec(code)) != null)
1038
+ result = result.concat(func(match, regexInfo));
1039
+
1040
+ return result;
1041
+ },
1042
+
1043
+ processUrls: function(code)
1044
+ {
1045
+ var lt = '&lt;',
1046
+ gt = '&gt;'
1047
+ ;
1048
+
1049
+ return code.replace(sh.regexLib.url, function(m)
1050
+ {
1051
+ var suffix = '', prefix = '';
1052
+
1053
+ // We include &lt; and &gt; in the URL for the common cases like <http://google.com>
1054
+ // The problem is that they get transformed into &lt;http://google.com&gt;
1055
+ // Where as &gt; easily looks like part of the URL string.
1056
+
1057
+ if (m.indexOf(lt) == 0)
1058
+ {
1059
+ prefix = lt;
1060
+ m = m.substring(lt.length);
1061
+ }
1062
+
1063
+ if (m.indexOf(gt) == m.length - gt.length)
1064
+ {
1065
+ m = m.substring(0, m.length - gt.length);
1066
+ suffix = gt;
1067
+ }
1068
+
1069
+ return prefix + '<a href="' + m + '">' + m + '</a>' + suffix;
1070
+ });
1071
+ },
1072
+
1073
+ /**
1074
+ * Finds all <SCRIPT TYPE="syntaxhighlighter" /> elements.
1075
+ * @return {Array} Returns array of all found SyntaxHighlighter tags.
1076
+ */
1077
+ getSyntaxHighlighterScriptTags: function()
1078
+ {
1079
+ var tags = document.getElementsByTagName('script'),
1080
+ result = []
1081
+ ;
1082
+
1083
+ for (var i = 0; i < tags.length; i++)
1084
+ if (tags[i].type == 'syntaxhighlighter')
1085
+ result.push(tags[i]);
1086
+
1087
+ return result;
1088
+ },
1089
+
1090
+ /**
1091
+ * Strips <![CDATA[]]> from <SCRIPT /> content because it should be used
1092
+ * there in most cases for XHTML compliance.
1093
+ * @param {String} original Input code.
1094
+ * @return {String} Returns code without leading <![CDATA[]]> tags.
1095
+ */
1096
+ stripCData: function(original)
1097
+ {
1098
+ var left = '<![CDATA[',
1099
+ right = ']]>',
1100
+ // for some reason IE inserts some leading blanks here
1101
+ copy = sh.utils.trim(original),
1102
+ changed = false
1103
+ ;
1104
+
1105
+ if (copy.indexOf(left) == 0)
1106
+ {
1107
+ copy = copy.substring(left.length);
1108
+ changed = true;
1109
+ }
1110
+
1111
+ if (copy.indexOf(right) == copy.length - right.length)
1112
+ {
1113
+ copy = copy.substring(0, copy.length - right.length);
1114
+ changed = true;
1115
+ }
1116
+
1117
+ return changed ? copy : original;
1118
+ }
1119
+ }, // end of utils
1120
+
1121
+ /**
1122
+ * Shorthand to highlight all elements on the page that are marked as
1123
+ * SyntaxHighlighter source code.
1124
+ *
1125
+ * @param {Object} globalParams Optional parameters which override element's
1126
+ * parameters. Only used if element is specified.
1127
+ *
1128
+ * @param {Object} element Optional element to highlight. If none is
1129
+ * provided, all elements in the current document
1130
+ * are highlighted.
1131
+ */
1132
+ highlight : function(globalParams, element)
1133
+ {
1134
+ function toArray(source)
1135
+ {
1136
+ var result = [];
1137
+
1138
+ for (var i = 0; i < source.length; i++)
1139
+ result.push(source[i]);
1140
+
1141
+ return result;
1142
+ };
1143
+
1144
+ var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
1145
+ propertyName = 'innerHTML',
1146
+ highlighter = null,
1147
+ conf = sh.config
1148
+ ;
1149
+
1150
+ // support for <SCRIPT TYPE="syntaxhighlighter" /> feature
1151
+ if (conf.useScriptTags)
1152
+ elements = elements.concat(sh.utils.getSyntaxHighlighterScriptTags());
1153
+
1154
+ if (elements.length === 0)
1155
+ return;
1156
+
1157
+ for (var i = 0; i < elements.length; i++)
1158
+ {
1159
+ var target = elements[i],
1160
+ params = sh.utils.parseParams(target.className),
1161
+ brushName,
1162
+ code,
1163
+ result
1164
+ ;
1165
+
1166
+ // local params take precedence over globals
1167
+ params = sh.utils.merge(globalParams, params);
1168
+ brushName = params['brush'];
1169
+
1170
+ if (brushName == null)
1171
+ continue;
1172
+
1173
+ // Instantiate a brush
1174
+ if (params['html-script'] == 'true' || sh.defaults['html-script'] == true)
1175
+ {
1176
+ highlighter = new sh.HtmlScript(brushName);
1177
+ brushName = 'htmlscript';
1178
+ }
1179
+ else
1180
+ {
1181
+ var brush = sh.utils.findBrush(brushName);
1182
+
1183
+ if (brush)
1184
+ {
1185
+ brushName = brush.name;
1186
+ highlighter = new brush();
1187
+ }
1188
+ else
1189
+ {
1190
+ continue;
1191
+ }
1192
+ }
1193
+
1194
+ code = target[propertyName];
1195
+
1196
+ // remove CDATA from <SCRIPT/> tags if it's present
1197
+ if (conf.useScriptTags)
1198
+ code = sh.utils.stripCData(code);
1199
+
1200
+ params['brush-name'] = brushName;
1201
+ highlighter.highlight(code, params);
1202
+
1203
+ result = highlighter.div;
1204
+
1205
+ if (sh.config.debug)
1206
+ {
1207
+ result = document.createElement('textarea');
1208
+ result.value = highlighter.div.innerHTML;
1209
+ result.style.width = '70em';
1210
+ result.style.height = '30em';
1211
+ }
1212
+
1213
+ target.parentNode.replaceChild(result, target);
1214
+ }
1215
+ },
1216
+
1217
+ /**
1218
+ * Main entry point for the SyntaxHighlighter.
1219
+ * @param {Object} params Optional params to apply to all highlighted elements.
1220
+ */
1221
+ all : function(params)
1222
+ {
1223
+ sh.utils.addEvent(
1224
+ window,
1225
+ 'load',
1226
+ function() { sh.highlight(params); }
1227
+ );
1228
+ }
1229
+ }; // end of sh
1230
+
1231
+ /**
1232
+ * Match object.
1233
+ */
1234
+ sh.Match = function(value, index, css)
1235
+ {
1236
+ this.value = value;
1237
+ this.index = index;
1238
+ this.length = value.length;
1239
+ this.css = css;
1240
+ this.brushName = null;
1241
+ };
1242
+
1243
+ sh.Match.prototype.toString = function()
1244
+ {
1245
+ return this.value;
1246
+ };
1247
+
1248
+ /**
1249
+ * Simulates HTML code with a scripting language embedded.
1250
+ *
1251
+ * @param {String} scriptBrushName Brush name of the scripting language.
1252
+ */
1253
+ sh.HtmlScript = function(scriptBrushName)
1254
+ {
1255
+ var brushClass = sh.utils.findBrush(scriptBrushName),
1256
+ scriptBrush,
1257
+ xmlBrush = new sh.brushes.Xml(),
1258
+ bracketsRegex = null
1259
+ ;
1260
+
1261
+ if (brushClass == null)
1262
+ return;
1263
+
1264
+ scriptBrush = new brushClass();
1265
+ this.xmlBrush = xmlBrush;
1266
+
1267
+ if (scriptBrush.htmlScript == null)
1268
+ {
1269
+ sh.utils.alert(sh.config.strings.brushNotHtmlScript + scriptBrushName);
1270
+ return;
1271
+ }
1272
+
1273
+ xmlBrush.regexList.push(
1274
+ { regex: scriptBrush.htmlScript.code, func: process }
1275
+ );
1276
+
1277
+ function offsetMatches(matches, offset)
1278
+ {
1279
+ for (var j = 0; j < matches.length; j++)
1280
+ matches[j].index += offset;
1281
+ }
1282
+
1283
+ function process(match, info)
1284
+ {
1285
+ var code = match.code,
1286
+ matches = [],
1287
+ regexList = scriptBrush.regexList,
1288
+ offset = match.index + match.left.length,
1289
+ htmlScript = scriptBrush.htmlScript,
1290
+ result
1291
+ ;
1292
+
1293
+ // add all matches from the code
1294
+ for (var i = 0; i < regexList.length; i++)
1295
+ {
1296
+ result = sh.utils.getMatches(code, regexList[i]);
1297
+ offsetMatches(result, offset);
1298
+ matches = matches.concat(result);
1299
+ }
1300
+
1301
+ // add left script bracket
1302
+ if (htmlScript.left != null && match.left != null)
1303
+ {
1304
+ result = sh.utils.getMatches(match.left, htmlScript.left);
1305
+ offsetMatches(result, match.index);
1306
+ matches = matches.concat(result);
1307
+ }
1308
+
1309
+ // add right script bracket
1310
+ if (htmlScript.right != null && match.right != null)
1311
+ {
1312
+ result = sh.utils.getMatches(match.right, htmlScript.right);
1313
+ offsetMatches(result, match.index + match[0].lastIndexOf(match.right));
1314
+ matches = matches.concat(result);
1315
+ }
1316
+
1317
+ for (var j = 0; j < matches.length; j++)
1318
+ matches[j].brushName = brushClass.name;
1319
+
1320
+ return matches;
1321
+ }
1322
+ };
1323
+
1324
+ sh.HtmlScript.prototype.highlight = function(code, params)
1325
+ {
1326
+ this.xmlBrush.highlight(code, params);
1327
+ this.div = this.xmlBrush.div;
1328
+ }
1329
+
1330
+ /**
1331
+ * Main Highlither class.
1332
+ * @constructor
1333
+ */
1334
+ sh.Highlighter = function()
1335
+ {
1336
+ };
1337
+
1338
+ sh.Highlighter.prototype = {
1339
+ /**
1340
+ * Returns value of the parameter passed to the highlighter.
1341
+ * @param {String} name Name of the parameter.
1342
+ * @param {Object} defaultValue Default value.
1343
+ * @return {Object} Returns found value or default value otherwise.
1344
+ */
1345
+ getParam : function(name, defaultValue)
1346
+ {
1347
+ var result = this.params[name];
1348
+ return sh.utils.toBoolean(result == null ? defaultValue : result);
1349
+ },
1350
+
1351
+ /**
1352
+ * Shortcut to document.createElement().
1353
+ * @param {String} name Name of the element to create (DIV, A, etc).
1354
+ * @return {HTMLElement} Returns new HTML element.
1355
+ */
1356
+ create: function(name)
1357
+ {
1358
+ return document.createElement(name);
1359
+ },
1360
+
1361
+ /**
1362
+ * Applies all regular expression to the code and stores all found
1363
+ * matches in the `this.matches` array.
1364
+ * @param {Array} regexList List of regular expressions.
1365
+ * @param {String} code Source code.
1366
+ * @return {Array} Returns list of matches.
1367
+ */
1368
+ findMatches: function(regexList, code)
1369
+ {
1370
+ var result = [];
1371
+
1372
+ if (regexList != null)
1373
+ for (var i = 0; i < regexList.length; i++)
1374
+ // BUG: length returns len+1 for array if methods added to prototype chain (oising@gmail.com)
1375
+ if (typeof (regexList[i]) == "object")
1376
+ result = result.concat(sh.utils.getMatches(code, regexList[i]));
1377
+
1378
+ // sort the matches
1379
+ return result.sort(sh.utils.matchesSortCallback);
1380
+ },
1381
+
1382
+ /**
1383
+ * Checks to see if any of the matches are inside of other matches.
1384
+ * This process would get rid of highligted strings inside comments,
1385
+ * keywords inside strings and so on.
1386
+ */
1387
+ removeNestedMatches: function()
1388
+ {
1389
+ var matches = this.matches;
1390
+
1391
+ // Optimized by Jose Prado (http://joseprado.com)
1392
+ for (var i = 0; i < matches.length; i++)
1393
+ {
1394
+ if (matches[i] === null)
1395
+ continue;
1396
+
1397
+ var itemI = matches[i],
1398
+ itemIEndPos = itemI.index + itemI.length
1399
+ ;
1400
+
1401
+ for (var j = i + 1; j < matches.length && matches[i] !== null; j++)
1402
+ {
1403
+ var itemJ = matches[j];
1404
+
1405
+ if (itemJ === null)
1406
+ continue;
1407
+ else if (itemJ.index > itemIEndPos)
1408
+ break;
1409
+ else if (itemJ.index == itemI.index && itemJ.length > itemI.length)
1410
+ this.matches[i] = null;
1411
+ else if (itemJ.index >= itemI.index && itemJ.index < itemIEndPos)
1412
+ this.matches[j] = null;
1413
+ }
1414
+ }
1415
+ },
1416
+
1417
+ /**
1418
+ * Splits block of text into individual DIV lines.
1419
+ * @param {String} code Code to highlight.
1420
+ * @return {String} Returns highlighted code in HTML form.
1421
+ */
1422
+ createDisplayLines : function(code)
1423
+ {
1424
+ var lines = code.split(/\n/g),
1425
+ firstLine = parseInt(this.getParam('first-line')),
1426
+ padLength = this.getParam('pad-line-numbers'),
1427
+ highlightedLines = this.getParam('highlight', []),
1428
+ hasGutter = this.getParam('gutter')
1429
+ ;
1430
+
1431
+ code = '';
1432
+
1433
+ if (padLength == true)
1434
+ padLength = (firstLine + lines.length - 1).toString().length;
1435
+ else if (isNaN(padLength) == true)
1436
+ padLength = 0;
1437
+
1438
+ for (var i = 0; i < lines.length; i++)
1439
+ {
1440
+ var line = lines[i],
1441
+ indent = /^(&nbsp;|\s)+/.exec(line),
1442
+ lineClass = 'alt' + (i % 2 == 0 ? 1 : 2),
1443
+ lineNumber = sh.utils.padNumber(firstLine + i, padLength),
1444
+ highlighted = sh.utils.indexOf(highlightedLines, (firstLine + i).toString()) != -1,
1445
+ spaces = null
1446
+ ;
1447
+
1448
+ if (indent != null)
1449
+ {
1450
+ spaces = indent[0].toString();
1451
+ line = line.substr(spaces.length);
1452
+ }
1453
+
1454
+ line = sh.utils.trim(line);
1455
+
1456
+ if (line.length == 0)
1457
+ line = '&nbsp;';
1458
+
1459
+ if (highlighted)
1460
+ lineClass += ' highlighted';
1461
+
1462
+ code +=
1463
+ '<div class="line ' + lineClass + '">'
1464
+ + '<table>'
1465
+ + '<tr>'
1466
+ + (hasGutter ? '<td class="number"><code>' + lineNumber + '</code></td>' : '')
1467
+ + '<td class="content">'
1468
+ + (spaces != null ? '<code class="spaces">' + spaces.replace(' ', '&nbsp;') + '</code>' : '')
1469
+ + line
1470
+ + '</td>'
1471
+ + '</tr>'
1472
+ + '</table>'
1473
+ + '</div>'
1474
+ ;
1475
+ }
1476
+
1477
+ return code;
1478
+ },
1479
+
1480
+ /**
1481
+ * Finds all matches in the source code.
1482
+ * @param {String} code Source code to process matches in.
1483
+ * @param {Array} matches Discovered regex matches.
1484
+ * @return {String} Returns formatted HTML with processed mathes.
1485
+ */
1486
+ processMatches: function(code, matches)
1487
+ {
1488
+ var pos = 0,
1489
+ result = '',
1490
+ decorate = sh.utils.decorate, // make an alias to save some bytes
1491
+ brushName = this.getParam('brush-name', '')
1492
+ ;
1493
+
1494
+ function getBrushNameCss(match)
1495
+ {
1496
+ var result = match ? (match.brushName || brushName) : brushName;
1497
+ return result ? result + ' ' : '';
1498
+ };
1499
+
1500
+ // Finally, go through the final list of matches and pull the all
1501
+ // together adding everything in between that isn't a match.
1502
+ for (var i = 0; i < matches.length; i++)
1503
+ {
1504
+ var match = matches[i],
1505
+ matchBrushName
1506
+ ;
1507
+
1508
+ if (match === null || match.length === 0)
1509
+ continue;
1510
+
1511
+ matchBrushName = getBrushNameCss(match);
1512
+
1513
+ result += decorate(code.substr(pos, match.index - pos), matchBrushName + 'plain')
1514
+ + decorate(match.value, matchBrushName + match.css)
1515
+ ;
1516
+
1517
+ pos = match.index + match.length;
1518
+ }
1519
+
1520
+ // don't forget to add whatever's remaining in the string
1521
+ result += decorate(code.substr(pos), getBrushNameCss() + 'plain');
1522
+
1523
+ return result;
1524
+ },
1525
+
1526
+ /**
1527
+ * Highlights the code and returns complete HTML.
1528
+ * @param {String} code Code to highlight.
1529
+ * @param {Object} params Parameters object.
1530
+ */
1531
+ highlight: function(code, params)
1532
+ {
1533
+ // using variables for shortcuts because JS compressor will shorten local variable names
1534
+ var conf = sh.config,
1535
+ vars = sh.vars,
1536
+ div,
1537
+ divClassName,
1538
+ tabSize,
1539
+ important = 'important'
1540
+ ;
1541
+
1542
+ this.params = {};
1543
+ this.div = null;
1544
+ this.lines = null;
1545
+ this.code = null;
1546
+ this.bar = null;
1547
+ this.toolbarCommands = {};
1548
+ this.id = sh.utils.guid('highlighter_');
1549
+
1550
+ // register this instance in the highlighters list
1551
+ vars.highlighters[this.id] = this;
1552
+
1553
+ if (code === null)
1554
+ code = '';
1555
+
1556
+ // local params take precedence over defaults
1557
+ this.params = sh.utils.merge(sh.defaults, params || {});
1558
+
1559
+ // process light mode
1560
+ if (this.getParam('light') == true)
1561
+ this.params.toolbar = this.params.gutter = false;
1562
+
1563
+ this.div = div = this.create('DIV');
1564
+ this.lines = this.create('DIV');
1565
+ this.lines.className = 'lines';
1566
+
1567
+ className = 'syntaxhighlighter';
1568
+ div.id = this.id;
1569
+
1570
+ // make collapsed
1571
+ if (this.getParam('collapse'))
1572
+ className += ' collapsed';
1573
+
1574
+ // disable gutter
1575
+ if (this.getParam('gutter') == false)
1576
+ className += ' nogutter';
1577
+
1578
+ // disable line wrapping
1579
+ if (this.getParam('wrap-lines') == false)
1580
+ this.lines.className += ' no-wrap';
1581
+
1582
+ // add custom user style name
1583
+ className += ' ' + this.getParam('class-name');
1584
+
1585
+ // add brush alias to the class name for custom CSS
1586
+ className += ' ' + this.getParam('brush-name');
1587
+
1588
+ div.className = className;
1589
+
1590
+ this.originalCode = code;
1591
+ this.code = sh.utils.trimFirstAndLastLines(code)
1592
+ .replace(/\r/g, ' ') // IE lets these buggers through
1593
+ ;
1594
+
1595
+ tabSize = this.getParam('tab-size');
1596
+
1597
+ // replace tabs with spaces
1598
+ this.code = this.getParam('smart-tabs') == true
1599
+ ? sh.utils.processSmartTabs(this.code, tabSize)
1600
+ : sh.utils.processTabs(this.code, tabSize)
1601
+ ;
1602
+
1603
+ this.code = sh.utils.unindent(this.code);
1604
+
1605
+ // add controls toolbar
1606
+ if (this.getParam('toolbar'))
1607
+ {
1608
+ this.bar = this.create('DIV');
1609
+ this.bar.className = 'bar';
1610
+ this.bar.appendChild(sh.toolbar.create(this));
1611
+ div.appendChild(this.bar);
1612
+
1613
+ // set up toolbar rollover
1614
+ var bar = this.bar;
1615
+ function hide() { bar.className = bar.className.replace('show', ''); }
1616
+ div.onmouseover = function() { hide(); bar.className += ' show'; };
1617
+ div.onmouseout = function() { hide(); }
1618
+ }
1619
+
1620
+ div.appendChild(this.lines);
1621
+
1622
+ this.matches = this.findMatches(this.regexList, this.code);
1623
+ this.removeNestedMatches();
1624
+
1625
+ code = this.processMatches(this.code, this.matches);
1626
+
1627
+ // finally, split all lines so that they wrap well
1628
+ code = this.createDisplayLines(sh.utils.trim(code));
1629
+
1630
+ // finally, process the links
1631
+ if (this.getParam('auto-links'))
1632
+ code = sh.utils.processUrls(code);
1633
+
1634
+ this.lines.innerHTML = code;
1635
+ },
1636
+
1637
+ /**
1638
+ * Converts space separated list of keywords into a regular expression string.
1639
+ * @param {String} str Space separated keywords.
1640
+ * @return {String} Returns regular expression string.
1641
+ */
1642
+ getKeywords: function(str)
1643
+ {
1644
+ str = str
1645
+ .replace(/^\s+|\s+$/g, '')
1646
+ .replace(/\s+/g, '|')
1647
+ ;
1648
+
1649
+ return '\\b(?:' + str + ')\\b';
1650
+ },
1651
+
1652
+ /**
1653
+ * Makes a brush compatible with the `html-script` functionality.
1654
+ * @param {Object} regexGroup Object containing `left` and `right` regular expressions.
1655
+ */
1656
+ forHtmlScript: function(regexGroup)
1657
+ {
1658
+ this.htmlScript = {
1659
+ left : { regex: regexGroup.left, css: 'script' },
1660
+ right : { regex: regexGroup.right, css: 'script' },
1661
+ code : new XRegExp(
1662
+ "(?<left>" + regexGroup.left.source + ")" +
1663
+ "(?<code>.*?)" +
1664
+ "(?<right>" + regexGroup.right.source + ")",
1665
+ "sgi"
1666
+ )
1667
+ };
1668
+ }
1669
+ }; // end of Highlighter
1670
+
1671
+ return sh;
1672
+ }(); // end of anonymous function
1673
+
1674
+
1675
+ /**
1676
+ * XRegExp 0.6.1
1677
+ * (c) 2007-2008 Steven Levithan
1678
+ * <http://stevenlevithan.com/regex/xregexp/>
1679
+ * MIT License
1680
+ *
1681
+ * provides an augmented, cross-browser implementation of regular expressions
1682
+ * including support for additional modifiers and syntax. several convenience
1683
+ * methods and a recursive-construct parser are also included.
1684
+ */
1685
+
1686
+ // prevent running twice, which would break references to native globals
1687
+ if (!window.XRegExp) {
1688
+ // anonymous function to avoid global variables
1689
+ (function () {
1690
+ // copy various native globals for reference. can't use the name ``native``
1691
+ // because it's a reserved JavaScript keyword.
1692
+ var real = {
1693
+ exec: RegExp.prototype.exec,
1694
+ match: String.prototype.match,
1695
+ replace: String.prototype.replace,
1696
+ split: String.prototype.split
1697
+ },
1698
+ /* regex syntax parsing with support for all the necessary cross-
1699
+ browser and context issues (escapings, character classes, etc.) */
1700
+ lib = {
1701
+ part: /(?:[^\\([#\s.]+|\\(?!k<[\w$]+>|[pP]{[^}]+})[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\(?:k<([\w$]+)>|[pP]{([^}]+)})|(\[\^?)|([\S\s])/g,
1702
+ replaceVar: /(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g,
1703
+ extended: /^(?:\s+|#.*)+/,
1704
+ quantifier: /^(?:[?*+]|{\d+(?:,\d*)?})/,
1705
+ classLeft: /&&\[\^?/g,
1706
+ classRight: /]/g
1707
+ },
1708
+ indexOf = function (array, item, from) {
1709
+ for (var i = from || 0; i < array.length; i++)
1710
+ if (array[i] === item) return i;
1711
+ return -1;
1712
+ },
1713
+ brokenExecUndef = /()??/.exec("")[1] !== undefined,
1714
+ plugins = {};
1715
+
1716
+ /**
1717
+ * Accepts a pattern and flags, returns a new, extended RegExp object.
1718
+ * differs from a native regex in that additional flags and syntax are
1719
+ * supported and browser inconsistencies are ameliorated.
1720
+ * @ignore
1721
+ */
1722
+ XRegExp = function (pattern, flags) {
1723
+ if (pattern instanceof RegExp) {
1724
+ if (flags !== undefined)
1725
+ throw TypeError("can't supply flags when constructing one RegExp from another");
1726
+ return pattern.addFlags(); // new copy
1727
+ }
1728
+
1729
+ var flags = flags || "",
1730
+ singleline = flags.indexOf("s") > -1,
1731
+ extended = flags.indexOf("x") > -1,
1732
+ hasNamedCapture = false,
1733
+ captureNames = [],
1734
+ output = [],
1735
+ part = lib.part,
1736
+ match, cc, len, index, regex;
1737
+
1738
+ part.lastIndex = 0; // in case the last XRegExp compilation threw an error (unbalanced character class)
1739
+
1740
+ while (match = real.exec.call(part, pattern)) {
1741
+ // comment pattern. this check must come before the capturing group check,
1742
+ // because both match[1] and match[2] will be non-empty.
1743
+ if (match[2]) {
1744
+ // keep tokens separated unless the following token is a quantifier
1745
+ if (!lib.quantifier.test(pattern.slice(part.lastIndex)))
1746
+ output.push("(?:)");
1747
+ // capturing group
1748
+ } else if (match[1]) {
1749
+ captureNames.push(match[3] || null);
1750
+ if (match[3])
1751
+ hasNamedCapture = true;
1752
+ output.push("(");
1753
+ // named backreference
1754
+ } else if (match[4]) {
1755
+ index = indexOf(captureNames, match[4]);
1756
+ // keep backreferences separate from subsequent literal numbers
1757
+ // preserve backreferences to named groups that are undefined at this point as literal strings
1758
+ output.push(index > -1 ?
1759
+ "\\" + (index + 1) + (isNaN(pattern.charAt(part.lastIndex)) ? "" : "(?:)") :
1760
+ match[0]
1761
+ );
1762
+ // unicode element (requires plugin)
1763
+ } else if (match[5]) {
1764
+ output.push(plugins.unicode ?
1765
+ plugins.unicode.get(match[5], match[0].charAt(1) === "P") :
1766
+ match[0]
1767
+ );
1768
+ // character class opening delimiter ("[" or "[^")
1769
+ // (non-native unicode elements are not supported within character classes)
1770
+ } else if (match[6]) {
1771
+ if (pattern.charAt(part.lastIndex) === "]") {
1772
+ // for cross-browser compatibility with ECMA-262 v3 behavior,
1773
+ // convert [] to (?!) and [^] to [\S\s].
1774
+ output.push(match[6] === "[" ? "(?!)" : "[\\S\\s]");
1775
+ part.lastIndex++;
1776
+ } else {
1777
+ // parse the character class with support for inner escapes and
1778
+ // ES4's infinitely nesting intersection syntax ([&&[^&&[]]]).
1779
+ cc = XRegExp.matchRecursive("&&" + pattern.slice(match.index), lib.classLeft, lib.classRight, "", {escapeChar: "\\"})[0];
1780
+ output.push(match[6] + cc + "]");
1781
+ part.lastIndex += cc.length + 1;
1782
+ }
1783
+ // dot ("."), pound sign ("#"), or whitespace character
1784
+ } else if (match[7]) {
1785
+ if (singleline && match[7] === ".") {
1786
+ output.push("[\\S\\s]");
1787
+ } else if (extended && lib.extended.test(match[7])) {
1788
+ len = real.exec.call(lib.extended, pattern.slice(part.lastIndex - 1))[0].length;
1789
+ // keep tokens separated unless the following token is a quantifier
1790
+ if (!lib.quantifier.test(pattern.slice(part.lastIndex - 1 + len)))
1791
+ output.push("(?:)");
1792
+ part.lastIndex += len - 1;
1793
+ } else {
1794
+ output.push(match[7]);
1795
+ }
1796
+ } else {
1797
+ output.push(match[0]);
1798
+ }
1799
+ }
1800
+
1801
+ regex = RegExp(output.join(""), real.replace.call(flags, /[sx]+/g, ""));
1802
+ regex._x = {
1803
+ source: pattern,
1804
+ captureNames: hasNamedCapture ? captureNames : null
1805
+ };
1806
+ return regex;
1807
+ };
1808
+
1809
+ /**
1810
+ * Barebones plugin support for now (intentionally undocumented)
1811
+ * @ignore
1812
+ * @param {Object} name
1813
+ * @param {Object} o
1814
+ */
1815
+ XRegExp.addPlugin = function (name, o) {
1816
+ plugins[name] = o;
1817
+ };
1818
+
1819
+ /**
1820
+ * Adds named capture support, with values returned as ``result.name``.
1821
+ *
1822
+ * Also fixes two cross-browser issues, following the ECMA-262 v3 spec:
1823
+ * - captured values for non-participating capturing groups should be returned
1824
+ * as ``undefined``, rather than the empty string.
1825
+ * - the regex's ``lastIndex`` should not be incremented after zero-length
1826
+ * matches.
1827
+ * @ignore
1828
+ */
1829
+ RegExp.prototype.exec = function (str) {
1830
+ var match = real.exec.call(this, str),
1831
+ name, i, r2;
1832
+ if (match) {
1833
+ // fix browsers whose exec methods don't consistently return
1834
+ // undefined for non-participating capturing groups
1835
+ if (brokenExecUndef && match.length > 1) {
1836
+ // r2 doesn't need /g or /y, but they shouldn't hurt
1837
+ r2 = new RegExp("^" + this.source + "$(?!\\s)", this.getNativeFlags());
1838
+ real.replace.call(match[0], r2, function () {
1839
+ for (i = 1; i < arguments.length - 2; i++) {
1840
+ if (arguments[i] === undefined) match[i] = undefined;
1841
+ }
1842
+ });
1843
+ }
1844
+ // attach named capture properties
1845
+ if (this._x && this._x.captureNames) {
1846
+ for (i = 1; i < match.length; i++) {
1847
+ name = this._x.captureNames[i - 1];
1848
+ if (name) match[name] = match[i];
1849
+ }
1850
+ }
1851
+ // fix browsers that increment lastIndex after zero-length matches
1852
+ if (this.global && this.lastIndex > (match.index + match[0].length))
1853
+ this.lastIndex--;
1854
+ }
1855
+ return match;
1856
+ };
1857
+ })(); // end anonymous function
1858
+ } // end if(!window.XRegExp)
1859
+
1860
+ /**
1861
+ * intentionally undocumented
1862
+ * @ignore
1863
+ */
1864
+ RegExp.prototype.getNativeFlags = function () {
1865
+ return (this.global ? "g" : "") +
1866
+ (this.ignoreCase ? "i" : "") +
1867
+ (this.multiline ? "m" : "") +
1868
+ (this.extended ? "x" : "") +
1869
+ (this.sticky ? "y" : "");
1870
+ };
1871
+
1872
+ /**
1873
+ * Accepts flags; returns a new XRegExp object generated by recompiling
1874
+ * the regex with the additional flags (may include non-native flags).
1875
+ * The original regex object is not altered.
1876
+ * @ignore
1877
+ */
1878
+ RegExp.prototype.addFlags = function (flags) {
1879
+ var regex = new XRegExp(this.source, (flags || "") + this.getNativeFlags());
1880
+ if (this._x) {
1881
+ regex._x = {
1882
+ source: this._x.source,
1883
+ captureNames: this._x.captureNames ? this._x.captureNames.slice(0) : null
1884
+ };
1885
+ }
1886
+ return regex;
1887
+ };
1888
+
1889
+ /**
1890
+ * Accepts a context object and string; returns the result of calling
1891
+ * ``exec`` with the provided string. the context is ignored but is
1892
+ * accepted for congruity with ``Function.prototype.call``.
1893
+ * @ignore
1894
+ */
1895
+ RegExp.prototype.call = function (context, str) {
1896
+ return this.exec(str);
1897
+ };
1898
+
1899
+ /**
1900
+ * Accepts a context object and arguments array; returns the result of
1901
+ * calling ``exec`` with the first value in the arguments array. the context
1902
+ * is ignored but is accepted for congruity with ``Function.prototype.apply``.
1903
+ * @ignore
1904
+ */
1905
+ RegExp.prototype.apply = function (context, args) {
1906
+ return this.exec(args[0]);
1907
+ };
1908
+
1909
+ /**
1910
+ * Accepts a pattern and flags; returns an XRegExp object. if the pattern
1911
+ * and flag combination has previously been cached, the cached copy is
1912
+ * returned, otherwise the new object is cached.
1913
+ * @ignore
1914
+ */
1915
+ XRegExp.cache = function (pattern, flags) {
1916
+ var key = "/" + pattern + "/" + (flags || "");
1917
+ return XRegExp.cache[key] || (XRegExp.cache[key] = new XRegExp(pattern, flags));
1918
+ };
1919
+
1920
+ /**
1921
+ * Accepts a string; returns the string with regex metacharacters escaped.
1922
+ * the returned string can safely be used within a regex to match a literal
1923
+ * string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \, ^, $,
1924
+ * |, #, [comma], and whitespace.
1925
+ * @ignore
1926
+ */
1927
+ XRegExp.escape = function (str) {
1928
+ return str.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&");
1929
+ };
1930
+
1931
+ /**
1932
+ * Accepts a string to search, left and right delimiters as regex pattern
1933
+ * strings, optional regex flags (may include non-native s, x, and y flags),
1934
+ * and an options object which allows setting an escape character and changing
1935
+ * the return format from an array of matches to a two-dimensional array of
1936
+ * string parts with extended position data. returns an array of matches
1937
+ * (optionally with extended data), allowing nested instances of left and right
1938
+ * delimiters. use the g flag to return all matches, otherwise only the first
1939
+ * is returned. if delimiters are unbalanced within the subject data, an error
1940
+ * is thrown.
1941
+ *
1942
+ * This function admittedly pushes the boundaries of what can be accomplished
1943
+ * sensibly without a "real" parser. however, by doing so it provides flexible
1944
+ * and powerful recursive parsing capabilities with minimal code weight.
1945
+ *
1946
+ * Warning: the ``escapeChar`` option is considered experimental and might be
1947
+ * changed or removed in future versions of XRegExp.
1948
+ *
1949
+ * unsupported features:
1950
+ * - backreferences within delimiter patterns when using ``escapeChar``.
1951
+ * - although providing delimiters as regex objects adds the minor feature of
1952
+ * independent delimiter flags, it introduces other limitations and is only
1953
+ * intended to be done by the ``XRegExp`` constructor (which can't call
1954
+ * itself while building a regex).
1955
+ *
1956
+ * @ignore
1957
+ */
1958
+ XRegExp.matchRecursive = function (str, left, right, flags, options) {
1959
+ var options = options || {},
1960
+ escapeChar = options.escapeChar,
1961
+ vN = options.valueNames,
1962
+ flags = flags || "",
1963
+ global = flags.indexOf("g") > -1,
1964
+ ignoreCase = flags.indexOf("i") > -1,
1965
+ multiline = flags.indexOf("m") > -1,
1966
+ sticky = flags.indexOf("y") > -1,
1967
+ /* sticky mode has its own handling in this function, which means you
1968
+ can use flag "y" even in browsers which don't support it natively */
1969
+ flags = flags.replace(/y/g, ""),
1970
+ left = left instanceof RegExp ? (left.global ? left : left.addFlags("g")) : new XRegExp(left, "g" + flags),
1971
+ right = right instanceof RegExp ? (right.global ? right : right.addFlags("g")) : new XRegExp(right, "g" + flags),
1972
+ output = [],
1973
+ openTokens = 0,
1974
+ delimStart = 0,
1975
+ delimEnd = 0,
1976
+ lastOuterEnd = 0,
1977
+ outerStart, innerStart, leftMatch, rightMatch, escaped, esc;
1978
+
1979
+ if (escapeChar) {
1980
+ if (escapeChar.length > 1) throw SyntaxError("can't supply more than one escape character");
1981
+ if (multiline) throw TypeError("can't supply escape character when using the multiline flag");
1982
+ escaped = XRegExp.escape(escapeChar);
1983
+ /* Escape pattern modifiers:
1984
+ /g - not needed here
1985
+ /i - included
1986
+ /m - **unsupported**, throws error
1987
+ /s - handled by XRegExp when delimiters are provided as strings
1988
+ /x - handled by XRegExp when delimiters are provided as strings
1989
+ /y - not needed here; supported by other handling in this function
1990
+ */
1991
+ esc = new RegExp(
1992
+ "^(?:" + escaped + "[\\S\\s]|(?:(?!" + left.source + "|" + right.source + ")[^" + escaped + "])+)+",
1993
+ ignoreCase ? "i" : ""
1994
+ );
1995
+ }
1996
+
1997
+ while (true) {
1998
+ /* advance the starting search position to the end of the last delimiter match.
1999
+ a couple special cases are also covered:
2000
+ - if using an escape character, advance to the next delimiter's starting position,
2001
+ skipping any escaped characters
2002
+ - first time through, reset lastIndex in case delimiters were provided as regexes
2003
+ */
2004
+ left.lastIndex = right.lastIndex = delimEnd +
2005
+ (escapeChar ? (esc.exec(str.slice(delimEnd)) || [""])[0].length : 0);
2006
+
2007
+ leftMatch = left.exec(str);
2008
+ rightMatch = right.exec(str);
2009
+
2010
+ // only keep the result which matched earlier in the string
2011
+ if (leftMatch && rightMatch) {
2012
+ if (leftMatch.index <= rightMatch.index)
2013
+ rightMatch = null;
2014
+ else leftMatch = null;
2015
+ }
2016
+
2017
+ /* paths*:
2018
+ leftMatch | rightMatch | openTokens | result
2019
+ 1 | 0 | 1 | ...
2020
+ 1 | 0 | 0 | ...
2021
+ 0 | 1 | 1 | ...
2022
+ 0 | 1 | 0 | throw
2023
+ 0 | 0 | 1 | throw
2024
+ 0 | 0 | 0 | break
2025
+ * - does not include the sticky mode special case
2026
+ - the loop ends after the first completed match if not in global mode
2027
+ */
2028
+
2029
+ if (leftMatch || rightMatch) {
2030
+ delimStart = (leftMatch || rightMatch).index;
2031
+ delimEnd = (leftMatch ? left : right).lastIndex;
2032
+ } else if (!openTokens) {
2033
+ break;
2034
+ }
2035
+
2036
+ if (sticky && !openTokens && delimStart > lastOuterEnd)
2037
+ break;
2038
+
2039
+ if (leftMatch) {
2040
+ if (!openTokens++) {
2041
+ outerStart = delimStart;
2042
+ innerStart = delimEnd;
2043
+ }
2044
+ } else if (rightMatch && openTokens) {
2045
+ if (!--openTokens) {
2046
+ if (vN) {
2047
+ if (vN[0] && outerStart > lastOuterEnd)
2048
+ output.push([vN[0], str.slice(lastOuterEnd, outerStart), lastOuterEnd, outerStart]);
2049
+ if (vN[1]) output.push([vN[1], str.slice(outerStart, innerStart), outerStart, innerStart]);
2050
+ if (vN[2]) output.push([vN[2], str.slice(innerStart, delimStart), innerStart, delimStart]);
2051
+ if (vN[3]) output.push([vN[3], str.slice(delimStart, delimEnd), delimStart, delimEnd]);
2052
+ } else {
2053
+ output.push(str.slice(innerStart, delimStart));
2054
+ }
2055
+ lastOuterEnd = delimEnd;
2056
+ if (!global)
2057
+ break;
2058
+ }
2059
+ } else {
2060
+ // reset lastIndex in case delimiters were provided as regexes
2061
+ left.lastIndex = right.lastIndex = 0;
2062
+ throw Error("subject data contains unbalanced delimiters");
2063
+ }
2064
+
2065
+ // if the delimiter matched an empty string, advance delimEnd to avoid an infinite loop
2066
+ if (delimStart === delimEnd)
2067
+ delimEnd++;
2068
+ }
2069
+
2070
+ if (global && !sticky && vN && vN[0] && str.length > lastOuterEnd)
2071
+ output.push([vN[0], str.slice(lastOuterEnd), lastOuterEnd, str.length]);
2072
+
2073
+ // reset lastIndex in case delimiters were provided as regexes
2074
+ left.lastIndex = right.lastIndex = 0;
2075
+
2076
+ return output;
2077
+ };