highlightjs-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +4 -0
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +57 -0
  8. data/Rakefile +10 -0
  9. data/VERSION.md +5 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/highlightjs-rails.gemspec +25 -0
  13. data/lib/highlightjs-rails.rb +7 -0
  14. data/lib/highlightjs-rails/version.rb +5 -0
  15. data/vendor/assets/images/brown-papersq.png +0 -0
  16. data/vendor/assets/images/pojoaque.jpg +0 -0
  17. data/vendor/assets/images/school-book.png +0 -0
  18. data/vendor/assets/javascripts/highlight.js +3006 -0
  19. data/vendor/assets/stylesheets/styles/agate.css +108 -0
  20. data/vendor/assets/stylesheets/styles/androidstudio.css +66 -0
  21. data/vendor/assets/stylesheets/styles/arta.css +73 -0
  22. data/vendor/assets/stylesheets/styles/ascetic.css +45 -0
  23. data/vendor/assets/stylesheets/styles/atelier-cave-dark.css +83 -0
  24. data/vendor/assets/stylesheets/styles/atelier-cave-light.css +85 -0
  25. data/vendor/assets/stylesheets/styles/atelier-dune-dark.css +69 -0
  26. data/vendor/assets/stylesheets/styles/atelier-dune-light.css +69 -0
  27. data/vendor/assets/stylesheets/styles/atelier-estuary-dark.css +84 -0
  28. data/vendor/assets/stylesheets/styles/atelier-estuary-light.css +84 -0
  29. data/vendor/assets/stylesheets/styles/atelier-forest-dark.css +69 -0
  30. data/vendor/assets/stylesheets/styles/atelier-forest-light.css +69 -0
  31. data/vendor/assets/stylesheets/styles/atelier-heath-dark.css +69 -0
  32. data/vendor/assets/stylesheets/styles/atelier-heath-light.css +69 -0
  33. data/vendor/assets/stylesheets/styles/atelier-lakeside-dark.css +69 -0
  34. data/vendor/assets/stylesheets/styles/atelier-lakeside-light.css +69 -0
  35. data/vendor/assets/stylesheets/styles/atelier-plateau-dark.css +84 -0
  36. data/vendor/assets/stylesheets/styles/atelier-plateau-light.css +84 -0
  37. data/vendor/assets/stylesheets/styles/atelier-savanna-dark.css +84 -0
  38. data/vendor/assets/stylesheets/styles/atelier-savanna-light.css +84 -0
  39. data/vendor/assets/stylesheets/styles/atelier-seaside-dark.css +69 -0
  40. data/vendor/assets/stylesheets/styles/atelier-seaside-light.css +69 -0
  41. data/vendor/assets/stylesheets/styles/atelier-sulphurpool-dark.css +69 -0
  42. data/vendor/assets/stylesheets/styles/atelier-sulphurpool-light.css +69 -0
  43. data/vendor/assets/stylesheets/styles/brown-paper.css +64 -0
  44. data/vendor/assets/stylesheets/styles/codepen-embed.css +60 -0
  45. data/vendor/assets/stylesheets/styles/color-brewer.css +71 -0
  46. data/vendor/assets/stylesheets/styles/dark.css +63 -0
  47. data/vendor/assets/stylesheets/styles/darkula.css +74 -0
  48. data/vendor/assets/stylesheets/styles/default.css +77 -0
  49. data/vendor/assets/stylesheets/styles/docco.css +97 -0
  50. data/vendor/assets/stylesheets/styles/far.css +71 -0
  51. data/vendor/assets/stylesheets/styles/foundation.css +88 -0
  52. data/vendor/assets/stylesheets/styles/github-gist.css +71 -0
  53. data/vendor/assets/stylesheets/styles/github.css +99 -0
  54. data/vendor/assets/stylesheets/styles/googlecode.css +89 -0
  55. data/vendor/assets/stylesheets/styles/grayscale.css +101 -0
  56. data/vendor/assets/stylesheets/styles/hopscotch.css +83 -0
  57. data/vendor/assets/stylesheets/styles/hybrid.css +102 -0
  58. data/vendor/assets/stylesheets/styles/idea.css +97 -0
  59. data/vendor/assets/stylesheets/styles/ir-black.css +73 -0
  60. data/vendor/assets/stylesheets/styles/kimbie.dark.css +74 -0
  61. data/vendor/assets/stylesheets/styles/kimbie.light.css +74 -0
  62. data/vendor/assets/stylesheets/styles/magula.css +70 -0
  63. data/vendor/assets/stylesheets/styles/mono-blue.css +59 -0
  64. data/vendor/assets/stylesheets/styles/monokai-sublime.css +83 -0
  65. data/vendor/assets/stylesheets/styles/monokai.css +70 -0
  66. data/vendor/assets/stylesheets/styles/obsidian.css +88 -0
  67. data/vendor/assets/stylesheets/styles/paraiso-dark.css +72 -0
  68. data/vendor/assets/stylesheets/styles/paraiso-light.css +72 -0
  69. data/vendor/assets/stylesheets/styles/pojoaque.css +83 -0
  70. data/vendor/assets/stylesheets/styles/railscasts.css +106 -0
  71. data/vendor/assets/stylesheets/styles/rainbow.css +85 -0
  72. data/vendor/assets/stylesheets/styles/school-book.css +72 -0
  73. data/vendor/assets/stylesheets/styles/solarized-dark.css +84 -0
  74. data/vendor/assets/stylesheets/styles/solarized-light.css +84 -0
  75. data/vendor/assets/stylesheets/styles/sunburst.css +102 -0
  76. data/vendor/assets/stylesheets/styles/tomorrow-night-blue.css +75 -0
  77. data/vendor/assets/stylesheets/styles/tomorrow-night-bright.css +74 -0
  78. data/vendor/assets/stylesheets/styles/tomorrow-night-eighties.css +74 -0
  79. data/vendor/assets/stylesheets/styles/tomorrow-night.css +75 -0
  80. data/vendor/assets/stylesheets/styles/tomorrow.css +72 -0
  81. data/vendor/assets/stylesheets/styles/vs.css +68 -0
  82. data/vendor/assets/stylesheets/styles/xcode.css +93 -0
  83. data/vendor/assets/stylesheets/styles/zenburn.css +80 -0
  84. metadata +170 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 289cabc0426a5446beaf12ba9cbca7b7a9642f35
