├── VERSION_PREFIX ├── .gitignore ├── bin ├── repl ├── docs ├── roundtrip ├── make_deps_js ├── test ├── build_jar ├── prelude ├── build ├── build_release ├── convert_json8k.js ├── convert.js ├── repl.js ├── read_write.js ├── convert_json.js ├── build_release_bench ├── build_dev_bench ├── build_dev_node ├── build_release_node ├── build_dev_browser ├── build_release_browser ├── build_dev_browser_amd ├── build_release_browser_amd ├── deps └── closure_deps_graph.clj ├── doctheme ├── partials │ ├── index.handlebars │ ├── files.handlebars │ ├── props.handlebars │ ├── module.handlebars │ ├── events.handlebars │ ├── attrs.handlebars │ ├── classes.handlebars │ ├── sidebar.handlebars │ └── method.handlebars ├── assets │ ├── css │ │ ├── logo.png │ │ ├── cognitect.jpg │ │ ├── external-small.png │ │ └── main.css │ ├── js │ │ ├── yui-prettify.js │ │ └── tabs.js │ └── vendor │ │ └── prettify │ │ ├── prettify-min.css │ │ ├── CHANGES.html │ │ ├── README.html │ │ ├── COPYING │ │ └── prettify-min.js ├── theme.json └── layouts │ └── main.handlebars ├── yuidoc.json ├── resources ├── bench.html ├── externs.js ├── index.html ├── test.html ├── prelude.txt ├── amd_externs.js ├── node_externs.js ├── example.tjs └── example.json ├── .github └── workflows │ └── test.yaml ├── src └── com │ └── cognitect │ ├── transit_amd.js │ └── transit │ ├── delimiters.js │ ├── impl │ ├── reader.js │ └── decoder.js │ ├── caching.js │ ├── util.js │ ├── eq.js │ └── handlers.js ├── package.json ├── SECURITY.md ├── bench ├── bson_compare.js ├── json.js ├── mapset.js └── bench.js ├── Gruntfile.js ├── pom.xml ├── README.md └── LICENSE /VERSION_PREFIX: -------------------------------------------------------------------------------- 1 | 0.8 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | docs 2 | deps 3 | node_modules 4 | target 5 | .idea -------------------------------------------------------------------------------- /bin/repl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ./bin/make_deps_js 3 | ./bin/repl.js -------------------------------------------------------------------------------- /doctheme/partials/index.handlebars: -------------------------------------------------------------------------------- 1 |
4 | {{fileData}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/bin/make_deps_js:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | java -cp deps/closure-compiler/compiler.jar:deps/clojure/clojure-1.6.0.jar clojure.main -i bin/closure_deps_graph.clj
--------------------------------------------------------------------------------
/bin/test:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd `dirname $0`/..
6 |
7 | bin/make_deps_js
8 | bin/build_dev_node
9 | node_modules/.bin/grunt nodeunit
10 |
--------------------------------------------------------------------------------
/bin/build_jar:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd src
6 |
7 | jar cf transit.jar com
8 |
9 | mkdir -p ../target
10 |
11 | mv transit.jar ../target/
12 |
--------------------------------------------------------------------------------
/bin/prelude:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | prefix=`cat VERSION_PREFIX`
6 | suffix=`build/revision`
7 | version=$prefix.$suffix
8 |
9 | sed "s/\$VERSION/$version/g" resources/prelude.txt
10 |
--------------------------------------------------------------------------------
/doctheme/theme.json:
--------------------------------------------------------------------------------
1 | {
2 | "yuiGridsUrl": "http://yui.yahooapis.com/3.8.0pr2/build/cssgrids/cssgrids-min.css",
3 | "yuiSeedUrl": "http://yui.yahooapis.com/combo?3.8.0pr2/build/yui/yui-min.js"
4 | }
5 |
--------------------------------------------------------------------------------
/yuidoc.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "transit-js",
3 | "description": "A JavaScript implementation of the Transit format",
4 | "version": "0.8.812",
5 | "url": "http://github.com/cognitect/transit-js",
6 | "options": {
7 | "outdir": "docs"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/bin/build:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | cd `dirname $0`/..
6 |
7 | java -jar deps/closure-compiler/compiler.jar -O WHITESPACE_ONLY \
8 | --dependency_mode=PRUNE --entry_point=com.cognitect.transit \
9 | --js_output_file=target/transit.js \
10 | 'deps/closure-library/closure/**.js' 'src/**.js'
11 |
--------------------------------------------------------------------------------
/resources/bench.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This module has the following classes:
9 |This module has the following submodules:
19 |{{{description}}}
{{title}}Fires when the value for the configuration attribute `{{name}}` is changed. You can listen for the event using the `on` method if you wish to be notified before the attribute's value has changed, or using the `after` method if you wish to be notified after the attribute's value has changed.
13 | Parameters:final {{/if}}`{{name}}`( `{{paramsList}} ` ) {{#if access}}`/* {{access}} method */`{{/if}}
4 | <code> elements with newlines in the text
15 | which use CSS to specify white-space:pre will have the newlines
16 | improperly stripped if the element is not attached to the document at the time
17 | the stripping is done. Also, on IE 6, all newlines will be stripped from
18 | <code> elements because of the way IE6 produces
19 | innerHTML. Workaround: use <pre> for code with
20 | newlines.
21 | prettyPrintOne was not halting. This was not
33 | reachable through the normal entry point.
34 | 45 |49 | is no longer applicable. 50 |Caveats: please properly escape less-thans. x<y 46 | instead of x<y, and use " instead of 47 | " for string delimiters.
48 |
lang-<language-file-extension>'''string'''
61 | / in regex [charsets] should not end regex
62 | nocode spans to allow embedding of line
71 | numbers and code annotations which should not be styled or otherwise
72 | affect the tokenization of prettified code.
73 | See the issue 22
74 | testcase.
75 | <code> blocks with embedded newlines.
104 |   instead of
124 | so that the output works when embedded in XML.
125 | Bug
126 | 108.29 | <link href="prettify.css" type="text/css" rel="stylesheet" /> 30 | <script type="text/javascript" src="prettify.js"></script>31 |
onload="prettyPrint()" to your
32 | document's body tag.
33 | Put code snippets in 38 | <pre class="prettyprint">...</pre> 39 | or <code class="prettyprint">...</code> 40 | and it will automatically be pretty printed. 41 | 42 |
| The original 45 | | Prettier 46 | |
|---|---|
class Voila { 49 | public: 50 | // Voila 51 | static const string VOILA = "Voila"; 52 | 53 | // will not interfere with embedded tags. 54 | }55 | 56 | | class Voila { 57 | public: 58 | // Voila 59 | static const string VOILA = "Voila"; 60 | 61 | // will not interfere with embedded tags. 62 | }63 | |
The comments in prettify.js are authoritative but the lexer 68 | should work on a number of languages including C and friends, 69 | Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. 70 | It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl 71 | and Ruby, but, because of commenting conventions, doesn't work on 72 | Smalltalk, or CAML-like languages.
73 | 74 |LISPy languages are supported via an extension:
75 | lang-lisp.js.
And similarly for
78 | CSS,
80 | Haskell,
82 | Lua,
84 | OCAML, SML, F#,
86 | Visual Basic,
88 | SQL,
90 | Protocol Buffers, and
92 | WikiText..
94 |
95 |
If you'd like to add an extension for your favorite language, please 96 | look at src/lang-lisp.js and file an 97 | issue including your language extension, and a testcase.
99 | 100 |You don't need to specify the language since prettyprint()
102 | will guess. You can specify a language by specifying the language extension
103 | along with the prettyprint class like so:
<pre class="prettyprint lang-html"> 106 | The lang-* class specifies the language file extensions. 107 | File extensions supported by default include 108 | "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", 109 | "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", 110 | "xhtml", "xml", "xsl". 111 | </pre>112 | 113 |
Yes. Prettifying obfuscated code is like putting lipstick on a pig 115 | — i.e. outside the scope of this tool.
116 | 117 |It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. 119 | Look at the test page to see if it 120 | works in your browser.
121 | 122 |See the change log
124 | 125 |Apparently wordpress does "smart quoting" which changes close quotes. 127 | This causes end quotes to not match up with open quotes. 128 |
This breaks prettifying as well as copying and pasting of code samples. 129 | See 130 | WordPress's help center for info on how to stop smart quoting of code 132 | snippets.
133 | 134 |You can use the linenums class to turn on line
136 | numbering. If your code doesn't start at line number 1, you can
137 | add a colon and a line number to the end of that class as in
138 | linenums:52.
139 |
140 |
For example 141 |
<pre class="prettyprint linenums:4" 142 | >// This is line 4. 143 | foo(); 144 | bar(); 145 | baz(); 146 | boo(); 147 | far(); 148 | faz(); 149 | <pre>150 | produces 151 |
// This is line 4. 153 | foo(); 154 | bar(); 155 | baz(); 156 | boo(); 157 | far(); 158 | faz(); 159 |160 | 161 |
You can use the nocode class to identify a span of markup
163 | that is not code.
164 |
<pre class=prettyprint> 165 | int x = foo(); /* This is a comment <span class="nocode">This is not code</span> 166 | Continuation of comment */ 167 | int y = bar(); 168 | </pre>169 | produces 170 |
171 | int x = foo(); /* This is a comment This is not code
172 | Continuation of comment */
173 | int y = bar();
174 |
175 |
176 | For a more complete example see the issue22 177 | testcase.
178 | 179 |If you are calling prettyPrint via an event handler, wrap it in a function.
181 | Instead of doing
182 |
183 | addEventListener('load', prettyPrint, false);
185 |
186 | wrap it in a closure like
187 |
188 | addEventListener('load', function (event) { prettyPrint() }, false);
190 |
191 | so that the browser does not pass an event object to prettyPrint which
192 | will confuse it.
193 |
194 | // elements inside
131 | blocks. */
132 | pre code, pre kbd, pre samp { font-size: 100%; }
133 |
134 | /* Used to denote text that shouldn't be selectable, such as line numbers or
135 | shell prompts. Guess which browser this doesn't work in. */
136 | .noselect {
137 | -moz-user-select: -moz-none;
138 | -khtml-user-select: none;
139 | -webkit-user-select: none;
140 | -o-user-select: none;
141 | user-select: none;
142 | }
143 |
144 | /* -- Lists ----------------------------------------------------------------- */
145 | dd { margin: 0.2em 0 0.7em 1em; }
146 | dl { margin: 1em 0; }
147 | dt { font-weight: bold; }
148 |
149 | /* -- Tables ---------------------------------------------------------------- */
150 | caption, th { text-align: left; }
151 |
152 | table {
153 | border-collapse: collapse;
154 | width: 100%;
155 | }
156 |
157 | td, th {
158 | border: 1px solid #fff;
159 | padding: 5px 12px;
160 | vertical-align: top;
161 | }
162 |
163 | td { background: #E6E9F5; }
164 | td dl { margin: 0; }
165 | td dl dl { margin: 1em 0; }
166 | td pre:first-child { margin-top: 0; }
167 |
168 | th {
169 | background: #D2D7E6;/*#97A0BF*/
170 | border-bottom: none;
171 | border-top: none;
172 | color: #000;/*#FFF1D5*/
173 | font-family: 'Trebuchet MS', sans-serif;
174 | font-weight: bold;
175 | line-height: 1.3;
176 | white-space: nowrap;
177 | }
178 |
179 |
180 | /* -- Layout and Content ---------------------------------------------------- */
181 | #doc {
182 | margin: auto;
183 | min-width: 1024px;
184 | }
185 |
186 | #main { width: 754px; }
187 | #sidebar { width: 270px; margin: 0 15px; }
188 |
189 | .content { padding: 0 20px 0 25px; }
190 |
191 | /* -- Sidebar --------------------------------------------------------------- */
192 | .sidebox {
193 | background: #F9F9FC;/*E6E9F5*/
194 | border: 1px solid #D4D8EB;
195 |
196 | -moz-border-radius: 4px;
197 | -webkit-border-radius: 4px;
198 | border-radius: 4px;
199 | -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
200 | -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
201 | box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
202 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Helvetica', 'Arial', sans-serif;
203 | margin: 0 0 15px 0;
204 | padding-bottom: 1px;
205 | }
206 |
207 | .sidebox h2 {
208 | background: #E5E6F1;
209 | -moz-border-radius: 4px 4px 0 0;
210 | -webkit-border-radius: 4px 4px 0 0;
211 | border-radius: 4px 4px 0 0;
212 | color: #5E6BA4;
213 | font-weight: bold;
214 | font-size: 107.692%;
215 | margin: 0;
216 | padding: 4px 7px 5px;
217 | }
218 |
219 | .sidebox .bd {
220 | font-size: 84.615%;
221 | padding: 0 5px 0 8px;
222 | }
223 |
224 | .sidebox li { list-style-type: disc; color:#D4D5E3; }
225 |
226 | .sidebox ol, .sidebox ul {
227 | margin-left: 0;
228 | padding-left: 16px;
229 | }
230 |
231 | .sidebox ol ol, .sidebox ol ul,
232 | .sidebox ul ol, .sidebox ul ul {
233 | margin: 0;
234 | padding-left: 16px;
235 | }
236 |
237 | /* -- Table of Contents ----------------------------------------------------- */
238 |
239 | /* The #toc id refers to the single global table of contents, while the .toc
240 | class refers to generic TOC lists that could be used throughout the page. */
241 |
242 | .toc code, .toc kbd, .toc samp { font-size: 100%; }
243 | .toc li { font-weight: bold; }
244 | .toc li li { font-weight: normal; }
245 |
246 | /* -- Intro and Example Boxes ----------------------------------------------- */
247 | .intro, .example { margin-bottom: 2em; }
248 |
249 | .example {
250 | -moz-border-radius: 4px;
251 | -webkit-border-radius: 4px;
252 | border-radius: 4px;
253 | -moz-box-shadow: 0 0 5px #bfbfbf;
254 | -webkit-box-shadow: 0 0 5px #bfbfbf;
255 | box-shadow: 0 0 5px #bfbfbf;
256 | padding: 1em;
257 | }
258 |
259 | .intro {
260 | background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
261 | }
262 |
263 | /* -- Other Styles ---------------------------------------------------------- */
264 |
265 | /* These are probably YUI-specific, and should be moved out of Selleck's default
266 | theme. */
267 |
268 | .button {
269 | border: 1px solid #dadada;
270 | -moz-border-radius: 3px;
271 | -webkit-border-radius: 3px;
272 | border-radius: 3px;
273 | color: #444;
274 | display: inline-block;
275 | font-family: Helvetica, Arial, sans-serif;
276 | font-size: 92.308%;
277 | font-weight: bold;
278 | padding: 4px 13px 3px;
279 | -moz-text-shadow: 1px 1px 0 #fff;
280 | -webkit-text-shadow: 1px 1px 0 #fff;
281 | text-shadow: 1px 1px 0 #fff;
282 | white-space: nowrap;
283 |
284 | background: #EFEFEF; /* old browsers */
285 | background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
286 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
287 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
288 | }
289 |
290 | .button:hover {
291 | border-color: #466899;
292 | color: #fff;
293 | text-decoration: none;
294 | -moz-text-shadow: 1px 1px 0 #222;
295 | -webkit-text-shadow: 1px 1px 0 #222;
296 | text-shadow: 1px 1px 0 #222;
297 |
298 | background: #6396D8; /* old browsers */
299 | background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
300 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
301 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
302 | }
303 |
304 | .newwindow { text-align: center; }
305 |
306 | .header .version em {
307 | display: block;
308 | text-align: right;
309 | }
310 |
311 | .yui3-skin-sam #classdocs .yui3-tabview-panel {
312 | background-color: transparent;
313 | }
314 |
315 | .yui3-skin-sam #classdocs .yui3-tabview-panel {
316 | border: none;
317 | }
318 |
319 | .yui3-skin-sam .yui3-tabview .yui3-tab,
320 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected,
321 | .yui3-skin-sam .yui3-tabview .yui3-tab-hover {
322 | background: -moz-linear-gradient(center top , #F4F0EC 0%, #D6D2CE 100%) repeat scroll 0 0 transparent;
323 | border-bottom: 1px solid #DEDCD9;
324 | border-right: 1px solid #CDCBC8;
325 | border-left: 1px solid #CDCBC8;
326 | border-top: 1px solid #DADADA;
327 | color: #333333;
328 | text-decoration: none;
329 | }
330 | .yui3-skin-sam .yui3-tabview .yui3-tab-label,
331 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected .yui3-tab-label {
332 | border: none;
333 | background: none;
334 | font-size: 100%;
335 | color: #000;
336 | }
337 |
338 | .yui3-skin-sam .yui3-tabview .yui3-tab-selected,
339 | .yui3-skin-sam .yui3-tabview .yui3-tab-hover {
340 | background: none;
341 | background-color: #fff;
342 | border-bottom-color: #FFFFFF;
343 | border-top: 2px solid #8193C9;
344 | font-weight: bold;
345 | color: #000;
346 |
347 | }
348 |
349 | .yui3-skin-sam .yui3-tabview-list {
350 | border-color: #DFDFDF;
351 | border-width: 0 0 1px;
352 | }
353 |
354 |
355 | a.external {
356 | background-image: url(external-small.png);
357 | background-repeat: no-repeat;
358 | background-position: 0 0;
359 | padding-left: 16px;
360 | }
361 |
362 | #classdocs .item {
363 | border-bottom: 1px solid #466899;
364 | margin: 1em 0;
365 | padding: 1.5em;
366 | }
367 |
368 | #classdocs .item .params p,
369 | #classdocs .item .returns p,{
370 | display: inline;
371 | }
372 |
373 | #classdocs .item em code, #classdocs .item em.comment {
374 | color: green;
375 | }
376 |
377 | #classdocs .item em.comment a {
378 | color: green;
379 | text-decoration: underline;
380 | }
381 |
382 | #classdocs .foundat {
383 | font-size: 11px;
384 | font-style: normal;
385 | }
386 |
387 | .attrs .emits {
388 | margin-left: 2em;
389 | padding: .5em;
390 | border-left: 1px dashed #ccc;
391 | }
392 |
393 | abbr {
394 | border-bottom: 1px dashed #ccc;
395 | font-size: 80%;
396 | cursor: help;
397 | }
398 |
399 | .prettyprint li.L0,
400 | .prettyprint li.L1,
401 | .prettyprint li.L2,
402 | .prettyprint li.L3,
403 | .prettyprint li.L5,
404 | .prettyprint li.L6,
405 | .prettyprint li.L7,
406 | .prettyprint li.L8 {
407 | list-style: decimal;
408 | }
409 |
410 | ul li p {
411 | margin-top: 0;
412 | }
413 |
414 | .method .name {
415 | font-size: 110%;
416 | }
417 |
418 | #hd {
419 | background: -moz-linear-gradient(center top , #DCDBD9 0%, #F6F5F3 100%) repeat scroll 0 0 transparent;
420 | border-bottom: 1px solid #DFDFDF;
421 | padding: 0 15px 1px 20px;
422 | margin-bottom: 15px;
423 | }
424 |
425 | #hd img {
426 | margin-right: 10px;
427 | vertical-align: middle;
428 | }
429 |
430 |
--------------------------------------------------------------------------------
/src/com/cognitect/transit/impl/decoder.js:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Cognitect. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS-IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | goog.provide("com.cognitect.transit.impl.decoder");
16 | goog.require("com.cognitect.transit.util");
17 | goog.require("com.cognitect.transit.delimiters");
18 | goog.require("com.cognitect.transit.caching");
19 | goog.require("com.cognitect.transit.types");
20 |
21 | goog.scope(function () {
22 |
23 | var decoder = com.cognitect.transit.impl.decoder,
24 | util = com.cognitect.transit.util,
25 | d = com.cognitect.transit.delimiters,
26 | caching = com.cognitect.transit.caching,
27 | types = com.cognitect.transit.types;
28 |
29 | // =========================================================================
30 | // Decoder
31 |
32 | /**
33 | * @constructor
34 | */
35 | decoder.Tag = function Transit$Tag(s) {
36 | this.str = s;
37 | };
38 |
39 | decoder.tag = function (s) {
40 | return new decoder.Tag(s);
41 | };
42 |
43 | decoder.isTag = function (x) {
44 | return x && (x instanceof decoder.Tag);
45 | };
46 |
47 | decoder.isGroundHandler = function (handler) {
48 | switch (handler) {
49 | case "_":
50 | case "s":
51 | case "?":
52 | case "i":
53 | case "d":
54 | case "b":
55 | case "'":
56 | case "array":
57 | case "map":
58 | return true;
59 | }
60 | return false;
61 | };
62 |
63 | /**
64 | * A transit decoder
65 | * @constructor
66 | */
67 | decoder.Decoder = function Transit$Decoder(options) {
68 | this.options = options || {};
69 | this.handlers = {};
70 | for (var h in this.defaults.handlers) {
71 | this.handlers[h] = this.defaults.handlers[h];
72 | }
73 | for (var h in this.options["handlers"]) {
74 | if (decoder.isGroundHandler(h)) {
75 | throw new Error("Cannot override handler for ground type \"" + h + "\"");
76 | }
77 | this.handlers[h] = this.options["handlers"][h];
78 | }
79 | this.preferStrings = this.options["preferStrings"] != null ? this.options["preferStrings"] : this.defaults.preferStrings;
80 | this.preferBuffers = this.options["preferBuffers"] != null ? this.options["preferBuffers"] : this.defaults.preferBuffers;
81 | this.defaultHandler = this.options["defaultHandler"] || this.defaults.defaultHandler;
82 | /* NOT PUBLIC */
83 | this.mapBuilder = this.options["mapBuilder"];
84 | this.arrayBuilder = this.options["arrayBuilder"];
85 | };
86 |
87 |
88 | decoder.Decoder.prototype.defaults = {
89 | handlers: {
90 | "_": function (v, d) {
91 | return types.nullValue();
92 | },
93 | "?": function (v, d) {
94 | return types.boolValue(v);
95 | },
96 | "b": function (v, d) {
97 | return types.binary(v, d);
98 | },
99 | "i": function (v, d) {
100 | return types.intValue(v);
101 | },
102 | "n": function (v, d) {
103 | return types.bigInteger(v);
104 | },
105 | "d": function (v, d) {
106 | return types.floatValue(v);
107 | },
108 | "f": function (v, d) {
109 | return types.bigDecimalValue(v);
110 | },
111 | "c": function (v, d) {
112 | return types.charValue(v);
113 | },
114 | ":": function (v, d) {
115 | return types.keyword(v);
116 | },
117 | "$": function (v, d) {
118 | return types.symbol(v);
119 | },
120 | "r": function (v, d) {
121 | return types.uri(v);
122 | },
123 | "z": function (v, d) {
124 | return types.specialDouble(v);
125 | },
126 |
127 | // tagged
128 | "'": function (v, d) {
129 | return v;
130 | },
131 | "m": function (v, d) {
132 | return types.date(v);
133 | },
134 | "t": function (v, d) {
135 | return types.verboseDate(v);
136 | },
137 | "u": function (v, d) {
138 | return types.uuid(v);
139 | },
140 | "set": function (v, d) {
141 | return types.set(v);
142 | },
143 | "list": function (v, d) {
144 | return types.list(v);
145 | },
146 | "link": function (v, d) {
147 | return types.link(v);
148 | },
149 | "cmap": function (v, d) {
150 | return types.map(v, false);
151 | }
152 | },
153 | defaultHandler: function (c, val) {
154 | return types.taggedValue(c, val);
155 | },
156 | preferStrings: true,
157 | preferBuffers: true
158 | };
159 |
160 | /**
161 | * @param {*} node
162 | * @param {*} cache
163 | * @param {boolean=} asMapKey
164 | * @param {boolean=} tagValue
165 | * @returns {*}
166 | */
167 | decoder.Decoder.prototype.decode = function (node, cache, asMapKey, tagValue) {
168 | if (node == null) return null;
169 |
170 | var t = typeof node;
171 |
172 | switch (t) {
173 | case "string":
174 | return this.decodeString(node, cache, asMapKey, tagValue);
175 | break;
176 | case "object":
177 | if (util.isArray(node)) {
178 | if (node[0] === "^ ") {
179 | return this.decodeArrayHash(node, cache, asMapKey, tagValue);
180 | } else {
181 | return this.decodeArray(node, cache, asMapKey, tagValue);
182 | }
183 | } else {
184 | return this.decodeHash(node, cache, asMapKey, tagValue);
185 | }
186 | break;
187 | }
188 |
189 | return node;
190 | };
191 | decoder.Decoder.prototype["decode"] = decoder.Decoder.prototype.decode;
192 |
193 | decoder.Decoder.prototype.decodeString = function (string, cache, asMapKey, tagValue) {
194 | if (caching.isCacheable(string, asMapKey)) {
195 | var val = this.parseString(string, cache, false);
196 | if (cache) {
197 | cache.write(val, asMapKey);
198 | }
199 | return val;
200 | } else if (caching.isCacheCode(string)) {
201 | return cache.read(string, asMapKey);
202 | } else {
203 | return this.parseString(string, cache, asMapKey);
204 | }
205 | };
206 |
207 | decoder.Decoder.prototype.decodeHash = function (hash, cache, asMapKey, tagValue) {
208 | var ks = util.objectKeys(hash),
209 | key = ks[0],
210 | tag = ks.length == 1 ? this.decode(key, cache, false, false) : null;
211 |
212 | if (decoder.isTag(tag)) {
213 | var val = hash[key],
214 | handler = this.handlers[tag.str];
215 | if (handler != null) {
216 | return handler(this.decode(val, cache, false, true), this);
217 | } else {
218 | return types.taggedValue(tag.str, this.decode(val, cache, false, false));
219 | }
220 | } else if (this.mapBuilder) {
221 | if ((ks.length < (types.SMALL_ARRAY_MAP_THRESHOLD * 2)) && this.mapBuilder.fromArray) {
222 | var nodep = [];
223 | for (var i = 0; i < ks.length; i++) {
224 | var strKey = ks[i];
225 | nodep.push(this.decode(strKey, cache, true, false));
226 | nodep.push(this.decode(hash[strKey], cache, false, false));
227 | }
228 | return this.mapBuilder.fromArray(nodep, hash);
229 | } else {
230 | var ret = this.mapBuilder.init(hash);
231 | for (var i = 0; i < ks.length; i++) {
232 | var strKey = ks[i];
233 | ret = this.mapBuilder.add(ret,
234 | this.decode(strKey, cache, true, false),
235 | this.decode(hash[strKey], cache, false, false),
236 | hash);
237 | }
238 | return this.mapBuilder.finalize(ret, hash);
239 | }
240 | } else {
241 | var nodep = [];
242 |
243 | for (var i = 0; i < ks.length; i++) {
244 | var strKey = ks[i];
245 | nodep.push(this.decode(strKey, cache, true, false));
246 | nodep.push(this.decode(hash[strKey], cache, false, false));
247 | }
248 |
249 | return types.map(nodep, false);
250 | }
251 | };
252 |
253 | decoder.Decoder.prototype.decodeArrayHash = function (node, cache, asMapKey, tagValue) {
254 | if (this.mapBuilder) {
255 | if ((node.length < ((types.SMALL_ARRAY_MAP_THRESHOLD * 2) + 1)) && this.mapBuilder.fromArray) {
256 | var nodep = [];
257 | for (var i = 1; i < node.length; i += 2) {
258 | nodep.push(this.decode(node[i], cache, true, false));
259 | nodep.push(this.decode(node[i + 1], cache, false, false));
260 | }
261 | return this.mapBuilder.fromArray(nodep, node);
262 | } else {
263 | var ret = this.mapBuilder.init(node);
264 | for (var i = 1; i < node.length; i += 2) {
265 | ret = this.mapBuilder.add(ret,
266 | this.decode(node[i], cache, true, false),
267 | this.decode(node[i + 1], cache, false, false),
268 | node)
269 | }
270 | return this.mapBuilder.finalize(ret, node);
271 | }
272 | } else {
273 | var nodep = [];
274 |
275 | // collect keys
276 | for (var i = 1; i < node.length; i += 2) {
277 | nodep.push(this.decode(node[i], cache, true, false));
278 | nodep.push(this.decode(node[i + 1], cache, false, false));
279 | }
280 |
281 | return types.map(nodep, false);
282 | }
283 | };
284 |
285 | decoder.Decoder.prototype.decodeArray = function (node, cache, asMapKey, tagValue) {
286 | if (tagValue) {
287 | var ret = [];
288 | for (var i = 0; i < node.length; i++) {
289 | ret.push(this.decode(node[i], cache, asMapKey, false));
290 | }
291 | return ret;
292 | } else {
293 | var cacheIdx = cache && cache.idx;
294 | // tagged value as 2-array case
295 | if ((node.length === 2) &&
296 | (typeof node[0] === "string")) {
297 | var tag = this.decode(node[0], cache, false, false);
298 | if (decoder.isTag(tag)) {
299 | var val = node[1],
300 | handler = this.handlers[tag.str];
301 | if (handler != null) {
302 | var ret = handler(this.decode(val, cache, asMapKey, true), this);
303 | return ret;
304 | } else {
305 | return types.taggedValue(tag.str, this.decode(val, cache, asMapKey, false))
306 | }
307 | }
308 | }
309 |
310 | // rewind cache
311 | if (cache && (cacheIdx != cache.idx)) {
312 | cache.idx = cacheIdx;
313 | }
314 |
315 | if (this.arrayBuilder) {
316 | // NOTE: hard coded for ClojureScript for now - David
317 | if (node.length <= 32 && this.arrayBuilder.fromArray) {
318 | var arr = [];
319 | for (var i = 0; i < node.length; i++) {
320 | arr.push(this.decode(node[i], cache, asMapKey, false));
321 | }
322 | return this.arrayBuilder.fromArray(arr, node);
323 | } else {
324 | var ret = this.arrayBuilder.init(node);
325 | for (var i = 0; i < node.length; i++) {
326 | ret = this.arrayBuilder.add(ret, this.decode(node[i], cache, asMapKey, false), node);
327 | }
328 | return this.arrayBuilder.finalize(ret, node);
329 | }
330 | } else {
331 | var ret = [];
332 | for (var i = 0; i < node.length; i++) {
333 | ret.push(this.decode(node[i], cache, asMapKey, false));
334 | }
335 | return ret;
336 | }
337 | }
338 | };
339 |
340 | decoder.Decoder.prototype.parseString = function (string, cache, asMapKey) {
341 | if (string.charAt(0) === d.ESC) {
342 | var c = string.charAt(1);
343 | if (c === d.ESC || c === d.SUB || c === d.RES) {
344 | return string.substring(1);
345 | } else if (c === d.TAG) {
346 | return decoder.tag(string.substring(2));
347 | } else {
348 | var handler = this.handlers[c];
349 | if (handler == null) {
350 | return this.defaultHandler(c, string.substring(2));
351 | } else {
352 | return handler(string.substring(2), this);
353 | }
354 | }
355 | } else {
356 | return string;
357 | }
358 | };
359 |
360 | decoder.decoder = function (options) {
361 | return new decoder.Decoder(options);
362 | };
363 |
364 | });
365 |
--------------------------------------------------------------------------------
/src/com/cognitect/transit/handlers.js:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Cognitect. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS-IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | goog.provide("com.cognitect.transit.handlers");
16 | goog.require("com.cognitect.transit.util");
17 | goog.require("com.cognitect.transit.types");
18 | goog.require("goog.math.Long");
19 |
20 | goog.scope(function () {
21 |
22 | var handlers = com.cognitect.transit.handlers,
23 | util = com.cognitect.transit.util,
24 | types = com.cognitect.transit.types,
25 | Long = goog.math.Long;
26 |
27 | handlers.ctorGuid = 0;
28 |
29 | /**
30 | * @const
31 | * @type {string}
32 | */
33 | handlers.ctorGuidProperty = "transit$guid$" + util.randomUUID();
34 |
35 | handlers.typeTag = function (ctor) {
36 | if (ctor == null) {
37 | return "null";
38 | } else if (ctor === String) {
39 | return "string";
40 | } else if (ctor === Boolean) {
41 | return "boolean";
42 | } else if (ctor === Number) {
43 | return "number";
44 | } else if (ctor === Array) {
45 | return "array";
46 | } else if (ctor === Object) {
47 | return "map";
48 | } else {
49 | var tag = ctor[handlers.ctorGuidProperty];
50 | if (tag == null) {
51 | if (typeof Object.defineProperty != "undefined") {
52 | tag = ++handlers.ctorGuid;
53 | Object.defineProperty(ctor, handlers.ctorGuidProperty, {
54 | value: tag,
55 | enumerable: false
56 | });
57 | } else {
58 | ctor[handlers.ctorGuidProperty] = tag = ++handlers.ctorGuid;
59 | }
60 | }
61 | return tag;
62 | }
63 | };
64 |
65 | handlers.constructor = function (x) {
66 | if (x == null) {
67 | return null;
68 | } else {
69 | return x.constructor;
70 | }
71 | };
72 |
73 | handlers.padZeros = function (n, m) {
74 | var s = n.toString();
75 | for (var i = s.length; i < m; i++) {
76 | s = "0" + s;
77 | }
78 | return s;
79 | };
80 |
81 | handlers.stringableKeys = function (m) {
82 | var stringable = false,
83 | ks = util.objectKeys(m);
84 |
85 | for (var i = 0; i < ks.length; i++) {
86 | }
87 |
88 | return true;
89 | };
90 |
91 | /**
92 | * @constructor
93 | */
94 | handlers.NilHandler = function Transit$NilHandler() {
95 | };
96 | handlers.NilHandler.prototype.tag = function (v) {
97 | return "_";
98 | };
99 | handlers.NilHandler.prototype.rep = function (v) {
100 | return null;
101 | };
102 | handlers.NilHandler.prototype.stringRep = function (v) {
103 | return "null";
104 | };
105 |
106 | /**
107 | * @constructor
108 | */
109 | handlers.StringHandler = function Transit$StringHandler() {
110 | };
111 | handlers.StringHandler.prototype.tag = function (v) {
112 | return "s";
113 | };
114 | handlers.StringHandler.prototype.rep = function (v) {
115 | return v;
116 | };
117 | handlers.StringHandler.prototype.stringRep = function (v) {
118 | return v;
119 | };
120 |
121 | /**
122 | * @constructor
123 | */
124 | handlers.NumberHandler = function Transit$NumberHandler() {
125 | };
126 | handlers.NumberHandler.prototype.tag = function (v) {
127 | return "i";
128 | };
129 | handlers.NumberHandler.prototype.rep = function (v) {
130 | return v;
131 | };
132 | handlers.NumberHandler.prototype.stringRep = function (v) {
133 | return v.toString();
134 | };
135 |
136 | /**
137 | * @constructor
138 | */
139 | handlers.IntegerHandler = function Transit$IntegerHandler() {
140 | };
141 | handlers.IntegerHandler.prototype.tag = function (v) {
142 | return "i";
143 | };
144 | handlers.IntegerHandler.prototype.rep = function (v) {
145 | return v.toString();
146 | };
147 | handlers.IntegerHandler.prototype.stringRep = function (v) {
148 | return v.toString();
149 | };
150 |
151 | /**
152 | * @constructor
153 | */
154 | handlers.BooleanHandler = function Transit$BooleanHandler() {
155 | };
156 | handlers.BooleanHandler.prototype.tag = function (v) {
157 | return "?";
158 | };
159 | handlers.BooleanHandler.prototype.rep = function (v) {
160 | return v;
161 | };
162 | handlers.BooleanHandler.prototype.stringRep = function (v) {
163 | return v.toString();
164 | };
165 |
166 | /**
167 | * @constructor
168 | */
169 | handlers.ArrayHandler = function Transit$ArrayHandler() {
170 | };
171 | handlers.ArrayHandler.prototype.tag = function (v) {
172 | return "array";
173 | };
174 | handlers.ArrayHandler.prototype.rep = function (v) {
175 | return v;
176 | };
177 | handlers.ArrayHandler.prototype.stringRep = function (v) {
178 | return null;
179 | };
180 |
181 | /**
182 | * @constructor
183 | */
184 | handlers.MapHandler = function Transit$MapHandler() {
185 | };
186 | handlers.MapHandler.prototype.tag = function (v) {
187 | return "map";
188 | };
189 | handlers.MapHandler.prototype.rep = function (v) {
190 | return v;
191 | };
192 | handlers.MapHandler.prototype.stringRep = function (v) {
193 | return null;
194 | };
195 |
196 | /**
197 | * @constructor
198 | */
199 | handlers.VerboseDateHandler = function Transit$VerboseDateHandler() {
200 | };
201 | handlers.VerboseDateHandler.prototype.tag = function (v) {
202 | return "t";
203 | };
204 | handlers.VerboseDateHandler.prototype.rep = function (v) {
205 | return v.getUTCFullYear() + "-" + handlers.padZeros(v.getUTCMonth() + 1, 2) + "-" +
206 | handlers.padZeros(v.getUTCDate(), 2) + "T" + handlers.padZeros(v.getUTCHours(), 2) + ":" +
207 | handlers.padZeros(v.getUTCMinutes(), 2) + ":" + handlers.padZeros(v.getUTCSeconds(), 2) + "." +
208 | handlers.padZeros(v.getUTCMilliseconds(), 3) + "Z";
209 | };
210 | handlers.VerboseDateHandler.prototype.stringRep = function (v, h) {
211 | return h.rep(v);
212 | };
213 |
214 | /**
215 | * @constructor
216 | */
217 | handlers.DateHandler = function Transit$DateHandler() {
218 | };
219 | handlers.DateHandler.prototype.tag = function (v) {
220 | return "m";
221 | };
222 | handlers.DateHandler.prototype.rep = function (v) {
223 | return v.valueOf();
224 | };
225 | handlers.DateHandler.prototype.stringRep = function (v) {
226 | return v.valueOf().toString();
227 | };
228 | handlers.DateHandler.prototype.getVerboseHandler = function (v) {
229 | return new handlers.VerboseDateHandler();
230 | };
231 |
232 | /**
233 | * @constructor
234 | */
235 | handlers.UUIDHandler = function Transit$UUIDHandler() {
236 | };
237 | handlers.UUIDHandler.prototype.tag = function (v) {
238 | return "u";
239 | };
240 | handlers.UUIDHandler.prototype.rep = function (v) {
241 | return v.toString();
242 | };
243 | handlers.UUIDHandler.prototype.stringRep = function (v) {
244 | return v.toString();
245 | };
246 |
247 | /**
248 | * @constructor
249 | */
250 | handlers.KeywordHandler = function Transit$KeywordHandler() {
251 | };
252 | handlers.KeywordHandler.prototype.tag = function (v) {
253 | return ":";
254 | };
255 | handlers.KeywordHandler.prototype.rep = function (v) {
256 | return v._name;
257 | }; // NOTE: should be fqn
258 | handlers.KeywordHandler.prototype.stringRep = function (v, h) {
259 | return h.rep(v);
260 | };
261 |
262 | /**
263 | * @constructor
264 | */
265 | handlers.SymbolHandler = function Transit$SymbolHandler() {
266 | };
267 | handlers.SymbolHandler.prototype.tag = function (v) {
268 | return "$";
269 | };
270 | handlers.SymbolHandler.prototype.rep = function (v) {
271 | return v._name;
272 | }; // NOTE: should be str
273 | handlers.SymbolHandler.prototype.stringRep = function (v, h) {
274 | return h.rep(v);
275 | };
276 |
277 | /**
278 | * @constructor
279 | */
280 | handlers.TaggedHandler = function Transit$TaggedHandler() {
281 | };
282 | handlers.TaggedHandler.prototype.tag = function (v) {
283 | return v.tag;
284 | };
285 | handlers.TaggedHandler.prototype.rep = function (v) {
286 | return v.rep;
287 | };
288 | handlers.TaggedHandler.prototype.stringRep = function (v, h) {
289 | return null;
290 | };
291 |
292 | /**
293 | * @constructor
294 | */
295 | handlers.TransitSetHandler = function Transit$TransitSetHandler() {
296 | };
297 | handlers.TransitSetHandler.prototype.tag = function (v) {
298 | return "set";
299 | };
300 | handlers.TransitSetHandler.prototype.rep = function (v) {
301 | var arr = [];
302 | v.forEach(function (key, set) {
303 | arr.push(key);
304 | });
305 | return types.taggedValue("array", arr);
306 | };
307 | handlers.TransitSetHandler.prototype.stringRep = function (v, h) {
308 | return null;
309 | };
310 |
311 | /**
312 | * @constructor
313 | */
314 | handlers.TransitArrayMapHandler = function Transit$ArrayMapHandler() {
315 | };
316 | handlers.TransitArrayMapHandler.prototype.tag = function (v) {
317 | return "map";
318 | };
319 | handlers.TransitArrayMapHandler.prototype.rep = function (v) {
320 | return v;
321 | };
322 | handlers.TransitArrayMapHandler.prototype.stringRep = function (v, h) {
323 | return null;
324 | };
325 |
326 | /**
327 | * @constructor
328 | */
329 | handlers.TransitMapHandler = function Transit$MapHandler() {
330 | };
331 | handlers.TransitMapHandler.prototype.tag = function (v) {
332 | return "map";
333 | };
334 | handlers.TransitMapHandler.prototype.rep = function (v) {
335 | return v;
336 | };
337 | handlers.TransitMapHandler.prototype.stringRep = function (v, h) {
338 | return null;
339 | };
340 |
341 | /**
342 | * @constructor
343 | */
344 | handlers.BufferHandler = function Transit$BufferHandler() {
345 | };
346 | handlers.BufferHandler.prototype.tag = function (v) {
347 | return "b";
348 | };
349 | handlers.BufferHandler.prototype.rep = function (v) {
350 | return v.toString("base64");
351 | };
352 | handlers.BufferHandler.prototype.stringRep = function (v, h) {
353 | return null;
354 | };
355 |
356 | /**
357 | * @constructor
358 | */
359 | handlers.Uint8ArrayHandler = function Transit$Uint8ArrayHandler() {
360 | };
361 | handlers.Uint8ArrayHandler.prototype.tag = function (v) {
362 | return "b";
363 | };
364 | handlers.Uint8ArrayHandler.prototype.rep = function (v) {
365 | return util.Uint8ToBase64(v);
366 | };
367 | handlers.Uint8ArrayHandler.prototype.stringRep = function (v, h) {
368 | return null;
369 | };
370 |
371 | handlers.defaultHandlers = function (hs) {
372 | hs.set(null, new handlers.NilHandler());
373 | hs.set(String, new handlers.StringHandler());
374 | hs.set(Number, new handlers.NumberHandler());
375 | hs.set(Long, new handlers.IntegerHandler());
376 | hs.set(Boolean, new handlers.BooleanHandler());
377 | hs.set(Array, new handlers.ArrayHandler());
378 | hs.set(Object, new handlers.MapHandler());
379 | hs.set(Date, new handlers.DateHandler());
380 | hs.set(types.UUID, new handlers.UUIDHandler());
381 | hs.set(types.Keyword, new handlers.KeywordHandler());
382 | hs.set(types.Symbol, new handlers.SymbolHandler());
383 | hs.set(types.TaggedValue, new handlers.TaggedHandler());
384 | hs.set(types.TransitSet, new handlers.TransitSetHandler());
385 | hs.set(types.TransitArrayMap, new handlers.TransitArrayMapHandler());
386 | hs.set(types.TransitMap, new handlers.TransitMapHandler());
387 |
388 | if (typeof goog.global.Buffer != "undefined") {
389 | hs.set(goog.global.Buffer, new handlers.BufferHandler());
390 | }
391 |
392 | if (typeof Uint8Array != "undefined") {
393 | hs.set(Uint8Array, new handlers.Uint8ArrayHandler());
394 | }
395 |
396 | return hs;
397 | };
398 |
399 | /**
400 | * @constructor
401 | */
402 | handlers.Handlers = function Transit$Handlers() {
403 | this.handlers = {};
404 | handlers.defaultHandlers(this);
405 | };
406 |
407 | handlers.Handlers.prototype.get = function (ctor) {
408 | var h = null;
409 | if (typeof ctor === "string") {
410 | h = this.handlers[ctor];
411 | } else {
412 | h = this.handlers[handlers.typeTag(ctor)];
413 | }
414 | if (h != null) {
415 | return h;
416 | } else {
417 | return this.handlers["default"];
418 | }
419 | };
420 | handlers.Handlers.prototype["get"] = handlers.Handlers.prototype.get;
421 |
422 | handlers.validTag = function (tag) {
423 | switch (tag) {
424 | case "null":
425 | case "string":
426 | case "boolean":
427 | case "number":
428 | case "array":
429 | case "map":
430 | return false;
431 | break;
432 | }
433 | return true;
434 | };
435 |
436 | handlers.Handlers.prototype.set = function (ctor, handler) {
437 | if (typeof ctor === "string" && handlers.validTag(ctor)) {
438 | this.handlers[ctor] = handler;
439 | } else {
440 | this.handlers[handlers.typeTag(ctor)] = handler;
441 | }
442 | };
443 |
444 | });
445 |
--------------------------------------------------------------------------------
/doctheme/assets/vendor/prettify/prettify-min.js:
--------------------------------------------------------------------------------
1 | window.PR_SHOULD_USE_CONTINUATION=true;var prettyPrintOne;var prettyPrint;(function(){var O=window;var j=["break,continue,do,else,for,if,return,while"];var v=[j,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var q=[v,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var m=[q,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var y=[q,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var T=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"];var s="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes";var x=[q,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var t="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var J=[j,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var g=[j,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var I=[j,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var B=[m,T,x,t+J,g,I];var f=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var D="str";var A="kwd";var k="com";var Q="typ";var H="lit";var M="pun";var G="pln";var n="tag";var F="dec";var K="src";var R="atn";var o="atv";var P="nocode";var N="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function l(ab){var af=0;var U=false;var ae=false;for(var X=0,W=ab.length;X122)){if(!(am<65||ai>90)){ah.push([Math.max(65,ai)|32,Math.min(am,90)|32])}if(!(am<97||ai>122)){ah.push([Math.max(97,ai)&~32,Math.min(am,122)&~32])}}}}ah.sort(function(aw,av){return(aw[0]-av[0])||(av[1]-aw[1])});var ak=[];var aq=[];for(var at=0;atau[0]){if(au[1]+1>au[0]){ao.push("-")}ao.push(V(au[1]))}}ao.push("]");return ao.join("")}function Y(an){var al=an.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var aj=al.length;var ap=[];for(var am=0,ao=0;am=2&&ak==="["){al[am]=Z(ai)}else{if(ak!=="\\"){al[am]=ai.replace(/[a-zA-Z]/g,function(aq){var ar=aq.charCodeAt(0);return"["+String.fromCharCode(ar&~32,ar|32)+"]"})}}}}return al.join("")}var ac=[];for(var X=0,W=ab.length;X=0;){U[ae.charAt(ag)]=aa}}var ah=aa[1];var ac=""+ah;if(!ai.hasOwnProperty(ac)){aj.push(ah);ai[ac]=null}}aj.push(/[\0-\uffff]/);X=l(aj)})();var Z=V.length;var Y=function(aj){var ab=aj.sourceCode,aa=aj.basePos;var af=[aa,G];var ah=0;var ap=ab.match(X)||[];var al={};for(var ag=0,at=ap.length;ag=5&&"lang-"===ar.substring(0,5);if(ao&&!(ak&&typeof ak[1]==="string")){ao=false;ar=K}if(!ao){al[ai]=ar}}var ad=ah;ah+=ai.length;if(!ao){af.push(aa+ad,ar)}else{var an=ak[1];var am=ai.indexOf(an);var ae=am+an.length;if(ak[2]){ae=ai.length-ak[2].length;am=ae-an.length}var au=ar.substring(5);C(aa+ad,ai.substring(0,am),Y,af);C(aa+ad+am,an,r(au,an),af);C(aa+ad+ae,ai.substring(ae),Y,af)}}aj.decorations=af};return Y}function i(V){var Y=[],U=[];if(V.tripleQuotedStrings){Y.push([D,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(V.multiLineStrings){Y.push([D,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{Y.push([D,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(V.verbatimStrings){U.push([D,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var ab=V.hashComments;if(ab){if(V.cStyleComments){if(ab>1){Y.push([k,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{Y.push([k,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}U.push([D,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])}else{Y.push([k,/^#[^\r\n]*/,null,"#"])}}if(V.cStyleComments){U.push([k,/^\/\/[^\r\n]*/,null]);U.push([k,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(V.regexLiterals){var aa=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");U.push(["lang-regex",new RegExp("^"+N+"("+aa+")")])}var X=V.types;if(X){U.push([Q,X])}var W=(""+V.keywords).replace(/^ | $/g,"");if(W.length){U.push([A,new RegExp("^(?:"+W.replace(/[\s,]+/g,"|")+")\\b"),null])}Y.push([G,/^\s+/,null," \r\n\t\xA0"]);var Z=/^.[^\s\w\.$@\'\"\`\/\\]*/;U.push([H,/^@[a-z_$][a-z_$@0-9]*/i,null],[Q,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[G,/^[a-z_$][a-z_$@0-9]*/i,null],[H,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[G,/^\\[\s\S]?/,null],[M,Z,null]);return h(Y,U)}var L=i({keywords:B,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function S(W,ah,aa){var V=/(?:^|\s)nocode(?:\s|$)/;var ac=/\r\n?|\n/;var ad=W.ownerDocument;var ag=ad.createElement("li");while(W.firstChild){ag.appendChild(W.firstChild)}var X=[ag];function af(am){switch(am.nodeType){case 1:if(V.test(am.className)){break}if("br"===am.nodeName){ae(am);if(am.parentNode){am.parentNode.removeChild(am)}}else{for(var ao=am.firstChild;ao;ao=ao.nextSibling){af(ao)}}break;case 3:case 4:if(aa){var an=am.nodeValue;var ak=an.match(ac);if(ak){var aj=an.substring(0,ak.index);am.nodeValue=aj;var ai=an.substring(ak.index+ak[0].length);if(ai){var al=am.parentNode;al.insertBefore(ad.createTextNode(ai),am.nextSibling)}ae(am);if(!aj){am.parentNode.removeChild(am)}}}break}}function ae(al){while(!al.nextSibling){al=al.parentNode;if(!al){return}}function aj(am,at){var ar=at?am.cloneNode(false):am;var ap=am.parentNode;if(ap){var aq=aj(ap,1);var ao=am.nextSibling;aq.appendChild(ar);for(var an=ao;an;an=ao){ao=an.nextSibling;aq.appendChild(an)}}return ar}var ai=aj(al.nextSibling,0);for(var ak;(ak=ai.parentNode)&&ak.nodeType===1;){ai=ak}X.push(ai)}for(var Z=0;Z=U){aj+=2}if(Y>=ar){ac+=2}}}finally{if(au){au.style.display=ak}}}var u={};function d(W,X){for(var U=X.length;--U>=0;){var V=X[U];if(!u.hasOwnProperty(V)){u[V]=W}else{if(O.console){console.warn("cannot override language handler %s",V)}}}}function r(V,U){if(!(V&&u.hasOwnProperty(V))){V=/^\s*]*(?:>|$)/],[k,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[M,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^