ueditor_rails4 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +45 -0
- data/Rakefile +40 -0
- data/app/assets/images/ueditor/themes/default/anchor.gif +0 -0
- data/app/assets/images/ueditor/themes/default/arrow.png +0 -0
- data/app/assets/images/ueditor/themes/default/button-bg.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cancelbutton.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_h.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_h.png +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_v.gif +0 -0
- data/app/assets/images/ueditor/themes/default/cursor_v.png +0 -0
- data/app/assets/images/ueditor/themes/default/dialog-title-bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/filescan.png +0 -0
- data/app/assets/images/ueditor/themes/default/highlighted.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons-all.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons.gif +0 -0
- data/app/assets/images/ueditor/themes/default/icons.png +0 -0
- data/app/assets/images/ueditor/themes/default/lock.gif +0 -0
- data/app/assets/images/ueditor/themes/default/neweditor-tab-bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/pagebreak.gif +0 -0
- data/app/assets/images/ueditor/themes/default/scale.png +0 -0
- data/app/assets/images/ueditor/themes/default/spacer.gif +0 -0
- data/app/assets/images/ueditor/themes/default/sparator_v.png +0 -0
- data/app/assets/images/ueditor/themes/default/toolbar_bg.png +0 -0
- data/app/assets/images/ueditor/themes/default/unhighlighted.gif +0 -0
- data/app/assets/images/ueditor/themes/default/upload.png +0 -0
- data/app/assets/images/ueditor/themes/default/videologo.gif +0 -0
- data/app/assets/images/ueditor/themes/default/word.gif +0 -0
- data/app/assets/images/ueditor/themes/default/wordpaste.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_chm.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_default.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_doc.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_exe.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mp3.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_mv.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_pdf.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_ppt.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_psd.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_rar.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_txt.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/attachment/fileTypeImages/icon_xls.gif +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/center_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/left_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/none_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/image/right_focus.jpg +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/addimg.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/brush.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/delimg.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/delimgH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/empty.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/emptyH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/eraser.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/redo.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/redoH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/scale.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/scaleH.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/size.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/undo.png +0 -0
- data/app/assets/images/ueditor_rails/dialogs/scrawl/undoH.png +0 -0
- data/app/assets/javascripts/ueditor_rails/_config.js.erb +211 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment.js +5 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_callbacks.js +166 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/attachment/_file_type_maps.js.erb +14 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/image.js.erb +724 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/scrawl.js +655 -0
- data/app/assets/javascripts/ueditor_rails/dialogs/wordimage.js +154 -0
- data/app/assets/javascripts/ueditor_rails/init.js +12 -0
- data/app/assets/stylesheets/ueditor/themes/default/dialogbase.css.erb +100 -0
- data/app/assets/stylesheets/ueditor/themes/default/ueditor.css +1582 -0
- data/app/assets/stylesheets/ueditor/themes/iframe.css +1 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/attachment.css.erb +161 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/image.css.erb +69 -0
- data/app/assets/stylesheets/ueditor_rails/dialogs/scrawl.css.erb +72 -0
- data/app/controllers/ueditor_rails/application_controller.rb +5 -0
- data/app/controllers/ueditor_rails/dialogs_controller.rb +21 -0
- data/app/controllers/ueditor_rails/libs_controller.rb +33 -0
- data/app/helpers/ueditor_rails/application_helper.rb +27 -0
- data/app/views/ueditor_rails/dialogs/attachment.html.erb +124 -0
- data/app/views/ueditor_rails/dialogs/image.html.erb +203 -0
- data/app/views/ueditor_rails/dialogs/scrawl.html.erb +96 -0
- data/app/views/ueditor_rails/dialogs/wordimage.html.erb +155 -0
- data/config/routes.rb +11 -0
- data/lib/generators/ueditor_rails/USAGE +8 -0
- data/lib/generators/ueditor_rails/install_generator.rb +15 -0
- data/lib/generators/ueditor_rails/templates/ueditor_config.js.erb +216 -0
- data/lib/tasks/ueditor_rails_tasks.rake +4 -0
- data/lib/ueditor_rails/engine.rb +17 -0
- data/lib/ueditor_rails/helpers/form_builder.rb +11 -0
- data/lib/ueditor_rails/helpers/form_helper.rb +37 -0
- data/lib/ueditor_rails/helpers/view_helper.rb +21 -0
- data/lib/ueditor_rails/util.rb +42 -0
- data/lib/ueditor_rails/version.rb +3 -0
- data/lib/ueditor_rails4.rb +32 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/posts.js +2 -0
- data/test/dummy/app/assets/javascripts/ueditor_config.js.erb +208 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/posts.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/posts/_form.html.erb +25 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +29 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +61 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +8 -0
- data/test/dummy/db/migrate/20130327173045_create_posts.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/posts.yml +9 -0
- data/test/dummy/test/functional/posts_controller_test.rb +49 -0
- data/test/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
- data/test/dummy/test/unit/post_test.rb +7 -0
- data/test/functional/ueditor_rails/dialogs_controller_test.rb +16 -0
- data/test/functional/ueditor_rails/libs_controller_test.rb +21 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/ueditor_rails_test.rb +7 -0
- data/vendor/assets/javascripts/ueditor/dialogs/anchor/anchor.html.erb +57 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.css +24 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.html.erb +55 -0
- data/vendor/assets/javascripts/ueditor/dialogs/background/background.js +348 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css.erb +43 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html.erb +54 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/gmap/gmap.html.erb +89 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.css +7 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.html.erb +84 -0
- data/vendor/assets/javascripts/ueditor/dialogs/help/help.js +54 -0
- data/vendor/assets/javascripts/ueditor/dialogs/highlightcode/highlightcode.html.erb +131 -0
- data/vendor/assets/javascripts/ueditor/dialogs/insertframe/insertframe.html.erb +98 -0
- data/vendor/assets/javascripts/ueditor/dialogs/internal.js +79 -0
- data/vendor/assets/javascripts/ueditor/dialogs/link/link.html.erb +141 -0
- data/vendor/assets/javascripts/ueditor/dialogs/map/map.html.erb +105 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.css +30 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.html.erb +32 -0
- data/vendor/assets/javascripts/ueditor/dialogs/music/music.js +192 -0
- data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.html.erb +74 -0
- data/vendor/assets/javascripts/ueditor/dialogs/searchreplace/searchreplace.js +160 -0
- data/vendor/assets/javascripts/ueditor/dialogs/snapscreen/snapscreen.html.erb +91 -0
- data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.html.erb +21 -0
- data/vendor/assets/javascripts/ueditor/dialogs/spechars/spechars.js +56 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/dragicon.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.css +75 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.html.erb +57 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittable.js +182 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittd.html.erb +51 -0
- data/vendor/assets/javascripts/ueditor/dialogs/table/edittip.html.erb +33 -0
- data/vendor/assets/javascripts/ueditor/dialogs/tangram.js +1238 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/config.js +42 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/bg.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre0.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre1.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre2.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre3.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/images/pre4.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.css +18 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.html.erb +26 -0
- data/vendor/assets/javascripts/ueditor/dialogs/template/template.js +53 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +59 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.html.erb +78 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.js.erb +409 -0
- data/vendor/assets/javascripts/ueditor/dialogs/webapp/webapp.html.erb +64 -0
- data/vendor/assets/javascripts/ueditor/editor_all.js.erb +19133 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +492 -0
- data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCore.js +3655 -0
- data/vendor/assets/javascripts/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css +316 -0
- data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.css +104 -0
- data/vendor/assets/javascripts/ueditor/third-party/codemirror/codemirror.js +3581 -0
- data/vendor/assets/javascripts/ueditor/third-party/fClipboard_ueditor.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/imageUploader.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/snapscreen/UEditorSnapscreen.exe +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/fileprogress.js +215 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.cookies.js +53 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.js +1132 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.proxy.js +96 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.queue.js +98 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.speed.js +346 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload.swf +0 -0
- data/vendor/assets/javascripts/ueditor/third-party/swfupload/swfupload_fp9.swf +0 -0
- data/vendor/assets/javascripts/ueditor/uparse.js +348 -0
- metadata +363 -0
@@ -0,0 +1,3655 @@
|
|
1
|
+
// XRegExp 1.5.1
|
2
|
+
// (c) 2007-2012 Steven Levithan
|
3
|
+
// MIT License
|
4
|
+
// <http://xregexp.com>
|
5
|
+
// Provides an augmented, extensible, cross-browser implementation of regular expressions,
|
6
|
+
// including support for additional syntax, flags, and methods
|
7
|
+
|
8
|
+
var XRegExp;
|
9
|
+
|
10
|
+
if (XRegExp) {
|
11
|
+
// Avoid running twice, since that would break references to native globals
|
12
|
+
throw Error("can't load XRegExp twice in the same frame");
|
13
|
+
}
|
14
|
+
|
15
|
+
// Run within an anonymous function to protect variables and avoid new globals
|
16
|
+
(function (undefined) {
|
17
|
+
|
18
|
+
//---------------------------------
|
19
|
+
// Constructor
|
20
|
+
//---------------------------------
|
21
|
+
|
22
|
+
// Accepts a pattern and flags; returns a new, extended `RegExp` object. Differs from a native
|
23
|
+
// regular expression in that additional syntax and flags are supported and cross-browser
|
24
|
+
// syntax inconsistencies are ameliorated. `XRegExp(/regex/)` clones an existing regex and
|
25
|
+
// converts to type XRegExp
|
26
|
+
XRegExp = function (pattern, flags) {
|
27
|
+
var output = [],
|
28
|
+
currScope = XRegExp.OUTSIDE_CLASS,
|
29
|
+
pos = 0,
|
30
|
+
context, tokenResult, match, chr, regex;
|
31
|
+
|
32
|
+
if (XRegExp.isRegExp(pattern)) {
|
33
|
+
if (flags !== undefined)
|
34
|
+
throw TypeError("can't supply flags when constructing one RegExp from another");
|
35
|
+
return clone(pattern);
|
36
|
+
}
|
37
|
+
// Tokens become part of the regex construction process, so protect against infinite
|
38
|
+
// recursion when an XRegExp is constructed within a token handler or trigger
|
39
|
+
if (isInsideConstructor)
|
40
|
+
throw Error("can't call the XRegExp constructor within token definition functions");
|
41
|
+
|
42
|
+
flags = flags || "";
|
43
|
+
context = { // `this` object for custom tokens
|
44
|
+
hasNamedCapture: false,
|
45
|
+
captureNames: [],
|
46
|
+
hasFlag: function (flag) {return flags.indexOf(flag) > -1;},
|
47
|
+
setFlag: function (flag) {flags += flag;}
|
48
|
+
};
|
49
|
+
|
50
|
+
while (pos < pattern.length) {
|
51
|
+
// Check for custom tokens at the current position
|
52
|
+
tokenResult = runTokens(pattern, pos, currScope, context);
|
53
|
+
|
54
|
+
if (tokenResult) {
|
55
|
+
output.push(tokenResult.output);
|
56
|
+
pos += (tokenResult.match[0].length || 1);
|
57
|
+
} else {
|
58
|
+
// Check for native multicharacter metasequences (excluding character classes) at
|
59
|
+
// the current position
|
60
|
+
if (match = nativ.exec.call(nativeTokens[currScope], pattern.slice(pos))) {
|
61
|
+
output.push(match[0]);
|
62
|
+
pos += match[0].length;
|
63
|
+
} else {
|
64
|
+
chr = pattern.charAt(pos);
|
65
|
+
if (chr === "[")
|
66
|
+
currScope = XRegExp.INSIDE_CLASS;
|
67
|
+
else if (chr === "]")
|
68
|
+
currScope = XRegExp.OUTSIDE_CLASS;
|
69
|
+
// Advance position one character
|
70
|
+
output.push(chr);
|
71
|
+
pos++;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
regex = RegExp(output.join(""), nativ.replace.call(flags, flagClip, ""));
|
77
|
+
regex._xregexp = {
|
78
|
+
source: pattern,
|
79
|
+
captureNames: context.hasNamedCapture ? context.captureNames : null
|
80
|
+
};
|
81
|
+
return regex;
|
82
|
+
};
|
83
|
+
|
84
|
+
|
85
|
+
//---------------------------------
|
86
|
+
// Public properties
|
87
|
+
//---------------------------------
|
88
|
+
|
89
|
+
XRegExp.version = "1.5.1";
|
90
|
+
|
91
|
+
// Token scope bitflags
|
92
|
+
XRegExp.INSIDE_CLASS = 1;
|
93
|
+
XRegExp.OUTSIDE_CLASS = 2;
|
94
|
+
|
95
|
+
|
96
|
+
//---------------------------------
|
97
|
+
// Private variables
|
98
|
+
//---------------------------------
|
99
|
+
|
100
|
+
var replacementToken = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g,
|
101
|
+
flagClip = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, // Nonnative and duplicate flags
|
102
|
+
quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/,
|
103
|
+
isInsideConstructor = false,
|
104
|
+
tokens = [],
|
105
|
+
// Copy native globals for reference ("native" is an ES3 reserved keyword)
|
106
|
+
nativ = {
|
107
|
+
exec: RegExp.prototype.exec,
|
108
|
+
test: RegExp.prototype.test,
|
109
|
+
match: String.prototype.match,
|
110
|
+
replace: String.prototype.replace,
|
111
|
+
split: String.prototype.split
|
112
|
+
},
|
113
|
+
compliantExecNpcg = nativ.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
|
114
|
+
compliantLastIndexIncrement = function () {
|
115
|
+
var x = /^/g;
|
116
|
+
nativ.test.call(x, "");
|
117
|
+
return !x.lastIndex;
|
118
|
+
}(),
|
119
|
+
hasNativeY = RegExp.prototype.sticky !== undefined,
|
120
|
+
nativeTokens = {};
|
121
|
+
|
122
|
+
// `nativeTokens` match native multicharacter metasequences only (including deprecated octals,
|
123
|
+
// excluding character classes)
|
124
|
+
nativeTokens[XRegExp.INSIDE_CLASS] = /^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/;
|
125
|
+
nativeTokens[XRegExp.OUTSIDE_CLASS] = /^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/;
|
126
|
+
|
127
|
+
|
128
|
+
//---------------------------------
|
129
|
+
// Public methods
|
130
|
+
//---------------------------------
|
131
|
+
|
132
|
+
// Lets you extend or change XRegExp syntax and create custom flags. This is used internally by
|
133
|
+
// the XRegExp library and can be used to create XRegExp plugins. This function is intended for
|
134
|
+
// users with advanced knowledge of JavaScript's regular expression syntax and behavior. It can
|
135
|
+
// be disabled by `XRegExp.freezeTokens`
|
136
|
+
XRegExp.addToken = function (regex, handler, scope, trigger) {
|
137
|
+
tokens.push({
|
138
|
+
pattern: clone(regex, "g" + (hasNativeY ? "y" : "")),
|
139
|
+
handler: handler,
|
140
|
+
scope: scope || XRegExp.OUTSIDE_CLASS,
|
141
|
+
trigger: trigger || null
|
142
|
+
});
|
143
|
+
};
|
144
|
+
|
145
|
+
// Accepts a pattern and flags; returns an extended `RegExp` object. If the pattern and flag
|
146
|
+
// combination has previously been cached, the cached copy is returned; otherwise the newly
|
147
|
+
// created regex is cached
|
148
|
+
XRegExp.cache = function (pattern, flags) {
|
149
|
+
var key = pattern + "/" + (flags || "");
|
150
|
+
return XRegExp.cache[key] || (XRegExp.cache[key] = XRegExp(pattern, flags));
|
151
|
+
};
|
152
|
+
|
153
|
+
// Accepts a `RegExp` instance; returns a copy with the `/g` flag set. The copy has a fresh
|
154
|
+
// `lastIndex` (set to zero). If you want to copy a regex without forcing the `global`
|
155
|
+
// property, use `XRegExp(regex)`. Do not use `RegExp(regex)` because it will not preserve
|
156
|
+
// special properties required for named capture
|
157
|
+
XRegExp.copyAsGlobal = function (regex) {
|
158
|
+
return clone(regex, "g");
|
159
|
+
};
|
160
|
+
|
161
|
+
// Accepts a string; returns the string with regex metacharacters escaped. The returned string
|
162
|
+
// can safely be used at any point within a regex to match the provided literal string. Escaped
|
163
|
+
// characters are [ ] { } ( ) * + ? - . , \ ^ $ | # and whitespace
|
164
|
+
XRegExp.escape = function (str) {
|
165
|
+
return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
166
|
+
};
|
167
|
+
|
168
|
+
// Accepts a string to search, regex to search with, position to start the search within the
|
169
|
+
// string (default: 0), and an optional Boolean indicating whether matches must start at-or-
|
170
|
+
// after the position or at the specified position only. This function ignores the `lastIndex`
|
171
|
+
// of the provided regex in its own handling, but updates the property for compatibility
|
172
|
+
XRegExp.execAt = function (str, regex, pos, anchored) {
|
173
|
+
var r2 = clone(regex, "g" + ((anchored && hasNativeY) ? "y" : "")),
|
174
|
+
match;
|
175
|
+
r2.lastIndex = pos = pos || 0;
|
176
|
+
match = r2.exec(str); // Run the altered `exec` (required for `lastIndex` fix, etc.)
|
177
|
+
if (anchored && match && match.index !== pos)
|
178
|
+
match = null;
|
179
|
+
if (regex.global)
|
180
|
+
regex.lastIndex = match ? r2.lastIndex : 0;
|
181
|
+
return match;
|
182
|
+
};
|
183
|
+
|
184
|
+
// Breaks the unrestorable link to XRegExp's private list of tokens, thereby preventing
|
185
|
+
// syntax and flag changes. Should be run after XRegExp and any plugins are loaded
|
186
|
+
XRegExp.freezeTokens = function () {
|
187
|
+
XRegExp.addToken = function () {
|
188
|
+
throw Error("can't run addToken after freezeTokens");
|
189
|
+
};
|
190
|
+
};
|
191
|
+
|
192
|
+
// Accepts any value; returns a Boolean indicating whether the argument is a `RegExp` object.
|
193
|
+
// Note that this is also `true` for regex literals and regexes created by the `XRegExp`
|
194
|
+
// constructor. This works correctly for variables created in another frame, when `instanceof`
|
195
|
+
// and `constructor` checks would fail to work as intended
|
196
|
+
XRegExp.isRegExp = function (o) {
|
197
|
+
return Object.prototype.toString.call(o) === "[object RegExp]";
|
198
|
+
};
|
199
|
+
|
200
|
+
// Executes `callback` once per match within `str`. Provides a simpler and cleaner way to
|
201
|
+
// iterate over regex matches compared to the traditional approaches of subverting
|
202
|
+
// `String.prototype.replace` or repeatedly calling `exec` within a `while` loop
|
203
|
+
XRegExp.iterate = function (str, regex, callback, context) {
|
204
|
+
var r2 = clone(regex, "g"),
|
205
|
+
i = -1, match;
|
206
|
+
while (match = r2.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
|
207
|
+
if (regex.global)
|
208
|
+
regex.lastIndex = r2.lastIndex; // Doing this to follow expectations if `lastIndex` is checked within `callback`
|
209
|
+
callback.call(context, match, ++i, str, regex);
|
210
|
+
if (r2.lastIndex === match.index)
|
211
|
+
r2.lastIndex++;
|
212
|
+
}
|
213
|
+
if (regex.global)
|
214
|
+
regex.lastIndex = 0;
|
215
|
+
};
|
216
|
+
|
217
|
+
// Accepts a string and an array of regexes; returns the result of using each successive regex
|
218
|
+
// to search within the matches of the previous regex. The array of regexes can also contain
|
219
|
+
// objects with `regex` and `backref` properties, in which case the named or numbered back-
|
220
|
+
// references specified are passed forward to the next regex or returned. E.g.:
|
221
|
+
// var xregexpImgFileNames = XRegExp.matchChain(html, [
|
222
|
+
// {regex: /<img\b([^>]+)>/i, backref: 1}, // <img> tag attributes
|
223
|
+
// {regex: XRegExp('(?ix) \\s src=" (?<src> [^"]+ )'), backref: "src"}, // src attribute values
|
224
|
+
// {regex: XRegExp("^http://xregexp\\.com(/[^#?]+)", "i"), backref: 1}, // xregexp.com paths
|
225
|
+
// /[^\/]+$/ // filenames (strip directory paths)
|
226
|
+
// ]);
|
227
|
+
XRegExp.matchChain = function (str, chain) {
|
228
|
+
return function recurseChain (values, level) {
|
229
|
+
var item = chain[level].regex ? chain[level] : {regex: chain[level]},
|
230
|
+
regex = clone(item.regex, "g"),
|
231
|
+
matches = [], i;
|
232
|
+
for (i = 0; i < values.length; i++) {
|
233
|
+
XRegExp.iterate(values[i], regex, function (match) {
|
234
|
+
matches.push(item.backref ? (match[item.backref] || "") : match[0]);
|
235
|
+
});
|
236
|
+
}
|
237
|
+
return ((level === chain.length - 1) || !matches.length) ?
|
238
|
+
matches : recurseChain(matches, level + 1);
|
239
|
+
}([str], 0);
|
240
|
+
};
|
241
|
+
|
242
|
+
|
243
|
+
//---------------------------------
|
244
|
+
// New RegExp prototype methods
|
245
|
+
//---------------------------------
|
246
|
+
|
247
|
+
// Accepts a context object and arguments array; returns the result of calling `exec` with the
|
248
|
+
// first value in the arguments array. the context is ignored but is accepted for congruity
|
249
|
+
// with `Function.prototype.apply`
|
250
|
+
RegExp.prototype.apply = function (context, args) {
|
251
|
+
return this.exec(args[0]);
|
252
|
+
};
|
253
|
+
|
254
|
+
// Accepts a context object and string; returns the result of calling `exec` with the provided
|
255
|
+
// string. the context is ignored but is accepted for congruity with `Function.prototype.call`
|
256
|
+
RegExp.prototype.call = function (context, str) {
|
257
|
+
return this.exec(str);
|
258
|
+
};
|
259
|
+
|
260
|
+
|
261
|
+
//---------------------------------
|
262
|
+
// Overriden native methods
|
263
|
+
//---------------------------------
|
264
|
+
|
265
|
+
// Adds named capture support (with backreferences returned as `result.name`), and fixes two
|
266
|
+
// cross-browser issues per ES3:
|
267
|
+
// - Captured values for nonparticipating capturing groups should be returned as `undefined`,
|
268
|
+
// rather than the empty string.
|
269
|
+
// - `lastIndex` should not be incremented after zero-length matches.
|
270
|
+
RegExp.prototype.exec = function (str) {
|
271
|
+
var match, name, r2, origLastIndex;
|
272
|
+
if (!this.global)
|
273
|
+
origLastIndex = this.lastIndex;
|
274
|
+
match = nativ.exec.apply(this, arguments);
|
275
|
+
if (match) {
|
276
|
+
// Fix browsers whose `exec` methods don't consistently return `undefined` for
|
277
|
+
// nonparticipating capturing groups
|
278
|
+
if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
|
279
|
+
r2 = RegExp(this.source, nativ.replace.call(getNativeFlags(this), "g", ""));
|
280
|
+
// Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
|
281
|
+
// matching due to characters outside the match
|
282
|
+
nativ.replace.call((str + "").slice(match.index), r2, function () {
|
283
|
+
for (var i = 1; i < arguments.length - 2; i++) {
|
284
|
+
if (arguments[i] === undefined)
|
285
|
+
match[i] = undefined;
|
286
|
+
}
|
287
|
+
});
|
288
|
+
}
|
289
|
+
// Attach named capture properties
|
290
|
+
if (this._xregexp && this._xregexp.captureNames) {
|
291
|
+
for (var i = 1; i < match.length; i++) {
|
292
|
+
name = this._xregexp.captureNames[i - 1];
|
293
|
+
if (name)
|
294
|
+
match[name] = match[i];
|
295
|
+
}
|
296
|
+
}
|
297
|
+
// Fix browsers that increment `lastIndex` after zero-length matches
|
298
|
+
if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
|
299
|
+
this.lastIndex--;
|
300
|
+
}
|
301
|
+
if (!this.global)
|
302
|
+
this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
|
303
|
+
return match;
|
304
|
+
};
|
305
|
+
|
306
|
+
// Fix browser bugs in native method
|
307
|
+
RegExp.prototype.test = function (str) {
|
308
|
+
// Use the native `exec` to skip some processing overhead, even though the altered
|
309
|
+
// `exec` would take care of the `lastIndex` fixes
|
310
|
+
var match, origLastIndex;
|
311
|
+
if (!this.global)
|
312
|
+
origLastIndex = this.lastIndex;
|
313
|
+
match = nativ.exec.call(this, str);
|
314
|
+
// Fix browsers that increment `lastIndex` after zero-length matches
|
315
|
+
if (match && !compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
|
316
|
+
this.lastIndex--;
|
317
|
+
if (!this.global)
|
318
|
+
this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
|
319
|
+
return !!match;
|
320
|
+
};
|
321
|
+
|
322
|
+
// Adds named capture support and fixes browser bugs in native method
|
323
|
+
String.prototype.match = function (regex) {
|
324
|
+
if (!XRegExp.isRegExp(regex))
|
325
|
+
regex = RegExp(regex); // Native `RegExp`
|
326
|
+
if (regex.global) {
|
327
|
+
var result = nativ.match.apply(this, arguments);
|
328
|
+
regex.lastIndex = 0; // Fix IE bug
|
329
|
+
return result;
|
330
|
+
}
|
331
|
+
return regex.exec(this); // Run the altered `exec`
|
332
|
+
};
|
333
|
+
|
334
|
+
// Adds support for `${n}` tokens for named and numbered backreferences in replacement text,
|
335
|
+
// and provides named backreferences to replacement functions as `arguments[0].name`. Also
|
336
|
+
// fixes cross-browser differences in replacement text syntax when performing a replacement
|
337
|
+
// using a nonregex search value, and the value of replacement regexes' `lastIndex` property
|
338
|
+
// during replacement iterations. Note that this doesn't support SpiderMonkey's proprietary
|
339
|
+
// third (`flags`) parameter
|
340
|
+
String.prototype.replace = function (search, replacement) {
|
341
|
+
var isRegex = XRegExp.isRegExp(search),
|
342
|
+
captureNames, result, str, origLastIndex;
|
343
|
+
|
344
|
+
// There are too many combinations of search/replacement types/values and browser bugs that
|
345
|
+
// preclude passing to native `replace`, so don't try
|
346
|
+
//if (...)
|
347
|
+
// return nativ.replace.apply(this, arguments);
|
348
|
+
|
349
|
+
if (isRegex) {
|
350
|
+
if (search._xregexp)
|
351
|
+
captureNames = search._xregexp.captureNames; // Array or `null`
|
352
|
+
if (!search.global)
|
353
|
+
origLastIndex = search.lastIndex;
|
354
|
+
} else {
|
355
|
+
search = search + ""; // Type conversion
|
356
|
+
}
|
357
|
+
|
358
|
+
if (Object.prototype.toString.call(replacement) === "[object Function]") {
|
359
|
+
result = nativ.replace.call(this + "", search, function () {
|
360
|
+
if (captureNames) {
|
361
|
+
// Change the `arguments[0]` string primitive to a String object which can store properties
|
362
|
+
arguments[0] = new String(arguments[0]);
|
363
|
+
// Store named backreferences on `arguments[0]`
|
364
|
+
for (var i = 0; i < captureNames.length; i++) {
|
365
|
+
if (captureNames[i])
|
366
|
+
arguments[0][captureNames[i]] = arguments[i + 1];
|
367
|
+
}
|
368
|
+
}
|
369
|
+
// Update `lastIndex` before calling `replacement` (fix browsers)
|
370
|
+
if (isRegex && search.global)
|
371
|
+
search.lastIndex = arguments[arguments.length - 2] + arguments[0].length;
|
372
|
+
return replacement.apply(null, arguments);
|
373
|
+
});
|
374
|
+
} else {
|
375
|
+
str = this + ""; // Type conversion, so `args[args.length - 1]` will be a string (given nonstring `this`)
|
376
|
+
result = nativ.replace.call(str, search, function () {
|
377
|
+
var args = arguments; // Keep this function's `arguments` available through closure
|
378
|
+
return nativ.replace.call(replacement + "", replacementToken, function ($0, $1, $2) {
|
379
|
+
// Numbered backreference (without delimiters) or special variable
|
380
|
+
if ($1) {
|
381
|
+
switch ($1) {
|
382
|
+
case "$": return "$";
|
383
|
+
case "&": return args[0];
|
384
|
+
case "`": return args[args.length - 1].slice(0, args[args.length - 2]);
|
385
|
+
case "'": return args[args.length - 1].slice(args[args.length - 2] + args[0].length);
|
386
|
+
// Numbered backreference
|
387
|
+
default:
|
388
|
+
// What does "$10" mean?
|
389
|
+
// - Backreference 10, if 10 or more capturing groups exist
|
390
|
+
// - Backreference 1 followed by "0", if 1-9 capturing groups exist
|
391
|
+
// - Otherwise, it's the string "$10"
|
392
|
+
// Also note:
|
393
|
+
// - Backreferences cannot be more than two digits (enforced by `replacementToken`)
|
394
|
+
// - "$01" is equivalent to "$1" if a capturing group exists, otherwise it's the string "$01"
|
395
|
+
// - There is no "$0" token ("$&" is the entire match)
|
396
|
+
var literalNumbers = "";
|
397
|
+
$1 = +$1; // Type conversion; drop leading zero
|
398
|
+
if (!$1) // `$1` was "0" or "00"
|
399
|
+
return $0;
|
400
|
+
while ($1 > args.length - 3) {
|
401
|
+
literalNumbers = String.prototype.slice.call($1, -1) + literalNumbers;
|
402
|
+
$1 = Math.floor($1 / 10); // Drop the last digit
|
403
|
+
}
|
404
|
+
return ($1 ? args[$1] || "" : "$") + literalNumbers;
|
405
|
+
}
|
406
|
+
// Named backreference or delimited numbered backreference
|
407
|
+
} else {
|
408
|
+
// What does "${n}" mean?
|
409
|
+
// - Backreference to numbered capture n. Two differences from "$n":
|
410
|
+
// - n can be more than two digits
|
411
|
+
// - Backreference 0 is allowed, and is the entire match
|
412
|
+
// - Backreference to named capture n, if it exists and is not a number overridden by numbered capture
|
413
|
+
// - Otherwise, it's the string "${n}"
|
414
|
+
var n = +$2; // Type conversion; drop leading zeros
|
415
|
+
if (n <= args.length - 3)
|
416
|
+
return args[n];
|
417
|
+
n = captureNames ? indexOf(captureNames, $2) : -1;
|
418
|
+
return n > -1 ? args[n + 1] : $0;
|
419
|
+
}
|
420
|
+
});
|
421
|
+
});
|
422
|
+
}
|
423
|
+
|
424
|
+
if (isRegex) {
|
425
|
+
if (search.global)
|
426
|
+
search.lastIndex = 0; // Fix IE, Safari bug (last tested IE 9.0.5, Safari 5.1.2 on Windows)
|
427
|
+
else
|
428
|
+
search.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows)
|
429
|
+
}
|
430
|
+
|
431
|
+
return result;
|
432
|
+
};
|
433
|
+
|
434
|
+
// A consistent cross-browser, ES3 compliant `split`
|
435
|
+
String.prototype.split = function (s /* separator */, limit) {
|
436
|
+
// If separator `s` is not a regex, use the native `split`
|
437
|
+
if (!XRegExp.isRegExp(s))
|
438
|
+
return nativ.split.apply(this, arguments);
|
439
|
+
|
440
|
+
var str = this + "", // Type conversion
|
441
|
+
output = [],
|
442
|
+
lastLastIndex = 0,
|
443
|
+
match, lastLength;
|
444
|
+
|
445
|
+
// Behavior for `limit`: if it's...
|
446
|
+
// - `undefined`: No limit
|
447
|
+
// - `NaN` or zero: Return an empty array
|
448
|
+
// - A positive number: Use `Math.floor(limit)`
|
449
|
+
// - A negative number: No limit
|
450
|
+
// - Other: Type-convert, then use the above rules
|
451
|
+
if (limit === undefined || +limit < 0) {
|
452
|
+
limit = Infinity;
|
453
|
+
} else {
|
454
|
+
limit = Math.floor(+limit);
|
455
|
+
if (!limit)
|
456
|
+
return [];
|
457
|
+
}
|
458
|
+
|
459
|
+
// This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero
|
460
|
+
// and restore it to its original value when we're done using the regex
|
461
|
+
s = XRegExp.copyAsGlobal(s);
|
462
|
+
|
463
|
+
while (match = s.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.)
|
464
|
+
if (s.lastIndex > lastLastIndex) {
|
465
|
+
output.push(str.slice(lastLastIndex, match.index));
|
466
|
+
|
467
|
+
if (match.length > 1 && match.index < str.length)
|
468
|
+
Array.prototype.push.apply(output, match.slice(1));
|
469
|
+
|
470
|
+
lastLength = match[0].length;
|
471
|
+
lastLastIndex = s.lastIndex;
|
472
|
+
|
473
|
+
if (output.length >= limit)
|
474
|
+
break;
|
475
|
+
}
|
476
|
+
|
477
|
+
if (s.lastIndex === match.index)
|
478
|
+
s.lastIndex++;
|
479
|
+
}
|
480
|
+
|
481
|
+
if (lastLastIndex === str.length) {
|
482
|
+
if (!nativ.test.call(s, "") || lastLength)
|
483
|
+
output.push("");
|
484
|
+
} else {
|
485
|
+
output.push(str.slice(lastLastIndex));
|
486
|
+
}
|
487
|
+
|
488
|
+
return output.length > limit ? output.slice(0, limit) : output;
|
489
|
+
};
|
490
|
+
|
491
|
+
|
492
|
+
//---------------------------------
|
493
|
+
// Private helper functions
|
494
|
+
//---------------------------------
|
495
|
+
|
496
|
+
// Supporting function for `XRegExp`, `XRegExp.copyAsGlobal`, etc. Returns a copy of a `RegExp`
|
497
|
+
// instance with a fresh `lastIndex` (set to zero), preserving properties required for named
|
498
|
+
// capture. Also allows adding new flags in the process of copying the regex
|
499
|
+
function clone (regex, additionalFlags) {
|
500
|
+
if (!XRegExp.isRegExp(regex))
|
501
|
+
throw TypeError("type RegExp expected");
|
502
|
+
var x = regex._xregexp;
|
503
|
+
regex = XRegExp(regex.source, getNativeFlags(regex) + (additionalFlags || ""));
|
504
|
+
if (x) {
|
505
|
+
regex._xregexp = {
|
506
|
+
source: x.source,
|
507
|
+
captureNames: x.captureNames ? x.captureNames.slice(0) : null
|
508
|
+
};
|
509
|
+
}
|
510
|
+
return regex;
|
511
|
+
}
|
512
|
+
|
513
|
+
function getNativeFlags (regex) {
|
514
|
+
return (regex.global ? "g" : "") +
|
515
|
+
(regex.ignoreCase ? "i" : "") +
|
516
|
+
(regex.multiline ? "m" : "") +
|
517
|
+
(regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
|
518
|
+
(regex.sticky ? "y" : "");
|
519
|
+
}
|
520
|
+
|
521
|
+
function runTokens (pattern, index, scope, context) {
|
522
|
+
var i = tokens.length,
|
523
|
+
result, match, t;
|
524
|
+
// Protect against constructing XRegExps within token handler and trigger functions
|
525
|
+
isInsideConstructor = true;
|
526
|
+
// Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws
|
527
|
+
try {
|
528
|
+
while (i--) { // Run in reverse order
|
529
|
+
t = tokens[i];
|
530
|
+
if ((scope & t.scope) && (!t.trigger || t.trigger.call(context))) {
|
531
|
+
t.pattern.lastIndex = index;
|
532
|
+
match = t.pattern.exec(pattern); // Running the altered `exec` here allows use of named backreferences, etc.
|
533
|
+
if (match && match.index === index) {
|
534
|
+
result = {
|
535
|
+
output: t.handler.call(context, match, scope),
|
536
|
+
match: match
|
537
|
+
};
|
538
|
+
break;
|
539
|
+
}
|
540
|
+
}
|
541
|
+
}
|
542
|
+
} catch (err) {
|
543
|
+
throw err;
|
544
|
+
} finally {
|
545
|
+
isInsideConstructor = false;
|
546
|
+
}
|
547
|
+
return result;
|
548
|
+
}
|
549
|
+
|
550
|
+
function indexOf (array, item, from) {
|
551
|
+
if (Array.prototype.indexOf) // Use the native array method if available
|
552
|
+
return array.indexOf(item, from);
|
553
|
+
for (var i = from || 0; i < array.length; i++) {
|
554
|
+
if (array[i] === item)
|
555
|
+
return i;
|
556
|
+
}
|
557
|
+
return -1;
|
558
|
+
}
|
559
|
+
|
560
|
+
|
561
|
+
//---------------------------------
|
562
|
+
// Built-in tokens
|
563
|
+
//---------------------------------
|
564
|
+
|
565
|
+
// Augment XRegExp's regular expression syntax and flags. Note that when adding tokens, the
|
566
|
+
// third (`scope`) argument defaults to `XRegExp.OUTSIDE_CLASS`
|
567
|
+
|
568
|
+
// Comment pattern: (?# )
|
569
|
+
XRegExp.addToken(
|
570
|
+
/\(\?#[^)]*\)/,
|
571
|
+
function (match) {
|
572
|
+
// Keep tokens separated unless the following token is a quantifier
|
573
|
+
return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
|
574
|
+
}
|
575
|
+
);
|
576
|
+
|
577
|
+
// Capturing group (match the opening parenthesis only).
|
578
|
+
// Required for support of named capturing groups
|
579
|
+
XRegExp.addToken(
|
580
|
+
/\((?!\?)/,
|
581
|
+
function () {
|
582
|
+
this.captureNames.push(null);
|
583
|
+
return "(";
|
584
|
+
}
|
585
|
+
);
|
586
|
+
|
587
|
+
// Named capturing group (match the opening delimiter only): (?<name>
|
588
|
+
XRegExp.addToken(
|
589
|
+
/\(\?<([$\w]+)>/,
|
590
|
+
function (match) {
|
591
|
+
this.captureNames.push(match[1]);
|
592
|
+
this.hasNamedCapture = true;
|
593
|
+
return "(";
|
594
|
+
}
|
595
|
+
);
|
596
|
+
|
597
|
+
// Named backreference: \k<name>
|
598
|
+
XRegExp.addToken(
|
599
|
+
/\\k<([\w$]+)>/,
|
600
|
+
function (match) {
|
601
|
+
var index = indexOf(this.captureNames, match[1]);
|
602
|
+
// Keep backreferences separate from subsequent literal numbers. Preserve back-
|
603
|
+
// references to named groups that are undefined at this point as literal strings
|
604
|
+
return index > -1 ?
|
605
|
+
"\\" + (index + 1) + (isNaN(match.input.charAt(match.index + match[0].length)) ? "" : "(?:)") :
|
606
|
+
match[0];
|
607
|
+
}
|
608
|
+
);
|
609
|
+
|
610
|
+
// Empty character class: [] or [^]
|
611
|
+
XRegExp.addToken(
|
612
|
+
/\[\^?]/,
|
613
|
+
function (match) {
|
614
|
+
// For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S].
|
615
|
+
// (?!) should work like \b\B, but is unreliable in Firefox
|
616
|
+
return match[0] === "[]" ? "\\b\\B" : "[\\s\\S]";
|
617
|
+
}
|
618
|
+
);
|
619
|
+
|
620
|
+
// Mode modifier at the start of the pattern only, with any combination of flags imsx: (?imsx)
|
621
|
+
// Does not support x(?i), (?-i), (?i-m), (?i: ), (?i)(?m), etc.
|
622
|
+
XRegExp.addToken(
|
623
|
+
/^\(\?([imsx]+)\)/,
|
624
|
+
function (match) {
|
625
|
+
this.setFlag(match[1]);
|
626
|
+
return "";
|
627
|
+
}
|
628
|
+
);
|
629
|
+
|
630
|
+
// Whitespace and comments, in free-spacing (aka extended) mode only
|
631
|
+
XRegExp.addToken(
|
632
|
+
/(?:\s+|#.*)+/,
|
633
|
+
function (match) {
|
634
|
+
// Keep tokens separated unless the following token is a quantifier
|
635
|
+
return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)";
|
636
|
+
},
|
637
|
+
XRegExp.OUTSIDE_CLASS,
|
638
|
+
function () {return this.hasFlag("x");}
|
639
|
+
);
|
640
|
+
|
641
|
+
// Dot, in dotall (aka singleline) mode only
|
642
|
+
XRegExp.addToken(
|
643
|
+
/\./,
|
644
|
+
function () {return "[\\s\\S]";},
|
645
|
+
XRegExp.OUTSIDE_CLASS,
|
646
|
+
function () {return this.hasFlag("s");}
|
647
|
+
);
|
648
|
+
|
649
|
+
|
650
|
+
//---------------------------------
|
651
|
+
// Backward compatibility
|
652
|
+
//---------------------------------
|
653
|
+
|
654
|
+
// Uncomment the following block for compatibility with XRegExp 1.0-1.2:
|
655
|
+
/*
|
656
|
+
XRegExp.matchWithinChain = XRegExp.matchChain;
|
657
|
+
RegExp.prototype.addFlags = function (s) {return clone(this, s);};
|
658
|
+
RegExp.prototype.execAll = function (s) {var r = []; XRegExp.iterate(s, this, function (m) {r.push(m);}); return r;};
|
659
|
+
RegExp.prototype.forEachExec = function (s, f, c) {return XRegExp.iterate(s, this, f, c);};
|
660
|
+
RegExp.prototype.validate = function (s) {var r = RegExp("^(?:" + this.source + ")$(?!\\s)", getNativeFlags(this)); if (this.global) this.lastIndex = 0; return s.search(r) === 0;};
|
661
|
+
*/
|
662
|
+
|
663
|
+
})();
|
664
|
+
|
665
|
+
//
|
666
|
+
// Begin anonymous function. This is used to contain local scope variables without polutting global scope.
|
667
|
+
//
|
668
|
+
if (typeof(SyntaxHighlighter) == 'undefined') var SyntaxHighlighter = function() {
|
669
|
+
|
670
|
+
// CommonJS
|
671
|
+
if (typeof(require) != 'undefined' && typeof(XRegExp) == 'undefined')
|
672
|
+
{
|
673
|
+
XRegExp = require('XRegExp').XRegExp;
|
674
|
+
}
|
675
|
+
|
676
|
+
// Shortcut object which will be assigned to the SyntaxHighlighter variable.
|
677
|
+
// This is a shorthand for local reference in order to avoid long namespace
|
678
|
+
// references to SyntaxHighlighter.whatever...
|
679
|
+
var sh = {
|
680
|
+
defaults : {
|
681
|
+
/** Additional CSS class names to be added to highlighter elements. */
|
682
|
+
'class-name' : '',
|
683
|
+
|
684
|
+
/** First line number. */
|
685
|
+
'first-line' : 1,
|
686
|
+
|
687
|
+
/**
|
688
|
+
* Pads line numbers. Possible values are:
|
689
|
+
*
|
690
|
+
* false - don't pad line numbers.
|
691
|
+
* true - automaticaly pad numbers with minimum required number of leading zeroes.
|
692
|
+
* [int] - length up to which pad line numbers.
|
693
|
+
*/
|
694
|
+
'pad-line-numbers' : false,
|
695
|
+
|
696
|
+
/** Lines to highlight. */
|
697
|
+
'highlight' : false,
|
698
|
+
|
699
|
+
/** Title to be displayed above the code block. */
|
700
|
+
'title' : null,
|
701
|
+
|
702
|
+
/** Enables or disables smart tabs. */
|
703
|
+
'smart-tabs' : true,
|
704
|
+
|
705
|
+
/** Gets or sets tab size. */
|
706
|
+
'tab-size' : 4,
|
707
|
+
|
708
|
+
/** Enables or disables gutter. */
|
709
|
+
'gutter' : true,
|
710
|
+
|
711
|
+
/** Enables or disables toolbar. */
|
712
|
+
'toolbar' : true,
|
713
|
+
|
714
|
+
/** Enables quick code copy and paste from double click. */
|
715
|
+
'quick-code' : true,
|
716
|
+
|
717
|
+
/** Forces code view to be collapsed. */
|
718
|
+
'collapse' : false,
|
719
|
+
|
720
|
+
/** Enables or disables automatic links. */
|
721
|
+
'auto-links' : false,
|
722
|
+
|
723
|
+
/** Gets or sets light mode. Equavalent to turning off gutter and toolbar. */
|
724
|
+
'light' : false,
|
725
|
+
|
726
|
+
'unindent' : true,
|
727
|
+
|
728
|
+
'html-script' : false
|
729
|
+
},
|
730
|
+
|
731
|
+
config : {
|
732
|
+
space : ' ',
|
733
|
+
|
734
|
+
/** Enables use of <SCRIPT type="syntaxhighlighter" /> tags. */
|
735
|
+
useScriptTags : true,
|
736
|
+
|
737
|
+
/** Blogger mode flag. */
|
738
|
+
bloggerMode : false,
|
739
|
+
|
740
|
+
stripBrs : false,
|
741
|
+
|
742
|
+
/** Name of the tag that SyntaxHighlighter will automatically look for. */
|
743
|
+
tagName : 'pre',
|
744
|
+
|
745
|
+
strings : {
|
746
|
+
expandSource : 'expand source',
|
747
|
+
help : '?',
|
748
|
+
alert: 'SyntaxHighlighter\n\n',
|
749
|
+
noBrush : 'Can\'t find brush for: ',
|
750
|
+
brushNotHtmlScript : 'Brush wasn\'t configured for html-script option: ',
|
751
|
+
|
752
|
+
// this is populated by the build script
|
753
|
+
aboutDialog : '@ABOUT@'
|
754
|
+
}
|
755
|
+
},
|
756
|
+
|
757
|
+
/** Internal 'global' variables. */
|
758
|
+
vars : {
|
759
|
+
discoveredBrushes : null,
|
760
|
+
highlighters : {}
|
761
|
+
},
|
762
|
+
|
763
|
+
/** This object is populated by user included external brush files. */
|
764
|
+
brushes : {},
|
765
|
+
|
766
|
+
/** Common regular expressions. */
|
767
|
+
regexLib : {
|
768
|
+
multiLineCComments : /\/\*[\s\S]*?\*\//gm,
|
769
|
+
singleLineCComments : /\/\/.*$/gm,
|
770
|
+
singleLinePerlComments : /#.*$/gm,
|
771
|
+
doubleQuotedString : /"([^\\"\n]|\\.)*"/g,
|
772
|
+
singleQuotedString : /'([^\\'\n]|\\.)*'/g,
|
773
|
+
multiLineDoubleQuotedString : new XRegExp('"([^\\\\"]|\\\\.)*"', 'gs'),
|
774
|
+
multiLineSingleQuotedString : new XRegExp("'([^\\\\']|\\\\.)*'", 'gs'),
|
775
|
+
xmlComments : /(<|<)!--[\s\S]*?--(>|>)/gm,
|
776
|
+
url : /\w+:\/\/[\w-.\/?%&=:@;#]*/g,
|
777
|
+
|
778
|
+
/** <?= ?> tags. */
|
779
|
+
phpScriptTags : { left: /(<|<)\?(?:=|php)?/g, right: /\?(>|>)/g, 'eof' : true },
|
780
|
+
|
781
|
+
/** <%= %> tags. */
|
782
|
+
aspScriptTags : { left: /(<|<)%=?/g, right: /%(>|>)/g },
|
783
|
+
|
784
|
+
/** <script> tags. */
|
785
|
+
scriptScriptTags : { left: /(<|<)\s*script.*?(>|>)/gi, right: /(<|<)\/\s*script\s*(>|>)/gi }
|
786
|
+
},
|
787
|
+
|
788
|
+
toolbar: {
|
789
|
+
/**
|
790
|
+
* Generates HTML markup for the toolbar.
|
791
|
+
* @param {Highlighter} highlighter Highlighter instance.
|
792
|
+
* @return {String} Returns HTML markup.
|
793
|
+
*/
|
794
|
+
getHtml: function(highlighter)
|
795
|
+
{
|
796
|
+
var html = '<div class="toolbar">',
|
797
|
+
items = sh.toolbar.items,
|
798
|
+
list = items.list
|
799
|
+
;
|
800
|
+
|
801
|
+
function defaultGetHtml(highlighter, name)
|
802
|
+
{
|
803
|
+
return sh.toolbar.getButtonHtml(highlighter, name, sh.config.strings[name]);
|
804
|
+
};
|
805
|
+
|
806
|
+
for (var i = 0; i < list.length; i++)
|
807
|
+
html += (items[list[i]].getHtml || defaultGetHtml)(highlighter, list[i]);
|
808
|
+
|
809
|
+
html += '</div>';
|
810
|
+
|
811
|
+
return html;
|
812
|
+
},
|
813
|
+
|
814
|
+
/**
|
815
|
+
* Generates HTML markup for a regular button in the toolbar.
|
816
|
+
* @param {Highlighter} highlighter Highlighter instance.
|
817
|
+
* @param {String} commandName Command name that would be executed.
|
818
|
+
* @param {String} label Label text to display.
|
819
|
+
* @return {String} Returns HTML markup.
|
820
|
+
*/
|
821
|
+
getButtonHtml: function(highlighter, commandName, label)
|
822
|
+
{
|
823
|
+
return '<span><a href="#" class="toolbar_item'
|
824
|
+
+ ' command_' + commandName
|
825
|
+
+ ' ' + commandName
|
826
|
+
+ '">' + label + '</a></span>'
|
827
|
+
;
|
828
|
+
},
|
829
|
+
|
830
|
+
/**
|
831
|
+
* Event handler for a toolbar anchor.
|
832
|
+
*/
|
833
|
+
handler: function(e)
|
834
|
+
{
|
835
|
+
var target = e.target,
|
836
|
+
className = target.className || ''
|
837
|
+
;
|
838
|
+
|
839
|
+
function getValue(name)
|
840
|
+
{
|
841
|
+
var r = new RegExp(name + '_(\\w+)'),
|
842
|
+
match = r.exec(className)
|
843
|
+
;
|
844
|
+
|
845
|
+
return match ? match[1] : null;
|
846
|
+
};
|
847
|
+
|
848
|
+
var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id),
|
849
|
+
commandName = getValue('command')
|
850
|
+
;
|
851
|
+
|
852
|
+
// execute the toolbar command
|
853
|
+
if (highlighter && commandName)
|
854
|
+
sh.toolbar.items[commandName].execute(highlighter);
|
855
|
+
|
856
|
+
// disable default A click behaviour
|
857
|
+
e.preventDefault();
|
858
|
+
},
|
859
|
+
|
860
|
+
/** Collection of toolbar items. */
|
861
|
+
items : {
|
862
|
+
// Ordered lis of items in the toolbar. Can't expect `for (var n in items)` to be consistent.
|
863
|
+
list: ['expandSource', 'help'],
|
864
|
+
|
865
|
+
expandSource: {
|
866
|
+
getHtml: function(highlighter)
|
867
|
+
{
|
868
|
+
if (highlighter.getParam('collapse') != true)
|
869
|
+
return '';
|
870
|
+
|
871
|
+
var title = highlighter.getParam('title');
|
872
|
+
return sh.toolbar.getButtonHtml(highlighter, 'expandSource', title ? title : sh.config.strings.expandSource);
|
873
|
+
},
|
874
|
+
|
875
|
+
execute: function(highlighter)
|
876
|
+
{
|
877
|
+
var div = getHighlighterDivById(highlighter.id);
|
878
|
+
removeClass(div, 'collapsed');
|
879
|
+
}
|
880
|
+
},
|
881
|
+
|
882
|
+
/** Command to display the about dialog window. */
|
883
|
+
help: {
|
884
|
+
execute: function(highlighter)
|
885
|
+
{
|
886
|
+
var wnd = popup('', '_blank', 500, 250, 'scrollbars=0'),
|
887
|
+
doc = wnd.document
|
888
|
+
;
|
889
|
+
|
890
|
+
doc.write(sh.config.strings.aboutDialog);
|
891
|
+
doc.close();
|
892
|
+
wnd.focus();
|
893
|
+
}
|
894
|
+
}
|
895
|
+
}
|
896
|
+
},
|
897
|
+
|
898
|
+
/**
|
899
|
+
* Finds all elements on the page which should be processes by SyntaxHighlighter.
|
900
|
+
*
|
901
|
+
* @param {Object} globalParams Optional parameters which override element's
|
902
|
+
* parameters. Only used if element is specified.
|
903
|
+
*
|
904
|
+
* @param {Object} element Optional element to highlight. If none is
|
905
|
+
* provided, all elements in the current document
|
906
|
+
* are returned which qualify.
|
907
|
+
*
|
908
|
+
* @return {Array} Returns list of <code>{ target: DOMElement, params: Object }</code> objects.
|
909
|
+
*/
|
910
|
+
findElements: function(globalParams, element)
|
911
|
+
{
|
912
|
+
var elements = element ? [element] : toArray(document.getElementsByTagName(sh.config.tagName)),
|
913
|
+
conf = sh.config,
|
914
|
+
result = []
|
915
|
+
;
|
916
|
+
|
917
|
+
// support for <SCRIPT TYPE="syntaxhighlighter" /> feature
|
918
|
+
if (conf.useScriptTags)
|
919
|
+
elements = elements.concat(getSyntaxHighlighterScriptTags());
|
920
|
+
|
921
|
+
if (elements.length === 0)
|
922
|
+
return result;
|
923
|
+
|
924
|
+
for (var i = 0; i < elements.length; i++)
|
925
|
+
{
|
926
|
+
var item = {
|
927
|
+
target: elements[i],
|
928
|
+
// local params take precedence over globals
|
929
|
+
params: merge(globalParams, parseParams(elements[i].className))
|
930
|
+
};
|
931
|
+
|
932
|
+
if (item.params['brush'] == null)
|
933
|
+
continue;
|
934
|
+
|
935
|
+
result.push(item);
|
936
|
+
}
|
937
|
+
|
938
|
+
return result;
|
939
|
+
},
|
940
|
+
|
941
|
+
/**
|
942
|
+
* Shorthand to highlight all elements on the page that are marked as
|
943
|
+
* SyntaxHighlighter source code.
|
944
|
+
*
|
945
|
+
* @param {Object} globalParams Optional parameters which override element's
|
946
|
+
* parameters. Only used if element is specified.
|
947
|
+
*
|
948
|
+
* @param {Object} element Optional element to highlight. If none is
|
949
|
+
* provided, all elements in the current document
|
950
|
+
* are highlighted.
|
951
|
+
*/
|
952
|
+
highlight: function(globalParams, element)
|
953
|
+
{
|
954
|
+
var elements = this.findElements(globalParams, element),
|
955
|
+
propertyName = 'innerHTML',
|
956
|
+
highlighter = null,
|
957
|
+
conf = sh.config
|
958
|
+
;
|
959
|
+
|
960
|
+
if (elements.length === 0)
|
961
|
+
return;
|
962
|
+
|
963
|
+
for (var i = 0; i < elements.length; i++)
|
964
|
+
{
|
965
|
+
var element = elements[i],
|
966
|
+
target = element.target,
|
967
|
+
params = element.params,
|
968
|
+
brushName = params.brush,
|
969
|
+
code
|
970
|
+
;
|
971
|
+
|
972
|
+
if (brushName == null)
|
973
|
+
continue;
|
974
|
+
|
975
|
+
// Instantiate a brush
|
976
|
+
if (params['html-script'] == 'true' || sh.defaults['html-script'] == true)
|
977
|
+
{
|
978
|
+
highlighter = new sh.HtmlScript(brushName);
|
979
|
+
brushName = 'htmlscript';
|
980
|
+
}
|
981
|
+
else
|
982
|
+
{
|
983
|
+
var brush = findBrush(brushName);
|
984
|
+
|
985
|
+
if (brush)
|
986
|
+
highlighter = new brush();
|
987
|
+
else
|
988
|
+
continue;
|
989
|
+
}
|
990
|
+
|
991
|
+
code = target[propertyName];
|
992
|
+
|
993
|
+
// remove CDATA from <SCRIPT/> tags if it's present
|
994
|
+
if (conf.useScriptTags)
|
995
|
+
code = stripCData(code);
|
996
|
+
|
997
|
+
// Inject title if the attribute is present
|
998
|
+
if ((target.title || '') != '')
|
999
|
+
params.title = target.title;
|
1000
|
+
|
1001
|
+
params['brush'] = brushName;
|
1002
|
+
highlighter.init(params);
|
1003
|
+
element = highlighter.getDiv(code);
|
1004
|
+
|
1005
|
+
// carry over ID
|
1006
|
+
if ((target.id || '') != '')
|
1007
|
+
element.id = target.id;
|
1008
|
+
//by zhanyi 去掉多余的外围div
|
1009
|
+
var tmp = element.firstChild.firstChild;
|
1010
|
+
tmp.className = element.firstChild.className;
|
1011
|
+
|
1012
|
+
target.parentNode.replaceChild(tmp, target);
|
1013
|
+
}
|
1014
|
+
},
|
1015
|
+
|
1016
|
+
/**
|
1017
|
+
* Main entry point for the SyntaxHighlighter.
|
1018
|
+
* @param {Object} params Optional params to apply to all highlighted elements.
|
1019
|
+
*/
|
1020
|
+
all: function(params)
|
1021
|
+
{
|
1022
|
+
attachEvent(
|
1023
|
+
window,
|
1024
|
+
'load',
|
1025
|
+
function() { sh.highlight(params); }
|
1026
|
+
);
|
1027
|
+
}
|
1028
|
+
}; // end of sh
|
1029
|
+
|
1030
|
+
/**
|
1031
|
+
* Checks if target DOM elements has specified CSS class.
|
1032
|
+
* @param {DOMElement} target Target DOM element to check.
|
1033
|
+
* @param {String} className Name of the CSS class to check for.
|
1034
|
+
* @return {Boolean} Returns true if class name is present, false otherwise.
|
1035
|
+
*/
|
1036
|
+
function hasClass(target, className)
|
1037
|
+
{
|
1038
|
+
return target.className.indexOf(className) != -1;
|
1039
|
+
};
|
1040
|
+
|
1041
|
+
/**
|
1042
|
+
* Adds CSS class name to the target DOM element.
|
1043
|
+
* @param {DOMElement} target Target DOM element.
|
1044
|
+
* @param {String} className New CSS class to add.
|
1045
|
+
*/
|
1046
|
+
function addClass(target, className)
|
1047
|
+
{
|
1048
|
+
if (!hasClass(target, className))
|
1049
|
+
target.className += ' ' + className;
|
1050
|
+
};
|
1051
|
+
|
1052
|
+
/**
|
1053
|
+
* Removes CSS class name from the target DOM element.
|
1054
|
+
* @param {DOMElement} target Target DOM element.
|
1055
|
+
* @param {String} className CSS class to remove.
|
1056
|
+
*/
|
1057
|
+
function removeClass(target, className)
|
1058
|
+
{
|
1059
|
+
target.className = target.className.replace(className, '');
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
/**
|
1063
|
+
* Converts the source to array object. Mostly used for function arguments and
|
1064
|
+
* lists returned by getElementsByTagName() which aren't Array objects.
|
1065
|
+
* @param {List} source Source list.
|
1066
|
+
* @return {Array} Returns array.
|
1067
|
+
*/
|
1068
|
+
function toArray(source)
|
1069
|
+
{
|
1070
|
+
var result = [];
|
1071
|
+
|
1072
|
+
for (var i = 0; i < source.length; i++)
|
1073
|
+
result.push(source[i]);
|
1074
|
+
|
1075
|
+
return result;
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
/**
|
1079
|
+
* Splits block of text into lines.
|
1080
|
+
* @param {String} block Block of text.
|
1081
|
+
* @return {Array} Returns array of lines.
|
1082
|
+
*/
|
1083
|
+
function splitLines(block)
|
1084
|
+
{
|
1085
|
+
return block.split(/\r?\n/);
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
/**
|
1089
|
+
* Generates HTML ID for the highlighter.
|
1090
|
+
* @param {String} highlighterId Highlighter ID.
|
1091
|
+
* @return {String} Returns HTML ID.
|
1092
|
+
*/
|
1093
|
+
function getHighlighterId(id)
|
1094
|
+
{
|
1095
|
+
var prefix = 'highlighter_';
|
1096
|
+
return id.indexOf(prefix) == 0 ? id : prefix + id;
|
1097
|
+
};
|
1098
|
+
|
1099
|
+
/**
|
1100
|
+
* Finds Highlighter instance by ID.
|
1101
|
+
* @param {String} highlighterId Highlighter ID.
|
1102
|
+
* @return {Highlighter} Returns instance of the highlighter.
|
1103
|
+
*/
|
1104
|
+
function getHighlighterById(id)
|
1105
|
+
{
|
1106
|
+
return sh.vars.highlighters[getHighlighterId(id)];
|
1107
|
+
};
|
1108
|
+
|
1109
|
+
/**
|
1110
|
+
* Finds highlighter's DIV container.
|
1111
|
+
* @param {String} highlighterId Highlighter ID.
|
1112
|
+
* @return {Element} Returns highlighter's DIV element.
|
1113
|
+
*/
|
1114
|
+
function getHighlighterDivById(id)
|
1115
|
+
{
|
1116
|
+
return document.getElementById(getHighlighterId(id));
|
1117
|
+
};
|
1118
|
+
|
1119
|
+
/**
|
1120
|
+
* Stores highlighter so that getHighlighterById() can do its thing. Each
|
1121
|
+
* highlighter must call this method to preserve itself.
|
1122
|
+
* @param {Highilghter} highlighter Highlighter instance.
|
1123
|
+
*/
|
1124
|
+
function storeHighlighter(highlighter)
|
1125
|
+
{
|
1126
|
+
sh.vars.highlighters[getHighlighterId(highlighter.id)] = highlighter;
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
/**
|
1130
|
+
* Looks for a child or parent node which has specified classname.
|
1131
|
+
* Equivalent to jQuery's $(container).find(".className")
|
1132
|
+
* @param {Element} target Target element.
|
1133
|
+
* @param {String} search Class name or node name to look for.
|
1134
|
+
* @param {Boolean} reverse If set to true, will go up the node tree instead of down.
|
1135
|
+
* @return {Element} Returns found child or parent element on null.
|
1136
|
+
*/
|
1137
|
+
function findElement(target, search, reverse /* optional */)
|
1138
|
+
{
|
1139
|
+
if (target == null)
|
1140
|
+
return null;
|
1141
|
+
|
1142
|
+
var nodes = reverse != true ? target.childNodes : [ target.parentNode ],
|
1143
|
+
propertyToFind = { '#' : 'id', '.' : 'className' }[search.substr(0, 1)] || 'nodeName',
|
1144
|
+
expectedValue,
|
1145
|
+
found
|
1146
|
+
;
|
1147
|
+
|
1148
|
+
expectedValue = propertyToFind != 'nodeName'
|
1149
|
+
? search.substr(1)
|
1150
|
+
: search.toUpperCase()
|
1151
|
+
;
|
1152
|
+
|
1153
|
+
// main return of the found node
|
1154
|
+
if ((target[propertyToFind] || '').indexOf(expectedValue) != -1)
|
1155
|
+
return target;
|
1156
|
+
|
1157
|
+
for (var i = 0; nodes && i < nodes.length && found == null; i++)
|
1158
|
+
found = findElement(nodes[i], search, reverse);
|
1159
|
+
|
1160
|
+
return found;
|
1161
|
+
};
|
1162
|
+
|
1163
|
+
/**
|
1164
|
+
* Looks for a parent node which has specified classname.
|
1165
|
+
* This is an alias to <code>findElement(container, className, true)</code>.
|
1166
|
+
* @param {Element} target Target element.
|
1167
|
+
* @param {String} className Class name to look for.
|
1168
|
+
* @return {Element} Returns found parent element on null.
|
1169
|
+
*/
|
1170
|
+
function findParentElement(target, className)
|
1171
|
+
{
|
1172
|
+
return findElement(target, className, true);
|
1173
|
+
};
|
1174
|
+
|
1175
|
+
/**
|
1176
|
+
* Finds an index of element in the array.
|
1177
|
+
* @ignore
|
1178
|
+
* @param {Object} searchElement
|
1179
|
+
* @param {Number} fromIndex
|
1180
|
+
* @return {Number} Returns index of element if found; -1 otherwise.
|
1181
|
+
*/
|
1182
|
+
function indexOf(array, searchElement, fromIndex)
|
1183
|
+
{
|
1184
|
+
fromIndex = Math.max(fromIndex || 0, 0);
|
1185
|
+
|
1186
|
+
for (var i = fromIndex; i < array.length; i++)
|
1187
|
+
if(array[i] == searchElement)
|
1188
|
+
return i;
|
1189
|
+
|
1190
|
+
return -1;
|
1191
|
+
};
|
1192
|
+
|
1193
|
+
/**
|
1194
|
+
* Generates a unique element ID.
|
1195
|
+
*/
|
1196
|
+
function guid(prefix)
|
1197
|
+
{
|
1198
|
+
return (prefix || '') + Math.round(Math.random() * 1000000).toString();
|
1199
|
+
};
|
1200
|
+
|
1201
|
+
/**
|
1202
|
+
* Merges two objects. Values from obj2 override values in obj1.
|
1203
|
+
* Function is NOT recursive and works only for one dimensional objects.
|
1204
|
+
* @param {Object} obj1 First object.
|
1205
|
+
* @param {Object} obj2 Second object.
|
1206
|
+
* @return {Object} Returns combination of both objects.
|
1207
|
+
*/
|
1208
|
+
function merge(obj1, obj2)
|
1209
|
+
{
|
1210
|
+
var result = {}, name;
|
1211
|
+
|
1212
|
+
for (name in obj1)
|
1213
|
+
result[name] = obj1[name];
|
1214
|
+
|
1215
|
+
for (name in obj2)
|
1216
|
+
result[name] = obj2[name];
|
1217
|
+
|
1218
|
+
return result;
|
1219
|
+
};
|
1220
|
+
|
1221
|
+
/**
|
1222
|
+
* Attempts to convert string to boolean.
|
1223
|
+
* @param {String} value Input string.
|
1224
|
+
* @return {Boolean} Returns true if input was "true", false if input was "false" and value otherwise.
|
1225
|
+
*/
|
1226
|
+
function toBoolean(value)
|
1227
|
+
{
|
1228
|
+
var result = { "true" : true, "false" : false }[value];
|
1229
|
+
return result == null ? value : result;
|
1230
|
+
};
|
1231
|
+
|
1232
|
+
/**
|
1233
|
+
* Opens up a centered popup window.
|
1234
|
+
* @param {String} url URL to open in the window.
|
1235
|
+
* @param {String} name Popup name.
|
1236
|
+
* @param {int} width Popup width.
|
1237
|
+
* @param {int} height Popup height.
|
1238
|
+
* @param {String} options window.open() options.
|
1239
|
+
* @return {Window} Returns window instance.
|
1240
|
+
*/
|
1241
|
+
function popup(url, name, width, height, options)
|
1242
|
+
{
|
1243
|
+
var x = (screen.width - width) / 2,
|
1244
|
+
y = (screen.height - height) / 2
|
1245
|
+
;
|
1246
|
+
|
1247
|
+
options += ', left=' + x +
|
1248
|
+
', top=' + y +
|
1249
|
+
', width=' + width +
|
1250
|
+
', height=' + height
|
1251
|
+
;
|
1252
|
+
options = options.replace(/^,/, '');
|
1253
|
+
|
1254
|
+
var win = window.open(url, name, options);
|
1255
|
+
win.focus();
|
1256
|
+
return win;
|
1257
|
+
};
|
1258
|
+
|
1259
|
+
/**
|
1260
|
+
* Adds event handler to the target object.
|
1261
|
+
* @param {Object} obj Target object.
|
1262
|
+
* @param {String} type Name of the event.
|
1263
|
+
* @param {Function} func Handling function.
|
1264
|
+
*/
|
1265
|
+
function attachEvent(obj, type, func, scope)
|
1266
|
+
{
|
1267
|
+
function handler(e)
|
1268
|
+
{
|
1269
|
+
e = e || window.event;
|
1270
|
+
|
1271
|
+
if (!e.target)
|
1272
|
+
{
|
1273
|
+
e.target = e.srcElement;
|
1274
|
+
e.preventDefault = function()
|
1275
|
+
{
|
1276
|
+
this.returnValue = false;
|
1277
|
+
};
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
func.call(scope || window, e);
|
1281
|
+
};
|
1282
|
+
|
1283
|
+
if (obj.attachEvent)
|
1284
|
+
{
|
1285
|
+
obj.attachEvent('on' + type, handler);
|
1286
|
+
}
|
1287
|
+
else
|
1288
|
+
{
|
1289
|
+
obj.addEventListener(type, handler, false);
|
1290
|
+
}
|
1291
|
+
};
|
1292
|
+
|
1293
|
+
/**
|
1294
|
+
* Displays an alert.
|
1295
|
+
* @param {String} str String to display.
|
1296
|
+
*/
|
1297
|
+
function alert(str)
|
1298
|
+
{
|
1299
|
+
window.alert(sh.config.strings.alert + str);
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
/**
|
1303
|
+
* Finds a brush by its alias.
|
1304
|
+
*
|
1305
|
+
* @param {String} alias Brush alias.
|
1306
|
+
* @param {Boolean} showAlert Suppresses the alert if false.
|
1307
|
+
* @return {Brush} Returns bursh constructor if found, null otherwise.
|
1308
|
+
*/
|
1309
|
+
function findBrush(alias, showAlert)
|
1310
|
+
{
|
1311
|
+
var brushes = sh.vars.discoveredBrushes,
|
1312
|
+
result = null
|
1313
|
+
;
|
1314
|
+
|
1315
|
+
if (brushes == null)
|
1316
|
+
{
|
1317
|
+
brushes = {};
|
1318
|
+
|
1319
|
+
// Find all brushes
|
1320
|
+
for (var brush in sh.brushes)
|
1321
|
+
{
|
1322
|
+
var info = sh.brushes[brush],
|
1323
|
+
aliases = info.aliases
|
1324
|
+
;
|
1325
|
+
|
1326
|
+
if (aliases == null)
|
1327
|
+
continue;
|
1328
|
+
|
1329
|
+
// keep the brush name
|
1330
|
+
info.brushName = brush.toLowerCase();
|
1331
|
+
|
1332
|
+
for (var i = 0; i < aliases.length; i++)
|
1333
|
+
brushes[aliases[i]] = brush;
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
sh.vars.discoveredBrushes = brushes;
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
result = sh.brushes[brushes[alias]];
|
1340
|
+
|
1341
|
+
if (result == null && showAlert)
|
1342
|
+
alert(sh.config.strings.noBrush + alias);
|
1343
|
+
|
1344
|
+
return result;
|
1345
|
+
};
|
1346
|
+
|
1347
|
+
/**
|
1348
|
+
* Executes a callback on each line and replaces each line with result from the callback.
|
1349
|
+
* @param {Object} str Input string.
|
1350
|
+
* @param {Object} callback Callback function taking one string argument and returning a string.
|
1351
|
+
*/
|
1352
|
+
function eachLine(str, callback)
|
1353
|
+
{
|
1354
|
+
var lines = splitLines(str);
|
1355
|
+
|
1356
|
+
for (var i = 0; i < lines.length; i++)
|
1357
|
+
lines[i] = callback(lines[i], i);
|
1358
|
+
|
1359
|
+
// include \r to enable copy-paste on windows (ie8) without getting everything on one line
|
1360
|
+
return lines.join('\r\n');
|
1361
|
+
};
|
1362
|
+
|
1363
|
+
/**
|
1364
|
+
* This is a special trim which only removes first and last empty lines
|
1365
|
+
* and doesn't affect valid leading space on the first line.
|
1366
|
+
*
|
1367
|
+
* @param {String} str Input string
|
1368
|
+
* @return {String} Returns string without empty first and last lines.
|
1369
|
+
*/
|
1370
|
+
function trimFirstAndLastLines(str)
|
1371
|
+
{
|
1372
|
+
return str.replace(/^[ ]*[\n]+|[\n]*[ ]*$/g, '');
|
1373
|
+
};
|
1374
|
+
|
1375
|
+
/**
|
1376
|
+
* Parses key/value pairs into hash object.
|
1377
|
+
*
|
1378
|
+
* Understands the following formats:
|
1379
|
+
* - name: word;
|
1380
|
+
* - name: [word, word];
|
1381
|
+
* - name: "string";
|
1382
|
+
* - name: 'string';
|
1383
|
+
*
|
1384
|
+
* For example:
|
1385
|
+
* name1: value; name2: [value, value]; name3: 'value'
|
1386
|
+
*
|
1387
|
+
* @param {String} str Input string.
|
1388
|
+
* @return {Object} Returns deserialized object.
|
1389
|
+
*/
|
1390
|
+
function parseParams(str)
|
1391
|
+
{
|
1392
|
+
var match,
|
1393
|
+
result = {},
|
1394
|
+
arrayRegex = new XRegExp("^\\[(?<values>(.*?))\\]$"),
|
1395
|
+
regex = new XRegExp(
|
1396
|
+
"(?<name>[\\w-]+)" +
|
1397
|
+
"\\s*:\\s*" +
|
1398
|
+
"(?<value>" +
|
1399
|
+
"[\\w-%#]+|" + // word
|
1400
|
+
"\\[.*?\\]|" + // [] array
|
1401
|
+
'".*?"|' + // "" string
|
1402
|
+
"'.*?'" + // '' string
|
1403
|
+
")\\s*;?",
|
1404
|
+
"g"
|
1405
|
+
)
|
1406
|
+
;
|
1407
|
+
|
1408
|
+
while ((match = regex.exec(str)) != null)
|
1409
|
+
{
|
1410
|
+
var value = match.value
|
1411
|
+
.replace(/^['"]|['"]$/g, '') // strip quotes from end of strings
|
1412
|
+
;
|
1413
|
+
|
1414
|
+
// try to parse array value
|
1415
|
+
if (value != null && arrayRegex.test(value))
|
1416
|
+
{
|
1417
|
+
var m = arrayRegex.exec(value);
|
1418
|
+
value = m.values.length > 0 ? m.values.split(/\s*,\s*/) : [];
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
result[match.name] = value;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
return result;
|
1425
|
+
};
|
1426
|
+
|
1427
|
+
/**
|
1428
|
+
* Wraps each line of the string into <code/> tag with given style applied to it.
|
1429
|
+
*
|
1430
|
+
* @param {String} str Input string.
|
1431
|
+
* @param {String} css Style name to apply to the string.
|
1432
|
+
* @return {String} Returns input string with each line surrounded by <span/> tag.
|
1433
|
+
*/
|
1434
|
+
function wrapLinesWithCode(str, css)
|
1435
|
+
{
|
1436
|
+
if (str == null || str.length == 0 || str == '\n')
|
1437
|
+
return str;
|
1438
|
+
|
1439
|
+
str = str.replace(/</g, '<');
|
1440
|
+
|
1441
|
+
// Replace two or more sequential spaces with leaving last space untouched.
|
1442
|
+
str = str.replace(/ {2,}/g, function(m)
|
1443
|
+
{
|
1444
|
+
var spaces = '';
|
1445
|
+
|
1446
|
+
for (var i = 0; i < m.length - 1; i++)
|
1447
|
+
spaces += sh.config.space;
|
1448
|
+
|
1449
|
+
return spaces + ' ';
|
1450
|
+
});
|
1451
|
+
|
1452
|
+
// Split each line and apply <span class="...">...</span> to them so that
|
1453
|
+
// leading spaces aren't included.
|
1454
|
+
if (css != null)
|
1455
|
+
str = eachLine(str, function(line)
|
1456
|
+
{
|
1457
|
+
if (line.length == 0)
|
1458
|
+
return '';
|
1459
|
+
|
1460
|
+
var spaces = '';
|
1461
|
+
|
1462
|
+
line = line.replace(/^( | )+/, function(s)
|
1463
|
+
{
|
1464
|
+
spaces = s;
|
1465
|
+
return '';
|
1466
|
+
});
|
1467
|
+
|
1468
|
+
if (line.length == 0)
|
1469
|
+
return spaces;
|
1470
|
+
|
1471
|
+
return spaces + '<code class="' + css + '">' + line + '</code>';
|
1472
|
+
});
|
1473
|
+
|
1474
|
+
return str;
|
1475
|
+
};
|
1476
|
+
|
1477
|
+
/**
|
1478
|
+
* Pads number with zeros until it's length is the same as given length.
|
1479
|
+
*
|
1480
|
+
* @param {Number} number Number to pad.
|
1481
|
+
* @param {Number} length Max string length with.
|
1482
|
+
* @return {String} Returns a string padded with proper amount of '0'.
|
1483
|
+
*/
|
1484
|
+
function padNumber(number, length)
|
1485
|
+
{
|
1486
|
+
var result = number.toString();
|
1487
|
+
|
1488
|
+
while (result.length < length)
|
1489
|
+
result = '0' + result;
|
1490
|
+
|
1491
|
+
return result;
|
1492
|
+
};
|
1493
|
+
|
1494
|
+
/**
|
1495
|
+
* Replaces tabs with spaces.
|
1496
|
+
*
|
1497
|
+
* @param {String} code Source code.
|
1498
|
+
* @param {Number} tabSize Size of the tab.
|
1499
|
+
* @return {String} Returns code with all tabs replaces by spaces.
|
1500
|
+
*/
|
1501
|
+
function processTabs(code, tabSize)
|
1502
|
+
{
|
1503
|
+
var tab = '';
|
1504
|
+
|
1505
|
+
for (var i = 0; i < tabSize; i++)
|
1506
|
+
tab += ' ';
|
1507
|
+
|
1508
|
+
return code.replace(/\t/g, tab);
|
1509
|
+
};
|
1510
|
+
|
1511
|
+
/**
|
1512
|
+
* Replaces tabs with smart spaces.
|
1513
|
+
*
|
1514
|
+
* @param {String} code Code to fix the tabs in.
|
1515
|
+
* @param {Number} tabSize Number of spaces in a column.
|
1516
|
+
* @return {String} Returns code with all tabs replaces with roper amount of spaces.
|
1517
|
+
*/
|
1518
|
+
function processSmartTabs(code, tabSize)
|
1519
|
+
{
|
1520
|
+
var lines = splitLines(code),
|
1521
|
+
tab = '\t',
|
1522
|
+
spaces = ''
|
1523
|
+
;
|
1524
|
+
|
1525
|
+
// Create a string with 1000 spaces to copy spaces from...
|
1526
|
+
// It's assumed that there would be no indentation longer than that.
|
1527
|
+
for (var i = 0; i < 50; i++)
|
1528
|
+
spaces += ' '; // 20 spaces * 50
|
1529
|
+
|
1530
|
+
// This function inserts specified amount of spaces in the string
|
1531
|
+
// where a tab is while removing that given tab.
|
1532
|
+
function insertSpaces(line, pos, count)
|
1533
|
+
{
|
1534
|
+
return line.substr(0, pos)
|
1535
|
+
+ spaces.substr(0, count)
|
1536
|
+
+ line.substr(pos + 1, line.length) // pos + 1 will get rid of the tab
|
1537
|
+
;
|
1538
|
+
};
|
1539
|
+
|
1540
|
+
// Go through all the lines and do the 'smart tabs' magic.
|
1541
|
+
code = eachLine(code, function(line)
|
1542
|
+
{
|
1543
|
+
if (line.indexOf(tab) == -1)
|
1544
|
+
return line;
|
1545
|
+
|
1546
|
+
var pos = 0;
|
1547
|
+
|
1548
|
+
while ((pos = line.indexOf(tab)) != -1)
|
1549
|
+
{
|
1550
|
+
// This is pretty much all there is to the 'smart tabs' logic.
|
1551
|
+
// Based on the position within the line and size of a tab,
|
1552
|
+
// calculate the amount of spaces we need to insert.
|
1553
|
+
var spaces = tabSize - pos % tabSize;
|
1554
|
+
line = insertSpaces(line, pos, spaces);
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
return line;
|
1558
|
+
});
|
1559
|
+
|
1560
|
+
return code;
|
1561
|
+
};
|
1562
|
+
|
1563
|
+
/**
|
1564
|
+
* Performs various string fixes based on configuration.
|
1565
|
+
*/
|
1566
|
+
function fixInputString(str)
|
1567
|
+
{
|
1568
|
+
var br = /<br\s*\/?>|<br\s*\/?>/gi;
|
1569
|
+
|
1570
|
+
if (sh.config.bloggerMode == true)
|
1571
|
+
str = str.replace(br, '\n');
|
1572
|
+
|
1573
|
+
if (sh.config.stripBrs == true)
|
1574
|
+
str = str.replace(br, '');
|
1575
|
+
|
1576
|
+
return str;
|
1577
|
+
};
|
1578
|
+
|
1579
|
+
/**
|
1580
|
+
* Removes all white space at the begining and end of a string.
|
1581
|
+
*
|
1582
|
+
* @param {String} str String to trim.
|
1583
|
+
* @return {String} Returns string without leading and following white space characters.
|
1584
|
+
*/
|
1585
|
+
function trim(str)
|
1586
|
+
{
|
1587
|
+
return str.replace(/^\s+|\s+$/g, '');
|
1588
|
+
};
|
1589
|
+
|
1590
|
+
/**
|
1591
|
+
* Unindents a block of text by the lowest common indent amount.
|
1592
|
+
* @param {String} str Text to unindent.
|
1593
|
+
* @return {String} Returns unindented text block.
|
1594
|
+
*/
|
1595
|
+
function unindent(str)
|
1596
|
+
{
|
1597
|
+
var lines = splitLines(fixInputString(str)),
|
1598
|
+
indents = new Array(),
|
1599
|
+
regex = /^\s*/,
|
1600
|
+
min = 1000
|
1601
|
+
;
|
1602
|
+
|
1603
|
+
// go through every line and check for common number of indents
|
1604
|
+
for (var i = 0; i < lines.length && min > 0; i++)
|
1605
|
+
{
|
1606
|
+
var line = lines[i];
|
1607
|
+
|
1608
|
+
if (trim(line).length == 0)
|
1609
|
+
continue;
|
1610
|
+
|
1611
|
+
var matches = regex.exec(line);
|
1612
|
+
|
1613
|
+
// In the event that just one line doesn't have leading white space
|
1614
|
+
// we can't unindent anything, so bail completely.
|
1615
|
+
if (matches == null)
|
1616
|
+
return str;
|
1617
|
+
|
1618
|
+
min = Math.min(matches[0].length, min);
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
// trim minimum common number of white space from the begining of every line
|
1622
|
+
if (min > 0)
|
1623
|
+
for (var i = 0; i < lines.length; i++)
|
1624
|
+
lines[i] = lines[i].substr(min);
|
1625
|
+
|
1626
|
+
return lines.join('\n');
|
1627
|
+
};
|
1628
|
+
|
1629
|
+
/**
|
1630
|
+
* Callback method for Array.sort() which sorts matches by
|
1631
|
+
* index position and then by length.
|
1632
|
+
*
|
1633
|
+
* @param {Match} m1 Left object.
|
1634
|
+
* @param {Match} m2 Right object.
|
1635
|
+
* @return {Number} Returns -1, 0 or -1 as a comparison result.
|
1636
|
+
*/
|
1637
|
+
function matchesSortCallback(m1, m2)
|
1638
|
+
{
|
1639
|
+
// sort matches by index first
|
1640
|
+
if(m1.index < m2.index)
|
1641
|
+
return -1;
|
1642
|
+
else if(m1.index > m2.index)
|
1643
|
+
return 1;
|
1644
|
+
else
|
1645
|
+
{
|
1646
|
+
// if index is the same, sort by length
|
1647
|
+
if(m1.length < m2.length)
|
1648
|
+
return -1;
|
1649
|
+
else if(m1.length > m2.length)
|
1650
|
+
return 1;
|
1651
|
+
}
|
1652
|
+
|
1653
|
+
return 0;
|
1654
|
+
};
|
1655
|
+
|
1656
|
+
/**
|
1657
|
+
* Executes given regular expression on provided code and returns all
|
1658
|
+
* matches that are found.
|
1659
|
+
*
|
1660
|
+
* @param {String} code Code to execute regular expression on.
|
1661
|
+
* @param {Object} regex Regular expression item info from <code>regexList</code> collection.
|
1662
|
+
* @return {Array} Returns a list of Match objects.
|
1663
|
+
*/
|
1664
|
+
function getMatches(code, regexInfo)
|
1665
|
+
{
|
1666
|
+
function defaultAdd(match, regexInfo)
|
1667
|
+
{
|
1668
|
+
return match[0];
|
1669
|
+
};
|
1670
|
+
|
1671
|
+
var index = 0,
|
1672
|
+
match = null,
|
1673
|
+
matches = [],
|
1674
|
+
func = regexInfo.func ? regexInfo.func : defaultAdd
|
1675
|
+
;
|
1676
|
+
|
1677
|
+
while((match = regexInfo.regex.exec(code)) != null)
|
1678
|
+
{
|
1679
|
+
var resultMatch = func(match, regexInfo);
|
1680
|
+
|
1681
|
+
if (typeof(resultMatch) == 'string')
|
1682
|
+
resultMatch = [new sh.Match(resultMatch, match.index, regexInfo.css)];
|
1683
|
+
|
1684
|
+
matches = matches.concat(resultMatch);
|
1685
|
+
}
|
1686
|
+
|
1687
|
+
return matches;
|
1688
|
+
};
|
1689
|
+
|
1690
|
+
/**
|
1691
|
+
* Turns all URLs in the code into <a/> tags.
|
1692
|
+
* @param {String} code Input code.
|
1693
|
+
* @return {String} Returns code with </a> tags.
|
1694
|
+
*/
|
1695
|
+
function processUrls(code)
|
1696
|
+
{
|
1697
|
+
var gt = /(.*)((>|<).*)/;
|
1698
|
+
|
1699
|
+
return code.replace(sh.regexLib.url, function(m)
|
1700
|
+
{
|
1701
|
+
var suffix = '',
|
1702
|
+
match = null
|
1703
|
+
;
|
1704
|
+
|
1705
|
+
// We include < and > in the URL for the common cases like <http://google.com>
|
1706
|
+
// The problem is that they get transformed into <http://google.com>
|
1707
|
+
// Where as > easily looks like part of the URL string.
|
1708
|
+
|
1709
|
+
if (match = gt.exec(m))
|
1710
|
+
{
|
1711
|
+
m = match[1];
|
1712
|
+
suffix = match[2];
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
return '<a href="' + m + '">' + m + '</a>' + suffix;
|
1716
|
+
});
|
1717
|
+
};
|
1718
|
+
|
1719
|
+
/**
|
1720
|
+
* Finds all <SCRIPT TYPE="syntaxhighlighter" /> elementss.
|
1721
|
+
* @return {Array} Returns array of all found SyntaxHighlighter tags.
|
1722
|
+
*/
|
1723
|
+
function getSyntaxHighlighterScriptTags()
|
1724
|
+
{
|
1725
|
+
var tags = document.getElementsByTagName('script'),
|
1726
|
+
result = []
|
1727
|
+
;
|
1728
|
+
|
1729
|
+
for (var i = 0; i < tags.length; i++)
|
1730
|
+
if (tags[i].type == 'syntaxhighlighter')
|
1731
|
+
result.push(tags[i]);
|
1732
|
+
|
1733
|
+
return result;
|
1734
|
+
};
|
1735
|
+
|
1736
|
+
/**
|
1737
|
+
* Strips <![CDATA[]]> from <SCRIPT /> content because it should be used
|
1738
|
+
* there in most cases for XHTML compliance.
|
1739
|
+
* @param {String} original Input code.
|
1740
|
+
* @return {String} Returns code without leading <![CDATA[]]> tags.
|
1741
|
+
*/
|
1742
|
+
function stripCData(original)
|
1743
|
+
{
|
1744
|
+
var left = '<![CDATA[',
|
1745
|
+
right = ']]>',
|
1746
|
+
// for some reason IE inserts some leading blanks here
|
1747
|
+
copy = trim(original),
|
1748
|
+
changed = false,
|
1749
|
+
leftLength = left.length,
|
1750
|
+
rightLength = right.length
|
1751
|
+
;
|
1752
|
+
|
1753
|
+
if (copy.indexOf(left) == 0)
|
1754
|
+
{
|
1755
|
+
copy = copy.substring(leftLength);
|
1756
|
+
changed = true;
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
var copyLength = copy.length;
|
1760
|
+
|
1761
|
+
if (copy.indexOf(right) == copyLength - rightLength)
|
1762
|
+
{
|
1763
|
+
copy = copy.substring(0, copyLength - rightLength);
|
1764
|
+
changed = true;
|
1765
|
+
}
|
1766
|
+
|
1767
|
+
return changed ? copy : original;
|
1768
|
+
};
|
1769
|
+
|
1770
|
+
|
1771
|
+
/**
|
1772
|
+
* Quick code mouse double click handler.
|
1773
|
+
*/
|
1774
|
+
function quickCodeHandler(e)
|
1775
|
+
{
|
1776
|
+
var target = e.target,
|
1777
|
+
highlighterDiv = findParentElement(target, '.syntaxhighlighter'),
|
1778
|
+
container = findParentElement(target, '.container'),
|
1779
|
+
textarea = document.createElement('textarea'),
|
1780
|
+
highlighter
|
1781
|
+
;
|
1782
|
+
|
1783
|
+
if (!container || !highlighterDiv || findElement(container, 'textarea'))
|
1784
|
+
return;
|
1785
|
+
|
1786
|
+
highlighter = getHighlighterById(highlighterDiv.id);
|
1787
|
+
|
1788
|
+
// add source class name
|
1789
|
+
addClass(highlighterDiv, 'source');
|
1790
|
+
|
1791
|
+
// Have to go over each line and grab it's text, can't just do it on the
|
1792
|
+
// container because Firefox loses all \n where as Webkit doesn't.
|
1793
|
+
var lines = container.childNodes,
|
1794
|
+
code = []
|
1795
|
+
;
|
1796
|
+
|
1797
|
+
for (var i = 0; i < lines.length; i++)
|
1798
|
+
code.push(lines[i].innerText || lines[i].textContent);
|
1799
|
+
|
1800
|
+
// using \r instead of \r or \r\n makes this work equally well on IE, FF and Webkit
|
1801
|
+
code = code.join('\r');
|
1802
|
+
|
1803
|
+
// For Webkit browsers, replace nbsp with a breaking space
|
1804
|
+
code = code.replace(/\u00a0/g, " ");
|
1805
|
+
|
1806
|
+
// inject <textarea/> tag
|
1807
|
+
textarea.appendChild(document.createTextNode(code));
|
1808
|
+
container.appendChild(textarea);
|
1809
|
+
|
1810
|
+
// preselect all text
|
1811
|
+
textarea.focus();
|
1812
|
+
textarea.select();
|
1813
|
+
|
1814
|
+
// set up handler for lost focus
|
1815
|
+
attachEvent(textarea, 'blur', function(e)
|
1816
|
+
{
|
1817
|
+
textarea.parentNode.removeChild(textarea);
|
1818
|
+
removeClass(highlighterDiv, 'source');
|
1819
|
+
});
|
1820
|
+
};
|
1821
|
+
|
1822
|
+
/**
|
1823
|
+
* Match object.
|
1824
|
+
*/
|
1825
|
+
sh.Match = function(value, index, css)
|
1826
|
+
{
|
1827
|
+
this.value = value;
|
1828
|
+
this.index = index;
|
1829
|
+
this.length = value.length;
|
1830
|
+
this.css = css;
|
1831
|
+
this.brushName = null;
|
1832
|
+
};
|
1833
|
+
|
1834
|
+
sh.Match.prototype.toString = function()
|
1835
|
+
{
|
1836
|
+
return this.value;
|
1837
|
+
};
|
1838
|
+
|
1839
|
+
/**
|
1840
|
+
* Simulates HTML code with a scripting language embedded.
|
1841
|
+
*
|
1842
|
+
* @param {String} scriptBrushName Brush name of the scripting language.
|
1843
|
+
*/
|
1844
|
+
sh.HtmlScript = function(scriptBrushName)
|
1845
|
+
{
|
1846
|
+
var brushClass = findBrush(scriptBrushName),
|
1847
|
+
scriptBrush,
|
1848
|
+
xmlBrush = new sh.brushes.Xml(),
|
1849
|
+
bracketsRegex = null,
|
1850
|
+
ref = this,
|
1851
|
+
methodsToExpose = 'getDiv getHtml init'.split(' ')
|
1852
|
+
;
|
1853
|
+
|
1854
|
+
if (brushClass == null)
|
1855
|
+
return;
|
1856
|
+
|
1857
|
+
scriptBrush = new brushClass();
|
1858
|
+
|
1859
|
+
for(var i = 0; i < methodsToExpose.length; i++)
|
1860
|
+
// make a closure so we don't lose the name after i changes
|
1861
|
+
(function() {
|
1862
|
+
var name = methodsToExpose[i];
|
1863
|
+
|
1864
|
+
ref[name] = function()
|
1865
|
+
{
|
1866
|
+
return xmlBrush[name].apply(xmlBrush, arguments);
|
1867
|
+
};
|
1868
|
+
})();
|
1869
|
+
|
1870
|
+
if (scriptBrush.htmlScript == null)
|
1871
|
+
{
|
1872
|
+
alert(sh.config.strings.brushNotHtmlScript + scriptBrushName);
|
1873
|
+
return;
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
xmlBrush.regexList.push(
|
1877
|
+
{ regex: scriptBrush.htmlScript.code, func: process }
|
1878
|
+
);
|
1879
|
+
|
1880
|
+
function offsetMatches(matches, offset)
|
1881
|
+
{
|
1882
|
+
for (var j = 0; j < matches.length; j++)
|
1883
|
+
matches[j].index += offset;
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
function process(match, info)
|
1887
|
+
{
|
1888
|
+
var code = match.code,
|
1889
|
+
matches = [],
|
1890
|
+
regexList = scriptBrush.regexList,
|
1891
|
+
offset = match.index + match.left.length,
|
1892
|
+
htmlScript = scriptBrush.htmlScript,
|
1893
|
+
result
|
1894
|
+
;
|
1895
|
+
|
1896
|
+
// add all matches from the code
|
1897
|
+
for (var i = 0; i < regexList.length; i++)
|
1898
|
+
{
|
1899
|
+
result = getMatches(code, regexList[i]);
|
1900
|
+
offsetMatches(result, offset);
|
1901
|
+
matches = matches.concat(result);
|
1902
|
+
}
|
1903
|
+
|
1904
|
+
// add left script bracket
|
1905
|
+
if (htmlScript.left != null && match.left != null)
|
1906
|
+
{
|
1907
|
+
result = getMatches(match.left, htmlScript.left);
|
1908
|
+
offsetMatches(result, match.index);
|
1909
|
+
matches = matches.concat(result);
|
1910
|
+
}
|
1911
|
+
|
1912
|
+
// add right script bracket
|
1913
|
+
if (htmlScript.right != null && match.right != null)
|
1914
|
+
{
|
1915
|
+
result = getMatches(match.right, htmlScript.right);
|
1916
|
+
offsetMatches(result, match.index + match[0].lastIndexOf(match.right));
|
1917
|
+
matches = matches.concat(result);
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
for (var j = 0; j < matches.length; j++)
|
1921
|
+
matches[j].brushName = brushClass.brushName;
|
1922
|
+
|
1923
|
+
return matches;
|
1924
|
+
}
|
1925
|
+
};
|
1926
|
+
|
1927
|
+
/**
|
1928
|
+
* Main Highlither class.
|
1929
|
+
* @constructor
|
1930
|
+
*/
|
1931
|
+
sh.Highlighter = function()
|
1932
|
+
{
|
1933
|
+
// not putting any code in here because of the prototype inheritance
|
1934
|
+
};
|
1935
|
+
|
1936
|
+
sh.Highlighter.prototype = {
|
1937
|
+
/**
|
1938
|
+
* Returns value of the parameter passed to the highlighter.
|
1939
|
+
* @param {String} name Name of the parameter.
|
1940
|
+
* @param {Object} defaultValue Default value.
|
1941
|
+
* @return {Object} Returns found value or default value otherwise.
|
1942
|
+
*/
|
1943
|
+
getParam: function(name, defaultValue)
|
1944
|
+
{
|
1945
|
+
var result = this.params[name];
|
1946
|
+
return toBoolean(result == null ? defaultValue : result);
|
1947
|
+
},
|
1948
|
+
|
1949
|
+
/**
|
1950
|
+
* Shortcut to document.createElement().
|
1951
|
+
* @param {String} name Name of the element to create (DIV, A, etc).
|
1952
|
+
* @return {HTMLElement} Returns new HTML element.
|
1953
|
+
*/
|
1954
|
+
create: function(name)
|
1955
|
+
{
|
1956
|
+
return document.createElement(name);
|
1957
|
+
},
|
1958
|
+
|
1959
|
+
/**
|
1960
|
+
* Applies all regular expression to the code and stores all found
|
1961
|
+
* matches in the `this.matches` array.
|
1962
|
+
* @param {Array} regexList List of regular expressions.
|
1963
|
+
* @param {String} code Source code.
|
1964
|
+
* @return {Array} Returns list of matches.
|
1965
|
+
*/
|
1966
|
+
findMatches: function(regexList, code)
|
1967
|
+
{
|
1968
|
+
var result = [];
|
1969
|
+
|
1970
|
+
if (regexList != null)
|
1971
|
+
for (var i = 0; i < regexList.length; i++)
|
1972
|
+
// BUG: length returns len+1 for array if methods added to prototype chain (oising@gmail.com)
|
1973
|
+
if (typeof (regexList[i]) == "object")
|
1974
|
+
result = result.concat(getMatches(code, regexList[i]));
|
1975
|
+
|
1976
|
+
// sort and remove nested the matches
|
1977
|
+
return this.removeNestedMatches(result.sort(matchesSortCallback));
|
1978
|
+
},
|
1979
|
+
|
1980
|
+
/**
|
1981
|
+
* Checks to see if any of the matches are inside of other matches.
|
1982
|
+
* This process would get rid of highligted strings inside comments,
|
1983
|
+
* keywords inside strings and so on.
|
1984
|
+
*/
|
1985
|
+
removeNestedMatches: function(matches)
|
1986
|
+
{
|
1987
|
+
// Optimized by Jose Prado (http://joseprado.com)
|
1988
|
+
for (var i = 0; i < matches.length; i++)
|
1989
|
+
{
|
1990
|
+
if (matches[i] === null)
|
1991
|
+
continue;
|
1992
|
+
|
1993
|
+
var itemI = matches[i],
|
1994
|
+
itemIEndPos = itemI.index + itemI.length
|
1995
|
+
;
|
1996
|
+
|
1997
|
+
for (var j = i + 1; j < matches.length && matches[i] !== null; j++)
|
1998
|
+
{
|
1999
|
+
var itemJ = matches[j];
|
2000
|
+
|
2001
|
+
if (itemJ === null)
|
2002
|
+
continue;
|
2003
|
+
else if (itemJ.index > itemIEndPos)
|
2004
|
+
break;
|
2005
|
+
else if (itemJ.index == itemI.index && itemJ.length > itemI.length)
|
2006
|
+
matches[i] = null;
|
2007
|
+
else if (itemJ.index >= itemI.index && itemJ.index < itemIEndPos)
|
2008
|
+
matches[j] = null;
|
2009
|
+
}
|
2010
|
+
}
|
2011
|
+
|
2012
|
+
return matches;
|
2013
|
+
},
|
2014
|
+
|
2015
|
+
/**
|
2016
|
+
* Creates an array containing integer line numbers starting from the 'first-line' param.
|
2017
|
+
* @return {Array} Returns array of integers.
|
2018
|
+
*/
|
2019
|
+
figureOutLineNumbers: function(code)
|
2020
|
+
{
|
2021
|
+
var lines = [],
|
2022
|
+
firstLine = parseInt(this.getParam('first-line'))
|
2023
|
+
;
|
2024
|
+
|
2025
|
+
eachLine(code, function(line, index)
|
2026
|
+
{
|
2027
|
+
lines.push(index + firstLine);
|
2028
|
+
});
|
2029
|
+
|
2030
|
+
return lines;
|
2031
|
+
},
|
2032
|
+
|
2033
|
+
/**
|
2034
|
+
* Determines if specified line number is in the highlighted list.
|
2035
|
+
*/
|
2036
|
+
isLineHighlighted: function(lineNumber)
|
2037
|
+
{
|
2038
|
+
var list = this.getParam('highlight', []);
|
2039
|
+
|
2040
|
+
if (typeof(list) != 'object' && list.push == null)
|
2041
|
+
list = [ list ];
|
2042
|
+
|
2043
|
+
return indexOf(list, lineNumber.toString()) != -1;
|
2044
|
+
},
|
2045
|
+
|
2046
|
+
/**
|
2047
|
+
* Generates HTML markup for a single line of code while determining alternating line style.
|
2048
|
+
* @param {Integer} lineNumber Line number.
|
2049
|
+
* @param {String} code Line HTML markup.
|
2050
|
+
* @return {String} Returns HTML markup.
|
2051
|
+
*/
|
2052
|
+
getLineHtml: function(lineIndex, lineNumber, code)
|
2053
|
+
{
|
2054
|
+
var classes = [
|
2055
|
+
'line',
|
2056
|
+
'number' + lineNumber,
|
2057
|
+
'index' + lineIndex,
|
2058
|
+
'alt' + (lineNumber % 2 == 0 ? 1 : 2).toString()
|
2059
|
+
];
|
2060
|
+
|
2061
|
+
if (this.isLineHighlighted(lineNumber))
|
2062
|
+
classes.push('highlighted');
|
2063
|
+
|
2064
|
+
if (lineNumber == 0)
|
2065
|
+
classes.push('break');
|
2066
|
+
|
2067
|
+
return '<div class="' + classes.join(' ') + '">' + code + '</div>';
|
2068
|
+
},
|
2069
|
+
|
2070
|
+
/**
|
2071
|
+
* Generates HTML markup for line number column.
|
2072
|
+
* @param {String} code Complete code HTML markup.
|
2073
|
+
* @param {Array} lineNumbers Calculated line numbers.
|
2074
|
+
* @return {String} Returns HTML markup.
|
2075
|
+
*/
|
2076
|
+
getLineNumbersHtml: function(code, lineNumbers)
|
2077
|
+
{
|
2078
|
+
var html = '',
|
2079
|
+
count = splitLines(code).length,
|
2080
|
+
firstLine = parseInt(this.getParam('first-line')),
|
2081
|
+
pad = this.getParam('pad-line-numbers')
|
2082
|
+
;
|
2083
|
+
|
2084
|
+
if (pad == true)
|
2085
|
+
pad = (firstLine + count - 1).toString().length;
|
2086
|
+
else if (isNaN(pad) == true)
|
2087
|
+
pad = 0;
|
2088
|
+
|
2089
|
+
for (var i = 0; i < count; i++)
|
2090
|
+
{
|
2091
|
+
var lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i,
|
2092
|
+
code = lineNumber == 0 ? sh.config.space : padNumber(lineNumber, pad)
|
2093
|
+
;
|
2094
|
+
|
2095
|
+
html += this.getLineHtml(i, lineNumber, code);
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
return html;
|
2099
|
+
},
|
2100
|
+
|
2101
|
+
/**
|
2102
|
+
* Splits block of text into individual DIV lines.
|
2103
|
+
* @param {String} code Code to highlight.
|
2104
|
+
* @param {Array} lineNumbers Calculated line numbers.
|
2105
|
+
* @return {String} Returns highlighted code in HTML form.
|
2106
|
+
*/
|
2107
|
+
getCodeLinesHtml: function(html, lineNumbers)
|
2108
|
+
{
|
2109
|
+
html = trim(html);
|
2110
|
+
|
2111
|
+
var lines = splitLines(html),
|
2112
|
+
padLength = this.getParam('pad-line-numbers'),
|
2113
|
+
firstLine = parseInt(this.getParam('first-line')),
|
2114
|
+
html = '',
|
2115
|
+
brushName = this.getParam('brush')
|
2116
|
+
;
|
2117
|
+
|
2118
|
+
for (var i = 0; i < lines.length; i++)
|
2119
|
+
{
|
2120
|
+
var line = lines[i],
|
2121
|
+
indent = /^( |\s)+/.exec(line),
|
2122
|
+
spaces = null,
|
2123
|
+
lineNumber = lineNumbers ? lineNumbers[i] : firstLine + i;
|
2124
|
+
;
|
2125
|
+
|
2126
|
+
if (indent != null)
|
2127
|
+
{
|
2128
|
+
spaces = indent[0].toString();
|
2129
|
+
line = line.substr(spaces.length);
|
2130
|
+
spaces = spaces.replace(' ', sh.config.space);
|
2131
|
+
}
|
2132
|
+
|
2133
|
+
line = trim(line);
|
2134
|
+
|
2135
|
+
if (line.length == 0)
|
2136
|
+
line = sh.config.space;
|
2137
|
+
|
2138
|
+
html += this.getLineHtml(
|
2139
|
+
i,
|
2140
|
+
lineNumber,
|
2141
|
+
(spaces != null ? '<code class="' + brushName + ' spaces">' + spaces + '</code>' : '') + line
|
2142
|
+
);
|
2143
|
+
}
|
2144
|
+
|
2145
|
+
return html;
|
2146
|
+
},
|
2147
|
+
|
2148
|
+
/**
|
2149
|
+
* Returns HTML for the table title or empty string if title is null.
|
2150
|
+
*/
|
2151
|
+
getTitleHtml: function(title)
|
2152
|
+
{
|
2153
|
+
return title ? '<caption>' + title + '</caption>' : '';
|
2154
|
+
},
|
2155
|
+
|
2156
|
+
/**
|
2157
|
+
* Finds all matches in the source code.
|
2158
|
+
* @param {String} code Source code to process matches in.
|
2159
|
+
* @param {Array} matches Discovered regex matches.
|
2160
|
+
* @return {String} Returns formatted HTML with processed mathes.
|
2161
|
+
*/
|
2162
|
+
getMatchesHtml: function(code, matches)
|
2163
|
+
{
|
2164
|
+
var pos = 0,
|
2165
|
+
result = '',
|
2166
|
+
brushName = this.getParam('brush', '')
|
2167
|
+
;
|
2168
|
+
|
2169
|
+
function getBrushNameCss(match)
|
2170
|
+
{
|
2171
|
+
var result = match ? (match.brushName || brushName) : brushName;
|
2172
|
+
return result ? result + ' ' : '';
|
2173
|
+
};
|
2174
|
+
|
2175
|
+
// Finally, go through the final list of matches and pull the all
|
2176
|
+
// together adding everything in between that isn't a match.
|
2177
|
+
for (var i = 0; i < matches.length; i++)
|
2178
|
+
{
|
2179
|
+
var match = matches[i],
|
2180
|
+
matchBrushName
|
2181
|
+
;
|
2182
|
+
|
2183
|
+
if (match === null || match.length === 0)
|
2184
|
+
continue;
|
2185
|
+
|
2186
|
+
matchBrushName = getBrushNameCss(match);
|
2187
|
+
|
2188
|
+
result += wrapLinesWithCode(code.substr(pos, match.index - pos), matchBrushName + 'plain')
|
2189
|
+
+ wrapLinesWithCode(match.value, matchBrushName + match.css)
|
2190
|
+
;
|
2191
|
+
|
2192
|
+
pos = match.index + match.length + (match.offset || 0);
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
// don't forget to add whatever's remaining in the string
|
2196
|
+
result += wrapLinesWithCode(code.substr(pos), getBrushNameCss() + 'plain');
|
2197
|
+
|
2198
|
+
return result;
|
2199
|
+
},
|
2200
|
+
|
2201
|
+
/**
|
2202
|
+
* Generates HTML markup for the whole syntax highlighter.
|
2203
|
+
* @param {String} code Source code.
|
2204
|
+
* @return {String} Returns HTML markup.
|
2205
|
+
*/
|
2206
|
+
getHtml: function(code)
|
2207
|
+
{
|
2208
|
+
var html = '',
|
2209
|
+
classes = [ 'syntaxhighlighter' ],
|
2210
|
+
tabSize,
|
2211
|
+
matches,
|
2212
|
+
lineNumbers
|
2213
|
+
;
|
2214
|
+
|
2215
|
+
// process light mode
|
2216
|
+
if (this.getParam('light') == true)
|
2217
|
+
this.params.toolbar = this.params.gutter = false;
|
2218
|
+
|
2219
|
+
className = 'syntaxhighlighter';
|
2220
|
+
|
2221
|
+
if (this.getParam('collapse') == true)
|
2222
|
+
classes.push('collapsed');
|
2223
|
+
|
2224
|
+
if ((gutter = this.getParam('gutter')) == false)
|
2225
|
+
classes.push('nogutter');
|
2226
|
+
|
2227
|
+
// add custom user style name
|
2228
|
+
classes.push(this.getParam('class-name'));
|
2229
|
+
|
2230
|
+
// add brush alias to the class name for custom CSS
|
2231
|
+
classes.push(this.getParam('brush'));
|
2232
|
+
|
2233
|
+
code = trimFirstAndLastLines(code)
|
2234
|
+
.replace(/\r/g, ' ') // IE lets these buggers through
|
2235
|
+
;
|
2236
|
+
|
2237
|
+
tabSize = this.getParam('tab-size');
|
2238
|
+
|
2239
|
+
// replace tabs with spaces
|
2240
|
+
code = this.getParam('smart-tabs') == true
|
2241
|
+
? processSmartTabs(code, tabSize)
|
2242
|
+
: processTabs(code, tabSize)
|
2243
|
+
;
|
2244
|
+
|
2245
|
+
// unindent code by the common indentation
|
2246
|
+
if (this.getParam('unindent'))
|
2247
|
+
code = unindent(code);
|
2248
|
+
|
2249
|
+
if (gutter)
|
2250
|
+
lineNumbers = this.figureOutLineNumbers(code);
|
2251
|
+
|
2252
|
+
// find matches in the code using brushes regex list
|
2253
|
+
matches = this.findMatches(this.regexList, code);
|
2254
|
+
// processes found matches into the html
|
2255
|
+
html = this.getMatchesHtml(code, matches);
|
2256
|
+
// finally, split all lines so that they wrap well
|
2257
|
+
html = this.getCodeLinesHtml(html, lineNumbers);
|
2258
|
+
|
2259
|
+
// finally, process the links
|
2260
|
+
if (this.getParam('auto-links'))
|
2261
|
+
html = processUrls(html);
|
2262
|
+
|
2263
|
+
if (typeof(navigator) != 'undefined' && navigator.userAgent && navigator.userAgent.match(/MSIE/))
|
2264
|
+
classes.push('ie');
|
2265
|
+
|
2266
|
+
html =
|
2267
|
+
'<div id="' + getHighlighterId(this.id) + '" class="' + classes.join(' ') + '">'
|
2268
|
+
+ (this.getParam('toolbar') ? sh.toolbar.getHtml(this) : '')
|
2269
|
+
+ '<table border="0" cellpadding="0" cellspacing="0">'
|
2270
|
+
+ this.getTitleHtml(this.getParam('title'))
|
2271
|
+
+ '<tbody>'
|
2272
|
+
+ '<tr>'
|
2273
|
+
+ (gutter ? '<td class="gutter">' + this.getLineNumbersHtml(code) + '</td>' : '')
|
2274
|
+
+ '<td class="code">'
|
2275
|
+
+ '<div class="container">'
|
2276
|
+
+ html
|
2277
|
+
+ '</div>'
|
2278
|
+
+ '</td>'
|
2279
|
+
+ '</tr>'
|
2280
|
+
+ '</tbody>'
|
2281
|
+
+ '</table>'
|
2282
|
+
+ '</div>'
|
2283
|
+
;
|
2284
|
+
|
2285
|
+
return html;
|
2286
|
+
},
|
2287
|
+
|
2288
|
+
/**
|
2289
|
+
* Highlights the code and returns complete HTML.
|
2290
|
+
* @param {String} code Code to highlight.
|
2291
|
+
* @return {Element} Returns container DIV element with all markup.
|
2292
|
+
*/
|
2293
|
+
getDiv: function(code)
|
2294
|
+
{
|
2295
|
+
if (code === null)
|
2296
|
+
code = '';
|
2297
|
+
|
2298
|
+
this.code = code;
|
2299
|
+
|
2300
|
+
var div = this.create('div');
|
2301
|
+
|
2302
|
+
// create main HTML
|
2303
|
+
div.innerHTML = this.getHtml(code);
|
2304
|
+
|
2305
|
+
// set up click handlers
|
2306
|
+
if (this.getParam('toolbar'))
|
2307
|
+
attachEvent(findElement(div, '.toolbar'), 'click', sh.toolbar.handler);
|
2308
|
+
|
2309
|
+
if (this.getParam('quick-code'))
|
2310
|
+
attachEvent(findElement(div, '.code'), 'dblclick', quickCodeHandler);
|
2311
|
+
|
2312
|
+
return div;
|
2313
|
+
},
|
2314
|
+
|
2315
|
+
/**
|
2316
|
+
* Initializes the highlighter/brush.
|
2317
|
+
*
|
2318
|
+
* Constructor isn't used for initialization so that nothing executes during necessary
|
2319
|
+
* `new SyntaxHighlighter.Highlighter()` call when setting up brush inheritence.
|
2320
|
+
*
|
2321
|
+
* @param {Hash} params Highlighter parameters.
|
2322
|
+
*/
|
2323
|
+
init: function(params)
|
2324
|
+
{
|
2325
|
+
this.id = guid();
|
2326
|
+
|
2327
|
+
// register this instance in the highlighters list
|
2328
|
+
storeHighlighter(this);
|
2329
|
+
|
2330
|
+
// local params take precedence over defaults
|
2331
|
+
this.params = merge(sh.defaults, params || {})
|
2332
|
+
|
2333
|
+
// process light mode
|
2334
|
+
if (this.getParam('light') == true)
|
2335
|
+
this.params.toolbar = this.params.gutter = false;
|
2336
|
+
},
|
2337
|
+
|
2338
|
+
/**
|
2339
|
+
* Converts space separated list of keywords into a regular expression string.
|
2340
|
+
* @param {String} str Space separated keywords.
|
2341
|
+
* @return {String} Returns regular expression string.
|
2342
|
+
*/
|
2343
|
+
getKeywords: function(str)
|
2344
|
+
{
|
2345
|
+
str = str
|
2346
|
+
.replace(/^\s+|\s+$/g, '')
|
2347
|
+
.replace(/\s+/g, '|')
|
2348
|
+
;
|
2349
|
+
|
2350
|
+
return '\\b(?:' + str + ')\\b';
|
2351
|
+
},
|
2352
|
+
|
2353
|
+
/**
|
2354
|
+
* Makes a brush compatible with the `html-script` functionality.
|
2355
|
+
* @param {Object} regexGroup Object containing `left` and `right` regular expressions.
|
2356
|
+
*/
|
2357
|
+
forHtmlScript: function(regexGroup)
|
2358
|
+
{
|
2359
|
+
var regex = { 'end' : regexGroup.right.source };
|
2360
|
+
|
2361
|
+
if(regexGroup.eof)
|
2362
|
+
regex.end = "(?:(?:" + regex.end + ")|$)";
|
2363
|
+
|
2364
|
+
this.htmlScript = {
|
2365
|
+
left : { regex: regexGroup.left, css: 'script' },
|
2366
|
+
right : { regex: regexGroup.right, css: 'script' },
|
2367
|
+
code : new XRegExp(
|
2368
|
+
"(?<left>" + regexGroup.left.source + ")" +
|
2369
|
+
"(?<code>.*?)" +
|
2370
|
+
"(?<right>" + regex.end + ")",
|
2371
|
+
"sgi"
|
2372
|
+
)
|
2373
|
+
};
|
2374
|
+
}
|
2375
|
+
}; // end of Highlighter
|
2376
|
+
|
2377
|
+
return sh;
|
2378
|
+
}(); // end of anonymous function
|
2379
|
+
|
2380
|
+
// CommonJS
|
2381
|
+
typeof(exports) != 'undefined' ? exports.SyntaxHighlighter = SyntaxHighlighter : null;
|
2382
|
+
|
2383
|
+
;(function()
|
2384
|
+
{
|
2385
|
+
// CommonJS
|
2386
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2387
|
+
|
2388
|
+
function Brush()
|
2389
|
+
{
|
2390
|
+
// Created by Peter Atoria @ http://iAtoria.com
|
2391
|
+
|
2392
|
+
var inits = 'class interface function package';
|
2393
|
+
|
2394
|
+
var keywords = '-Infinity ...rest Array as AS3 Boolean break case catch const continue Date decodeURI ' +
|
2395
|
+
'decodeURIComponent default delete do dynamic each else encodeURI encodeURIComponent escape ' +
|
2396
|
+
'extends false final finally flash_proxy for get if implements import in include Infinity ' +
|
2397
|
+
'instanceof int internal is isFinite isNaN isXMLName label namespace NaN native new null ' +
|
2398
|
+
'Null Number Object object_proxy override parseFloat parseInt private protected public ' +
|
2399
|
+
'return set static String super switch this throw true try typeof uint undefined unescape ' +
|
2400
|
+
'use void while with'
|
2401
|
+
;
|
2402
|
+
|
2403
|
+
this.regexList = [
|
2404
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
2405
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
2406
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
2407
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
2408
|
+
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
|
2409
|
+
{ regex: new RegExp(this.getKeywords(inits), 'gm'), css: 'color3' }, // initializations
|
2410
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
|
2411
|
+
{ regex: new RegExp('var', 'gm'), css: 'variable' }, // variable
|
2412
|
+
{ regex: new RegExp('trace', 'gm'), css: 'color1' } // trace
|
2413
|
+
];
|
2414
|
+
|
2415
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags);
|
2416
|
+
};
|
2417
|
+
|
2418
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2419
|
+
Brush.aliases = ['actionscript3', 'as3'];
|
2420
|
+
|
2421
|
+
SyntaxHighlighter.brushes.AS3 = Brush;
|
2422
|
+
|
2423
|
+
// CommonJS
|
2424
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2425
|
+
})();
|
2426
|
+
|
2427
|
+
;(function()
|
2428
|
+
{
|
2429
|
+
// CommonJS
|
2430
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2431
|
+
|
2432
|
+
function Brush()
|
2433
|
+
{
|
2434
|
+
// AppleScript brush by David Chambers
|
2435
|
+
// http://davidchambersdesign.com/
|
2436
|
+
var keywords = 'after before beginning continue copy each end every from return get global in local named of set some that the then times to where whose with without';
|
2437
|
+
var ordinals = 'first second third fourth fifth sixth seventh eighth ninth tenth last front back middle';
|
2438
|
+
var specials = 'activate add alias AppleScript ask attachment boolean class constant delete duplicate empty exists false id integer list make message modal modified new no paragraph pi properties quit real record remove rest result reveal reverse run running save string true word yes';
|
2439
|
+
|
2440
|
+
this.regexList = [
|
2441
|
+
|
2442
|
+
{ regex: /(--|#).*$/gm,
|
2443
|
+
css: 'comments' },
|
2444
|
+
|
2445
|
+
{ regex: /\(\*(?:[\s\S]*?\(\*[\s\S]*?\*\))*[\s\S]*?\*\)/gm, // support nested comments
|
2446
|
+
css: 'comments' },
|
2447
|
+
|
2448
|
+
{ regex: /"[\s\S]*?"/gm,
|
2449
|
+
css: 'string' },
|
2450
|
+
|
2451
|
+
{ regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g,
|
2452
|
+
css: 'color1' },
|
2453
|
+
|
2454
|
+
{ regex: /(-)?(\d)+(\.(\d)?)?(E\+(\d)+)?/g, // numbers
|
2455
|
+
css: 'color1' },
|
2456
|
+
|
2457
|
+
{ regex: /(?:&(amp;|gt;|lt;)?|=|� |>|<|≥|>=|≤|<=|\*|\+|-|\/|÷|\^)/g,
|
2458
|
+
css: 'color2' },
|
2459
|
+
|
2460
|
+
{ regex: /\b(?:and|as|div|mod|not|or|return(?!\s&)(ing)?|equals|(is(n't| not)? )?equal( to)?|does(n't| not) equal|(is(n't| not)? )?(greater|less) than( or equal( to)?)?|(comes|does(n't| not) come) (after|before)|is(n't| not)?( in)? (back|front) of|is(n't| not)? behind|is(n't| not)?( (in|contained by))?|does(n't| not) contain|contain(s)?|(start|begin|end)(s)? with|((but|end) )?(consider|ignor)ing|prop(erty)?|(a )?ref(erence)?( to)?|repeat (until|while|with)|((end|exit) )?repeat|((else|end) )?if|else|(end )?(script|tell|try)|(on )?error|(put )?into|(of )?(it|me)|its|my|with (timeout( of)?|transaction)|end (timeout|transaction))\b/g,
|
2461
|
+
css: 'keyword' },
|
2462
|
+
|
2463
|
+
{ regex: /\b\d+(st|nd|rd|th)\b/g, // ordinals
|
2464
|
+
css: 'keyword' },
|
2465
|
+
|
2466
|
+
{ regex: /\b(?:about|above|against|around|at|below|beneath|beside|between|by|(apart|aside) from|(instead|out) of|into|on(to)?|over|since|thr(ough|u)|under)\b/g,
|
2467
|
+
css: 'color3' },
|
2468
|
+
|
2469
|
+
{ regex: /\b(?:adding folder items to|after receiving|choose( ((remote )?application|color|folder|from list|URL))?|clipboard info|set the clipboard to|(the )?clipboard|entire contents|display(ing| (alert|dialog|mode))?|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|quoted form|return(ed)?|second(?! item)(s)?|list (disks|folder)|text item(s| delimiters)?|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|using( delimiters)?|starting at|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor)|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|(do( shell)?|load|run|store) script|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|POSIX (file|path)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|group|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
|
2470
|
+
css: 'color3' },
|
2471
|
+
|
2472
|
+
{ regex: new RegExp(this.getKeywords(specials), 'gm'), css: 'color3' },
|
2473
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
|
2474
|
+
{ regex: new RegExp(this.getKeywords(ordinals), 'gm'), css: 'keyword' }
|
2475
|
+
];
|
2476
|
+
};
|
2477
|
+
|
2478
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2479
|
+
Brush.aliases = ['applescript'];
|
2480
|
+
|
2481
|
+
SyntaxHighlighter.brushes.AppleScript = Brush;
|
2482
|
+
|
2483
|
+
// CommonJS
|
2484
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2485
|
+
})();
|
2486
|
+
;(function()
|
2487
|
+
{
|
2488
|
+
// CommonJS
|
2489
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2490
|
+
|
2491
|
+
function Brush()
|
2492
|
+
{
|
2493
|
+
var keywords = 'if fi then elif else for do done until while break continue case esac function return in eq ne ge le';
|
2494
|
+
var commands = 'alias apropos awk basename bash bc bg builtin bzip2 cal cat cd cfdisk chgrp chmod chown chroot' +
|
2495
|
+
'cksum clear cmp comm command cp cron crontab csplit cut date dc dd ddrescue declare df ' +
|
2496
|
+
'diff diff3 dig dir dircolors dirname dirs du echo egrep eject enable env ethtool eval ' +
|
2497
|
+
'exec exit expand export expr false fdformat fdisk fg fgrep file find fmt fold format ' +
|
2498
|
+
'free fsck ftp gawk getopts grep groups gzip hash head history hostname id ifconfig ' +
|
2499
|
+
'import install join kill less let ln local locate logname logout look lpc lpr lprint ' +
|
2500
|
+
'lprintd lprintq lprm ls lsof make man mkdir mkfifo mkisofs mknod more mount mtools ' +
|
2501
|
+
'mv netstat nice nl nohup nslookup open op passwd paste pathchk ping popd pr printcap ' +
|
2502
|
+
'printenv printf ps pushd pwd quota quotacheck quotactl ram rcp read readonly renice ' +
|
2503
|
+
'remsync rm rmdir rsync screen scp sdiff sed select seq set sftp shift shopt shutdown ' +
|
2504
|
+
'sleep sort source split ssh strace su sudo sum symlink sync tail tar tee test time ' +
|
2505
|
+
'times touch top traceroute trap tr true tsort tty type ulimit umask umount unalias ' +
|
2506
|
+
'uname unexpand uniq units unset unshar useradd usermod users uuencode uudecode v vdir ' +
|
2507
|
+
'vi watch wc whereis which who whoami Wget xargs yes'
|
2508
|
+
;
|
2509
|
+
|
2510
|
+
this.regexList = [
|
2511
|
+
{ regex: /^#!.*$/gm, css: 'preprocessor bold' },
|
2512
|
+
{ regex: /\/[\w-\/]+/gm, css: 'plain' },
|
2513
|
+
{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
|
2514
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
2515
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
2516
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
|
2517
|
+
{ regex: new RegExp(this.getKeywords(commands), 'gm'), css: 'functions' } // commands
|
2518
|
+
];
|
2519
|
+
}
|
2520
|
+
|
2521
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2522
|
+
Brush.aliases = ['bash', 'shell', 'sh'];
|
2523
|
+
|
2524
|
+
SyntaxHighlighter.brushes.Bash = Brush;
|
2525
|
+
|
2526
|
+
// CommonJS
|
2527
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2528
|
+
})();
|
2529
|
+
;(function()
|
2530
|
+
{
|
2531
|
+
// CommonJS
|
2532
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2533
|
+
|
2534
|
+
function Brush()
|
2535
|
+
{
|
2536
|
+
// Contributed by Jen
|
2537
|
+
// http://www.jensbits.com/2009/05/14/coldfusion-brush-for-syntaxhighlighter-plus
|
2538
|
+
|
2539
|
+
var funcs = 'Abs ACos AddSOAPRequestHeader AddSOAPResponseHeader AjaxLink AjaxOnLoad ArrayAppend ArrayAvg ArrayClear ArrayDeleteAt ' +
|
2540
|
+
'ArrayInsertAt ArrayIsDefined ArrayIsEmpty ArrayLen ArrayMax ArrayMin ArraySet ArraySort ArraySum ArraySwap ArrayToList ' +
|
2541
|
+
'Asc ASin Atn BinaryDecode BinaryEncode BitAnd BitMaskClear BitMaskRead BitMaskSet BitNot BitOr BitSHLN BitSHRN BitXor ' +
|
2542
|
+
'Ceiling CharsetDecode CharsetEncode Chr CJustify Compare CompareNoCase Cos CreateDate CreateDateTime CreateObject ' +
|
2543
|
+
'CreateODBCDate CreateODBCDateTime CreateODBCTime CreateTime CreateTimeSpan CreateUUID DateAdd DateCompare DateConvert ' +
|
2544
|
+
'DateDiff DateFormat DatePart Day DayOfWeek DayOfWeekAsString DayOfYear DaysInMonth DaysInYear DE DecimalFormat DecrementValue ' +
|
2545
|
+
'Decrypt DecryptBinary DeleteClientVariable DeserializeJSON DirectoryExists DollarFormat DotNetToCFType Duplicate Encrypt ' +
|
2546
|
+
'EncryptBinary Evaluate Exp ExpandPath FileClose FileCopy FileDelete FileExists FileIsEOF FileMove FileOpen FileRead ' +
|
2547
|
+
'FileReadBinary FileReadLine FileSetAccessMode FileSetAttribute FileSetLastModified FileWrite Find FindNoCase FindOneOf ' +
|
2548
|
+
'FirstDayOfMonth Fix FormatBaseN GenerateSecretKey GetAuthUser GetBaseTagData GetBaseTagList GetBaseTemplatePath ' +
|
2549
|
+
'GetClientVariablesList GetComponentMetaData GetContextRoot GetCurrentTemplatePath GetDirectoryFromPath GetEncoding ' +
|
2550
|
+
'GetException GetFileFromPath GetFileInfo GetFunctionList GetGatewayHelper GetHttpRequestData GetHttpTimeString ' +
|
2551
|
+
'GetK2ServerDocCount GetK2ServerDocCountLimit GetLocale GetLocaleDisplayName GetLocalHostIP GetMetaData GetMetricData ' +
|
2552
|
+
'GetPageContext GetPrinterInfo GetProfileSections GetProfileString GetReadableImageFormats GetSOAPRequest GetSOAPRequestHeader ' +
|
2553
|
+
'GetSOAPResponse GetSOAPResponseHeader GetTempDirectory GetTempFile GetTemplatePath GetTickCount GetTimeZoneInfo GetToken ' +
|
2554
|
+
'GetUserRoles GetWriteableImageFormats Hash Hour HTMLCodeFormat HTMLEditFormat IIf ImageAddBorder ImageBlur ImageClearRect ' +
|
2555
|
+
'ImageCopy ImageCrop ImageDrawArc ImageDrawBeveledRect ImageDrawCubicCurve ImageDrawLine ImageDrawLines ImageDrawOval ' +
|
2556
|
+
'ImageDrawPoint ImageDrawQuadraticCurve ImageDrawRect ImageDrawRoundRect ImageDrawText ImageFlip ImageGetBlob ImageGetBufferedImage ' +
|
2557
|
+
'ImageGetEXIFTag ImageGetHeight ImageGetIPTCTag ImageGetWidth ImageGrayscale ImageInfo ImageNegative ImageNew ImageOverlay ImagePaste ' +
|
2558
|
+
'ImageRead ImageReadBase64 ImageResize ImageRotate ImageRotateDrawingAxis ImageScaleToFit ImageSetAntialiasing ImageSetBackgroundColor ' +
|
2559
|
+
'ImageSetDrawingColor ImageSetDrawingStroke ImageSetDrawingTransparency ImageSharpen ImageShear ImageShearDrawingAxis ImageTranslate ' +
|
2560
|
+
'ImageTranslateDrawingAxis ImageWrite ImageWriteBase64 ImageXORDrawingMode IncrementValue InputBaseN Insert Int IsArray IsBinary ' +
|
2561
|
+
'IsBoolean IsCustomFunction IsDate IsDDX IsDebugMode IsDefined IsImage IsImageFile IsInstanceOf IsJSON IsLeapYear IsLocalHost ' +
|
2562
|
+
'IsNumeric IsNumericDate IsObject IsPDFFile IsPDFObject IsQuery IsSimpleValue IsSOAPRequest IsStruct IsUserInAnyRole IsUserInRole ' +
|
2563
|
+
'IsUserLoggedIn IsValid IsWDDX IsXML IsXmlAttribute IsXmlDoc IsXmlElem IsXmlNode IsXmlRoot JavaCast JSStringFormat LCase Left Len ' +
|
2564
|
+
'ListAppend ListChangeDelims ListContains ListContainsNoCase ListDeleteAt ListFind ListFindNoCase ListFirst ListGetAt ListInsertAt ' +
|
2565
|
+
'ListLast ListLen ListPrepend ListQualify ListRest ListSetAt ListSort ListToArray ListValueCount ListValueCountNoCase LJustify Log ' +
|
2566
|
+
'Log10 LSCurrencyFormat LSDateFormat LSEuroCurrencyFormat LSIsCurrency LSIsDate LSIsNumeric LSNumberFormat LSParseCurrency LSParseDateTime ' +
|
2567
|
+
'LSParseEuroCurrency LSParseNumber LSTimeFormat LTrim Max Mid Min Minute Month MonthAsString Now NumberFormat ParagraphFormat ParseDateTime ' +
|
2568
|
+
'Pi PrecisionEvaluate PreserveSingleQuotes Quarter QueryAddColumn QueryAddRow QueryConvertForGrid QueryNew QuerySetCell QuotedValueList Rand ' +
|
2569
|
+
'Randomize RandRange REFind REFindNoCase ReleaseComObject REMatch REMatchNoCase RemoveChars RepeatString Replace ReplaceList ReplaceNoCase ' +
|
2570
|
+
'REReplace REReplaceNoCase Reverse Right RJustify Round RTrim Second SendGatewayMessage SerializeJSON SetEncoding SetLocale SetProfileString ' +
|
2571
|
+
'SetVariable Sgn Sin Sleep SpanExcluding SpanIncluding Sqr StripCR StructAppend StructClear StructCopy StructCount StructDelete StructFind ' +
|
2572
|
+
'StructFindKey StructFindValue StructGet StructInsert StructIsEmpty StructKeyArray StructKeyExists StructKeyList StructKeyList StructNew ' +
|
2573
|
+
'StructSort StructUpdate Tan TimeFormat ToBase64 ToBinary ToScript ToString Trim UCase URLDecode URLEncodedFormat URLSessionFormat Val ' +
|
2574
|
+
'ValueList VerifyClient Week Wrap Wrap WriteOutput XmlChildPos XmlElemNew XmlFormat XmlGetNodeType XmlNew XmlParse XmlSearch XmlTransform ' +
|
2575
|
+
'XmlValidate Year YesNoFormat';
|
2576
|
+
|
2577
|
+
var keywords = 'cfabort cfajaximport cfajaxproxy cfapplet cfapplication cfargument cfassociate cfbreak cfcache cfcalendar ' +
|
2578
|
+
'cfcase cfcatch cfchart cfchartdata cfchartseries cfcol cfcollection cfcomponent cfcontent cfcookie cfdbinfo ' +
|
2579
|
+
'cfdefaultcase cfdirectory cfdiv cfdocument cfdocumentitem cfdocumentsection cfdump cfelse cfelseif cferror ' +
|
2580
|
+
'cfexchangecalendar cfexchangeconnection cfexchangecontact cfexchangefilter cfexchangemail cfexchangetask ' +
|
2581
|
+
'cfexecute cfexit cffeed cffile cfflush cfform cfformgroup cfformitem cfftp cffunction cfgrid cfgridcolumn ' +
|
2582
|
+
'cfgridrow cfgridupdate cfheader cfhtmlhead cfhttp cfhttpparam cfif cfimage cfimport cfinclude cfindex ' +
|
2583
|
+
'cfinput cfinsert cfinterface cfinvoke cfinvokeargument cflayout cflayoutarea cfldap cflocation cflock cflog ' +
|
2584
|
+
'cflogin cfloginuser cflogout cfloop cfmail cfmailparam cfmailpart cfmenu cfmenuitem cfmodule cfNTauthenticate ' +
|
2585
|
+
'cfobject cfobjectcache cfoutput cfparam cfpdf cfpdfform cfpdfformparam cfpdfparam cfpdfsubform cfpod cfpop ' +
|
2586
|
+
'cfpresentation cfpresentationslide cfpresenter cfprint cfprocessingdirective cfprocparam cfprocresult ' +
|
2587
|
+
'cfproperty cfquery cfqueryparam cfregistry cfreport cfreportparam cfrethrow cfreturn cfsavecontent cfschedule ' +
|
2588
|
+
'cfscript cfsearch cfselect cfset cfsetting cfsilent cfslider cfsprydataset cfstoredproc cfswitch cftable ' +
|
2589
|
+
'cftextarea cfthread cfthrow cftimer cftooltip cftrace cftransaction cftree cftreeitem cftry cfupdate cfwddx ' +
|
2590
|
+
'cfwindow cfxml cfzip cfzipparam';
|
2591
|
+
|
2592
|
+
var operators = 'all and any between cross in join like not null or outer some';
|
2593
|
+
|
2594
|
+
this.regexList = [
|
2595
|
+
{ regex: new RegExp('--(.*)$', 'gm'), css: 'comments' }, // one line and multiline comments
|
2596
|
+
{ regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // single quoted strings
|
2597
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
2598
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
2599
|
+
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // functions
|
2600
|
+
{ regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such
|
2601
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
|
2602
|
+
];
|
2603
|
+
}
|
2604
|
+
|
2605
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2606
|
+
Brush.aliases = ['coldfusion','cf'];
|
2607
|
+
|
2608
|
+
SyntaxHighlighter.brushes.ColdFusion = Brush;
|
2609
|
+
|
2610
|
+
// CommonJS
|
2611
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2612
|
+
})();
|
2613
|
+
;(function()
|
2614
|
+
{
|
2615
|
+
// CommonJS
|
2616
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2617
|
+
|
2618
|
+
function Brush()
|
2619
|
+
{
|
2620
|
+
// Copyright 2006 Shin, YoungJin
|
2621
|
+
|
2622
|
+
var datatypes = 'ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR ' +
|
2623
|
+
'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH ' +
|
2624
|
+
'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP ' +
|
2625
|
+
'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY ' +
|
2626
|
+
'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT ' +
|
2627
|
+
'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE ' +
|
2628
|
+
'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF ' +
|
2629
|
+
'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR ' +
|
2630
|
+
'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR ' +
|
2631
|
+
'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT ' +
|
2632
|
+
'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 ' +
|
2633
|
+
'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR ' +
|
2634
|
+
'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 ' +
|
2635
|
+
'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT ' +
|
2636
|
+
'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG ' +
|
2637
|
+
'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM ' +
|
2638
|
+
'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t ' +
|
2639
|
+
'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS ' +
|
2640
|
+
'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t ' +
|
2641
|
+
'__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t ' +
|
2642
|
+
'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler ' +
|
2643
|
+
'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function ' +
|
2644
|
+
'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf ' +
|
2645
|
+
'va_list wchar_t wctrans_t wctype_t wint_t signed';
|
2646
|
+
|
2647
|
+
var keywords = 'auto break case catch class const decltype __finally __exception __try ' +
|
2648
|
+
'const_cast continue private public protected __declspec ' +
|
2649
|
+
'default delete deprecated dllexport dllimport do dynamic_cast ' +
|
2650
|
+
'else enum explicit extern if for friend goto inline ' +
|
2651
|
+
'mutable naked namespace new noinline noreturn nothrow ' +
|
2652
|
+
'register reinterpret_cast return selectany ' +
|
2653
|
+
'sizeof static static_cast struct switch template this ' +
|
2654
|
+
'thread throw true false try typedef typeid typename union ' +
|
2655
|
+
'using uuid virtual void volatile whcar_t while';
|
2656
|
+
|
2657
|
+
var functions = 'assert isalnum isalpha iscntrl isdigit isgraph islower isprint' +
|
2658
|
+
'ispunct isspace isupper isxdigit tolower toupper errno localeconv ' +
|
2659
|
+
'setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod ' +
|
2660
|
+
'frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf ' +
|
2661
|
+
'longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start ' +
|
2662
|
+
'clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen ' +
|
2663
|
+
'fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell ' +
|
2664
|
+
'fwrite getc getchar gets perror printf putc putchar puts remove ' +
|
2665
|
+
'rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ' +
|
2666
|
+
'ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol ' +
|
2667
|
+
'bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs ' +
|
2668
|
+
'mbtowc qsort rand realloc srand strtod strtol strtoul system ' +
|
2669
|
+
'wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr ' +
|
2670
|
+
'strcmp strcoll strcpy strcspn strerror strlen strncat strncmp ' +
|
2671
|
+
'strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime ' +
|
2672
|
+
'clock ctime difftime gmtime localtime mktime strftime time';
|
2673
|
+
|
2674
|
+
this.regexList = [
|
2675
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
2676
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
2677
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
|
2678
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
2679
|
+
{ regex: /^ *#.*/gm, css: 'preprocessor' },
|
2680
|
+
{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' },
|
2681
|
+
{ regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' },
|
2682
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
|
2683
|
+
];
|
2684
|
+
};
|
2685
|
+
|
2686
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2687
|
+
Brush.aliases = ['cpp', 'c'];
|
2688
|
+
|
2689
|
+
SyntaxHighlighter.brushes.Cpp = Brush;
|
2690
|
+
|
2691
|
+
// CommonJS
|
2692
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2693
|
+
})();
|
2694
|
+
;(function()
|
2695
|
+
{
|
2696
|
+
// CommonJS
|
2697
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2698
|
+
|
2699
|
+
function Brush()
|
2700
|
+
{
|
2701
|
+
var keywords = 'abstract as base bool break byte case catch char checked class const ' +
|
2702
|
+
'continue decimal default delegate do double else enum event explicit volatile ' +
|
2703
|
+
'extern false finally fixed float for foreach get goto if implicit in int ' +
|
2704
|
+
'interface internal is lock long namespace new null object operator out ' +
|
2705
|
+
'override params private protected public readonly ref return sbyte sealed set ' +
|
2706
|
+
'short sizeof stackalloc static string struct switch this throw true try ' +
|
2707
|
+
'typeof uint ulong unchecked unsafe ushort using virtual void while var ' +
|
2708
|
+
'from group by into select let where orderby join on equals ascending descending';
|
2709
|
+
|
2710
|
+
function fixComments(match, regexInfo)
|
2711
|
+
{
|
2712
|
+
var css = (match[0].indexOf("///") == 0)
|
2713
|
+
? 'color1'
|
2714
|
+
: 'comments'
|
2715
|
+
;
|
2716
|
+
|
2717
|
+
return [new SyntaxHighlighter.Match(match[0], match.index, css)];
|
2718
|
+
}
|
2719
|
+
|
2720
|
+
this.regexList = [
|
2721
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments
|
2722
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
2723
|
+
{ regex: /@"(?:[^"]|"")*"/g, css: 'string' }, // @-quoted strings
|
2724
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
|
2725
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
2726
|
+
{ regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
|
2727
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // c# keyword
|
2728
|
+
{ regex: /\bpartial(?=\s+(?:class|interface|struct)\b)/g, css: 'keyword' }, // contextual keyword: 'partial'
|
2729
|
+
{ regex: /\byield(?=\s+(?:return|break)\b)/g, css: 'keyword' } // contextual keyword: 'yield'
|
2730
|
+
];
|
2731
|
+
|
2732
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
2733
|
+
};
|
2734
|
+
|
2735
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2736
|
+
Brush.aliases = ['c#', 'c-sharp', 'csharp'];
|
2737
|
+
|
2738
|
+
SyntaxHighlighter.brushes.CSharp = Brush;
|
2739
|
+
|
2740
|
+
// CommonJS
|
2741
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2742
|
+
})();
|
2743
|
+
;(function()
|
2744
|
+
{
|
2745
|
+
// CommonJS
|
2746
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2747
|
+
|
2748
|
+
function Brush()
|
2749
|
+
{
|
2750
|
+
function getKeywordsCSS(str)
|
2751
|
+
{
|
2752
|
+
return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
|
2753
|
+
};
|
2754
|
+
|
2755
|
+
function getValuesCSS(str)
|
2756
|
+
{
|
2757
|
+
return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b';
|
2758
|
+
};
|
2759
|
+
|
2760
|
+
var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' +
|
2761
|
+
'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' +
|
2762
|
+
'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' +
|
2763
|
+
'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' +
|
2764
|
+
'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' +
|
2765
|
+
'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' +
|
2766
|
+
'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' +
|
2767
|
+
'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' +
|
2768
|
+
'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' +
|
2769
|
+
'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' +
|
2770
|
+
'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' +
|
2771
|
+
'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' +
|
2772
|
+
'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' +
|
2773
|
+
'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index';
|
2774
|
+
|
2775
|
+
var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+
|
2776
|
+
'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+
|
2777
|
+
'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double '+
|
2778
|
+
'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+
|
2779
|
+
'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+
|
2780
|
+
'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+
|
2781
|
+
'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+
|
2782
|
+
'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+
|
2783
|
+
'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+
|
2784
|
+
'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+
|
2785
|
+
'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+
|
2786
|
+
'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+
|
2787
|
+
'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+
|
2788
|
+
'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';
|
2789
|
+
|
2790
|
+
var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif';
|
2791
|
+
|
2792
|
+
this.regexList = [
|
2793
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
2794
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
2795
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
2796
|
+
{ regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors
|
2797
|
+
{ regex: /(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)/g, css: 'value' }, // sizes
|
2798
|
+
{ regex: /!important/g, css: 'color3' }, // !important
|
2799
|
+
{ regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords
|
2800
|
+
{ regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values
|
2801
|
+
{ regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts
|
2802
|
+
];
|
2803
|
+
|
2804
|
+
this.forHtmlScript({
|
2805
|
+
left: /(<|<)\s*style.*?(>|>)/gi,
|
2806
|
+
right: /(<|<)\/\s*style\s*(>|>)/gi
|
2807
|
+
});
|
2808
|
+
};
|
2809
|
+
|
2810
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2811
|
+
Brush.aliases = ['css'];
|
2812
|
+
|
2813
|
+
SyntaxHighlighter.brushes.CSS = Brush;
|
2814
|
+
|
2815
|
+
// CommonJS
|
2816
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2817
|
+
})();
|
2818
|
+
;(function()
|
2819
|
+
{
|
2820
|
+
// CommonJS
|
2821
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2822
|
+
|
2823
|
+
function Brush()
|
2824
|
+
{
|
2825
|
+
var keywords = 'abs addr and ansichar ansistring array as asm begin boolean byte cardinal ' +
|
2826
|
+
'case char class comp const constructor currency destructor div do double ' +
|
2827
|
+
'downto else end except exports extended false file finalization finally ' +
|
2828
|
+
'for function goto if implementation in inherited int64 initialization ' +
|
2829
|
+
'integer interface is label library longint longword mod nil not object ' +
|
2830
|
+
'of on or packed pansichar pansistring pchar pcurrency pdatetime pextended ' +
|
2831
|
+
'pint64 pointer private procedure program property pshortstring pstring ' +
|
2832
|
+
'pvariant pwidechar pwidestring protected public published raise real real48 ' +
|
2833
|
+
'record repeat set shl shortint shortstring shr single smallint string then ' +
|
2834
|
+
'threadvar to true try type unit until uses val var varirnt while widechar ' +
|
2835
|
+
'widestring with word write writeln xor';
|
2836
|
+
|
2837
|
+
this.regexList = [
|
2838
|
+
{ regex: /\(\*[\s\S]*?\*\)/gm, css: 'comments' }, // multiline comments (* *)
|
2839
|
+
{ regex: /{(?!\$)[\s\S]*?}/gm, css: 'comments' }, // multiline comments { }
|
2840
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line
|
2841
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
2842
|
+
{ regex: /\{\$[a-zA-Z]+ .+\}/g, css: 'color1' }, // compiler Directives and Region tags
|
2843
|
+
{ regex: /\b[\d\.]+\b/g, css: 'value' }, // numbers 12345
|
2844
|
+
{ regex: /\$[a-zA-Z0-9]+\b/g, css: 'value' }, // numbers $F5D3
|
2845
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
|
2846
|
+
];
|
2847
|
+
};
|
2848
|
+
|
2849
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2850
|
+
Brush.aliases = ['delphi', 'pascal', 'pas'];
|
2851
|
+
|
2852
|
+
SyntaxHighlighter.brushes.Delphi = Brush;
|
2853
|
+
|
2854
|
+
// CommonJS
|
2855
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2856
|
+
})();
|
2857
|
+
;(function()
|
2858
|
+
{
|
2859
|
+
// CommonJS
|
2860
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2861
|
+
|
2862
|
+
function Brush()
|
2863
|
+
{
|
2864
|
+
this.regexList = [
|
2865
|
+
{ regex: /^\+\+\+ .*$/gm, css: 'color2' }, // new file
|
2866
|
+
{ regex: /^\-\-\- .*$/gm, css: 'color2' }, // old file
|
2867
|
+
{ regex: /^\s.*$/gm, css: 'color1' }, // unchanged
|
2868
|
+
{ regex: /^@@.*@@.*$/gm, css: 'variable' }, // location
|
2869
|
+
{ regex: /^\+.*$/gm, css: 'string' }, // additions
|
2870
|
+
{ regex: /^\-.*$/gm, css: 'color3' } // deletions
|
2871
|
+
];
|
2872
|
+
};
|
2873
|
+
|
2874
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2875
|
+
Brush.aliases = ['diff', 'patch'];
|
2876
|
+
|
2877
|
+
SyntaxHighlighter.brushes.Diff = Brush;
|
2878
|
+
|
2879
|
+
// CommonJS
|
2880
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2881
|
+
})();
|
2882
|
+
;(function()
|
2883
|
+
{
|
2884
|
+
// CommonJS
|
2885
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2886
|
+
|
2887
|
+
function Brush()
|
2888
|
+
{
|
2889
|
+
// Contributed by Jean-Lou Dupont
|
2890
|
+
// http://jldupont.blogspot.com/2009/06/erlang-syntax-highlighter.html
|
2891
|
+
|
2892
|
+
// According to: http://erlang.org/doc/reference_manual/introduction.html#1.5
|
2893
|
+
var keywords = 'after and andalso band begin bnot bor bsl bsr bxor '+
|
2894
|
+
'case catch cond div end fun if let not of or orelse '+
|
2895
|
+
'query receive rem try when xor'+
|
2896
|
+
// additional
|
2897
|
+
' module export import define';
|
2898
|
+
|
2899
|
+
this.regexList = [
|
2900
|
+
{ regex: new RegExp("[A-Z][A-Za-z0-9_]+", 'g'), css: 'constants' },
|
2901
|
+
{ regex: new RegExp("\\%.+", 'gm'), css: 'comments' },
|
2902
|
+
{ regex: new RegExp("\\?[A-Za-z0-9_]+", 'g'), css: 'preprocessor' },
|
2903
|
+
{ regex: new RegExp("[a-z0-9_]+:[a-z0-9_]+", 'g'), css: 'functions' },
|
2904
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
|
2905
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
|
2906
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
|
2907
|
+
];
|
2908
|
+
};
|
2909
|
+
|
2910
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2911
|
+
Brush.aliases = ['erl', 'erlang'];
|
2912
|
+
|
2913
|
+
SyntaxHighlighter.brushes.Erland = Brush;
|
2914
|
+
|
2915
|
+
// CommonJS
|
2916
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2917
|
+
})();
|
2918
|
+
;(function()
|
2919
|
+
{
|
2920
|
+
// CommonJS
|
2921
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2922
|
+
|
2923
|
+
function Brush()
|
2924
|
+
{
|
2925
|
+
// Contributed by Andres Almiray
|
2926
|
+
// http://jroller.com/aalmiray/entry/nice_source_code_syntax_highlighter
|
2927
|
+
|
2928
|
+
var keywords = 'as assert break case catch class continue def default do else extends finally ' +
|
2929
|
+
'if in implements import instanceof interface new package property return switch ' +
|
2930
|
+
'throw throws try while public protected private static';
|
2931
|
+
var types = 'void boolean byte char short int long float double';
|
2932
|
+
var constants = 'null';
|
2933
|
+
var methods = 'allProperties count get size '+
|
2934
|
+
'collect each eachProperty eachPropertyName eachWithIndex find findAll ' +
|
2935
|
+
'findIndexOf grep inject max min reverseEach sort ' +
|
2936
|
+
'asImmutable asSynchronized flatten intersect join pop reverse subMap toList ' +
|
2937
|
+
'padRight padLeft contains eachMatch toCharacter toLong toUrl tokenize ' +
|
2938
|
+
'eachFile eachFileRecurse eachB yte eachLine readBytes readLine getText ' +
|
2939
|
+
'splitEachLine withReader append encodeBase64 decodeBase64 filterLine ' +
|
2940
|
+
'transformChar transformLine withOutputStream withPrintWriter withStream ' +
|
2941
|
+
'withStreams withWriter withWriterAppend write writeLine '+
|
2942
|
+
'dump inspect invokeMethod print println step times upto use waitForOrKill '+
|
2943
|
+
'getText';
|
2944
|
+
|
2945
|
+
this.regexList = [
|
2946
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
2947
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
2948
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
|
2949
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
2950
|
+
{ regex: /""".*"""/g, css: 'string' }, // GStrings
|
2951
|
+
{ regex: new RegExp('\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b', 'gi'), css: 'value' }, // numbers
|
2952
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // goovy keyword
|
2953
|
+
{ regex: new RegExp(this.getKeywords(types), 'gm'), css: 'color1' }, // goovy/java type
|
2954
|
+
{ regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants' }, // constants
|
2955
|
+
{ regex: new RegExp(this.getKeywords(methods), 'gm'), css: 'functions' } // methods
|
2956
|
+
];
|
2957
|
+
|
2958
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
2959
|
+
}
|
2960
|
+
|
2961
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
2962
|
+
Brush.aliases = ['groovy'];
|
2963
|
+
|
2964
|
+
SyntaxHighlighter.brushes.Groovy = Brush;
|
2965
|
+
|
2966
|
+
// CommonJS
|
2967
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
2968
|
+
})();
|
2969
|
+
;(function()
|
2970
|
+
{
|
2971
|
+
// CommonJS
|
2972
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
2973
|
+
|
2974
|
+
function Brush()
|
2975
|
+
{
|
2976
|
+
var keywords = 'abstract assert boolean break byte case catch char class const ' +
|
2977
|
+
'continue default do double else enum extends ' +
|
2978
|
+
'false final finally float for goto if implements import ' +
|
2979
|
+
'instanceof int interface long native new null ' +
|
2980
|
+
'package private protected public return ' +
|
2981
|
+
'short static strictfp super switch synchronized this throw throws true ' +
|
2982
|
+
'transient try void volatile while';
|
2983
|
+
|
2984
|
+
this.regexList = [
|
2985
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
2986
|
+
{ regex: /\/\*([^\*][\s\S]*)?\*\//gm, css: 'comments' }, // multiline comments
|
2987
|
+
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' }, // documentation comments
|
2988
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
|
2989
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
2990
|
+
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
|
2991
|
+
{ regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno
|
2992
|
+
{ regex: /\@interface\b/g, css: 'color2' }, // @interface keyword
|
2993
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // java keyword
|
2994
|
+
];
|
2995
|
+
|
2996
|
+
this.forHtmlScript({
|
2997
|
+
left : /(<|<)%[@!=]?/g,
|
2998
|
+
right : /%(>|>)/g
|
2999
|
+
});
|
3000
|
+
};
|
3001
|
+
|
3002
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3003
|
+
Brush.aliases = ['java'];
|
3004
|
+
|
3005
|
+
SyntaxHighlighter.brushes.Java = Brush;
|
3006
|
+
|
3007
|
+
// CommonJS
|
3008
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3009
|
+
})();
|
3010
|
+
;(function()
|
3011
|
+
{
|
3012
|
+
// CommonJS
|
3013
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3014
|
+
|
3015
|
+
function Brush()
|
3016
|
+
{
|
3017
|
+
// Contributed by Patrick Webster
|
3018
|
+
// http://patrickwebster.blogspot.com/2009/04/javafx-brush-for-syntaxhighlighter.html
|
3019
|
+
var datatypes = 'Boolean Byte Character Double Duration '
|
3020
|
+
+ 'Float Integer Long Number Short String Void'
|
3021
|
+
;
|
3022
|
+
|
3023
|
+
var keywords = 'abstract after and as assert at before bind bound break catch class '
|
3024
|
+
+ 'continue def delete else exclusive extends false finally first for from '
|
3025
|
+
+ 'function if import in indexof init insert instanceof into inverse last '
|
3026
|
+
+ 'lazy mixin mod nativearray new not null on or override package postinit '
|
3027
|
+
+ 'protected public public-init public-read replace return reverse sizeof '
|
3028
|
+
+ 'step super then this throw true try tween typeof var where while with '
|
3029
|
+
+ 'attribute let private readonly static trigger'
|
3030
|
+
;
|
3031
|
+
|
3032
|
+
this.regexList = [
|
3033
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' },
|
3034
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' },
|
3035
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
|
3036
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
|
3037
|
+
{ regex: /(-?\.?)(\b(\d*\.?\d+|\d+\.?\d*)(e[+-]?\d+)?|0x[a-f\d]+)\b\.?/gi, css: 'color2' }, // numbers
|
3038
|
+
{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'variable' }, // datatypes
|
3039
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
|
3040
|
+
];
|
3041
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
3042
|
+
};
|
3043
|
+
|
3044
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3045
|
+
Brush.aliases = ['jfx', 'javafx'];
|
3046
|
+
|
3047
|
+
SyntaxHighlighter.brushes.JavaFX = Brush;
|
3048
|
+
|
3049
|
+
// CommonJS
|
3050
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3051
|
+
})();
|
3052
|
+
;(function()
|
3053
|
+
{
|
3054
|
+
// CommonJS
|
3055
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3056
|
+
|
3057
|
+
function Brush()
|
3058
|
+
{
|
3059
|
+
var keywords = 'break case catch continue ' +
|
3060
|
+
'default delete do else false ' +
|
3061
|
+
'for function if in instanceof ' +
|
3062
|
+
'new null return super switch ' +
|
3063
|
+
'this throw true try typeof var while with'
|
3064
|
+
;
|
3065
|
+
|
3066
|
+
var r = SyntaxHighlighter.regexLib;
|
3067
|
+
|
3068
|
+
this.regexList = [
|
3069
|
+
{ regex: r.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings
|
3070
|
+
{ regex: r.multiLineSingleQuotedString, css: 'string' }, // single quoted strings
|
3071
|
+
{ regex: r.singleLineCComments, css: 'comments' }, // one line comments
|
3072
|
+
{ regex: r.multiLineCComments, css: 'comments' }, // multiline comments
|
3073
|
+
{ regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
|
3074
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords
|
3075
|
+
];
|
3076
|
+
|
3077
|
+
this.forHtmlScript(r.scriptScriptTags);
|
3078
|
+
};
|
3079
|
+
|
3080
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3081
|
+
Brush.aliases = ['js', 'jscript', 'javascript'];
|
3082
|
+
|
3083
|
+
SyntaxHighlighter.brushes.JScript = Brush;
|
3084
|
+
|
3085
|
+
// CommonJS
|
3086
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3087
|
+
})();
|
3088
|
+
;(function()
|
3089
|
+
{
|
3090
|
+
// CommonJS
|
3091
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3092
|
+
|
3093
|
+
function Brush()
|
3094
|
+
{
|
3095
|
+
// Contributed by David Simmons-Duffin and Marty Kube
|
3096
|
+
|
3097
|
+
var funcs =
|
3098
|
+
'abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr ' +
|
3099
|
+
'chroot close closedir connect cos crypt defined delete each endgrent ' +
|
3100
|
+
'endhostent endnetent endprotoent endpwent endservent eof exec exists ' +
|
3101
|
+
'exp fcntl fileno flock fork format formline getc getgrent getgrgid ' +
|
3102
|
+
'getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr ' +
|
3103
|
+
'getnetbyname getnetent getpeername getpgrp getppid getpriority ' +
|
3104
|
+
'getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid ' +
|
3105
|
+
'getservbyname getservbyport getservent getsockname getsockopt glob ' +
|
3106
|
+
'gmtime grep hex index int ioctl join keys kill lc lcfirst length link ' +
|
3107
|
+
'listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd ' +
|
3108
|
+
'oct open opendir ord pack pipe pop pos print printf prototype push ' +
|
3109
|
+
'quotemeta rand read readdir readline readlink readpipe recv rename ' +
|
3110
|
+
'reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl ' +
|
3111
|
+
'semget semop send setgrent sethostent setnetent setpgrp setpriority ' +
|
3112
|
+
'setprotoent setpwent setservent setsockopt shift shmctl shmget shmread ' +
|
3113
|
+
'shmwrite shutdown sin sleep socket socketpair sort splice split sprintf ' +
|
3114
|
+
'sqrt srand stat study substr symlink syscall sysopen sysread sysseek ' +
|
3115
|
+
'system syswrite tell telldir time times tr truncate uc ucfirst umask ' +
|
3116
|
+
'undef unlink unpack unshift utime values vec wait waitpid warn write ' +
|
3117
|
+
// feature
|
3118
|
+
'say';
|
3119
|
+
|
3120
|
+
var keywords =
|
3121
|
+
'bless caller continue dbmclose dbmopen die do dump else elsif eval exit ' +
|
3122
|
+
'for foreach goto if import last local my next no our package redo ref ' +
|
3123
|
+
'require return sub tie tied unless untie until use wantarray while ' +
|
3124
|
+
// feature
|
3125
|
+
'given when default ' +
|
3126
|
+
// Try::Tiny
|
3127
|
+
'try catch finally ' +
|
3128
|
+
// Moose
|
3129
|
+
'has extends with before after around override augment';
|
3130
|
+
|
3131
|
+
this.regexList = [
|
3132
|
+
{ regex: /(<<|<<)((\w+)|(['"])(.+?)\4)[\s\S]+?\n\3\5\n/g, css: 'string' }, // here doc (maybe html encoded)
|
3133
|
+
{ regex: /#.*$/gm, css: 'comments' },
|
3134
|
+
{ regex: /^#!.*\n/g, css: 'preprocessor' }, // shebang
|
3135
|
+
{ regex: /-?\w+(?=\s*=(>|>))/g, css: 'string' }, // fat comma
|
3136
|
+
|
3137
|
+
// is this too much?
|
3138
|
+
{ regex: /\bq[qwxr]?\([\s\S]*?\)/g, css: 'string' }, // quote-like operators ()
|
3139
|
+
{ regex: /\bq[qwxr]?\{[\s\S]*?\}/g, css: 'string' }, // quote-like operators {}
|
3140
|
+
{ regex: /\bq[qwxr]?\[[\s\S]*?\]/g, css: 'string' }, // quote-like operators []
|
3141
|
+
{ regex: /\bq[qwxr]?(<|<)[\s\S]*?(>|>)/g, css: 'string' }, // quote-like operators <>
|
3142
|
+
{ regex: /\bq[qwxr]?([^\w({<[])[\s\S]*?\1/g, css: 'string' }, // quote-like operators non-paired
|
3143
|
+
|
3144
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
|
3145
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
|
3146
|
+
// currently ignoring single quote package separator and utf8 names
|
3147
|
+
{ regex: /(?:&|[$@%*]|\$#)[a-zA-Z_](\w+|::)*/g, css: 'variable' },
|
3148
|
+
{ regex: /\b__(?:END|DATA)__\b[\s\S]*$/g, css: 'comments' },
|
3149
|
+
{ regex: /(^|\n)=\w[\s\S]*?(\n=cut\s*\n|$)/g, css: 'comments' }, // pod
|
3150
|
+
{ regex: new RegExp(this.getKeywords(funcs), 'gm'), css: 'functions' },
|
3151
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }
|
3152
|
+
];
|
3153
|
+
|
3154
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags);
|
3155
|
+
}
|
3156
|
+
|
3157
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3158
|
+
Brush.aliases = ['perl', 'Perl', 'pl'];
|
3159
|
+
|
3160
|
+
SyntaxHighlighter.brushes.Perl = Brush;
|
3161
|
+
|
3162
|
+
// CommonJS
|
3163
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3164
|
+
})();
|
3165
|
+
;(function()
|
3166
|
+
{
|
3167
|
+
// CommonJS
|
3168
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3169
|
+
|
3170
|
+
function Brush()
|
3171
|
+
{
|
3172
|
+
var funcs = 'abs acos acosh addcslashes addslashes ' +
|
3173
|
+
'array_change_key_case array_chunk array_combine array_count_values array_diff '+
|
3174
|
+
'array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill '+
|
3175
|
+
'array_filter array_flip array_intersect array_intersect_assoc array_intersect_key '+
|
3176
|
+
'array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map '+
|
3177
|
+
'array_merge array_merge_recursive array_multisort array_pad array_pop array_product '+
|
3178
|
+
'array_push array_rand array_reduce array_reverse array_search array_shift '+
|
3179
|
+
'array_slice array_splice array_sum array_udiff array_udiff_assoc '+
|
3180
|
+
'array_udiff_uassoc array_uintersect array_uintersect_assoc '+
|
3181
|
+
'array_uintersect_uassoc array_unique array_unshift array_values array_walk '+
|
3182
|
+
'array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert '+
|
3183
|
+
'basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress '+
|
3184
|
+
'bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir '+
|
3185
|
+
'checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists '+
|
3186
|
+
'closedir closelog copy cos cosh count count_chars date decbin dechex decoct '+
|
3187
|
+
'deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log '+
|
3188
|
+
'error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded '+
|
3189
|
+
'feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents '+
|
3190
|
+
'fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype '+
|
3191
|
+
'floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf '+
|
3192
|
+
'fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname '+
|
3193
|
+
'gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt '+
|
3194
|
+
'getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext '+
|
3195
|
+
'gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set '+
|
3196
|
+
'interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double '+
|
3197
|
+
'is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long '+
|
3198
|
+
'is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault '+
|
3199
|
+
'is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br '+
|
3200
|
+
'parse_ini_file parse_str parse_url passthru pathinfo print readlink realpath rewind rewinddir rmdir '+
|
3201
|
+
'round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split '+
|
3202
|
+
'str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes '+
|
3203
|
+
'stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk '+
|
3204
|
+
'strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime '+
|
3205
|
+
'strtoupper strtr strval substr substr_compare';
|
3206
|
+
|
3207
|
+
var keywords = 'abstract and array as break case catch cfunction class clone const continue declare default die do ' +
|
3208
|
+
'else elseif enddeclare endfor endforeach endif endswitch endwhile extends final for foreach ' +
|
3209
|
+
'function global goto if implements include include_once interface instanceof insteadof namespace new ' +
|
3210
|
+
'old_function or private protected public return require require_once static switch ' +
|
3211
|
+
'trait throw try use var while xor ';
|
3212
|
+
|
3213
|
+
var constants = '__FILE__ __LINE__ __METHOD__ __FUNCTION__ __CLASS__';
|
3214
|
+
|
3215
|
+
this.regexList = [
|
3216
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
3217
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
3218
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
3219
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
3220
|
+
{ regex: /\$\w+/g, css: 'variable' }, // variables
|
3221
|
+
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }, // common functions
|
3222
|
+
{ regex: new RegExp(this.getKeywords(constants), 'gmi'), css: 'constants' }, // constants
|
3223
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keyword
|
3224
|
+
];
|
3225
|
+
|
3226
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags);
|
3227
|
+
};
|
3228
|
+
|
3229
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3230
|
+
Brush.aliases = ['php'];
|
3231
|
+
|
3232
|
+
SyntaxHighlighter.brushes.Php = Brush;
|
3233
|
+
|
3234
|
+
// CommonJS
|
3235
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3236
|
+
})();
|
3237
|
+
;(function()
|
3238
|
+
{
|
3239
|
+
// CommonJS
|
3240
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3241
|
+
|
3242
|
+
function Brush()
|
3243
|
+
{
|
3244
|
+
};
|
3245
|
+
|
3246
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3247
|
+
Brush.aliases = ['text', 'plain'];
|
3248
|
+
|
3249
|
+
SyntaxHighlighter.brushes.Plain = Brush;
|
3250
|
+
|
3251
|
+
// CommonJS
|
3252
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3253
|
+
})();
|
3254
|
+
;(function()
|
3255
|
+
{
|
3256
|
+
// CommonJS
|
3257
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3258
|
+
|
3259
|
+
function Brush()
|
3260
|
+
{
|
3261
|
+
// Contributed by Joel 'Jaykul' Bennett, http://PoshCode.org | http://HuddledMasses.org
|
3262
|
+
var keywords = 'while validateset validaterange validatepattern validatelength validatecount ' +
|
3263
|
+
'until trap switch return ref process param parameter in if global: '+
|
3264
|
+
'function foreach for finally filter end elseif else dynamicparam do default ' +
|
3265
|
+
'continue cmdletbinding break begin alias \\? % #script #private #local #global '+
|
3266
|
+
'mandatory parametersetname position valuefrompipeline ' +
|
3267
|
+
'valuefrompipelinebypropertyname valuefromremainingarguments helpmessage ';
|
3268
|
+
|
3269
|
+
var operators = ' and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle ' +
|
3270
|
+
'clike clt cmatch cne cnotcontains cnotlike cnotmatch contains ' +
|
3271
|
+
'creplace eq exact f file ge gt icontains ieq ige igt ile ilike ilt ' +
|
3272
|
+
'imatch ine inotcontains inotlike inotmatch ireplace is isnot le like ' +
|
3273
|
+
'lt match ne not notcontains notlike notmatch or regex replace wildcard';
|
3274
|
+
|
3275
|
+
var verbs = 'write where wait use update unregister undo trace test tee take suspend ' +
|
3276
|
+
'stop start split sort skip show set send select scroll resume restore ' +
|
3277
|
+
'restart resolve resize reset rename remove register receive read push ' +
|
3278
|
+
'pop ping out new move measure limit join invoke import group get format ' +
|
3279
|
+
'foreach export expand exit enter enable disconnect disable debug cxnew ' +
|
3280
|
+
'copy convertto convertfrom convert connect complete compare clear ' +
|
3281
|
+
'checkpoint aggregate add';
|
3282
|
+
|
3283
|
+
// I can't find a way to match the comment based help in multi-line comments, because SH won't highlight in highlights, and javascript doesn't support lookbehind
|
3284
|
+
var commenthelp = ' component description example externalhelp forwardhelpcategory forwardhelptargetname forwardhelptargetname functionality inputs link notes outputs parameter remotehelprunspace role synopsis';
|
3285
|
+
|
3286
|
+
this.regexList = [
|
3287
|
+
{ regex: new RegExp('^\\s*#[#\\s]*\\.('+this.getKeywords(commenthelp)+').*$', 'gim'), css: 'preprocessor help bold' }, // comment-based help
|
3288
|
+
{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
|
3289
|
+
{ regex: /(<|<)#[\s\S]*?#(>|>)/gm, css: 'comments here' }, // multi-line comments
|
3290
|
+
|
3291
|
+
{ regex: new RegExp('@"\\n[\\s\\S]*?\\n"@', 'gm'), css: 'script string here' }, // double quoted here-strings
|
3292
|
+
{ regex: new RegExp("@'\\n[\\s\\S]*?\\n'@", 'gm'), css: 'script string single here' }, // single quoted here-strings
|
3293
|
+
{ regex: new RegExp('"(?:\\$\\([^\\)]*\\)|[^"]|`"|"")*[^`]"','g'), css: 'string' }, // double quoted strings
|
3294
|
+
{ regex: new RegExp("'(?:[^']|'')*'", 'g'), css: 'string single' }, // single quoted strings
|
3295
|
+
|
3296
|
+
{ regex: new RegExp('[\\$|@|@@](?:(?:global|script|private|env):)?[A-Z0-9_]+', 'gi'), css: 'variable' }, // $variables
|
3297
|
+
{ regex: new RegExp('(?:\\b'+verbs.replace(/ /g, '\\b|\\b')+')-[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'), css: 'functions' }, // functions and cmdlets
|
3298
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' }, // keywords
|
3299
|
+
{ regex: new RegExp('-'+this.getKeywords(operators), 'gmi'), css: 'operator value' }, // operators
|
3300
|
+
{ regex: new RegExp('\\[[A-Z_\\[][A-Z0-9_. `,\\[\\]]*\\]', 'gi'), css: 'constants' }, // .Net [Type]s
|
3301
|
+
{ regex: new RegExp('\\s+-(?!'+this.getKeywords(operators)+')[a-zA-Z_][a-zA-Z0-9_]*', 'gmi'), css: 'color1' }, // parameters
|
3302
|
+
];
|
3303
|
+
};
|
3304
|
+
|
3305
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3306
|
+
Brush.aliases = ['powershell', 'ps', 'posh'];
|
3307
|
+
|
3308
|
+
SyntaxHighlighter.brushes.PowerShell = Brush;
|
3309
|
+
|
3310
|
+
// CommonJS
|
3311
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3312
|
+
})();
|
3313
|
+
;(function()
|
3314
|
+
{
|
3315
|
+
// CommonJS
|
3316
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3317
|
+
|
3318
|
+
function Brush()
|
3319
|
+
{
|
3320
|
+
// Contributed by Gheorghe Milas and Ahmad Sherif
|
3321
|
+
|
3322
|
+
var keywords = 'and assert break class continue def del elif else ' +
|
3323
|
+
'except exec finally for from global if import in is ' +
|
3324
|
+
'lambda not or pass print raise return try yield while';
|
3325
|
+
|
3326
|
+
var funcs = '__import__ abs all any apply basestring bin bool buffer callable ' +
|
3327
|
+
'chr classmethod cmp coerce compile complex delattr dict dir ' +
|
3328
|
+
'divmod enumerate eval execfile file filter float format frozenset ' +
|
3329
|
+
'getattr globals hasattr hash help hex id input int intern ' +
|
3330
|
+
'isinstance issubclass iter len list locals long map max min next ' +
|
3331
|
+
'object oct open ord pow print property range raw_input reduce ' +
|
3332
|
+
'reload repr reversed round set setattr slice sorted staticmethod ' +
|
3333
|
+
'str sum super tuple type type unichr unicode vars xrange zip';
|
3334
|
+
|
3335
|
+
var special = 'None True False self cls class_';
|
3336
|
+
|
3337
|
+
this.regexList = [
|
3338
|
+
{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' },
|
3339
|
+
{ regex: /^\s*@\w+/gm, css: 'decorator' },
|
3340
|
+
{ regex: /(['\"]{3})([^\1])*?\1/gm, css: 'comments' },
|
3341
|
+
{ regex: /"(?!")(?:\.|\\\"|[^\""\n])*"/gm, css: 'string' },
|
3342
|
+
{ regex: /'(?!')(?:\.|(\\\')|[^\''\n])*'/gm, css: 'string' },
|
3343
|
+
{ regex: /\+|\-|\*|\/|\%|=|==/gm, css: 'keyword' },
|
3344
|
+
{ regex: /\b\d+\.?\w*/g, css: 'value' },
|
3345
|
+
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' },
|
3346
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
|
3347
|
+
{ regex: new RegExp(this.getKeywords(special), 'gm'), css: 'color1' }
|
3348
|
+
];
|
3349
|
+
|
3350
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
3351
|
+
};
|
3352
|
+
|
3353
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3354
|
+
Brush.aliases = ['py', 'python'];
|
3355
|
+
|
3356
|
+
SyntaxHighlighter.brushes.Python = Brush;
|
3357
|
+
|
3358
|
+
// CommonJS
|
3359
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3360
|
+
})();
|
3361
|
+
;(function()
|
3362
|
+
{
|
3363
|
+
// CommonJS
|
3364
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3365
|
+
|
3366
|
+
function Brush()
|
3367
|
+
{
|
3368
|
+
// Contributed by Erik Peterson.
|
3369
|
+
|
3370
|
+
var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' +
|
3371
|
+
'END end ensure false for if in module new next nil not or raise redo rescue retry return ' +
|
3372
|
+
'self super then throw true undef unless until when while yield';
|
3373
|
+
|
3374
|
+
var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' +
|
3375
|
+
'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' +
|
3376
|
+
'ThreadGroup Thread Time TrueClass';
|
3377
|
+
|
3378
|
+
this.regexList = [
|
3379
|
+
{ regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
|
3380
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
|
3381
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
|
3382
|
+
{ regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants
|
3383
|
+
{ regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols
|
3384
|
+
{ regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables
|
3385
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
|
3386
|
+
{ regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins
|
3387
|
+
];
|
3388
|
+
|
3389
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
3390
|
+
};
|
3391
|
+
|
3392
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3393
|
+
Brush.aliases = ['ruby', 'rails', 'ror', 'rb'];
|
3394
|
+
|
3395
|
+
SyntaxHighlighter.brushes.Ruby = Brush;
|
3396
|
+
|
3397
|
+
// CommonJS
|
3398
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3399
|
+
})();
|
3400
|
+
;(function()
|
3401
|
+
{
|
3402
|
+
// CommonJS
|
3403
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3404
|
+
|
3405
|
+
function Brush()
|
3406
|
+
{
|
3407
|
+
function getKeywordsCSS(str)
|
3408
|
+
{
|
3409
|
+
return '\\b([a-z_]|)' + str.replace(/ /g, '(?=:)\\b|\\b([a-z_\\*]|\\*|)') + '(?=:)\\b';
|
3410
|
+
};
|
3411
|
+
|
3412
|
+
function getValuesCSS(str)
|
3413
|
+
{
|
3414
|
+
return '\\b' + str.replace(/ /g, '(?!-)(?!:)\\b|\\b()') + '\:\\b';
|
3415
|
+
};
|
3416
|
+
|
3417
|
+
var keywords = 'ascent azimuth background-attachment background-color background-image background-position ' +
|
3418
|
+
'background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top ' +
|
3419
|
+
'border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color ' +
|
3420
|
+
'border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width ' +
|
3421
|
+
'border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color ' +
|
3422
|
+
'content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display ' +
|
3423
|
+
'elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font ' +
|
3424
|
+
'height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top ' +
|
3425
|
+
'margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans ' +
|
3426
|
+
'outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page ' +
|
3427
|
+
'page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position ' +
|
3428
|
+
'quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress ' +
|
3429
|
+
'table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em ' +
|
3430
|
+
'vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index';
|
3431
|
+
|
3432
|
+
var values = 'above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder '+
|
3433
|
+
'both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed '+
|
3434
|
+
'continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero digits disc dotted double '+
|
3435
|
+
'embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia '+
|
3436
|
+
'gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic '+
|
3437
|
+
'justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha '+
|
3438
|
+
'lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower '+
|
3439
|
+
'navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset '+
|
3440
|
+
'outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side '+
|
3441
|
+
'rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow '+
|
3442
|
+
'small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize '+
|
3443
|
+
'table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal '+
|
3444
|
+
'text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin '+
|
3445
|
+
'upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow';
|
3446
|
+
|
3447
|
+
var fonts = '[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif';
|
3448
|
+
|
3449
|
+
var statements = '!important !default';
|
3450
|
+
var preprocessor = '@import @extend @debug @warn @if @for @while @mixin @include';
|
3451
|
+
|
3452
|
+
var r = SyntaxHighlighter.regexLib;
|
3453
|
+
|
3454
|
+
this.regexList = [
|
3455
|
+
{ regex: r.multiLineCComments, css: 'comments' }, // multiline comments
|
3456
|
+
{ regex: r.singleLineCComments, css: 'comments' }, // singleline comments
|
3457
|
+
{ regex: r.doubleQuotedString, css: 'string' }, // double quoted strings
|
3458
|
+
{ regex: r.singleQuotedString, css: 'string' }, // single quoted strings
|
3459
|
+
{ regex: /\#[a-fA-F0-9]{3,6}/g, css: 'value' }, // html colors
|
3460
|
+
{ regex: /\b(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)\b/g, css: 'value' }, // sizes
|
3461
|
+
{ regex: /\$\w+/g, css: 'variable' }, // variables
|
3462
|
+
{ regex: new RegExp(this.getKeywords(statements), 'g'), css: 'color3' }, // statements
|
3463
|
+
{ regex: new RegExp(this.getKeywords(preprocessor), 'g'), css: 'preprocessor' }, // preprocessor
|
3464
|
+
{ regex: new RegExp(getKeywordsCSS(keywords), 'gm'), css: 'keyword' }, // keywords
|
3465
|
+
{ regex: new RegExp(getValuesCSS(values), 'g'), css: 'value' }, // values
|
3466
|
+
{ regex: new RegExp(this.getKeywords(fonts), 'g'), css: 'color1' } // fonts
|
3467
|
+
];
|
3468
|
+
};
|
3469
|
+
|
3470
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3471
|
+
Brush.aliases = ['sass', 'scss'];
|
3472
|
+
|
3473
|
+
SyntaxHighlighter.brushes.Sass = Brush;
|
3474
|
+
|
3475
|
+
// CommonJS
|
3476
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3477
|
+
})();
|
3478
|
+
;(function()
|
3479
|
+
{
|
3480
|
+
// CommonJS
|
3481
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3482
|
+
|
3483
|
+
function Brush()
|
3484
|
+
{
|
3485
|
+
// Contributed by Yegor Jbanov and David Bernard.
|
3486
|
+
|
3487
|
+
var keywords = 'val sealed case def true trait implicit forSome import match object null finally super ' +
|
3488
|
+
'override try lazy for var catch throw type extends class while with new final yield abstract ' +
|
3489
|
+
'else do if return protected private this package false';
|
3490
|
+
|
3491
|
+
var keyops = '[_:=><%#@]+';
|
3492
|
+
|
3493
|
+
this.regexList = [
|
3494
|
+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
|
3495
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
|
3496
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // multi-line strings
|
3497
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double-quoted string
|
3498
|
+
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
|
3499
|
+
{ regex: /0x[a-f0-9]+|\d+(\.\d+)?/gi, css: 'value' }, // numbers
|
3500
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
|
3501
|
+
{ regex: new RegExp(keyops, 'gm'), css: 'keyword' } // scala keyword
|
3502
|
+
];
|
3503
|
+
}
|
3504
|
+
|
3505
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3506
|
+
Brush.aliases = ['scala'];
|
3507
|
+
|
3508
|
+
SyntaxHighlighter.brushes.Scala = Brush;
|
3509
|
+
|
3510
|
+
// CommonJS
|
3511
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3512
|
+
})();
|
3513
|
+
;(function()
|
3514
|
+
{
|
3515
|
+
// CommonJS
|
3516
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3517
|
+
|
3518
|
+
function Brush()
|
3519
|
+
{
|
3520
|
+
var funcs = 'abs avg case cast coalesce convert count current_timestamp ' +
|
3521
|
+
'current_user day isnull left lower month nullif replace right ' +
|
3522
|
+
'session_user space substring sum system_user upper user year';
|
3523
|
+
|
3524
|
+
var keywords = 'absolute action add after alter as asc at authorization begin bigint ' +
|
3525
|
+
'binary bit by cascade char character check checkpoint close collate ' +
|
3526
|
+
'column commit committed connect connection constraint contains continue ' +
|
3527
|
+
'create cube current current_date current_time cursor database date ' +
|
3528
|
+
'deallocate dec decimal declare default delete desc distinct double drop ' +
|
3529
|
+
'dynamic else end end-exec escape except exec execute false fetch first ' +
|
3530
|
+
'float for force foreign forward free from full function global goto grant ' +
|
3531
|
+
'group grouping having hour ignore index inner insensitive insert instead ' +
|
3532
|
+
'int integer intersect into is isolation key last level load local max min ' +
|
3533
|
+
'minute modify move name national nchar next no numeric of off on only ' +
|
3534
|
+
'open option order out output partial password precision prepare primary ' +
|
3535
|
+
'prior privileges procedure public read real references relative repeatable ' +
|
3536
|
+
'restrict return returns revoke rollback rollup rows rule schema scroll ' +
|
3537
|
+
'second section select sequence serializable set size smallint static ' +
|
3538
|
+
'statistics table temp temporary then time timestamp to top transaction ' +
|
3539
|
+
'translation trigger true truncate uncommitted union unique update values ' +
|
3540
|
+
'varchar varying view when where with work';
|
3541
|
+
|
3542
|
+
var operators = 'all and any between cross in join like not null or outer some';
|
3543
|
+
|
3544
|
+
this.regexList = [
|
3545
|
+
{ regex: /--(.*)$/gm, css: 'comments' }, // one line and multiline comments
|
3546
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings
|
3547
|
+
{ regex: SyntaxHighlighter.regexLib.multiLineSingleQuotedString, css: 'string' }, // single quoted strings
|
3548
|
+
{ regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'color2' }, // functions
|
3549
|
+
{ regex: new RegExp(this.getKeywords(operators), 'gmi'), css: 'color1' }, // operators and such
|
3550
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gmi'), css: 'keyword' } // keyword
|
3551
|
+
];
|
3552
|
+
};
|
3553
|
+
|
3554
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3555
|
+
Brush.aliases = ['sql'];
|
3556
|
+
|
3557
|
+
SyntaxHighlighter.brushes.Sql = Brush;
|
3558
|
+
|
3559
|
+
// CommonJS
|
3560
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3561
|
+
})();
|
3562
|
+
|
3563
|
+
;(function()
|
3564
|
+
{
|
3565
|
+
// CommonJS
|
3566
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3567
|
+
|
3568
|
+
function Brush()
|
3569
|
+
{
|
3570
|
+
var keywords = 'AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto ' +
|
3571
|
+
'Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate ' +
|
3572
|
+
'CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType ' +
|
3573
|
+
'Date Decimal Declare Default Delegate Dim DirectCast Do Double Each ' +
|
3574
|
+
'Else ElseIf End Enum Erase Error Event Exit False Finally For Friend ' +
|
3575
|
+
'Function Get GetType GoSub GoTo Handles If Implements Imports In ' +
|
3576
|
+
'Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module ' +
|
3577
|
+
'MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing ' +
|
3578
|
+
'NotInheritable NotOverridable Object On Option Optional Or OrElse ' +
|
3579
|
+
'Overloads Overridable Overrides ParamArray Preserve Private Property ' +
|
3580
|
+
'Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume ' +
|
3581
|
+
'Return Select Set Shadows Shared Short Single Static Step Stop String ' +
|
3582
|
+
'Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until ' +
|
3583
|
+
'Variant When While With WithEvents WriteOnly Xor';
|
3584
|
+
|
3585
|
+
this.regexList = [
|
3586
|
+
{ regex: /'.*$/gm, css: 'comments' }, // one line comments
|
3587
|
+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
|
3588
|
+
{ regex: /^\s*#.*$/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
|
3589
|
+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // vb keyword
|
3590
|
+
];
|
3591
|
+
|
3592
|
+
this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
|
3593
|
+
};
|
3594
|
+
|
3595
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3596
|
+
Brush.aliases = ['vb', 'vbnet'];
|
3597
|
+
|
3598
|
+
SyntaxHighlighter.brushes.Vb = Brush;
|
3599
|
+
|
3600
|
+
// CommonJS
|
3601
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3602
|
+
})();
|
3603
|
+
;(function()
|
3604
|
+
{
|
3605
|
+
// CommonJS
|
3606
|
+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
|
3607
|
+
|
3608
|
+
function Brush()
|
3609
|
+
{
|
3610
|
+
function process(match, regexInfo)
|
3611
|
+
{
|
3612
|
+
var constructor = SyntaxHighlighter.Match,
|
3613
|
+
code = match[0],
|
3614
|
+
tag = new XRegExp('(<|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
|
3615
|
+
result = []
|
3616
|
+
;
|
3617
|
+
|
3618
|
+
if (match.attributes != null)
|
3619
|
+
{
|
3620
|
+
var attributes,
|
3621
|
+
regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
|
3622
|
+
'\\s*=\\s*' +
|
3623
|
+
'(?<value> ".*?"|\'.*?\'|\\w+)',
|
3624
|
+
'xg');
|
3625
|
+
|
3626
|
+
while ((attributes = regex.exec(code)) != null)
|
3627
|
+
{
|
3628
|
+
result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
|
3629
|
+
result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
|
3630
|
+
}
|
3631
|
+
}
|
3632
|
+
|
3633
|
+
if (tag != null)
|
3634
|
+
result.push(
|
3635
|
+
new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
|
3636
|
+
);
|
3637
|
+
|
3638
|
+
return result;
|
3639
|
+
}
|
3640
|
+
|
3641
|
+
this.regexList = [
|
3642
|
+
{ regex: new XRegExp('(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)', 'gm'), css: 'color2' }, // <![ ... [ ... ]]>
|
3643
|
+
{ regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // <!-- ... -->
|
3644
|
+
{ regex: new XRegExp('(<|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(>|>)', 'sg'), func: process }
|
3645
|
+
];
|
3646
|
+
};
|
3647
|
+
|
3648
|
+
Brush.prototype = new SyntaxHighlighter.Highlighter();
|
3649
|
+
Brush.aliases = ['xml', 'xhtml', 'xslt', 'html'];
|
3650
|
+
|
3651
|
+
SyntaxHighlighter.brushes.Xml = Brush;
|
3652
|
+
|
3653
|
+
// CommonJS
|
3654
|
+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
|
3655
|
+
})();
|