4
+ data.tar.gz: ae6d7cec251b1ccc54550ae75198feac0e369f3d
5
+ SHA512:
6
+ metadata.gz: 3d0c985e5311c85ea1a3e63b7528c0ed7bb7960208a257b19161d95e03b3a63bd5a5d1f43a2a6f38ea2fe4fb67b00f5f520186dac1f99cbebc4be487fb99fa94
7
+ data.tar.gz: bbc64f2ad7777d9a6a6ab4d39dbf0a5564ff811dfa954aec8d23fb9a0d7c4476e52386d2516897f21a842eb7c61777fe3bf6513da1e9b84dde4947a69dbd7c0c
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at rezajatnika@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in highlightjs-rails.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Reza Jatnika
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ [![Build Status](https://travis-ci.org/rezajatnika/highlightjs-rails.svg)](https://travis-ci.org/rezajatnika/highlightjs-rails)
2
+ # highlightjs-rails
3
+
4
+ A gemified version of the awesome [highlight.js](https://highlightjs.org) library.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'highlightjs-rails'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install highlightjs-rails
21
+
22
+ ## Usage
23
+
24
+ The highlight.js files will be added to the asset pipeline and available for you to use. Add these lines to application.js:
25
+
26
+ ```js
27
+ //= require highlight
28
+ ```
29
+
30
+ and to application.css:
31
+
32
+ ```css
33
+ *= require styles/github
34
+ ```
35
+
36
+ The bare minimum for using highlight.js on a web page is linking to the library along with one of the styles and calling `initHighlightingOnLoad`:
37
+
38
+ ```js
39
+ hljs.initHighlightingOnLoad();
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rezajatnika/highlightjs-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+
46
+ A couple of notes:
47
+
48
+ * If it's an issue pertaining to the highlight.js javascript, please report it to the [highlight.js project](https://github.com/isagalaev/highlight.js).
49
+ * If the highlight.js scripts are outdated, feel free to open an issue and prod us to get that thing updated.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
+
55
+ ## Acknowledgements
56
+
57
+ This README is heavily inspired by the one for [jquery-rails](https://github.com/rails/jquery-rails).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,5 @@
1
+ # Bundled Versions
2
+
3
+ | Gem | Highlight.js |
4
+ |-------|--------------|
5
+ | 0.0.1 | 9.0.0 |
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "highlightjs/rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'highlightjs-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "highlightjs-rails"
8
+ spec.version = Highlightjs::Rails::VERSION
9
+ spec.authors = ["Reza Jatnika"]
10
+ spec.email = ["rezajatnika@gmail.com"]
11
+
12
+ spec.summary = %q{A gemified version of the isagalaev/highlight.js}
13
+ spec.description = %q{A gemified version of the isagalaev/highlight.js: "Highlight.js is a syntax highlighter written in JavaScript."}
14
+ spec.homepage = "https://github.com/rezajatnika/highlightjs-rails"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+ end
@@ -0,0 +1,7 @@
1
+ require "highlightjs-rails/version"
2
+
3
+ module Highlightjs
4
+ module Rails
5
+ class Engine < ::Rails::Engine; end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Highlightjs
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,3006 @@
1
+ /*! highlight.js v9.0.0 | BSD3 License | git.io/hljslicense */
2
+ (function(factory) {
3
+
4
+ // Setup highlight.js for different environments. First is Node.js or
5
+ // CommonJS.
6
+ if(typeof exports !== 'undefined') {
7
+ factory(exports);
8
+ } else {
9
+ // Export hljs globally even when using AMD for cases when this script
10
+ // is loaded with others that may still expect a global hljs.
11
+ self.hljs = factory({});
12
+
13
+ // Finally register the global hljs with AMD.
14
+ if(typeof define === 'function' && define.amd) {
15
+ define('hljs', [], function() {
16
+ return self.hljs;
17
+ });
18
+ }
19
+ }
20
+
21
+ }(function(hljs) {
22
+
23
+ /* Utility functions */
24
+
25
+ function escape(value) {
26
+ return value.replace(/&/gm, '&amp;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;');
27
+ }
28
+
29
+ function tag(node) {
30
+ return node.nodeName.toLowerCase();
31
+ }
32
+
33
+ function testRe(re, lexeme) {
34
+ var match = re && re.exec(lexeme);
35
+ return match && match.index == 0;
36
+ }
37
+
38
+ function isNotHighlighted(language) {
39
+ return (/^(no-?highlight|plain|text)$/i).test(language);
40
+ }
41
+
42
+ function blockLanguage(block) {
43
+ var i, match, length,
44
+ classes = block.className + ' ';
45
+
46
+ classes += block.parentNode ? block.parentNode.className : '';
47
+
48
+ // language-* takes precedence over non-prefixed class names
49
+ match = (/\blang(?:uage)?-([\w-]+)\b/i).exec(classes);
50
+ if (match) {
51
+ return getLanguage(match[1]) ? match[1] : 'no-highlight';
52
+ }
53
+
54
+ classes = classes.split(/\s+/);
55
+ for (i = 0, length = classes.length; i < length; i++) {
56
+ if (getLanguage(classes[i]) || isNotHighlighted(classes[i])) {
57
+ return classes[i];
58
+ }
59
+ }
60
+ }
61
+
62
+ function inherit(parent, obj) {
63
+ var result = {}, key;
64
+ for (key in parent)
65
+ result[key] = parent[key];
66
+ if (obj)
67
+ for (key in obj)
68
+ result[key] = obj[key];
69
+ return result;
70
+ }
71
+
72
+ /* Stream merging */
73
+
74
+ function nodeStream(node) {
75
+ var result = [];
76
+ (function _nodeStream(node, offset) {
77
+ for (var child = node.firstChild; child; child = child.nextSibling) {
78
+ if (child.nodeType == 3)
79
+ offset += child.nodeValue.length;
80
+ else if (child.nodeType == 1) {
81
+ result.push({
82
+ event: 'start',
83
+ offset: offset,
84
+ node: child
85
+ });
86
+ offset = _nodeStream(child, offset);
87
+ // Prevent void elements from having an end tag that would actually
88
+ // double them in the output. There are more void elements in HTML
89
+ // but we list only those realistically expected in code display.
90
+ if (!tag(child).match(/br|hr|img|input/)) {
91
+ result.push({
92
+ event: 'stop',
93
+ offset: offset,
94
+ node: child
95
+ });
96
+ }
97
+ }
98
+ }
99
+ return offset;
100
+ })(node, 0);
101
+ return result;
102
+ }
103
+
104
+ function mergeStreams(original, highlighted, value) {
105
+ var processed = 0;
106
+ var result = '';
107
+ var nodeStack = [];
108
+
109
+ function selectStream() {
110
+ if (!original.length || !highlighted.length) {
111
+ return original.length ? original : highlighted;
112
+ }
113
+ if (original[0].offset != highlighted[0].offset) {
114
+ return (original[0].offset < highlighted[0].offset) ? original : highlighted;
115
+ }
116
+
117
+ /*
118
+ To avoid starting the stream just before it should stop the order is
119
+ ensured that original always starts first and closes last:
120
+
121
+ if (event1 == 'start' && event2 == 'start')
122
+ return original;
123
+ if (event1 == 'start' && event2 == 'stop')
124
+ return highlighted;
125
+ if (event1 == 'stop' && event2 == 'start')
126
+ return original;
127
+ if (event1 == 'stop' && event2 == 'stop')
128
+ return highlighted;
129
+
130
+ ... which is collapsed to:
131
+ */
132
+ return highlighted[0].event == 'start' ? original : highlighted;
133
+ }
134
+
135
+ function open(node) {
136
+ function attr_str(a) {return ' ' + a.nodeName + '="' + escape(a.value) + '"';}
137
+ result += '<' + tag(node) + Array.prototype.map.call(node.attributes, attr_str).join('') + '>';
138
+ }
139
+
140
+ function close(node) {
141
+ result += '</' + tag(node) + '>';
142
+ }
143
+
144
+ function render(event) {
145
+ (event.event == 'start' ? open : close)(event.node);
146
+ }
147
+
148
+ while (original.length || highlighted.length) {
149
+ var stream = selectStream();
150
+ result += escape(value.substr(processed, stream[0].offset - processed));
151
+ processed = stream[0].offset;
152
+ if (stream == original) {
153
+ /*
154
+ On any opening or closing tag of the original markup we first close
155
+ the entire highlighted node stack, then render the original tag along
156
+ with all the following original tags at the same offset and then
157
+ reopen all the tags on the highlighted stack.
158
+ */
159
+ nodeStack.reverse().forEach(close);
160
+ do {
161
+ render(stream.splice(0, 1)[0]);
162
+ stream = selectStream();
163
+ } while (stream == original && stream.length && stream[0].offset == processed);
164
+ nodeStack.reverse().forEach(open);
165
+ } else {
166
+ if (stream[0].event == 'start') {
167
+ nodeStack.push(stream[0].node);
168
+ } else {
169
+ nodeStack.pop();
170
+ }
171
+ render(stream.splice(0, 1)[0]);
172
+ }
173
+ }
174
+ return result + escape(value.substr(processed));
175
+ }
176
+
177
+ /* Initialization */
178
+
179
+ function compileLanguage(language) {
180
+
181
+ function reStr(re) {
182
+ return (re && re.source) || re;
183
+ }
184
+
185
+ function langRe(value, global) {
186
+ return new RegExp(
187
+ reStr(value),
188
+ 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '')
189
+ );
190
+ }
191
+
192
+ function compileMode(mode, parent) {
193
+ if (mode.compiled)
194
+ return;
195
+ mode.compiled = true;
196
+
197
+ mode.keywords = mode.keywords || mode.beginKeywords;
198
+ if (mode.keywords) {
199
+ var compiled_keywords = {};
200
+
201
+ var flatten = function(className, str) {
202
+ if (language.case_insensitive) {
203
+ str = str.toLowerCase();
204
+ }
205
+ str.split(' ').forEach(function(kw) {
206
+ var pair = kw.split('|');
207
+ compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1];
208
+ });
209
+ };
210
+
211
+ if (typeof mode.keywords == 'string') { // string
212
+ flatten('keyword', mode.keywords);
213
+ } else {
214
+ Object.keys(mode.keywords).forEach(function (className) {
215
+ flatten(className, mode.keywords[className]);
216
+ });
217
+ }
218
+ mode.keywords = compiled_keywords;
219
+ }
220
+ mode.lexemesRe = langRe(mode.lexemes || /\b\w+\b/, true);
221
+
222
+ if (parent) {
223
+ if (mode.beginKeywords) {
224
+ mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b';
225
+ }
226
+ if (!mode.begin)
227
+ mode.begin = /\B|\b/;
228
+ mode.beginRe = langRe(mode.begin);
229
+ if (!mode.end && !mode.endsWithParent)
230
+ mode.end = /\B|\b/;
231
+ if (mode.end)
232
+ mode.endRe = langRe(mode.end);
233
+ mode.terminator_end = reStr(mode.end) || '';
234
+ if (mode.endsWithParent && parent.terminator_end)
235
+ mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end;
236
+ }
237
+ if (mode.illegal)
238
+ mode.illegalRe = langRe(mode.illegal);
239
+ if (mode.relevance === undefined)
240
+ mode.relevance = 1;
241
+ if (!mode.contains) {
242
+ mode.contains = [];
243
+ }
244
+ var expanded_contains = [];
245
+ mode.contains.forEach(function(c) {
246
+ if (c.variants) {
247
+ c.variants.forEach(function(v) {expanded_contains.push(inherit(c, v));});
248
+ } else {
249
+ expanded_contains.push(c == 'self' ? mode : c);
250
+ }
251
+ });
252
+ mode.contains = expanded_contains;
253
+ mode.contains.forEach(function(c) {compileMode(c, mode);});
254
+
255
+ if (mode.starts) {
256
+ compileMode(mode.starts, parent);
257
+ }
258
+
259
+ var terminators =
260
+ mode.contains.map(function(c) {
261
+ return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin;
262
+ })
263
+ .concat([mode.terminator_end, mode.illegal])
264
+ .map(reStr)
265
+ .filter(Boolean);
266
+ mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : {exec: function(/*s*/) {return null;}};
267
+ }
268
+
269
+ compileMode(language);
270
+ }
271
+
272
+ /*
273
+ Core highlighting function. Accepts a language name, or an alias, and a
274
+ string with the code to highlight. Returns an object with the following
275
+ properties:
276
+
277
+ - relevance (int)
278
+ - value (an HTML string with highlighting markup)
279
+
280
+ */
281
+ function highlight(name, value, ignore_illegals, continuation) {
282
+
283
+ function subMode(lexeme, mode) {
284
+ for (var i = 0; i < mode.contains.length; i++) {
285
+ if (testRe(mode.contains[i].beginRe, lexeme)) {
286
+ return mode.contains[i];
287
+ }
288
+ }
289
+ }
290
+
291
+ function endOfMode(mode, lexeme) {
292
+ if (testRe(mode.endRe, lexeme)) {
293
+ while (mode.endsParent && mode.parent) {
294
+ mode = mode.parent;
295
+ }
296
+ return mode;
297
+ }
298
+ if (mode.endsWithParent) {
299
+ return endOfMode(mode.parent, lexeme);
300
+ }
301
+ }
302
+
303
+ function isIllegal(lexeme, mode) {
304
+ return !ignore_illegals && testRe(mode.illegalRe, lexeme);
305
+ }
306
+
307
+ function keywordMatch(mode, match) {
308
+ var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
309
+ return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str];
310
+ }
311
+
312
+ function buildSpan(classname, insideSpan, leaveOpen, noPrefix) {
313
+ var classPrefix = noPrefix ? '' : options.classPrefix,
314
+ openSpan = '<span class="' + classPrefix,
315
+ closeSpan = leaveOpen ? '' : '</span>';
316
+
317
+ openSpan += classname + '">';
318
+
319
+ return openSpan + insideSpan + closeSpan;
320
+ }
321
+
322
+ function processKeywords() {
323
+ if (!top.keywords)
324
+ return escape(mode_buffer);
325
+ var result = '';
326
+ var last_index = 0;
327
+ top.lexemesRe.lastIndex = 0;
328
+ var match = top.lexemesRe.exec(mode_buffer);
329
+ while (match) {
330
+ result += escape(mode_buffer.substr(last_index, match.index - last_index));
331
+ var keyword_match = keywordMatch(top, match);
332
+ if (keyword_match) {
333
+ relevance += keyword_match[1];
334
+ result += buildSpan(keyword_match[0], escape(match[0]));
335
+ } else {
336
+ result += escape(match[0]);
337
+ }
338
+ last_index = top.lexemesRe.lastIndex;
339
+ match = top.lexemesRe.exec(mode_buffer);
340
+ }
341
+ return result + escape(mode_buffer.substr(last_index));
342
+ }
343
+
344
+ function processSubLanguage() {
345
+ var explicit = typeof top.subLanguage == 'string';
346
+ if (explicit && !languages[top.subLanguage]) {
347
+ return escape(mode_buffer);
348
+ }
349
+
350
+ var result = explicit ?
351
+ highlight(top.subLanguage, mode_buffer, true, continuations[top.subLanguage]) :
352
+ highlightAuto(mode_buffer, top.subLanguage.length ? top.subLanguage : undefined);
353
+
354
+ // Counting embedded language score towards the host language may be disabled
355
+ // with zeroing the containing mode relevance. Usecase in point is Markdown that
356
+ // allows XML everywhere and makes every XML snippet to have a much larger Markdown
357
+ // score.
358
+ if (top.relevance > 0) {
359
+ relevance += result.relevance;
360
+ }
361
+ if (explicit) {
362
+ continuations[top.subLanguage] = result.top;
363
+ }
364
+ return buildSpan(result.language, result.value, false, true);
365
+ }
366
+
367
+ function processBuffer() {
368
+ return top.subLanguage !== undefined ? processSubLanguage() : processKeywords();
369
+ }
370
+
371
+ function startNewMode(mode, lexeme) {
372
+ var markup = mode.className? buildSpan(mode.className, '', true): '';
373
+ if (mode.returnBegin) {
374
+ result += markup;
375
+ mode_buffer = '';
376
+ } else if (mode.excludeBegin) {
377
+ result += escape(lexeme) + markup;
378
+ mode_buffer = '';
379
+ } else {
380
+ result += markup;
381
+ mode_buffer = lexeme;
382
+ }
383
+ top = Object.create(mode, {parent: {value: top}});
384
+ }
385
+
386
+ function processLexeme(buffer, lexeme) {
387
+
388
+ mode_buffer += buffer;
389
+ if (lexeme === undefined) {
390
+ result += processBuffer();
391
+ return 0;
392
+ }
393
+
394
+ var new_mode = subMode(lexeme, top);
395
+ if (new_mode) {
396
+ result += processBuffer();
397
+ startNewMode(new_mode, lexeme);
398
+ return new_mode.returnBegin ? 0 : lexeme.length;
399
+ }
400
+
401
+ var end_mode = endOfMode(top, lexeme);
402
+ if (end_mode) {
403
+ var origin = top;
404
+ if (!(origin.returnEnd || origin.excludeEnd)) {
405
+ mode_buffer += lexeme;
406
+ }
407
+ result += processBuffer();
408
+ do {
409
+ if (top.className) {
410
+ result += '</span>';
411
+ }
412
+ relevance += top.relevance;
413
+ top = top.parent;
414
+ } while (top != end_mode.parent);
415
+ if (origin.excludeEnd) {
416
+ result += escape(lexeme);
417
+ }
418
+ mode_buffer = '';
419
+ if (end_mode.starts) {
420
+ startNewMode(end_mode.starts, '');
421
+ }
422
+ return origin.returnEnd ? 0 : lexeme.length;
423
+ }
424
+
425
+ if (isIllegal(lexeme, top))
426
+ throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '<unnamed>') + '"');
427
+
428
+ /*
429
+ Parser should not reach this point as all types of lexemes should be caught
430
+ earlier, but if it does due to some bug make sure it advances at least one
431
+ character forward to prevent infinite looping.
432
+ */
433
+ mode_buffer += lexeme;
434
+ return lexeme.length || 1;
435
+ }
436
+
437
+ var language = getLanguage(name);
438
+ if (!language) {
439
+ throw new Error('Unknown language: "' + name + '"');
440
+ }
441
+
442
+ compileLanguage(language);
443
+ var top = continuation || language;
444
+ var continuations = {}; // keep continuations for sub-languages
445
+ var result = '', current;
446
+ for(current = top; current != language; current = current.parent) {
447
+ if (current.className) {
448
+ result = buildSpan(current.className, '', true) + result;
449
+ }
450
+ }
451
+ var mode_buffer = '';
452
+ var relevance = 0;
453
+ try {
454
+ var match, count, index = 0;
455
+ while (true) {
456
+ top.terminators.lastIndex = index;
457
+ match = top.terminators.exec(value);
458
+ if (!match)
459
+ break;
460
+ count = processLexeme(value.substr(index, match.index - index), match[0]);
461
+ index = match.index + count;
462
+ }
463
+ processLexeme(value.substr(index));
464
+ for(current = top; current.parent; current = current.parent) { // close dangling modes
465
+ if (current.className) {
466
+ result += '</span>';
467
+ }
468
+ }
469
+ return {
470
+ relevance: relevance,
471
+ value: result,
472
+ language: name,
473
+ top: top
474
+ };
475
+ } catch (e) {
476
+ if (e.message.indexOf('Illegal') != -1) {
477
+ return {
478
+ relevance: 0,
479
+ value: escape(value)
480
+ };
481
+ } else {
482
+ throw e;
483
+ }
484
+ }
485
+ }
486
+
487
+ /*
488
+ Highlighting with language detection. Accepts a string with the code to
489
+ highlight. Returns an object with the following properties:
490
+
491
+ - language (detected language)
492
+ - relevance (int)
493
+ - value (an HTML string with highlighting markup)
494
+ - second_best (object with the same structure for second-best heuristically
495
+ detected language, may be absent)
496
+
497
+ */
498
+ function highlightAuto(text, languageSubset) {
499
+ languageSubset = languageSubset || options.languages || Object.keys(languages);
500
+ var result = {
501
+ relevance: 0,
502
+ value: escape(text)
503
+ };
504
+ var second_best = result;
505
+ languageSubset.forEach(function(name) {
506
+ if (!getLanguage(name)) {
507
+ return;
508
+ }
509
+ var current = highlight(name, text, false);
510
+ current.language = name;
511
+ if (current.relevance > second_best.relevance) {
512
+ second_best = current;
513
+ }
514
+ if (current.relevance > result.relevance) {
515
+ second_best = result;
516
+ result = current;
517
+ }
518
+ });
519
+ if (second_best.language) {
520
+ result.second_best = second_best;
521
+ }
522
+ return result;
523
+ }
524
+
525
+ /*
526
+ Post-processing of the highlighted markup:
527
+
528
+ - replace TABs with something more useful
529
+ - replace real line-breaks with '<br>' for non-pre containers
530
+
531
+ */
532
+ function fixMarkup(value) {
533
+ if (options.tabReplace) {
534
+ value = value.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1 /*..., offset, s*/) {
535
+ return p1.replace(/\t/g, options.tabReplace);
536
+ });
537
+ }
538
+ if (options.useBR) {
539
+ value = value.replace(/\n/g, '<br>');
540
+ }
541
+ return value;
542
+ }
543
+
544
+ function buildClassName(prevClassName, currentLang, resultLang) {
545
+ var language = currentLang ? aliases[currentLang] : resultLang,
546
+ result = [prevClassName.trim()];
547
+
548
+ if (!prevClassName.match(/\bhljs\b/)) {
549
+ result.push('hljs');
550
+ }
551
+
552
+ if (prevClassName.indexOf(language) === -1) {
553
+ result.push(language);
554
+ }
555
+
556
+ return result.join(' ').trim();
557
+ }
558
+
559
+ /*
560
+ Applies highlighting to a DOM node containing code. Accepts a DOM node and
561
+ two optional parameters for fixMarkup.
562
+ */
563
+ function highlightBlock(block) {
564
+ var language = blockLanguage(block);
565
+ if (isNotHighlighted(language))
566
+ return;
567
+
568
+ var node;
569
+ if (options.useBR) {
570
+ node = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
571
+ node.innerHTML = block.innerHTML.replace(/\n/g, '').replace(/<br[ \/]*>/g, '\n');
572
+ } else {
573
+ node = block;
574
+ }
575
+ var text = node.textContent;
576
+ var result = language ? highlight(language, text, true) : highlightAuto(text);
577
+
578
+ var originalStream = nodeStream(node);
579
+ if (originalStream.length) {
580
+ var resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
581
+ resultNode.innerHTML = result.value;
582
+ result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
583
+ }
584
+ result.value = fixMarkup(result.value);
585
+
586
+ block.innerHTML = result.value;
587
+ block.className = buildClassName(block.className, language, result.language);
588
+ block.result = {
589
+ language: result.language,
590
+ re: result.relevance
591
+ };
592
+ if (result.second_best) {
593
+ block.second_best = {
594
+ language: result.second_best.language,
595
+ re: result.second_best.relevance
596
+ };
597
+ }
598
+ }
599
+
600
+ var options = {
601
+ classPrefix: 'hljs-',
602
+ tabReplace: null,
603
+ useBR: false,
604
+ languages: undefined
605
+ };
606
+
607
+ /*
608
+ Updates highlight.js global options with values passed in the form of an object
609
+ */
610
+ function configure(user_options) {
611
+ options = inherit(options, user_options);
612
+ }
613
+
614
+ /*
615
+ Applies highlighting to all <pre><code>..</code></pre> blocks on a page.
616
+ */
617
+ function initHighlighting() {
618
+ if (initHighlighting.called)
619
+ return;
620
+ initHighlighting.called = true;
621
+
622
+ var blocks = document.querySelectorAll('pre code');
623
+ Array.prototype.forEach.call(blocks, highlightBlock);
624
+ }
625
+
626
+ /*
627
+ Attaches highlighting to the page load event.
628
+ */
629
+ function initHighlightingOnLoad() {
630
+ addEventListener('DOMContentLoaded', initHighlighting, false);
631
+ addEventListener('load', initHighlighting, false);
632
+ }
633
+
634
+ var languages = {};
635
+ var aliases = {};
636
+
637
+ function registerLanguage(name, language) {
638
+ var lang = languages[name] = language(hljs);
639
+ if (lang.aliases) {
640
+ lang.aliases.forEach(function(alias) {aliases[alias] = name;});
641
+ }
642
+ }
643
+
644
+ function listLanguages() {
645
+ return Object.keys(languages);
646
+ }
647
+
648
+ function getLanguage(name) {
649
+ name = (name || '').toLowerCase();
650
+ return languages[name] || languages[aliases[name]];
651
+ }
652
+
653
+ /* Interface definition */
654
+
655
+ hljs.highlight = highlight;
656
+ hljs.highlightAuto = highlightAuto;
657
+ hljs.fixMarkup = fixMarkup;
658
+ hljs.highlightBlock = highlightBlock;
659
+ hljs.configure = configure;
660
+ hljs.initHighlighting = initHighlighting;
661
+ hljs.initHighlightingOnLoad = initHighlightingOnLoad;
662
+ hljs.registerLanguage = registerLanguage;
663
+ hljs.listLanguages = listLanguages;
664
+ hljs.getLanguage = getLanguage;
665
+ hljs.inherit = inherit;
666
+
667
+ // Common regexps
668
+ hljs.IDENT_RE = '[a-zA-Z]\\w*';
669
+ hljs.UNDERSCORE_IDENT_RE = '[a-zA-Z_]\\w*';
670
+ hljs.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
671
+ hljs.C_NUMBER_RE = '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float
672
+ hljs.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b...
673
+ hljs.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
674
+
675
+ // Common modes
676
+ hljs.BACKSLASH_ESCAPE = {
677
+ begin: '\\\\[\\s\\S]', relevance: 0
678
+ };
679
+ hljs.APOS_STRING_MODE = {
680
+ className: 'string',
681
+ begin: '\'', end: '\'',
682
+ illegal: '\\n',
683
+ contains: [hljs.BACKSLASH_ESCAPE]
684
+ };
685
+ hljs.QUOTE_STRING_MODE = {
686
+ className: 'string',
687
+ begin: '"', end: '"',
688
+ illegal: '\\n',
689
+ contains: [hljs.BACKSLASH_ESCAPE]
690
+ };
691
+ hljs.PHRASAL_WORDS_MODE = {
692
+ begin: /\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/
693
+ };
694
+ hljs.COMMENT = function (begin, end, inherits) {
695
+ var mode = hljs.inherit(
696
+ {
697
+ className: 'comment',
698
+ begin: begin, end: end,
699
+ contains: []
700
+ },
701
+ inherits || {}
702
+ );
703
+ mode.contains.push(hljs.PHRASAL_WORDS_MODE);
704
+ mode.contains.push({
705
+ className: 'doctag',
706
+ begin: "(?:TODO|FIXME|NOTE|BUG|XXX):",
707
+ relevance: 0
708
+ });
709
+ return mode;
710
+ };
711
+ hljs.C_LINE_COMMENT_MODE = hljs.COMMENT('//', '$');
712
+ hljs.C_BLOCK_COMMENT_MODE = hljs.COMMENT('/\\*', '\\*/');
713
+ hljs.HASH_COMMENT_MODE = hljs.COMMENT('#', '$');
714
+ hljs.NUMBER_MODE = {
715
+ className: 'number',
716
+ begin: hljs.NUMBER_RE,
717
+ relevance: 0
718
+ };
719
+ hljs.C_NUMBER_MODE = {
720
+ className: 'number',
721
+ begin: hljs.C_NUMBER_RE,
722
+ relevance: 0
723
+ };
724
+ hljs.BINARY_NUMBER_MODE = {
725
+ className: 'number',
726
+ begin: hljs.BINARY_NUMBER_RE,
727
+ relevance: 0
728
+ };
729
+ hljs.CSS_NUMBER_MODE = {
730
+ className: 'number',
731
+ begin: hljs.NUMBER_RE + '(' +
732
+ '%|em|ex|ch|rem' +
733
+ '|vw|vh|vmin|vmax' +
734
+ '|cm|mm|in|pt|pc|px' +
735
+ '|deg|grad|rad|turn' +
736
+ '|s|ms' +
737
+ '|Hz|kHz' +
738
+ '|dpi|dpcm|dppx' +
739
+ ')?',
740
+ relevance: 0
741
+ };
742
+ hljs.REGEXP_MODE = {
743
+ className: 'regexp',
744
+ begin: /\//, end: /\/[gimuy]*/,
745
+ illegal: /\n/,
746
+ contains: [
747
+ hljs.BACKSLASH_ESCAPE,
748
+ {
749
+ begin: /\[/, end: /\]/,
750
+ relevance: 0,
751
+ contains: [hljs.BACKSLASH_ESCAPE]
752
+ }
753
+ ]
754
+ };
755
+ hljs.TITLE_MODE = {
756
+ className: 'title',
757
+ begin: hljs.IDENT_RE,
758
+ relevance: 0
759
+ };
760
+ hljs.UNDERSCORE_TITLE_MODE = {
761
+ className: 'title',
762
+ begin: hljs.UNDERSCORE_IDENT_RE,
763
+ relevance: 0
764
+ };
765
+
766
+ hljs.registerLanguage('apache', function(hljs) {
767
+ var NUMBER = {className: 'number', begin: '[\\$%]\\d+'};
768
+ return {
769
+ aliases: ['apacheconf'],
770
+ case_insensitive: true,
771
+ contains: [
772
+ hljs.HASH_COMMENT_MODE,
773
+ {className: 'section', begin: '</?', end: '>'},
774
+ {
775
+ className: 'attribute',
776
+ begin: /\w+/,
777
+ relevance: 0,
778
+ // keywords aren’t needed for highlighting per se, they only boost relevance
779
+ // for a very generally defined mode (starts with a word, ends with line-end
780
+ keywords: {
781
+ nomarkup:
782
+ 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
783
+ 'sethandler errordocument loadmodule options header listen serverroot ' +
784
+ 'servername'
785
+ },
786
+ starts: {
787
+ end: /$/,
788
+ relevance: 0,
789
+ keywords: {
790
+ literal: 'on off all'
791
+ },
792
+ contains: [
793
+ {
794
+ className: 'meta',
795
+ begin: '\\s\\[', end: '\\]$'
796
+ },
797
+ {
798
+ className: 'variable',
799
+ begin: '[\\$%]\\{', end: '\\}',
800
+ contains: ['self', NUMBER]
801
+ },
802
+ NUMBER,
803
+ hljs.QUOTE_STRING_MODE
804
+ ]
805
+ }
806
+ }
807
+ ],
808
+ illegal: /\S/
809
+ };
810
+ });
811
+
812
+ hljs.registerLanguage('bash', function(hljs) {
813
+ var VAR = {
814
+ className: 'variable',
815
+ variants: [
816
+ {begin: /\$[\w\d#@][\w\d_]*/},
817
+ {begin: /\$\{(.*?)}/}
818
+ ]
819
+ };
820
+ var QUOTE_STRING = {
821
+ className: 'string',
822
+ begin: /"/, end: /"/,
823
+ contains: [
824
+ hljs.BACKSLASH_ESCAPE,
825
+ VAR,
826
+ {
827
+ className: 'variable',
828
+ begin: /\$\(/, end: /\)/,
829
+ contains: [hljs.BACKSLASH_ESCAPE]
830
+ }
831
+ ]
832
+ };
833
+ var APOS_STRING = {
834
+ className: 'string',
835
+ begin: /'/, end: /'/
836
+ };
837
+
838
+ return {
839
+ aliases: ['sh', 'zsh'],
840
+ lexemes: /-?[a-z\.]+/,
841
+ keywords: {
842
+ keyword:
843
+ 'if then else elif fi for while in do done case esac function',
844
+ literal:
845
+ 'true false',
846
+ built_in:
847
+ // Shell built-ins
848
+ // http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
849
+ 'break cd continue eval exec exit export getopts hash pwd readonly return shift test times ' +
850
+ 'trap umask unset ' +
851
+ // Bash built-ins
852
+ 'alias bind builtin caller command declare echo enable help let local logout mapfile printf ' +
853
+ 'read readarray source type typeset ulimit unalias ' +
854
+ // Shell modifiers
855
+ 'set shopt ' +
856
+ // Zsh built-ins
857
+ 'autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles ' +
858
+ 'compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate ' +
859
+ 'fc fg float functions getcap getln history integer jobs kill limit log noglob popd print ' +
860
+ 'pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit ' +
861
+ 'unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof ' +
862
+ 'zpty zregexparse zsocket zstyle ztcp',
863
+ _:
864
+ '-ne -eq -lt -gt -f -d -e -s -l -a' // relevance booster
865
+ },
866
+ contains: [
867
+ {
868
+ className: 'meta',
869
+ begin: /^#![^\n]+sh\s*$/,
870
+ relevance: 10
871
+ },
872
+ {
873
+ className: 'function',
874
+ begin: /\w[\w\d_]*\s*\(\s*\)\s*\{/,
875
+ returnBegin: true,
876
+ contains: [hljs.inherit(hljs.TITLE_MODE, {begin: /\w[\w\d_]*/})],
877
+ relevance: 0
878
+ },
879
+ hljs.HASH_COMMENT_MODE,
880
+ QUOTE_STRING,
881
+ APOS_STRING,
882
+ VAR
883
+ ]
884
+ };
885
+ });
886
+
887
+ hljs.registerLanguage('coffeescript', function(hljs) {
888
+ var KEYWORDS = {
889
+ keyword:
890
+ // JS keywords
891
+ 'in if for while finally new do return else break catch instanceof throw try this ' +
892
+ 'switch continue typeof delete debugger super ' +
893
+ // Coffee keywords
894
+ 'then unless until loop of by when and or is isnt not',
895
+ literal:
896
+ // JS literals
897
+ 'true false null undefined ' +
898
+ // Coffee literals
899
+ 'yes no on off',
900
+ built_in:
901
+ 'npm require console print module global window document'
902
+ };
903
+ var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*';
904
+ var SUBST = {
905
+ className: 'subst',
906
+ begin: /#\{/, end: /}/,
907
+ keywords: KEYWORDS
908
+ };
909
+ var EXPRESSIONS = [
910
+ hljs.BINARY_NUMBER_MODE,
911
+ hljs.inherit(hljs.C_NUMBER_MODE, {starts: {end: '(\\s*/)?', relevance: 0}}), // a number tries to eat the following slash to prevent treating it as a regexp
912
+ {
913
+ className: 'string',
914
+ variants: [
915
+ {
916
+ begin: /'''/, end: /'''/,
917
+ contains: [hljs.BACKSLASH_ESCAPE]
918
+ },
919
+ {
920
+ begin: /'/, end: /'/,
921
+ contains: [hljs.BACKSLASH_ESCAPE]
922
+ },
923
+ {
924
+ begin: /"""/, end: /"""/,
925
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
926
+ },
927
+ {
928
+ begin: /"/, end: /"/,
929
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST]
930
+ }
931
+ ]
932
+ },
933
+ {
934
+ className: 'regexp',
935
+ variants: [
936
+ {
937
+ begin: '///', end: '///',
938
+ contains: [SUBST, hljs.HASH_COMMENT_MODE]
939
+ },
940
+ {
941
+ begin: '//[gim]*',
942
+ relevance: 0
943
+ },
944
+ {
945
+ // regex can't start with space to parse x / 2 / 3 as two divisions
946
+ // regex can't start with *, and it supports an "illegal" in the main mode
947
+ begin: /\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/
948
+ }
949
+ ]
950
+ },
951
+ {
952
+ begin: '@' + JS_IDENT_RE // relevance booster
953
+ },
954
+ {
955
+ begin: '`', end: '`',
956
+ excludeBegin: true, excludeEnd: true,
957
+ subLanguage: 'javascript'
958
+ }
959
+ ];
960
+ SUBST.contains = EXPRESSIONS;
961
+
962
+ var TITLE = hljs.inherit(hljs.TITLE_MODE, {begin: JS_IDENT_RE});
963
+ var PARAMS_RE = '(\\(.*\\))?\\s*\\B[-=]>';
964
+ var PARAMS = {
965
+ className: 'params',
966
+ begin: '\\([^\\(]', returnBegin: true,
967
+ /* We need another contained nameless mode to not have every nested
968
+ pair of parens to be called "params" */
969
+ contains: [{
970
+ begin: /\(/, end: /\)/,
971
+ keywords: KEYWORDS,
972
+ contains: ['self'].concat(EXPRESSIONS)
973
+ }]
974
+ };
975
+
976
+ return {
977
+ aliases: ['coffee', 'cson', 'iced'],
978
+ keywords: KEYWORDS,
979
+ illegal: /\/\*/,
980
+ contains: EXPRESSIONS.concat([
981
+ hljs.COMMENT('###', '###'),
982
+ hljs.HASH_COMMENT_MODE,
983
+ {
984
+ className: 'function',
985
+ begin: '^\\s*' + JS_IDENT_RE + '\\s*=\\s*' + PARAMS_RE, end: '[-=]>',
986
+ returnBegin: true,
987
+ contains: [TITLE, PARAMS]
988
+ },
989
+ {
990
+ // anonymous function start
991
+ begin: /[:\(,=]\s*/,
992
+ relevance: 0,
993
+ contains: [
994
+ {
995
+ className: 'function',
996
+ begin: PARAMS_RE, end: '[-=]>',
997
+ returnBegin: true,
998
+ contains: [PARAMS]
999
+ }
1000
+ ]
1001
+ },
1002
+ {
1003
+ className: 'class',
1004
+ beginKeywords: 'class',
1005
+ end: '$',
1006
+ illegal: /[:="\[\]]/,
1007
+ contains: [
1008
+ {
1009
+ beginKeywords: 'extends',
1010
+ endsWithParent: true,
1011
+ illegal: /[:="\[\]]/,
1012
+ contains: [TITLE]
1013
+ },
1014
+ TITLE
1015
+ ]
1016
+ },
1017
+ {
1018
+ begin: JS_IDENT_RE + ':', end: ':',
1019
+ returnBegin: true, returnEnd: true,
1020
+ relevance: 0
1021
+ }
1022
+ ])
1023
+ };
1024
+ });
1025
+
1026
+ hljs.registerLanguage('cos', function cos (hljs) {
1027
+
1028
+ var STRINGS = {
1029
+ className: 'string',
1030
+ variants: [
1031
+ {
1032
+ begin: '"',
1033
+ end: '"',
1034
+ contains: [{ // escaped
1035
+ begin: "\"\"",
1036
+ relevance: 0
1037
+ }]
1038
+ }
1039
+ ]
1040
+ };
1041
+
1042
+ var NUMBERS = {
1043
+ className: "number",
1044
+ begin: "\\b(\\d+(\\.\\d*)?|\\.\\d+)",
1045
+ relevance: 0
1046
+ };
1047
+
1048
+ var METHOD_TITLE = hljs.IDENT_RE + "\\s*\\(";
1049
+
1050
+ var COS_KEYWORDS = {
1051
+ keyword: [
1052
+
1053
+ "break", "catch", "close", "continue", "do", "d", "else",
1054
+ "elseif", "for", "goto", "halt", "hang", "h", "if", "job",
1055
+ "j", "kill", "k", "lock", "l", "merge", "new", "open", "quit",
1056
+ "q", "read", "r", "return", "set", "s", "tcommit", "throw",
1057
+ "trollback", "try", "tstart", "use", "view", "while", "write",
1058
+ "w", "xecute", "x", "zkill", "znspace", "zn", "ztrap", "zwrite",
1059
+ "zw", "zzdump", "zzwrite", "print", "zbreak", "zinsert", "zload",
1060
+ "zprint", "zremove", "zsave", "zzprint", "mv", "mvcall", "mvcrt",
1061
+ "mvdim", "mvprint", "zquit", "zsync", "ascii"
1062
+
1063
+ // registered function - no need in them due to all functions are highlighted,
1064
+ // but I'll just leave this here.
1065
+
1066
+ //"$bit", "$bitcount",
1067
+ //"$bitfind", "$bitlogic", "$case", "$char", "$classmethod", "$classname",
1068
+ //"$compile", "$data", "$decimal", "$double", "$extract", "$factor",
1069
+ //"$find", "$fnumber", "$get", "$increment", "$inumber", "$isobject",
1070
+ //"$isvaliddouble", "$isvalidnum", "$justify", "$length", "$list",
1071
+ //"$listbuild", "$listdata", "$listfind", "$listfromstring", "$listget",
1072
+ //"$listlength", "$listnext", "$listsame", "$listtostring", "$listvalid",
1073
+ //"$locate", "$match", "$method", "$name", "$nconvert", "$next",
1074
+ //"$normalize", "$now", "$number", "$order", "$parameter", "$piece",
1075
+ //"$prefetchoff", "$prefetchon", "$property", "$qlength", "$qsubscript",
1076
+ //"$query", "$random", "$replace", "$reverse", "$sconvert", "$select",
1077
+ //"$sortbegin", "$sortend", "$stack", "$text", "$translate", "$view",
1078
+ //"$wascii", "$wchar", "$wextract", "$wfind", "$wiswide", "$wlength",
1079
+ //"$wreverse", "$xecute", "$zabs", "$zarccos", "$zarcsin", "$zarctan",
1080
+ //"$zcos", "$zcot", "$zcsc", "$zdate", "$zdateh", "$zdatetime",
1081
+ //"$zdatetimeh", "$zexp", "$zhex", "$zln", "$zlog", "$zpower", "$zsec",
1082
+ //"$zsin", "$zsqr", "$ztan", "$ztime", "$ztimeh", "$zboolean",
1083
+ //"$zconvert", "$zcrc", "$zcyc", "$zdascii", "$zdchar", "$zf",
1084
+ //"$ziswide", "$zlascii", "$zlchar", "$zname", "$zposition", "$zqascii",
1085
+ //"$zqchar", "$zsearch", "$zseek", "$zstrip", "$zwascii", "$zwchar",
1086
+ //"$zwidth", "$zwpack", "$zwbpack", "$zwunpack", "$zwbunpack", "$zzenkaku",
1087
+ //"$change", "$mv", "$mvat", "$mvfmt", "$mvfmts", "$mviconv",
1088
+ //"$mviconvs", "$mvinmat", "$mvlover", "$mvoconv", "$mvoconvs", "$mvraise",
1089
+ //"$mvtrans", "$mvv", "$mvname", "$zbitand", "$zbitcount", "$zbitfind",
1090
+ //"$zbitget", "$zbitlen", "$zbitnot", "$zbitor", "$zbitset", "$zbitstr",
1091
+ //"$zbitxor", "$zincrement", "$znext", "$zorder", "$zprevious", "$zsort",
1092
+ //"device", "$ecode", "$estack", "$etrap", "$halt", "$horolog",
1093
+ //"$io", "$job", "$key", "$namespace", "$principal", "$quit", "$roles",
1094
+ //"$storage", "$system", "$test", "$this", "$tlevel", "$username",
1095
+ //"$x", "$y", "$za", "$zb", "$zchild", "$zeof", "$zeos", "$zerror",
1096
+ //"$zhorolog", "$zio", "$zjob", "$zmode", "$znspace", "$zparent", "$zpi",
1097
+ //"$zpos", "$zreference", "$zstorage", "$ztimestamp", "$ztimezone",
1098
+ //"$ztrap", "$zversion"
1099
+
1100
+ ].join(" ")
1101
+ };
1102
+
1103
+ return {
1104
+ case_insensitive: true,
1105
+ aliases: ["cos", "cls"],
1106
+ keywords: COS_KEYWORDS,
1107
+ contains: [
1108
+ NUMBERS,
1109
+ STRINGS,
1110
+ hljs.C_LINE_COMMENT_MODE,
1111
+ hljs.C_BLOCK_COMMENT_MODE,
1112
+ { // functions
1113
+ className: "built_in",
1114
+ begin: /\$\$?[a-zA-Z]+/
1115
+ },
1116
+ { // macro
1117
+ className: "keyword",
1118
+ begin: /\$\$\$[a-zA-Z]+/
1119
+ },
1120
+ { // globals
1121
+ className: "symbol",
1122
+ begin: /\^%?[a-zA-Z][\w]*/
1123
+ },
1124
+ { // static class reference constructions
1125
+ className: 'keyword',
1126
+ begin: /##class/
1127
+ },
1128
+
1129
+ // sub-languages: are not fully supported by hljs by 11/15/2015
1130
+ // left for the future implementation.
1131
+ {
1132
+ begin: /&sql\(/, end: /\)/,
1133
+ excludeBegin: true, excludeEnd: true,
1134
+ subLanguage: "sql"
1135
+ },
1136
+ {
1137
+ begin: /&(js|jscript|javascript)</, end: />/,
1138
+ excludeBegin: true, excludeEnd: true,
1139
+ subLanguage: "javascript"
1140
+ },
1141
+ {
1142
+ begin: /&html<\s*</, end: />\s*>/, // brakes first tag, but the only way to embed valid html
1143
+ subLanguage: "xml" // no html?
1144
+ }
1145
+ ]
1146
+ };
1147
+ });
1148
+
1149
+ hljs.registerLanguage('cpp', function(hljs) {
1150
+ var CPP_PRIMATIVE_TYPES = {
1151
+ className: 'keyword',
1152
+ begin: '\\b[a-z\\d_]*_t\\b'
1153
+ };
1154
+
1155
+ var STRINGS = {
1156
+ className: 'string',
1157
+ variants: [
1158
+ hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),
1159
+ {
1160
+ begin: '(u8?|U)?R"', end: '"',
1161
+ contains: [hljs.BACKSLASH_ESCAPE]
1162
+ },
1163
+ {
1164
+ begin: '\'\\\\?.', end: '\'',
1165
+ illegal: '.'
1166
+ }
1167
+ ]
1168
+ };
1169
+
1170
+ var NUMBERS = {
1171
+ className: 'number',
1172
+ variants: [
1173
+ { begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)' },
1174
+ { begin: hljs.C_NUMBER_RE }
1175
+ ],
1176
+ relevance: 0
1177
+ };
1178
+
1179
+ var PREPROCESSOR = {
1180
+ className: 'meta',
1181
+ begin: '#', end: '$',
1182
+ keywords: {'meta-keyword': 'if else elif endif define undef warning error line ' +
1183
+ 'pragma ifdef ifndef'},
1184
+ contains: [
1185
+ {
1186
+ begin: /\\\n/, relevance: 0
1187
+ },
1188
+ {
1189
+ beginKeywords: 'include', end: '$',
1190
+ keywords: {'meta-keyword': 'include'},
1191
+ contains: [
1192
+ hljs.inherit(STRINGS, {className: 'meta-string'}),
1193
+ {
1194
+ className: 'meta-string',
1195
+ begin: '<', end: '>',
1196
+ illegal: '\\n',
1197
+ }
1198
+ ]
1199
+ },
1200
+ STRINGS,
1201
+ hljs.C_LINE_COMMENT_MODE,
1202
+ hljs.C_BLOCK_COMMENT_MODE
1203
+ ]
1204
+ };
1205
+
1206
+ var FUNCTION_TITLE = hljs.IDENT_RE + '\\s*\\(';
1207
+
1208
+ var CPP_KEYWORDS = {
1209
+ keyword: 'int float while private char catch export virtual operator sizeof ' +
1210
+ 'dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace ' +
1211
+ 'unsigned long volatile static protected bool template mutable if public friend ' +
1212
+ 'do goto auto void enum else break extern using class asm case typeid ' +
1213
+ 'short reinterpret_cast|10 default double register explicit signed typename try this ' +
1214
+ 'switch continue inline delete alignof constexpr decltype ' +
1215
+ 'noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary ' +
1216
+ 'atomic_bool atomic_char atomic_schar ' +
1217
+ 'atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong ' +
1218
+ 'atomic_ullong',
1219
+ built_in: 'std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream ' +
1220
+ 'auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set ' +
1221
+ 'unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos ' +
1222
+ 'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
1223
+ 'fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
1224
+ 'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
1225
+ 'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
1226
+ 'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
1227
+ 'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
1228
+ literal: 'true false nullptr NULL'
1229
+ };
1230
+
1231
+ return {
1232
+ aliases: ['c', 'cc', 'h', 'c++', 'h++', 'hpp'],
1233
+ keywords: CPP_KEYWORDS,
1234
+ illegal: '</',
1235
+ contains: [
1236
+ CPP_PRIMATIVE_TYPES,
1237
+ hljs.C_LINE_COMMENT_MODE,
1238
+ hljs.C_BLOCK_COMMENT_MODE,
1239
+ NUMBERS,
1240
+ STRINGS,
1241
+ PREPROCESSOR,
1242
+ {
1243
+ begin: '\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', end: '>',
1244
+ keywords: CPP_KEYWORDS,
1245
+ contains: ['self', CPP_PRIMATIVE_TYPES]
1246
+ },
1247
+ {
1248
+ begin: hljs.IDENT_RE + '::',
1249
+ keywords: CPP_KEYWORDS
1250
+ },
1251
+ {
1252
+ // Expression keywords prevent 'keyword Name(...) or else if(...)' from
1253
+ // being recognized as a function definition
1254
+ beginKeywords: 'new throw return else',
1255
+ relevance: 0
1256
+ },
1257
+ {
1258
+ className: 'function',
1259
+ begin: '(' + hljs.IDENT_RE + '[\\*&\\s]+)+' + FUNCTION_TITLE,
1260
+ returnBegin: true, end: /[{;=]/,
1261
+ excludeEnd: true,
1262
+ keywords: CPP_KEYWORDS,
1263
+ illegal: /[^\w\s\*&]/,
1264
+ contains: [
1265
+ {
1266
+ begin: FUNCTION_TITLE, returnBegin: true,
1267
+ contains: [hljs.TITLE_MODE],
1268
+ relevance: 0
1269
+ },
1270
+ {
1271
+ className: 'params',
1272
+ begin: /\(/, end: /\)/,
1273
+ keywords: CPP_KEYWORDS,
1274
+ relevance: 0,
1275
+ contains: [
1276
+ hljs.C_LINE_COMMENT_MODE,
1277
+ hljs.C_BLOCK_COMMENT_MODE,
1278
+ STRINGS,
1279
+ NUMBERS
1280
+ ]
1281
+ },
1282
+ hljs.C_LINE_COMMENT_MODE,
1283
+ hljs.C_BLOCK_COMMENT_MODE,
1284
+ PREPROCESSOR
1285
+ ]
1286
+ }
1287
+ ]
1288
+ };
1289
+ });
1290
+
1291
+ hljs.registerLanguage('cs', function(hljs) {
1292
+ var KEYWORDS =
1293
+ // Normal keywords.
1294
+ 'abstract as base bool break byte case catch char checked const continue decimal dynamic ' +
1295
+ 'default delegate do double else enum event explicit extern false finally fixed float ' +
1296
+ 'for foreach goto if implicit in int interface internal is lock long null when ' +
1297
+ 'object operator out override params private protected public readonly ref sbyte ' +
1298
+ 'sealed short sizeof stackalloc static string struct switch this true try typeof ' +
1299
+ 'uint ulong unchecked unsafe ushort using virtual volatile void while async ' +
1300
+ 'protected public private internal ' +
1301
+ // Contextual keywords.
1302
+ 'ascending descending from get group into join let orderby partial select set value var ' +
1303
+ 'where yield';
1304
+ var GENERIC_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '>)?';
1305
+ return {
1306
+ aliases: ['csharp'],
1307
+ keywords: KEYWORDS,
1308
+ illegal: /::/,
1309
+ contains: [
1310
+ hljs.COMMENT(
1311
+ '///',
1312
+ '$',
1313
+ {
1314
+ returnBegin: true,
1315
+ contains: [
1316
+ {
1317
+ className: 'doctag',
1318
+ variants: [
1319
+ {
1320
+ begin: '///', relevance: 0
1321
+ },
1322
+ {
1323
+ begin: '<!--|-->'
1324
+ },
1325
+ {
1326
+ begin: '</?', end: '>'
1327
+ }
1328
+ ]
1329
+ }
1330
+ ]
1331
+ }
1332
+ ),
1333
+ hljs.C_LINE_COMMENT_MODE,
1334
+ hljs.C_BLOCK_COMMENT_MODE,
1335
+ {
1336
+ className: 'meta',
1337
+ begin: '#', end: '$',
1338
+ keywords: {'meta-keyword': 'if else elif endif define undef warning error line region endregion pragma checksum'}
1339
+ },
1340
+ {
1341
+ className: 'string',
1342
+ begin: '@"', end: '"',
1343
+ contains: [{begin: '""'}]
1344
+ },
1345
+ hljs.APOS_STRING_MODE,
1346
+ hljs.QUOTE_STRING_MODE,
1347
+ hljs.C_NUMBER_MODE,
1348
+ {
1349
+ beginKeywords: 'class interface', end: /[{;=]/,
1350
+ illegal: /[^\s:]/,
1351
+ contains: [
1352
+ hljs.TITLE_MODE,
1353
+ hljs.C_LINE_COMMENT_MODE,
1354
+ hljs.C_BLOCK_COMMENT_MODE
1355
+ ]
1356
+ },
1357
+ {
1358
+ beginKeywords: 'namespace', end: /[{;=]/,
1359
+ illegal: /[^\s:]/,
1360
+ contains: [
1361
+ hljs.inherit(hljs.TITLE_MODE, {begin: '[a-zA-Z](\\.?\\w)*'}),
1362
+ hljs.C_LINE_COMMENT_MODE,
1363
+ hljs.C_BLOCK_COMMENT_MODE
1364
+ ]
1365
+ },
1366
+ {
1367
+ // Expression keywords prevent 'keyword Name(...)' from being
1368
+ // recognized as a function definition
1369
+ beginKeywords: 'new return throw await',
1370
+ relevance: 0
1371
+ },
1372
+ {
1373
+ className: 'function',
1374
+ begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
1375
+ excludeEnd: true,
1376
+ keywords: KEYWORDS,
1377
+ contains: [
1378
+ {
1379
+ begin: hljs.IDENT_RE + '\\s*\\(', returnBegin: true,
1380
+ contains: [hljs.TITLE_MODE],
1381
+ relevance: 0
1382
+ },
1383
+ {
1384
+ className: 'params',
1385
+ begin: /\(/, end: /\)/,
1386
+ excludeBegin: true,
1387
+ excludeEnd: true,
1388
+ keywords: KEYWORDS,
1389
+ relevance: 0,
1390
+ contains: [
1391
+ hljs.APOS_STRING_MODE,
1392
+ hljs.QUOTE_STRING_MODE,
1393
+ hljs.C_NUMBER_MODE,
1394
+ hljs.C_BLOCK_COMMENT_MODE
1395
+ ]
1396
+ },
1397
+ hljs.C_LINE_COMMENT_MODE,
1398
+ hljs.C_BLOCK_COMMENT_MODE
1399
+ ]
1400
+ }
1401
+ ]
1402
+ };
1403
+ });
1404
+
1405
+ hljs.registerLanguage('css', function(hljs) {
1406
+ var IDENT_RE = '[a-zA-Z-][a-zA-Z0-9_-]*';
1407
+ var RULE = {
1408
+ begin: /[A-Z\_\.\-]+\s*:/, returnBegin: true, end: ';', endsWithParent: true,
1409
+ contains: [
1410
+ {
1411
+ className: 'attribute',
1412
+ begin: /\S/, end: ':', excludeEnd: true,
1413
+ starts: {
1414
+ endsWithParent: true, excludeEnd: true,
1415
+ contains: [
1416
+ {
1417
+ begin: /[\w-]+\s*\(/, returnBegin: true,
1418
+ contains: [
1419
+ {
1420
+ className: 'built_in',
1421
+ begin: /[\w-]+/
1422
+ }
1423
+ ]
1424
+ },
1425
+ hljs.CSS_NUMBER_MODE,
1426
+ hljs.QUOTE_STRING_MODE,
1427
+ hljs.APOS_STRING_MODE,
1428
+ hljs.C_BLOCK_COMMENT_MODE,
1429
+ {
1430
+ className: 'number', begin: '#[0-9A-Fa-f]+'
1431
+ },
1432
+ {
1433
+ className: 'meta', begin: '!important'
1434
+ }
1435
+ ]
1436
+ }
1437
+ }
1438
+ ]
1439
+ };
1440
+
1441
+ return {
1442
+ case_insensitive: true,
1443
+ illegal: /[=\/|'\$]/,
1444
+ contains: [
1445
+ hljs.C_BLOCK_COMMENT_MODE,
1446
+ {
1447
+ className: 'selector-id', begin: /#[A-Za-z0-9_-]+/
1448
+ },
1449
+ {
1450
+ className: 'selector-class', begin: /\.[A-Za-z0-9_-]+/
1451
+ },
1452
+ {
1453
+ className: 'selector-attr',
1454
+ begin: /\[/, end: /\]/,
1455
+ illegal: '$'
1456
+ },
1457
+ {
1458
+ className: 'selector-pseudo',
1459
+ begin: /:(:)?[a-zA-Z0-9\_\-\+\(\)"']+/
1460
+ },
1461
+ {
1462
+ begin: '@(font-face|page)',
1463
+ lexemes: '[a-z-]+',
1464
+ keywords: 'font-face page'
1465
+ },
1466
+ {
1467
+ begin: '@', end: '[{;]', // at_rule eating first "{" is a good thing
1468
+ // because it doesn’t let it to be parsed as
1469
+ // a rule set but instead drops parser into
1470
+ // the default mode which is how it should be.
1471
+ contains: [
1472
+ {
1473
+ className: 'keyword',
1474
+ begin: /\S+/
1475
+ },
1476
+ {
1477
+ begin: /\s/, endsWithParent: true, excludeEnd: true,
1478
+ relevance: 0,
1479
+ contains: [
1480
+ hljs.APOS_STRING_MODE, hljs.QUOTE_STRING_MODE,
1481
+ hljs.CSS_NUMBER_MODE
1482
+ ]
1483
+ }
1484
+ ]
1485
+ },
1486
+ {
1487
+ className: 'selector-tag', begin: IDENT_RE,
1488
+ relevance: 0
1489
+ },
1490
+ {
1491
+ begin: '{', end: '}',
1492
+ illegal: /\S/,
1493
+ contains: [
1494
+ hljs.C_BLOCK_COMMENT_MODE,
1495
+ RULE,
1496
+ ]
1497
+ }
1498
+ ]
1499
+ };
1500
+ });
1501
+
1502
+ hljs.registerLanguage('diff', function(hljs) {
1503
+ return {
1504
+ aliases: ['patch'],
1505
+ contains: [
1506
+ {
1507
+ className: 'meta',
1508
+ relevance: 10,
1509
+ variants: [
1510
+ {begin: /^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},
1511
+ {begin: /^\*\*\* +\d+,\d+ +\*\*\*\*$/},
1512
+ {begin: /^\-\-\- +\d+,\d+ +\-\-\-\-$/}
1513
+ ]
1514
+ },
1515
+ {
1516
+ className: 'comment',
1517
+ variants: [
1518
+ {begin: /Index: /, end: /$/},
1519
+ {begin: /=====/, end: /=====$/},
1520
+ {begin: /^\-\-\-/, end: /$/},
1521
+ {begin: /^\*{3} /, end: /$/},
1522
+ {begin: /^\+\+\+/, end: /$/},
1523
+ {begin: /\*{5}/, end: /\*{5}$/}
1524
+ ]
1525
+ },
1526
+ {
1527
+ className: 'addition',
1528
+ begin: '^\\+', end: '$'
1529
+ },
1530
+ {
1531
+ className: 'deletion',
1532
+ begin: '^\\-', end: '$'
1533
+ },
1534
+ {
1535
+ className: 'addition',
1536
+ begin: '^\\!', end: '$'
1537
+ }
1538
+ ]
1539
+ };
1540
+ });
1541
+
1542
+ hljs.registerLanguage('http', function(hljs) {
1543
+ var VERSION = 'HTTP/[0-9\\.]+';
1544
+ return {
1545
+ aliases: ['https'],
1546
+ illegal: '\\S',
1547
+ contains: [
1548
+ {
1549
+ begin: '^' + VERSION, end: '$',
1550
+ contains: [{className: 'number', begin: '\\b\\d{3}\\b'}]
1551
+ },
1552
+ {
1553
+ begin: '^[A-Z]+ (.*?) ' + VERSION + '$', returnBegin: true, end: '$',
1554
+ contains: [
1555
+ {
1556
+ className: 'string',
1557
+ begin: ' ', end: ' ',
1558
+ excludeBegin: true, excludeEnd: true
1559
+ },
1560
+ {
1561
+ begin: VERSION
1562
+ },
1563
+ {
1564
+ className: 'keyword',
1565
+ begin: '[A-Z]+'
1566
+ }
1567
+ ]
1568
+ },
1569
+ {
1570
+ className: 'attribute',
1571
+ begin: '^\\w', end: ': ', excludeEnd: true,
1572
+ illegal: '\\n|\\s|=',
1573
+ starts: {end: '$', relevance: 0}
1574
+ },
1575
+ {
1576
+ begin: '\\n\\n',
1577
+ starts: {subLanguage: [], endsWithParent: true}
1578
+ }
1579
+ ]
1580
+ };
1581
+ });
1582
+
1583
+ hljs.registerLanguage('ini', function(hljs) {
1584
+ var STRING = {
1585
+ className: "string",
1586
+ contains: [hljs.BACKSLASH_ESCAPE],
1587
+ variants: [
1588
+ {
1589
+ begin: "'''", end: "'''",
1590
+ relevance: 10
1591
+ }, {
1592
+ begin: '"""', end: '"""',
1593
+ relevance: 10
1594
+ }, {
1595
+ begin: '"', end: '"'
1596
+ }, {
1597
+ begin: "'", end: "'"
1598
+ }
1599
+ ]
1600
+ };
1601
+ return {
1602
+ aliases: ['toml'],
1603
+ case_insensitive: true,
1604
+ illegal: /\S/,
1605
+ contains: [
1606
+ hljs.COMMENT(';', '$'),
1607
+ hljs.HASH_COMMENT_MODE,
1608
+ {
1609
+ className: 'section',
1610
+ begin: /^\s*\[+/, end: /\]+/
1611
+ },
1612
+ {
1613
+ begin: /^[a-z0-9\[\]_-]+\s*=\s*/, end: '$',
1614
+ returnBegin: true,
1615
+ contains: [
1616
+ {
1617
+ className: 'attr',
1618
+ begin: /[a-z0-9\[\]_-]+/
1619
+ },
1620
+ {
1621
+ begin: /=/, endsWithParent: true,
1622
+ relevance: 0,
1623
+ contains: [
1624
+ {
1625
+ className: 'literal',
1626
+ begin: /\bon|off|true|false|yes|no\b/
1627
+ },
1628
+ {
1629
+ className: 'variable',
1630
+ variants: [
1631
+ {begin: /\$[\w\d"][\w\d_]*/},
1632
+ {begin: /\$\{(.*?)}/}
1633
+ ]
1634
+ },
1635
+ STRING,
1636
+ {
1637
+ className: 'number',
1638
+ begin: /([\+\-]+)?[\d]+_[\d_]+/
1639
+ },
1640
+ hljs.NUMBER_MODE
1641
+ ]
1642
+ }
1643
+ ]
1644
+ }
1645
+ ]
1646
+ };
1647
+ });
1648
+
1649
+ hljs.registerLanguage('java', function(hljs) {
1650
+ var GENERIC_IDENT_RE = hljs.UNDERSCORE_IDENT_RE + '(<(' + hljs.UNDERSCORE_IDENT_RE + '|\\s*,\\s*)+>)?';
1651
+ var KEYWORDS =
1652
+ 'false synchronized int abstract float private char boolean static null if const ' +
1653
+ 'for true while long strictfp finally protected import native final void ' +
1654
+ 'enum else break transient catch instanceof byte super volatile case assert short ' +
1655
+ 'package default double public try this switch continue throws protected public private';
1656
+
1657
+ // https://docs.oracle.com/javase/7/docs/technotes/guides/language/underscores-literals.html
1658
+ var JAVA_NUMBER_RE = '\\b' +
1659
+ '(' +
1660
+ '0[bB]([01]+[01_]+[01]+|[01]+)' + // 0b...
1661
+ '|' +
1662
+ '0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)' + // 0x...
1663
+ '|' +
1664
+ '(' +
1665
+ '([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?' +
1666
+ '|' +
1667
+ '\\.([\\d]+[\\d_]+[\\d]+|[\\d]+)' +
1668
+ ')' +
1669
+ '([eE][-+]?\\d+)?' + // octal, decimal, float
1670
+ ')' +
1671
+ '[lLfF]?';
1672
+ var JAVA_NUMBER_MODE = {
1673
+ className: 'number',
1674
+ begin: JAVA_NUMBER_RE,
1675
+ relevance: 0
1676
+ };
1677
+
1678
+ return {
1679
+ aliases: ['jsp'],
1680
+ keywords: KEYWORDS,
1681
+ illegal: /<\/|#/,
1682
+ contains: [
1683
+ hljs.COMMENT(
1684
+ '/\\*\\*',
1685
+ '\\*/',
1686
+ {
1687
+ relevance : 0,
1688
+ contains : [
1689
+ {
1690
+ // eat up @'s in emails to prevent them to be recognized as doctags
1691
+ begin: /\w+@/, relevance: 0
1692
+ },
1693
+ {
1694
+ className : 'doctag',
1695
+ begin : '@[A-Za-z]+'
1696
+ }
1697
+ ]
1698
+ }
1699
+ ),
1700
+ hljs.C_LINE_COMMENT_MODE,
1701
+ hljs.C_BLOCK_COMMENT_MODE,
1702
+ hljs.APOS_STRING_MODE,
1703
+ hljs.QUOTE_STRING_MODE,
1704
+ {
1705
+ className: 'class',
1706
+ beginKeywords: 'class interface', end: /[{;=]/, excludeEnd: true,
1707
+ keywords: 'class interface',
1708
+ illegal: /[:"\[\]]/,
1709
+ contains: [
1710
+ {beginKeywords: 'extends implements'},
1711
+ hljs.UNDERSCORE_TITLE_MODE
1712
+ ]
1713
+ },
1714
+ {
1715
+ // Expression keywords prevent 'keyword Name(...)' from being
1716
+ // recognized as a function definition
1717
+ beginKeywords: 'new throw return else',
1718
+ relevance: 0
1719
+ },
1720
+ {
1721
+ className: 'function',
1722
+ begin: '(' + GENERIC_IDENT_RE + '\\s+)+' + hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true, end: /[{;=]/,
1723
+ excludeEnd: true,
1724
+ keywords: KEYWORDS,
1725
+ contains: [
1726
+ {
1727
+ begin: hljs.UNDERSCORE_IDENT_RE + '\\s*\\(', returnBegin: true,
1728
+ relevance: 0,
1729
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
1730
+ },
1731
+ {
1732
+ className: 'params',
1733
+ begin: /\(/, end: /\)/,
1734
+ keywords: KEYWORDS,
1735
+ relevance: 0,
1736
+ contains: [
1737
+ hljs.APOS_STRING_MODE,
1738
+ hljs.QUOTE_STRING_MODE,
1739
+ hljs.C_NUMBER_MODE,
1740
+ hljs.C_BLOCK_COMMENT_MODE
1741
+ ]
1742
+ },
1743
+ hljs.C_LINE_COMMENT_MODE,
1744
+ hljs.C_BLOCK_COMMENT_MODE
1745
+ ]
1746
+ },
1747
+ JAVA_NUMBER_MODE,
1748
+ {
1749
+ className: 'meta', begin: '@[A-Za-z]+'
1750
+ }
1751
+ ]
1752
+ };
1753
+ });
1754
+
1755
+ hljs.registerLanguage('javascript', function(hljs) {
1756
+ return {
1757
+ aliases: ['js'],
1758
+ keywords: {
1759
+ keyword:
1760
+ 'in of if for while finally var new function do return void else break catch ' +
1761
+ 'instanceof with throw case default try this switch continue typeof delete ' +
1762
+ 'let yield const export super debugger as async await ' +
1763
+ // ECMAScript 6 modules import
1764
+ 'import from as'
1765
+ ,
1766
+ literal:
1767
+ 'true false null undefined NaN Infinity',
1768
+ built_in:
1769
+ 'eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent ' +
1770
+ 'encodeURI encodeURIComponent escape unescape Object Function Boolean Error ' +
1771
+ 'EvalError InternalError RangeError ReferenceError StopIteration SyntaxError ' +
1772
+ 'TypeError URIError Number Math Date String RegExp Array Float32Array ' +
1773
+ 'Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array ' +
1774
+ 'Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require ' +
1775
+ 'module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect ' +
1776
+ 'Promise'
1777
+ },
1778
+ contains: [
1779
+ {
1780
+ className: 'meta',
1781
+ relevance: 10,
1782
+ begin: /^\s*['"]use (strict|asm)['"]/
1783
+ },
1784
+ hljs.APOS_STRING_MODE,
1785
+ hljs.QUOTE_STRING_MODE,
1786
+ { // template string
1787
+ className: 'string',
1788
+ begin: '`', end: '`',
1789
+ contains: [
1790
+ hljs.BACKSLASH_ESCAPE,
1791
+ {
1792
+ className: 'subst',
1793
+ begin: '\\$\\{', end: '\\}'
1794
+ }
1795
+ ]
1796
+ },
1797
+ hljs.C_LINE_COMMENT_MODE,
1798
+ hljs.C_BLOCK_COMMENT_MODE,
1799
+ {
1800
+ className: 'number',
1801
+ variants: [
1802
+ { begin: '\\b(0[bB][01]+)' },
1803
+ { begin: '\\b(0[oO][0-7]+)' },
1804
+ { begin: hljs.C_NUMBER_RE }
1805
+ ],
1806
+ relevance: 0
1807
+ },
1808
+ { // "value" container
1809
+ begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*',
1810
+ keywords: 'return throw case',
1811
+ contains: [
1812
+ hljs.C_LINE_COMMENT_MODE,
1813
+ hljs.C_BLOCK_COMMENT_MODE,
1814
+ hljs.REGEXP_MODE,
1815
+ { // E4X / JSX
1816
+ begin: /</, end: />\s*[);\]]/,
1817
+ relevance: 0,
1818
+ subLanguage: 'xml'
1819
+ }
1820
+ ],
1821
+ relevance: 0
1822
+ },
1823
+ {
1824
+ className: 'function',
1825
+ beginKeywords: 'function', end: /\{/, excludeEnd: true,
1826
+ contains: [
1827
+ hljs.inherit(hljs.TITLE_MODE, {begin: /[A-Za-z$_][0-9A-Za-z$_]*/}),
1828
+ {
1829
+ className: 'params',
1830
+ begin: /\(/, end: /\)/,
1831
+ excludeBegin: true,
1832
+ excludeEnd: true,
1833
+ contains: [
1834
+ hljs.C_LINE_COMMENT_MODE,
1835
+ hljs.C_BLOCK_COMMENT_MODE
1836
+ ]
1837
+ }
1838
+ ],
1839
+ illegal: /\[|%/
1840
+ },
1841
+ {
1842
+ begin: /\$[(.]/ // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
1843
+ },
1844
+ {
1845
+ begin: '\\.' + hljs.IDENT_RE, relevance: 0 // hack: prevents detection of keywords after dots
1846
+ },
1847
+ { // ES6 class
1848
+ className: 'class',
1849
+ beginKeywords: 'class', end: /[{;=]/, excludeEnd: true,
1850
+ illegal: /[:"\[\]]/,
1851
+ contains: [
1852
+ {beginKeywords: 'extends'},
1853
+ hljs.UNDERSCORE_TITLE_MODE
1854
+ ]
1855
+ },
1856
+ {
1857
+ beginKeywords: 'constructor', end: /\{/, excludeEnd: true
1858
+ }
1859
+ ],
1860
+ illegal: /#/
1861
+ };
1862
+ });
1863
+
1864
+ hljs.registerLanguage('json', function(hljs) {
1865
+ var LITERALS = {literal: 'true false null'};
1866
+ var TYPES = [
1867
+ hljs.QUOTE_STRING_MODE,
1868
+ hljs.C_NUMBER_MODE
1869
+ ];
1870
+ var VALUE_CONTAINER = {
1871
+ end: ',', endsWithParent: true, excludeEnd: true,
1872
+ contains: TYPES,
1873
+ keywords: LITERALS
1874
+ };
1875
+ var OBJECT = {
1876
+ begin: '{', end: '}',
1877
+ contains: [
1878
+ {
1879
+ className: 'attr',
1880
+ begin: '\\s*"', end: '"\\s*:\\s*', excludeBegin: true, excludeEnd: true,
1881
+ contains: [hljs.BACKSLASH_ESCAPE],
1882
+ illegal: '\\n',
1883
+ starts: VALUE_CONTAINER
1884
+ }
1885
+ ],
1886
+ illegal: '\\S'
1887
+ };
1888
+ var ARRAY = {
1889
+ begin: '\\[', end: '\\]',
1890
+ contains: [hljs.inherit(VALUE_CONTAINER)], // inherit is a workaround for a bug that makes shared modes with endsWithParent compile only the ending of one of the parents
1891
+ illegal: '\\S'
1892
+ };
1893
+ TYPES.splice(TYPES.length, 0, OBJECT, ARRAY);
1894
+ return {
1895
+ contains: TYPES,
1896
+ keywords: LITERALS,
1897
+ illegal: '\\S'
1898
+ };
1899
+ });
1900
+
1901
+ hljs.registerLanguage('makefile', function(hljs) {
1902
+ var VARIABLE = {
1903
+ className: 'variable',
1904
+ begin: /\$\(/, end: /\)/,
1905
+ contains: [hljs.BACKSLASH_ESCAPE]
1906
+ };
1907
+ return {
1908
+ aliases: ['mk', 'mak'],
1909
+ contains: [
1910
+ hljs.HASH_COMMENT_MODE,
1911
+ {
1912
+ begin: /^\w+\s*\W*=/, returnBegin: true,
1913
+ relevance: 0,
1914
+ starts: {
1915
+ end: /\s*\W*=/, excludeEnd: true,
1916
+ starts: {
1917
+ end: /$/,
1918
+ relevance: 0,
1919
+ contains: [
1920
+ VARIABLE
1921
+ ]
1922
+ }
1923
+ }
1924
+ },
1925
+ {
1926
+ className: 'section',
1927
+ begin: /^[\w]+:\s*$/
1928
+ },
1929
+ {
1930
+ className: 'meta',
1931
+ begin: /^\.PHONY:/, end: /$/,
1932
+ keywords: {'meta-keyword': '.PHONY'}, lexemes: /[\.\w]+/
1933
+ },
1934
+ {
1935
+ begin: /^\t+/, end: /$/,
1936
+ relevance: 0,
1937
+ contains: [
1938
+ hljs.QUOTE_STRING_MODE,
1939
+ VARIABLE
1940
+ ]
1941
+ }
1942
+ ]
1943
+ };
1944
+ });
1945
+
1946
+ hljs.registerLanguage('xml', function(hljs) {
1947
+ var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
1948
+ var PHP = {
1949
+ begin: /<\?(php)?(?!\w)/, end: /\?>/,
1950
+ subLanguage: 'php'
1951
+ };
1952
+ var TAG_INTERNALS = {
1953
+ endsWithParent: true,
1954
+ illegal: /</,
1955
+ relevance: 0,
1956
+ contains: [
1957
+ PHP,
1958
+ {
1959
+ className: 'attr',
1960
+ begin: XML_IDENT_RE,
1961
+ relevance: 0
1962
+ },
1963
+ {
1964
+ begin: '=',
1965
+ relevance: 0,
1966
+ contains: [
1967
+ {
1968
+ className: 'string',
1969
+ contains: [PHP],
1970
+ variants: [
1971
+ {begin: /"/, end: /"/},
1972
+ {begin: /'/, end: /'/},
1973
+ {begin: /[^\s\/>]+/}
1974
+ ]
1975
+ }
1976
+ ]
1977
+ }
1978
+ ]
1979
+ };
1980
+ return {
1981
+ aliases: ['html', 'xhtml', 'rss', 'atom', 'xsl', 'plist'],
1982
+ case_insensitive: true,
1983
+ contains: [
1984
+ {
1985
+ className: 'meta',
1986
+ begin: '<!DOCTYPE', end: '>',
1987
+ relevance: 10,
1988
+ contains: [{begin: '\\[', end: '\\]'}]
1989
+ },
1990
+ hljs.COMMENT(
1991
+ '<!--',
1992
+ '-->',
1993
+ {
1994
+ relevance: 10
1995
+ }
1996
+ ),
1997
+ {
1998
+ begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
1999
+ relevance: 10
2000
+ },
2001
+ {
2002
+ className: 'tag',
2003
+ /*
2004
+ The lookahead pattern (?=...) ensures that 'begin' only matches
2005
+ '<style' as a single word, followed by a whitespace or an
2006
+ ending braket. The '$' is needed for the lexeme to be recognized
2007
+ by hljs.subMode() that tests lexemes outside the stream.
2008
+ */
2009
+ begin: '<style(?=\\s|>|$)', end: '>',
2010
+ keywords: {name: 'style'},
2011
+ contains: [TAG_INTERNALS],
2012
+ starts: {
2013
+ end: '</style>', returnEnd: true,
2014
+ subLanguage: ['css', 'xml']
2015
+ }
2016
+ },
2017
+ {
2018
+ className: 'tag',
2019
+ // See the comment in the <style tag about the lookahead pattern
2020
+ begin: '<script(?=\\s|>|$)', end: '>',
2021
+ keywords: {name: 'script'},
2022
+ contains: [TAG_INTERNALS],
2023
+ starts: {
2024
+ end: '\<\/script\>', returnEnd: true,
2025
+ subLanguage: ['actionscript', 'javascript', 'handlebars', 'xml']
2026
+ }
2027
+ },
2028
+ PHP,
2029
+ {
2030
+ className: 'meta',
2031
+ begin: /<\?\w+/, end: /\?>/,
2032
+ relevance: 10
2033
+ },
2034
+ {
2035
+ className: 'tag',
2036
+ begin: '</?', end: '/?>',
2037
+ contains: [
2038
+ {
2039
+ className: 'name', begin: /[^\/><\s]+/, relevance: 0
2040
+ },
2041
+ TAG_INTERNALS
2042
+ ]
2043
+ }
2044
+ ]
2045
+ };
2046
+ });
2047
+
2048
+ hljs.registerLanguage('markdown', function(hljs) {
2049
+ return {
2050
+ aliases: ['md', 'mkdown', 'mkd'],
2051
+ contains: [
2052
+ // highlight headers
2053
+ {
2054
+ className: 'section',
2055
+ variants: [
2056
+ { begin: '^#{1,6}', end: '$' },
2057
+ { begin: '^.+?\\n[=-]{2,}$' }
2058
+ ]
2059
+ },
2060
+ // inline html
2061
+ {
2062
+ begin: '<', end: '>',
2063
+ subLanguage: 'xml',
2064
+ relevance: 0
2065
+ },
2066
+ // lists (indicators only)
2067
+ {
2068
+ className: 'bullet',
2069
+ begin: '^([*+-]|(\\d+\\.))\\s+'
2070
+ },
2071
+ // strong segments
2072
+ {
2073
+ className: 'strong',
2074
+ begin: '[*_]{2}.+?[*_]{2}'
2075
+ },
2076
+ // emphasis segments
2077
+ {
2078
+ className: 'emphasis',
2079
+ variants: [
2080
+ { begin: '\\*.+?\\*' },
2081
+ { begin: '_.+?_'
2082
+ , relevance: 0
2083
+ }
2084
+ ]
2085
+ },
2086
+ // blockquotes
2087
+ {
2088
+ className: 'quote',
2089
+ begin: '^>\\s+', end: '$'
2090
+ },
2091
+ // code snippets
2092
+ {
2093
+ className: 'code',
2094
+ variants: [
2095
+ { begin: '`.+?`' },
2096
+ { begin: '^( {4}|\t)', end: '$'
2097
+ , relevance: 0
2098
+ }
2099
+ ]
2100
+ },
2101
+ // horizontal rules
2102
+ {
2103
+ begin: '^[-\\*]{3,}', end: '$'
2104
+ },
2105
+ // using links - title and link
2106
+ {
2107
+ begin: '\\[.+?\\][\\(\\[].*?[\\)\\]]',
2108
+ returnBegin: true,
2109
+ contains: [
2110
+ {
2111
+ className: 'string',
2112
+ begin: '\\[', end: '\\]',
2113
+ excludeBegin: true,
2114
+ returnEnd: true,
2115
+ relevance: 0
2116
+ },
2117
+ {
2118
+ className: 'link',
2119
+ begin: '\\]\\(', end: '\\)',
2120
+ excludeBegin: true, excludeEnd: true
2121
+ },
2122
+ {
2123
+ className: 'symbol',
2124
+ begin: '\\]\\[', end: '\\]',
2125
+ excludeBegin: true, excludeEnd: true
2126
+ }
2127
+ ],
2128
+ relevance: 10
2129
+ },
2130
+ {
2131
+ begin: '^\\[\.+\\]:',
2132
+ returnBegin: true,
2133
+ contains: [
2134
+ {
2135
+ className: 'symbol',
2136
+ begin: '\\[', end: '\\]:',
2137
+ excludeBegin: true, excludeEnd: true,
2138
+ starts: {
2139
+ className: 'link',
2140
+ end: '$'
2141
+ }
2142
+ }
2143
+ ]
2144
+ }
2145
+ ]
2146
+ };
2147
+ });
2148
+
2149
+ hljs.registerLanguage('nginx', function(hljs) {
2150
+ var VAR = {
2151
+ className: 'variable',
2152
+ variants: [
2153
+ {begin: /\$\d+/},
2154
+ {begin: /\$\{/, end: /}/},
2155
+ {begin: '[\\$\\@]' + hljs.UNDERSCORE_IDENT_RE}
2156
+ ]
2157
+ };
2158
+ var DEFAULT = {
2159
+ endsWithParent: true,
2160
+ lexemes: '[a-z/_]+',
2161
+ keywords: {
2162
+ literal:
2163
+ 'on off yes no true false none blocked debug info notice warn error crit ' +
2164
+ 'select break last permanent redirect kqueue rtsig epoll poll /dev/poll'
2165
+ },
2166
+ relevance: 0,
2167
+ illegal: '=>',
2168
+ contains: [
2169
+ hljs.HASH_COMMENT_MODE,
2170
+ {
2171
+ className: 'string',
2172
+ contains: [hljs.BACKSLASH_ESCAPE, VAR],
2173
+ variants: [
2174
+ {begin: /"/, end: /"/},
2175
+ {begin: /'/, end: /'/}
2176
+ ]
2177
+ },
2178
+ // this swallows entire URLs to avoid detecting numbers within
2179
+ {
2180
+ begin: '([a-z]+):/', end: '\\s', endsWithParent: true, excludeEnd: true,
2181
+ contains: [VAR]
2182
+ },
2183
+ {
2184
+ className: 'regexp',
2185
+ contains: [hljs.BACKSLASH_ESCAPE, VAR],
2186
+ variants: [
2187
+ {begin: "\\s\\^", end: "\\s|{|;", returnEnd: true},
2188
+ // regexp locations (~, ~*)
2189
+ {begin: "~\\*?\\s+", end: "\\s|{|;", returnEnd: true},
2190
+ // *.example.com
2191
+ {begin: "\\*(\\.[a-z\\-]+)+"},
2192
+ // sub.example.*
2193
+ {begin: "([a-z\\-]+\\.)+\\*"}
2194
+ ]
2195
+ },
2196
+ // IP
2197
+ {
2198
+ className: 'number',
2199
+ begin: '\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b'
2200
+ },
2201
+ // units
2202
+ {
2203
+ className: 'number',
2204
+ begin: '\\b\\d+[kKmMgGdshdwy]*\\b',
2205
+ relevance: 0
2206
+ },
2207
+ VAR
2208
+ ]
2209
+ };
2210
+
2211
+ return {
2212
+ aliases: ['nginxconf'],
2213
+ contains: [
2214
+ hljs.HASH_COMMENT_MODE,
2215
+ {
2216
+ begin: hljs.UNDERSCORE_IDENT_RE + '\\s+{', returnBegin: true,
2217
+ end: '{',
2218
+ contains: [
2219
+ {
2220
+ className: 'section',
2221
+ begin: hljs.UNDERSCORE_IDENT_RE
2222
+ }
2223
+ ],
2224
+ relevance: 0
2225
+ },
2226
+ {
2227
+ begin: hljs.UNDERSCORE_IDENT_RE + '\\s', end: ';|{', returnBegin: true,
2228
+ contains: [
2229
+ {
2230
+ className: 'attribute',
2231
+ begin: hljs.UNDERSCORE_IDENT_RE,
2232
+ starts: DEFAULT
2233
+ }
2234
+ ],
2235
+ relevance: 0
2236
+ }
2237
+ ],
2238
+ illegal: '[^\\s\\}]'
2239
+ };
2240
+ });
2241
+
2242
+ hljs.registerLanguage('objectivec', function(hljs) {
2243
+ var API_CLASS = {
2244
+ className: 'built_in',
2245
+ begin: '(AV|CA|CF|CG|CI|MK|MP|NS|UI|XC)\\w+',
2246
+ };
2247
+ var OBJC_KEYWORDS = {
2248
+ keyword:
2249
+ 'int float while char export sizeof typedef const struct for union ' +
2250
+ 'unsigned long volatile static bool mutable if do return goto void ' +
2251
+ 'enum else break extern asm case short default double register explicit ' +
2252
+ 'signed typename this switch continue wchar_t inline readonly assign ' +
2253
+ 'readwrite self @synchronized id typeof ' +
2254
+ 'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
2255
+ 'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
2256
+ '@private @protected @public @try @property @end @throw @catch @finally ' +
2257
+ '@autoreleasepool @synthesize @dynamic @selector @optional @required',
2258
+ literal:
2259
+ 'false true FALSE TRUE nil YES NO NULL',
2260
+ built_in:
2261
+ 'BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
2262
+ };
2263
+ var LEXEMES = /[a-zA-Z@][a-zA-Z0-9_]*/;
2264
+ var CLASS_KEYWORDS = '@interface @class @protocol @implementation';
2265
+ return {
2266
+ aliases: ['mm', 'objc', 'obj-c'],
2267
+ keywords: OBJC_KEYWORDS,
2268
+ lexemes: LEXEMES,
2269
+ illegal: '</',
2270
+ contains: [
2271
+ API_CLASS,
2272
+ hljs.C_LINE_COMMENT_MODE,
2273
+ hljs.C_BLOCK_COMMENT_MODE,
2274
+ hljs.C_NUMBER_MODE,
2275
+ hljs.QUOTE_STRING_MODE,
2276
+ {
2277
+ className: 'string',
2278
+ variants: [
2279
+ {
2280
+ begin: '@"', end: '"',
2281
+ illegal: '\\n',
2282
+ contains: [hljs.BACKSLASH_ESCAPE]
2283
+ },
2284
+ {
2285
+ begin: '\'', end: '[^\\\\]\'',
2286
+ illegal: '[^\\\\][^\']'
2287
+ }
2288
+ ]
2289
+ },
2290
+ {
2291
+ className: 'meta',
2292
+ begin: '#',
2293
+ end: '$',
2294
+ contains: [
2295
+ {
2296
+ className: 'meta-string',
2297
+ variants: [
2298
+ { begin: '\"', end: '\"' },
2299
+ { begin: '<', end: '>' }
2300
+ ]
2301
+ }
2302
+ ]
2303
+ },
2304
+ {
2305
+ className: 'class',
2306
+ begin: '(' + CLASS_KEYWORDS.split(' ').join('|') + ')\\b', end: '({|$)', excludeEnd: true,
2307
+ keywords: CLASS_KEYWORDS, lexemes: LEXEMES,
2308
+ contains: [
2309
+ hljs.UNDERSCORE_TITLE_MODE
2310
+ ]
2311
+ },
2312
+ {
2313
+ begin: '\\.'+hljs.UNDERSCORE_IDENT_RE,
2314
+ relevance: 0
2315
+ }
2316
+ ]
2317
+ };
2318
+ });
2319
+
2320
+ hljs.registerLanguage('perl', function(hljs) {
2321
+ var PERL_KEYWORDS = 'getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ' +
2322
+ 'ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime ' +
2323
+ 'readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qq' +
2324
+ 'fileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent ' +
2325
+ 'shutdown dump chomp connect getsockname die socketpair close flock exists index shmget' +
2326
+ 'sub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr ' +
2327
+ 'unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 ' +
2328
+ 'getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline ' +
2329
+ 'endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand ' +
2330
+ 'mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink ' +
2331
+ 'getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr ' +
2332
+ 'untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link ' +
2333
+ 'getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller ' +
2334
+ 'lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and ' +
2335
+ 'sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 ' +
2336
+ 'chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach ' +
2337
+ 'tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedir' +
2338
+ 'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' +
2339
+ 'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when';
2340
+ var SUBST = {
2341
+ className: 'subst',
2342
+ begin: '[$@]\\{', end: '\\}',
2343
+ keywords: PERL_KEYWORDS
2344
+ };
2345
+ var METHOD = {
2346
+ begin: '->{', end: '}'
2347
+ // contains defined later
2348
+ };
2349
+ var VAR = {
2350
+ variants: [
2351
+ {begin: /\$\d/},
2352
+ {begin: /[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},
2353
+ {begin: /[\$%@][^\s\w{]/, relevance: 0}
2354
+ ]
2355
+ };
2356
+ var STRING_CONTAINS = [hljs.BACKSLASH_ESCAPE, SUBST, VAR];
2357
+ var PERL_DEFAULT_CONTAINS = [
2358
+ VAR,
2359
+ hljs.HASH_COMMENT_MODE,
2360
+ hljs.COMMENT(
2361
+ '^\\=\\w',
2362
+ '\\=cut',
2363
+ {
2364
+ endsWithParent: true
2365
+ }
2366
+ ),
2367
+ METHOD,
2368
+ {
2369
+ className: 'string',
2370
+ contains: STRING_CONTAINS,
2371
+ variants: [
2372
+ {
2373
+ begin: 'q[qwxr]?\\s*\\(', end: '\\)',
2374
+ relevance: 5
2375
+ },
2376
+ {
2377
+ begin: 'q[qwxr]?\\s*\\[', end: '\\]',
2378
+ relevance: 5
2379
+ },
2380
+ {
2381
+ begin: 'q[qwxr]?\\s*\\{', end: '\\}',
2382
+ relevance: 5
2383
+ },
2384
+ {
2385
+ begin: 'q[qwxr]?\\s*\\|', end: '\\|',
2386
+ relevance: 5
2387
+ },
2388
+ {
2389
+ begin: 'q[qwxr]?\\s*\\<', end: '\\>',
2390
+ relevance: 5
2391
+ },
2392
+ {
2393
+ begin: 'qw\\s+q', end: 'q',
2394
+ relevance: 5
2395
+ },
2396
+ {
2397
+ begin: '\'', end: '\'',
2398
+ contains: [hljs.BACKSLASH_ESCAPE]
2399
+ },
2400
+ {
2401
+ begin: '"', end: '"'
2402
+ },
2403
+ {
2404
+ begin: '`', end: '`',
2405
+ contains: [hljs.BACKSLASH_ESCAPE]
2406
+ },
2407
+ {
2408
+ begin: '{\\w+}',
2409
+ contains: [],
2410
+ relevance: 0
2411
+ },
2412
+ {
2413
+ begin: '\-?\\w+\\s*\\=\\>',
2414
+ contains: [],
2415
+ relevance: 0
2416
+ }
2417
+ ]
2418
+ },
2419
+ {
2420
+ className: 'number',
2421
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
2422
+ relevance: 0
2423
+ },
2424
+ { // regexp container
2425
+ begin: '(\\/\\/|' + hljs.RE_STARTERS_RE + '|\\b(split|return|print|reverse|grep)\\b)\\s*',
2426
+ keywords: 'split return print reverse grep',
2427
+ relevance: 0,
2428
+ contains: [
2429
+ hljs.HASH_COMMENT_MODE,
2430
+ {
2431
+ className: 'regexp',
2432
+ begin: '(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*',
2433
+ relevance: 10
2434
+ },
2435
+ {
2436
+ className: 'regexp',
2437
+ begin: '(m|qr)?/', end: '/[a-z]*',
2438
+ contains: [hljs.BACKSLASH_ESCAPE],
2439
+ relevance: 0 // allows empty "//" which is a common comment delimiter in other languages
2440
+ }
2441
+ ]
2442
+ },
2443
+ {
2444
+ className: 'function',
2445
+ beginKeywords: 'sub', end: '(\\s*\\(.*?\\))?[;{]', excludeEnd: true,
2446
+ relevance: 5,
2447
+ contains: [hljs.TITLE_MODE]
2448
+ },
2449
+ {
2450
+ begin: '-\\w\\b',
2451
+ relevance: 0
2452
+ },
2453
+ {
2454
+ begin: "^__DATA__$",
2455
+ end: "^__END__$",
2456
+ subLanguage: 'mojolicious',
2457
+ contains: [
2458
+ {
2459
+ begin: "^@@.*",
2460
+ end: "$",
2461
+ className: "comment"
2462
+ }
2463
+ ]
2464
+ }
2465
+ ];
2466
+ SUBST.contains = PERL_DEFAULT_CONTAINS;
2467
+ METHOD.contains = PERL_DEFAULT_CONTAINS;
2468
+
2469
+ return {
2470
+ aliases: ['pl'],
2471
+ keywords: PERL_KEYWORDS,
2472
+ contains: PERL_DEFAULT_CONTAINS
2473
+ };
2474
+ });
2475
+
2476
+ hljs.registerLanguage('php', function(hljs) {
2477
+ var VARIABLE = {
2478
+ begin: '\\$+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
2479
+ };
2480
+ var PREPROCESSOR = {
2481
+ className: 'meta', begin: /<\?(php)?|\?>/
2482
+ };
2483
+ var STRING = {
2484
+ className: 'string',
2485
+ contains: [hljs.BACKSLASH_ESCAPE, PREPROCESSOR],
2486
+ variants: [
2487
+ {
2488
+ begin: 'b"', end: '"'
2489
+ },
2490
+ {
2491
+ begin: 'b\'', end: '\''
2492
+ },
2493
+ hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
2494
+ hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null})
2495
+ ]
2496
+ };
2497
+ var NUMBER = {variants: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]};
2498
+ return {
2499
+ aliases: ['php3', 'php4', 'php5', 'php6'],
2500
+ case_insensitive: true,
2501
+ keywords:
2502
+ 'and include_once list abstract global private echo interface as static endswitch ' +
2503
+ 'array null if endwhile or const for endforeach self var while isset public ' +
2504
+ 'protected exit foreach throw elseif include __FILE__ empty require_once do xor ' +
2505
+ 'return parent clone use __CLASS__ __LINE__ else break print eval new ' +
2506
+ 'catch __METHOD__ case exception default die require __FUNCTION__ ' +
2507
+ 'enddeclare final try switch continue endfor endif declare unset true false ' +
2508
+ 'trait goto instanceof insteadof __DIR__ __NAMESPACE__ ' +
2509
+ 'yield finally',
2510
+ contains: [
2511
+ hljs.C_LINE_COMMENT_MODE,
2512
+ hljs.HASH_COMMENT_MODE,
2513
+ hljs.COMMENT(
2514
+ '/\\*',
2515
+ '\\*/',
2516
+ {
2517
+ contains: [
2518
+ {
2519
+ className: 'doctag',
2520
+ begin: '@[A-Za-z]+'
2521
+ },
2522
+ PREPROCESSOR
2523
+ ]
2524
+ }
2525
+ ),
2526
+ hljs.COMMENT(
2527
+ '__halt_compiler.+?;',
2528
+ false,
2529
+ {
2530
+ endsWithParent: true,
2531
+ keywords: '__halt_compiler',
2532
+ lexemes: hljs.UNDERSCORE_IDENT_RE
2533
+ }
2534
+ ),
2535
+ {
2536
+ className: 'string',
2537
+ begin: /<<<['"]?\w+['"]?$/, end: /^\w+;?$/,
2538
+ contains: [
2539
+ hljs.BACKSLASH_ESCAPE,
2540
+ {
2541
+ className: 'subst',
2542
+ variants: [
2543
+ {begin: /\$\w+/},
2544
+ {begin: /\{\$/, end: /\}/}
2545
+ ]
2546
+ }
2547
+ ]
2548
+ },
2549
+ PREPROCESSOR,
2550
+ VARIABLE,
2551
+ {
2552
+ // swallow composed identifiers to avoid parsing them as keywords
2553
+ begin: /(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
2554
+ },
2555
+ {
2556
+ className: 'function',
2557
+ beginKeywords: 'function', end: /[;{]/, excludeEnd: true,
2558
+ illegal: '\\$|\\[|%',
2559
+ contains: [
2560
+ hljs.UNDERSCORE_TITLE_MODE,
2561
+ {
2562
+ className: 'params',
2563
+ begin: '\\(', end: '\\)',
2564
+ contains: [
2565
+ 'self',
2566
+ VARIABLE,
2567
+ hljs.C_BLOCK_COMMENT_MODE,
2568
+ STRING,
2569
+ NUMBER
2570
+ ]
2571
+ }
2572
+ ]
2573
+ },
2574
+ {
2575
+ className: 'class',
2576
+ beginKeywords: 'class interface', end: '{', excludeEnd: true,
2577
+ illegal: /[:\(\$"]/,
2578
+ contains: [
2579
+ {beginKeywords: 'extends implements'},
2580
+ hljs.UNDERSCORE_TITLE_MODE
2581
+ ]
2582
+ },
2583
+ {
2584
+ beginKeywords: 'namespace', end: ';',
2585
+ illegal: /[\.']/,
2586
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
2587
+ },
2588
+ {
2589
+ beginKeywords: 'use', end: ';',
2590
+ contains: [hljs.UNDERSCORE_TITLE_MODE]
2591
+ },
2592
+ {
2593
+ begin: '=>' // No markup, just a relevance booster
2594
+ },
2595
+ STRING,
2596
+ NUMBER
2597
+ ]
2598
+ };
2599
+ });
2600
+
2601
+ hljs.registerLanguage('python', function(hljs) {
2602
+ var PROMPT = {
2603
+ className: 'meta', begin: /^(>>>|\.\.\.) /
2604
+ };
2605
+ var STRING = {
2606
+ className: 'string',
2607
+ contains: [hljs.BACKSLASH_ESCAPE],
2608
+ variants: [
2609
+ {
2610
+ begin: /(u|b)?r?'''/, end: /'''/,
2611
+ contains: [PROMPT],
2612
+ relevance: 10
2613
+ },
2614
+ {
2615
+ begin: /(u|b)?r?"""/, end: /"""/,
2616
+ contains: [PROMPT],
2617
+ relevance: 10
2618
+ },
2619
+ {
2620
+ begin: /(u|r|ur)'/, end: /'/,
2621
+ relevance: 10
2622
+ },
2623
+ {
2624
+ begin: /(u|r|ur)"/, end: /"/,
2625
+ relevance: 10
2626
+ },
2627
+ {
2628
+ begin: /(b|br)'/, end: /'/
2629
+ },
2630
+ {
2631
+ begin: /(b|br)"/, end: /"/
2632
+ },
2633
+ hljs.APOS_STRING_MODE,
2634
+ hljs.QUOTE_STRING_MODE
2635
+ ]
2636
+ };
2637
+ var NUMBER = {
2638
+ className: 'number', relevance: 0,
2639
+ variants: [
2640
+ {begin: hljs.BINARY_NUMBER_RE + '[lLjJ]?'},
2641
+ {begin: '\\b(0o[0-7]+)[lLjJ]?'},
2642
+ {begin: hljs.C_NUMBER_RE + '[lLjJ]?'}
2643
+ ]
2644
+ };
2645
+ var PARAMS = {
2646
+ className: 'params',
2647
+ begin: /\(/, end: /\)/,
2648
+ contains: ['self', PROMPT, NUMBER, STRING]
2649
+ };
2650
+ return {
2651
+ aliases: ['py', 'gyp'],
2652
+ keywords: {
2653
+ keyword:
2654
+ 'and elif is global as in if from raise for except finally print import pass return ' +
2655
+ 'exec else break not with class assert yield try while continue del or def lambda ' +
2656
+ 'async await nonlocal|10 None True False',
2657
+ built_in:
2658
+ 'Ellipsis NotImplemented'
2659
+ },
2660
+ illegal: /(<\/|->|\?)/,
2661
+ contains: [
2662
+ PROMPT,
2663
+ NUMBER,
2664
+ STRING,
2665
+ hljs.HASH_COMMENT_MODE,
2666
+ {
2667
+ variants: [
2668
+ {className: 'function', beginKeywords: 'def', relevance: 10},
2669
+ {className: 'class', beginKeywords: 'class'}
2670
+ ],
2671
+ end: /:/,
2672
+ illegal: /[${=;\n,]/,
2673
+ contains: [hljs.UNDERSCORE_TITLE_MODE, PARAMS]
2674
+ },
2675
+ {
2676
+ className: 'meta',
2677
+ begin: /^[\t ]*@/, end: /$/
2678
+ },
2679
+ {
2680
+ begin: /\b(print|exec)\(/ // don’t highlight keywords-turned-functions in Python 3
2681
+ }
2682
+ ]
2683
+ };
2684
+ });
2685
+
2686
+ hljs.registerLanguage('ruby', function(hljs) {
2687
+ var RUBY_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?';
2688
+ var RUBY_KEYWORDS =
2689
+ 'and false then defined module in return redo if BEGIN retry end for true self when ' +
2690
+ 'next until do begin unless END rescue nil else break undef not super class case ' +
2691
+ 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor';
2692
+ var YARDOCTAG = {
2693
+ className: 'doctag',
2694
+ begin: '@[A-Za-z]+'
2695
+ };
2696
+ var IRB_OBJECT = {
2697
+ begin: '#<', end: '>'
2698
+ };
2699
+ var COMMENT_MODES = [
2700
+ hljs.COMMENT(
2701
+ '#',
2702
+ '$',
2703
+ {
2704
+ contains: [YARDOCTAG]
2705
+ }
2706
+ ),
2707
+ hljs.COMMENT(
2708
+ '^\\=begin',
2709
+ '^\\=end',
2710
+ {
2711
+ contains: [YARDOCTAG],
2712
+ relevance: 10
2713
+ }
2714
+ ),
2715
+ hljs.COMMENT('^__END__', '\\n$')
2716
+ ];
2717
+ var SUBST = {
2718
+ className: 'subst',
2719
+ begin: '#\\{', end: '}',
2720
+ keywords: RUBY_KEYWORDS
2721
+ };
2722
+ var STRING = {
2723
+ className: 'string',
2724
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
2725
+ variants: [
2726
+ {begin: /'/, end: /'/},
2727
+ {begin: /"/, end: /"/},
2728
+ {begin: /`/, end: /`/},
2729
+ {begin: '%[qQwWx]?\\(', end: '\\)'},
2730
+ {begin: '%[qQwWx]?\\[', end: '\\]'},
2731
+ {begin: '%[qQwWx]?{', end: '}'},
2732
+ {begin: '%[qQwWx]?<', end: '>'},
2733
+ {begin: '%[qQwWx]?/', end: '/'},
2734
+ {begin: '%[qQwWx]?%', end: '%'},
2735
+ {begin: '%[qQwWx]?-', end: '-'},
2736
+ {begin: '%[qQwWx]?\\|', end: '\\|'},
2737
+ {
2738
+ // \B in the beginning suppresses recognition of ?-sequences where ?
2739
+ // is the last character of a preceding identifier, as in: `func?4`
2740
+ begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/
2741
+ }
2742
+ ]
2743
+ };
2744
+ var PARAMS = {
2745
+ className: 'params',
2746
+ begin: '\\(', end: '\\)', endsParent: true,
2747
+ keywords: RUBY_KEYWORDS
2748
+ };
2749
+
2750
+ var RUBY_DEFAULT_CONTAINS = [
2751
+ STRING,
2752
+ IRB_OBJECT,
2753
+ {
2754
+ className: 'class',
2755
+ beginKeywords: 'class module', end: '$|;',
2756
+ illegal: /=/,
2757
+ contains: [
2758
+ hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),
2759
+ {
2760
+ begin: '<\\s*',
2761
+ contains: [{
2762
+ begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE
2763
+ }]
2764
+ }
2765
+ ].concat(COMMENT_MODES)
2766
+ },
2767
+ {
2768
+ className: 'function',
2769
+ beginKeywords: 'def', end: '$|;',
2770
+ contains: [
2771
+ hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),
2772
+ PARAMS
2773
+ ].concat(COMMENT_MODES)
2774
+ },
2775
+ {
2776
+ className: 'symbol',
2777
+ begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',
2778
+ relevance: 0
2779
+ },
2780
+ {
2781
+ className: 'symbol',
2782
+ begin: ':',
2783
+ contains: [STRING, {begin: RUBY_METHOD_RE}],
2784
+ relevance: 0
2785
+ },
2786
+ {
2787
+ className: 'number',
2788
+ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',
2789
+ relevance: 0
2790
+ },
2791
+ {
2792
+ begin: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))' // variables
2793
+ },
2794
+ { // regexp container
2795
+ begin: '(' + hljs.RE_STARTERS_RE + ')\\s*',
2796
+ contains: [
2797
+ IRB_OBJECT,
2798
+ {
2799
+ className: 'regexp',
2800
+ contains: [hljs.BACKSLASH_ESCAPE, SUBST],
2801
+ illegal: /\n/,
2802
+ variants: [
2803
+ {begin: '/', end: '/[a-z]*'},
2804
+ {begin: '%r{', end: '}[a-z]*'},
2805
+ {begin: '%r\\(', end: '\\)[a-z]*'},
2806
+ {begin: '%r!', end: '![a-z]*'},
2807
+ {begin: '%r\\[', end: '\\][a-z]*'}
2808
+ ]
2809
+ }
2810
+ ].concat(COMMENT_MODES),
2811
+ relevance: 0
2812
+ }
2813
+ ].concat(COMMENT_MODES);
2814
+
2815
+ SUBST.contains = RUBY_DEFAULT_CONTAINS;
2816
+ PARAMS.contains = RUBY_DEFAULT_CONTAINS;
2817
+
2818
+ var SIMPLE_PROMPT = "[>?]>";
2819
+ var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>";
2820
+ var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>";
2821
+
2822
+ var IRB_DEFAULT = [
2823
+ {
2824
+ begin: /^\s*=>/,
2825
+ starts: {
2826
+ end: '$', contains: RUBY_DEFAULT_CONTAINS
2827
+ }
2828
+ },
2829
+ {
2830
+ className: 'meta',
2831
+ begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')',
2832
+ starts: {
2833
+ end: '$', contains: RUBY_DEFAULT_CONTAINS
2834
+ }
2835
+ }
2836
+ ];
2837
+
2838
+ return {
2839
+ aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],
2840
+ keywords: RUBY_KEYWORDS,
2841
+ illegal: /\/\*/,
2842
+ contains: COMMENT_MODES.concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS)
2843
+ };
2844
+ });
2845
+
2846
+ hljs.registerLanguage('sql', function(hljs) {
2847
+ var COMMENT_MODE = hljs.COMMENT('--', '$');
2848
+ return {
2849
+ case_insensitive: true,
2850
+ illegal: /[<>{}*]/,
2851
+ contains: [
2852
+ {
2853
+ beginKeywords:
2854
+ 'begin end start commit rollback savepoint lock alter create drop rename call ' +
2855
+ 'delete do handler insert load replace select truncate update set show pragma grant ' +
2856
+ 'merge describe use explain help declare prepare execute deallocate release ' +
2857
+ 'unlock purge reset change stop analyze cache flush optimize repair kill ' +
2858
+ 'install uninstall checksum restore check backup revoke',
2859
+ end: /;/, endsWithParent: true,
2860
+ keywords: {
2861
+ keyword:
2862
+ 'abort abs absolute acc acce accep accept access accessed accessible account acos action activate add ' +
2863
+ 'addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias ' +
2864
+ 'allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply ' +
2865
+ 'archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan ' +
2866
+ 'atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid ' +
2867
+ 'authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile ' +
2868
+ 'before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float ' +
2869
+ 'binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound ' +
2870
+ 'buffer_cache buffer_pool build bulk by byte byteordermark bytes c cache caching call calling cancel ' +
2871
+ 'capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base ' +
2872
+ 'char_length character_length characters characterset charindex charset charsetform charsetid check ' +
2873
+ 'checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close ' +
2874
+ 'cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation ' +
2875
+ 'collect colu colum column column_value columns columns_updated comment commit compact compatibility ' +
2876
+ 'compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn ' +
2877
+ 'connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection ' +
2878
+ 'consider consistent constant constraint constraints constructor container content contents context ' +
2879
+ 'contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost ' +
2880
+ 'count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation ' +
2881
+ 'critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user ' +
2882
+ 'cursor curtime customdatum cycle d data database databases datafile datafiles datalength date_add ' +
2883
+ 'date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts ' +
2884
+ 'day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate ' +
2885
+ 'declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults ' +
2886
+ 'deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank ' +
2887
+ 'depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor ' +
2888
+ 'deterministic diagnostics difference dimension direct_load directory disable disable_all ' +
2889
+ 'disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div ' +
2890
+ 'do document domain dotnet double downgrade drop dumpfile duplicate duration e each edition editionable ' +
2891
+ 'editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt ' +
2892
+ 'end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors ' +
2893
+ 'escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding ' +
2894
+ 'execu execut execute exempt exists exit exp expire explain export export_set extended extent external ' +
2895
+ 'external_1 external_2 externally extract f failed failed_login_attempts failover failure far fast ' +
2896
+ 'feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final ' +
2897
+ 'finish first first_value fixed flash_cache flashback floor flush following follows for forall force ' +
2898
+ 'form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ' +
2899
+ 'ftp full function g general generated get get_format get_lock getdate getutcdate global global_name ' +
2900
+ 'globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups ' +
2901
+ 'gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex ' +
2902
+ 'hierarchy high high_priority hosts hour http i id ident_current ident_incr ident_seed identified ' +
2903
+ 'identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment ' +
2904
+ 'index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile ' +
2905
+ 'initial initialized initially initrans inmemory inner innodb input insert install instance instantiable ' +
2906
+ 'instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat ' +
2907
+ 'is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists ' +
2908
+ 'k keep keep_duplicates key keys kill l language large last last_day last_insert_id last_value lax lcase ' +
2909
+ 'lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit ' +
2910
+ 'lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate ' +
2911
+ 'locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call ' +
2912
+ 'logoff logon logs long loop low low_priority lower lpad lrtrim ltrim m main make_set makedate maketime ' +
2913
+ 'managed management manual map mapping mask master master_pos_wait match matched materialized max ' +
2914
+ 'maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans ' +
2915
+ 'md5 measures median medium member memcompress memory merge microsecond mid migration min minextents ' +
2916
+ 'minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month ' +
2917
+ 'months mount move movement multiset mutex n name name_const names nan national native natural nav nchar ' +
2918
+ 'nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile ' +
2919
+ 'nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile ' +
2920
+ 'nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder ' +
2921
+ 'nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck ' +
2922
+ 'noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe ' +
2923
+ 'nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ' +
2924
+ 'ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old ' +
2925
+ 'on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date ' +
2926
+ 'oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary ' +
2927
+ 'out outer outfile outline output over overflow overriding p package pad parallel parallel_enable ' +
2928
+ 'parameters parent parse partial partition partitions pascal passing password password_grace_time ' +
2929
+ 'password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex ' +
2930
+ 'pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc ' +
2931
+ 'performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin ' +
2932
+ 'policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction ' +
2933
+ 'prediction_cost prediction_details prediction_probability prediction_set prepare present preserve ' +
2934
+ 'prior priority private private_sga privileges procedural procedure procedure_analyze processlist ' +
2935
+ 'profiles project prompt protection public publishingservername purge quarter query quick quiesce quota ' +
2936
+ 'quotename radians raise rand range rank raw read reads readsize rebuild record records ' +
2937
+ 'recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh ' +
2938
+ 'regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy ' +
2939
+ 'reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename ' +
2940
+ 'repair repeat replace replicate replication required reset resetlogs resize resource respect restore ' +
2941
+ 'restricted result result_cache resumable resume retention return returning returns reuse reverse revoke ' +
2942
+ 'right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows ' +
2943
+ 'rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll ' +
2944
+ 'sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select ' +
2945
+ 'self sequence sequential serializable server servererror session session_user sessions_per_user set ' +
2946
+ 'sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor ' +
2947
+ 'si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin ' +
2948
+ 'size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex ' +
2949
+ 'source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows ' +
2950
+ 'sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone ' +
2951
+ 'standby start starting startup statement static statistics stats_binomial_test stats_crosstab ' +
2952
+ 'stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep ' +
2953
+ 'stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev ' +
2954
+ 'stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate ' +
2955
+ 'subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum ' +
2956
+ 'suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate ' +
2957
+ 'sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime t table tables tablespace tan tdo ' +
2958
+ 'template temporary terminated tertiary_weights test than then thread through tier ties time time_format ' +
2959
+ 'time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr ' +
2960
+ 'timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking ' +
2961
+ 'transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate ' +
2962
+ 'try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress ' +
2963
+ 'under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot ' +
2964
+ 'unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert ' +
2965
+ 'url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date ' +
2966
+ 'utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var ' +
2967
+ 'var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray ' +
2968
+ 'verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear ' +
2969
+ 'wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped ' +
2970
+ 'xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces ' +
2971
+ 'xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek',
2972
+ literal:
2973
+ 'true false null',
2974
+ built_in:
2975
+ 'array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number ' +
2976
+ 'numeric real record serial serial8 smallint text varchar varying void'
2977
+ },
2978
+ contains: [
2979
+ {
2980
+ className: 'string',
2981
+ begin: '\'', end: '\'',
2982
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
2983
+ },
2984
+ {
2985
+ className: 'string',
2986
+ begin: '"', end: '"',
2987
+ contains: [hljs.BACKSLASH_ESCAPE, {begin: '""'}]
2988
+ },
2989
+ {
2990
+ className: 'string',
2991
+ begin: '`', end: '`',
2992
+ contains: [hljs.BACKSLASH_ESCAPE]
2993
+ },
2994
+ hljs.C_NUMBER_MODE,
2995
+ hljs.C_BLOCK_COMMENT_MODE,
2996
+ COMMENT_MODE
2997
+ ]
2998
+ },
2999
+ hljs.C_BLOCK_COMMENT_MODE,
3000
+ COMMENT_MODE
3001
+ ]
3002
+ };
3003
+ });
3004
+
3005
+ return hljs;
3006
+ }));