Get 'mvn clean site' to work.
[commons-testing.git] / target / site / js / prettify.js
1 /**
2 *
3 * Copyright (C) 2006 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 function H() {
19 var x = navigator && navigator.userAgent
20 && /\bMSIE 6\./.test(navigator.userAgent);
21 H = function() {
22 return x
23 };
24 return x
25 }
26 (function() {
27 function x(b) {
28 b = b.split(/ /g);
29 var a = {};
30 for ( var c = b.length; --c >= 0;) {
31 var d = b[c];
32 if (d)
33 a[d] = null
34 }
35 return a
36 }
37 var y = "break continue do else for if return while ", U = y
38 + "auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile ", D = U
39 + "catch class delete false import new operator private protected public this throw true try ", I = D
40 + "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 typeof using virtual wchar_t where ", J = D
41 + "boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ", V = J
42 + "as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ", K = D
43 + "debugger eval export function get null set undefined var with Infinity NaN ", L = "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 ", M = y
44 + "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 ", N = y
45 + "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 ", O = y
46 + "case done elif esac eval fi function in local set then until ", W = I
47 + V + K + L + M + N + O;
48 function X(b) {
49 return b >= "a" && b <= "z" || b >= "A" && b <= "Z"
50 }
51 function u(b, a, c, d) {
52 b.unshift(c, d || 0);
53 try {
54 a.splice.apply(a, b)
55 } finally {
56 b.splice(0, 2)
57 }
58 }
59 var Y = (function() {
60 var b = [ "!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=", "&=",
61 "(", "*", "*=", "+=", ",", "-=", "->", "/", "/=", ":", "::",
62 ";", "<", "<<", "<<=", "<=", "=", "==", "===", ">", ">=", ">>",
63 ">>=", ">>>", ">>>=", "?", "@", "[", "^", "^=", "^^", "^^=",
64 "{", "|", "|=", "||", "||=", "~", "break", "case", "continue",
65 "delete", "do", "else", "finally", "instanceof", "return",
66 "throw", "try", "typeof" ], a = "(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)";
67 for ( var c = 0; c < b.length; ++c) {
68 var d = b[c];
69 a += X(d.charAt(0)) ? "|\\b" + d : "|"
70 + d.replace(/([^=<>:&])/g, "\\$1")
71 }
72 a += "|^)\\s*$";
73 return new RegExp(a)
74 })(), P = /&/g, Q = /</g, R = />/g, Z = /\"/g;
75 function $(b) {
76 return b.replace(P, "&amp;").replace(Q, "&lt;").replace(R, "&gt;")
77 .replace(Z, "&quot;")
78 }
79 function E(b) {
80 return b.replace(P, "&amp;").replace(Q, "&lt;").replace(R, "&gt;")
81 }
82 var aa = /&lt;/g, ba = /&gt;/g, ca = /&apos;/g, da = /&quot;/g, ea = /&amp;/g, fa = /&nbsp;/g;
83 function ga(b) {
84 var a = b.indexOf("&");
85 if (a < 0)
86 return b;
87 for (--a; (a = b.indexOf("&#", a + 1)) >= 0;) {
88 var c = b.indexOf(";", a);
89 if (c >= 0) {
90 var d = b.substring(a + 3, c), g = 10;
91 if (d && d.charAt(0) === "x") {
92 d = d.substring(1);
93 g = 16
94 }
95 var e = parseInt(d, g);
96 if (!isNaN(e))
97 b = b.substring(0, a) + String.fromCharCode(e)
98 + b.substring(c + 1)
99 }
100 }
101 return b.replace(aa, "<").replace(ba, ">").replace(ca, "'").replace(da,
102 '"').replace(ea, "&").replace(fa, " ")
103 }
104 function S(b) {
105 return "XMP" === b.tagName
106 }
107 function z(b, a) {
108 switch (b.nodeType) {
109 case 1:
110 var c = b.tagName.toLowerCase();
111 a.push("<", c);
112 for ( var d = 0; d < b.attributes.length; ++d) {
113 var g = b.attributes[d];
114 if (!g.specified)
115 continue;
116 a.push(" ");
117 z(g, a)
118 }
119 a.push(">");
120 for ( var e = b.firstChild; e; e = e.nextSibling)
121 z(e, a);
122 if (b.firstChild || !/^(?:br|link|img)$/.test(c))
123 a.push("</", c, ">");
124 break;
125 case 2:
126 a.push(b.name.toLowerCase(), '="', $(b.value), '"');
127 break;
128 case 3:
129 case 4:
130 a.push(E(b.nodeValue));
131 break
132 }
133 }
134 var F = null;
135 function ha(b) {
136 if (null === F) {
137 var a = document.createElement("pre");
138 a
139 .appendChild(document
140 .createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
141 F = !/</.test(a.innerHTML)
142 }
143 if (F) {
144 var c = b.innerHTML;
145 if (S(b))
146 c = E(c);
147 return c
148 }
149 var d = [];
150 for ( var g = b.firstChild; g; g = g.nextSibling)
151 z(g, d);
152 return d.join("")
153 }
154 function ia(b) {
155 var a = 0;
156 return function(c) {
157 var d = null, g = 0;
158 for ( var e = 0, h = c.length; e < h; ++e) {
159 var f = c.charAt(e);
160 switch (f) {
161 case "\t":
162 if (!d)
163 d = [];
164 d.push(c.substring(g, e));
165 var i = b - a % b;
166 a += i;
167 for (; i >= 0; i -= " ".length)
168 d.push(" ".substring(0, i));
169 g = e + 1;
170 break;
171 case "\n":
172 a = 0;
173 break;
174 default:
175 ++a
176 }
177 }
178 if (!d)
179 return c;
180 d.push(c.substring(g));
181 return d.join("")
182 }
183 }
184 var ja = /(?:[^<]+|<!--[\s\S]*?--\>|<!\[CDATA\[([\s\S]*?)\]\]>|<\/?[a-zA-Z][^>]*>|<)/g, ka = /^<!--/, la = /^<\[CDATA\[/, ma = /^<br\b/i;
185 function na(b) {
186 var a = b.match(ja), c = [], d = 0, g = [];
187 if (a)
188 for ( var e = 0, h = a.length; e < h; ++e) {
189 var f = a[e];
190 if (f.length > 1 && f.charAt(0) === "<") {
191 if (ka.test(f))
192 continue;
193 if (la.test(f)) {
194 c.push(f.substring(9, f.length - 3));
195 d += f.length - 12
196 } else if (ma.test(f)) {
197 c.push("\n");
198 ++d
199 } else
200 g.push(d, f)
201 } else {
202 var i = ga(f);
203 c.push(i);
204 d += i.length
205 }
206 }
207 return {
208 source : c.join(""),
209 tags : g
210 }
211 }
212 function v(b, a) {
213 var c = {};
214 (function() {
215 var g = b.concat(a);
216 for ( var e = g.length; --e >= 0;) {
217 var h = g[e], f = h[3];
218 if (f)
219 for ( var i = f.length; --i >= 0;)
220 c[f.charAt(i)] = h
221 }
222 })();
223 var d = a.length;
224 return function(g, e) {
225 e = e || 0;
226 var h = [ e, "pln" ], f = "", i = 0, j = g;
227 while (j.length) {
228 var o, m = null, k, l = c[j.charAt(0)];
229 if (l) {
230 k = j.match(l[1]);
231 m = k[0];
232 o = l[0]
233 } else {
234 for ( var n = 0; n < d; ++n) {
235 l = a[n];
236 var p = l[2];
237 if (p && !p.test(f))
238 continue;
239 k = j.match(l[1]);
240 if (k) {
241 m = k[0];
242 o = l[0];
243 break
244 }
245 }
246 if (!m) {
247 o = "pln";
248 m = j.substring(0, 1)
249 }
250 }
251 h.push(e + i, o);
252 i += m.length;
253 j = j.substring(m.length);
254 if (o !== "com" && /\S/.test(m))
255 f = m
256 }
257 return h
258 }
259 }
260 var oa = v(
261 [],
262 [
263 [ "pln", /^[^<]+/, null ],
264 [ "dec", /^<!\w[^>]*(?:>|$)/, null ],
265 [ "com", /^<!--[\s\S]*?(?:--\>|$)/, null ],
266 [ "src", /^<\?[\s\S]*?(?:\?>|$)/, null ],
267 [ "src", /^<%[\s\S]*?(?:%>|$)/, null ],
268 [
269 "src",
270 /^<(script|style|xmp)\b[^>]*>[\s\S]*?<\/\1\b[^>]*>/i,
271 null ], [ "tag", /^<\/?\w[^<>]*>/, null ] ]);
272 function pa(b) {
273 var a = oa(b);
274 for ( var c = 0; c < a.length; c += 2)
275 if (a[c + 1] === "src") {
276 var d, g;
277 d = a[c];
278 g = c + 2 < a.length ? a[c + 2] : b.length;
279 var e = b.substring(d, g), h = e
280 .match(/^(<[^>]*>)([\s\S]*)(<\/[^>]*>)$/);
281 if (h)
282 a.splice(c, 2, d, "tag", d + h[1].length, "src", d
283 + h[1].length + (h[2] || "").length, "tag")
284 }
285 return a
286 }
287 var qa = v( [ [ "atv", /^\'[^\']*(?:\'|$)/, null, "'" ],
288 [ "atv", /^\"[^\"]*(?:\"|$)/, null, '"' ],
289 [ "pun", /^[<>\/=]+/, null, "<>/=" ] ], [
290 [ "tag", /^[\w:\-]+/, /^</ ], [ "atv", /^[\w\-]+/, /^=/ ],
291 [ "atn", /^[\w:\-]+/, null ], [ "pln", /^\s+/, null, " \t\r\n" ] ]);
292 function ra(b, a) {
293 for ( var c = 0; c < a.length; c += 2) {
294 var d = a[c + 1];
295 if (d === "tag") {
296 var g, e;
297 g = a[c];
298 e = c + 2 < a.length ? a[c + 2] : b.length;
299 var h = b.substring(g, e), f = qa(h, g);
300 u(f, a, c, 2);
301 c += f.length - 2
302 }
303 }
304 return a
305 }
306 function r(b) {
307 var a = [], c = [];
308 if (b.tripleQuotedStrings)
309 a
310 .push( [
311 "str",
312 /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
313 null, "'\"" ]);
314 else if (b.multiLineStrings)
315 a
316 .push( [
317 "str",
318 /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
319 null, "'\"`" ]);
320 else
321 a
322 .push( [
323 "str",
324 /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
325 null, "\"'" ]);
326 c.push( [ "pln", /^(?:[^\'\"\`\/\#]+)/, null, " \r\n" ]);
327 if (b.hashComments)
328 a.push( [ "com", /^#[^\r\n]*/, null, "#" ]);
329 if (b.cStyleComments)
330 c.push( [ "com", /^\/\/[^\r\n]*/, null ]);
331 if (b.regexLiterals)
332 c
333 .push( [
334 "str",
335 /^\/(?:[^\\\*\/\[]|\\[\s\S]|\[(?:[^\]\\]|\\.)*(?:\]|$))+(?:\/|$)/,
336 Y ]);
337 if (b.cStyleComments)
338 c.push( [ "com", /^\/\*[\s\S]*?(?:\*\/|$)/, null ]);
339 var d = x(b.keywords);
340 b = null;
341 var g = v(a, c), e = v(
342 [],
343 [
344 [ "pln", /^\s+/, null, " \r\n" ],
345 [ "pln", /^[a-z_$@][a-z_$@0-9]*/i, null ],
346 [ "lit", /^0x[a-f0-9]+[a-z]/i, null ],
347 [
348 "lit",
349 /^(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?[a-z]*/i,
350 null, "123456789" ],
351 [ "pun", /^[^\s\w\.$@]+/, null ] ]);
352 function h(f, i) {
353 for ( var j = 0; j < i.length; j += 2) {
354 var o = i[j + 1];
355 if (o === "pln") {
356 var m, k, l, n;
357 m = i[j];
358 k = j + 2 < i.length ? i[j + 2] : f.length;
359 l = f.substring(m, k);
360 n = e(l, m);
361 for ( var p = 0, t = n.length; p < t; p += 2) {
362 var w = n[p + 1];
363 if (w === "pln") {
364 var A = n[p], B = p + 2 < t ? n[p + 2] : l.length, s = f
365 .substring(A, B);
366 if (s === ".")
367 n[p + 1] = "pun";
368 else if (s in d)
369 n[p + 1] = "kwd";
370 else if (/^@?[A-Z][A-Z$]*[a-z][A-Za-z$]*$/.test(s))
371 n[p + 1] = s.charAt(0) === "@" ? "lit" : "typ"
372 }
373 }
374 u(n, i, j, 2);
375 j += n.length - 2
376 }
377 }
378 return i
379 }
380 return function(f) {
381 var i = g(f);
382 i = h(f, i);
383 return i
384 }
385 }
386 var G = r( {
387 keywords : W,
388 hashComments : true,
389 cStyleComments : true,
390 multiLineStrings : true,
391 regexLiterals : true
392 });
393 function sa(b, a) {
394 for ( var c = 0; c < a.length; c += 2) {
395 var d = a[c + 1];
396 if (d === "src") {
397 var g, e;
398 g = a[c];
399 e = c + 2 < a.length ? a[c + 2] : b.length;
400 var h = G(b.substring(g, e));
401 for ( var f = 0, i = h.length; f < i; f += 2)
402 h[f] += g;
403 u(h, a, c, 2);
404 c += h.length - 2
405 }
406 }
407 return a
408 }
409 function ta(b, a) {
410 var c = false;
411 for ( var d = 0; d < a.length; d += 2) {
412 var g = a[d + 1], e, h;
413 if (g === "atn") {
414 e = a[d];
415 h = d + 2 < a.length ? a[d + 2] : b.length;
416 c = /^on|^style$/i.test(b.substring(e, h))
417 } else if (g === "atv") {
418 if (c) {
419 e = a[d];
420 h = d + 2 < a.length ? a[d + 2] : b.length;
421 var f = b.substring(e, h), i = f.length, j = i >= 2
422 && /^[\"\']/.test(f)
423 && f.charAt(0) === f.charAt(i - 1), o, m, k;
424 if (j) {
425 m = e + 1;
426 k = h - 1;
427 o = f
428 } else {
429 m = e + 1;
430 k = h - 1;
431 o = f.substring(1, f.length - 1)
432 }
433 var l = G(o);
434 for ( var n = 0, p = l.length; n < p; n += 2)
435 l[n] += m;
436 if (j) {
437 l.push(k, "atv");
438 u(l, a, d + 2, 0)
439 } else
440 u(l, a, d, 2)
441 }
442 c = false
443 }
444 }
445 return a
446 }
447 function ua(b) {
448 var a = pa(b);
449 a = ra(b, a);
450 a = sa(b, a);
451 a = ta(b, a);
452 return a
453 }
454 function va(b, a, c) {
455 var d = [], g = 0, e = null, h = null, f = 0, i = 0, j = ia(8);
456 function o(k) {
457 if (k > g) {
458 if (e && e !== h) {
459 d.push("</span>");
460 e = null
461 }
462 if (!e && h) {
463 e = h;
464 d.push('<span class="', e, '">')
465 }
466 var l = E(j(b.substring(g, k))).replace(/(\r\n?|\n| ) /g,
467 "$1&nbsp;").replace(/\r\n?|\n/g, "<br />");
468 d.push(l);
469 g = k
470 }
471 }
472 while (true) {
473 var m;
474 m = f < a.length ? (i < c.length ? a[f] <= c[i] : true) : false;
475 if (m) {
476 o(a[f]);
477 if (e) {
478 d.push("</span>");
479 e = null
480 }
481 d.push(a[f + 1]);
482 f += 2
483 } else if (i < c.length) {
484 o(c[i]);
485 h = c[i + 1];
486 i += 2
487 } else
488 break
489 }
490 o(b.length);
491 if (e)
492 d.push("</span>");
493 return d.join("")
494 }
495 var C = {};
496 function q(b, a) {
497 for ( var c = a.length; --c >= 0;) {
498 var d = a[c];
499 if (!C.hasOwnProperty(d))
500 C[d] = b;
501 else if ("console" in window)
502 console.log("cannot override language handler %s", d)
503 }
504 }
505 q(G, [ "default-code" ]);
506 q(ua, [ "default-markup", "html", "htm", "xhtml", "xml", "xsl" ]);
507 q(r( {
508 keywords : I,
509 hashComments : true,
510 cStyleComments : true
511 }), [ "c", "cc", "cpp", "cs", "cxx", "cyc" ]);
512 q(r( {
513 keywords : J,
514 cStyleComments : true
515 }), [ "java" ]);
516 q(r( {
517 keywords : O,
518 hashComments : true,
519 multiLineStrings : true
520 }), [ "bsh", "csh", "sh" ]);
521 q(r( {
522 keywords : M,
523 hashComments : true,
524 multiLineStrings : true,
525 tripleQuotedStrings : true
526 }), [ "cv", "py" ]);
527 q(r( {
528 keywords : L,
529 hashComments : true,
530 multiLineStrings : true,
531 regexLiterals : true
532 }), [ "perl", "pl", "pm" ]);
533 q(r( {
534 keywords : N,
535 hashComments : true,
536 multiLineStrings : true,
537 regexLiterals : true
538 }), [ "rb" ]);
539 q(r( {
540 keywords : K,
541 cStyleComments : true,
542 regexLiterals : true
543 }), [ "js" ]);
544 function T(b, a) {
545 try {
546 var c = na(b), d = c.source, g = c.tags;
547 if (!C.hasOwnProperty(a))
548 a = /^\s*</.test(d) ? "default-markup" : "default-code";
549 var e = C[a].call( {}, d);
550 return va(d, g, e)
551 } catch (h) {
552 if ("console" in window) {
553 console.log(h);
554 console.trace()
555 }
556 return b
557 }
558 }
559 function wa(b) {
560 var a = H(), c = [ document.getElementsByTagName("pre"),
561 document.getElementsByTagName("code"),
562 document.getElementsByTagName("xmp"),
563 document.getElementsByTagName("div")], d = [];
564 for ( var g = 0; g < c.length; ++g)
565 for ( var e = 0; e < c[g].length; ++e)
566 d.push(c[g][e]);
567 c = null;
568 var h = 0;
569 function f() {
570 var i = (new Date).getTime() + 250;
571 for (; h < d.length && (new Date).getTime() < i; h++) {
572 var j = d[h];
573 if (j.className && j.className.indexOf("source") >= 0) {
574 var o = j.className.match(/\blang-(\w+)\b/);
575 if (o)
576 o = o[1];
577 var m = false;
578 for ( var k = j.parentNode; k; k = k.parentNode)
579 if ((k.tagName === "pre" || k.tagName === "code" || k.tagName === "xmp" || k.tagName == "div")
580 && k.className
581 && k.className.indexOf("source") >= 0) {
582 m = true;
583 break
584 }
585 if (!m) {
586 var l = ha(j);
587 l = l.replace(/(?:\r\n?|\n)$/, "");
588 var n = T(l, o);
589 if (!S(j))
590 j.innerHTML = n;
591 else {
592 var p = document.createElement("pre");
593 for ( var t = 0; t < j.attributes.length; ++t) {
594 var w = j.attributes[t];
595 if (w.specified)
596 p.setAttribute(w.name, w.value)
597 }
598 p.innerHTML = n;
599 j.parentNode.replaceChild(p, j);
600 p = j
601 }
602 if (a && j.tagName === "pre") {
603 var A = j.getElementsByTagName("br");
604 for ( var B = A.length; --B >= 0;) {
605 var s = A[B];
606 s.parentNode.replaceChild(document
607 .createTextNode("\r\n"), s)
608 }
609 }
610 }
611 }
612 }
613 if (h < d.length)
614 setTimeout(f, 250);
615 else if (b)
616 b()
617 }
618 f()
619 }
620 window.PR_normalizedHtml = z;
621 window.prettyPrintOne = T;
622 window.prettyPrint = wa;
623 window.PR = {
624 createSimpleLexer : v,
625 registerLangHandler : q,
626 sourceDecorator : r,
627 PR_ATTRIB_NAME : "atn",
628 PR_ATTRIB_VALUE : "atv",
629 PR_COMMENT : "com",
630 PR_DECLARATION : "dec",
631 PR_KEYWORD : "kwd",
632 PR_LITERAL : "lit",
633 PR_PLAIN : "pln",
634 PR_PUNCTUATION : "pun",
635 PR_SOURCE : "src",
636 PR_STRING : "str",
637 PR_TAG : "tag",
638 PR_TYPE : "typ"
639 }
640 })();