md2html 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +27 -0
- data/bin/md2html +4 -0
- data/lib/md2html.rb +50 -0
- data/lib/md2html/cli.rb +13 -0
- data/lib/md2html/html/bootstrap.css +2363 -0
- data/lib/md2html/html/layout.html +16 -0
- data/lib/md2html/html/layout.min.html +25 -0
- data/lib/md2html/html/prettify.css +52 -0
- data/lib/md2html/html/prettify.js +1477 -0
- data/lib/md2html/version.rb +3 -0
- data/md2html.gemspec +22 -0
- data/readme.md +30 -0
- metadata +99 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title></title>
|
6
|
+
<style type="text/css"> #content{ margin-top: 18px } </style>
|
7
|
+
<script type="text/javascript" charset="utf-8"> </script>
|
8
|
+
</head>
|
9
|
+
<body onload="prettyPrint()">
|
10
|
+
<div class="container">
|
11
|
+
<div class="row">
|
12
|
+
<div id="content" class="span12 offset2"></div>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html SYSTEM>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title></title>
|
6
|
+
<style type="text/css"> #content{ margin-top: 18px } /*!
|
7
|
+
* Bootstrap v1.3.0
|
8
|
+
*
|
9
|
+
* Copyright 2011 Twitter, Inc
|
10
|
+
* Licensed under the Apache License v2.0
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
14
|
+
* Date: Mon Oct 10 14:31:07 CDT 2011
|
15
|
+
*/html,body{margin:0;padding:0}h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,cite,code,del,dfn,em,img,q,s,samp,small,strike,strong,sub,sup,tt,var,dd,dl,dt,li,ol,ul,fieldset,form,label,legend,button,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:normal;font-style:normal;font-size:100%;line-height:1;font-family:inherit}table{border-collapse:collapse;border-spacing:0}ol,ul{list-style:none}q:before,q:after,blockquote:before,blockquote:after{content:""}html{overflow-y:scroll;font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted}a:hover,a:active{outline:0}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0;-ms-interpolation-mode:bicubic}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}html,body{background-color:#fff}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:18px;color:#404040}.container{width:940px;margin-left:auto;margin-right:auto;zoom:1}.container:before,.container:after{display:table;content:"";zoom:1;*display:inline}.container:after{clear:both}.container-fluid{position:relative;min-width:940px;padding-left:20px;padding-right:20px;zoom:1}.container-fluid:before,.container-fluid:after{display:table;content:"";zoom:1;*display:inline}.container-fluid:after{clear:both}.container-fluid>.sidebar{float:left;width:220px}.container-fluid>.content{margin-left:240px}a{color:#0069d6;text-decoration:none;line-height:inherit;font-weight:inherit}a:hover{color:#00438a;text-decoration:underline}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.row{zoom:1;margin-left:-20px}.row:before,.row:after{display:table;content:"";zoom:1;*display:inline}.row:after{clear:both}[class*="span"]{display:inline;float:left;margin-left:20px}.span1{width:40px}.span2{width:100px}.span3{width:160px}.span4{width:220px}.span5{width:280px}.span6{width:340px}.span7{width:400px}.span8{width:460px}.span9{width:520px}.span10{width:580px}.span11{width:640px}.span12{width:700px}.span13{width:760px}.span14{width:820px}.span15{width:880px}.span16{width:940px}.span17{width:1000px}.span18{width:1060px}.span19{width:1120px}.span20{width:1180px}.span21{width:1240px}.span22{width:1300px}.span23{width:1360px}.span24{width:1420px}.offset1{margin-left:80px}.offset2{margin-left:140px}.offset3{margin-left:200px}.offset4{margin-left:260px}.offset5{margin-left:320px}.offset6{margin-left:380px}.offset7{margin-left:440px}.offset8{margin-left:500px}.offset9{margin-left:560px}.offset10{margin-left:620px}.offset11{margin-left:680px}.offset12{margin-left:740px}.span-one-third{width:300px}.span-two-thirds{width:620px}.offset-one-third{margin-left:340px}.offset-two-thirds{margin-left:660px}p{font-size:13px;font-weight:normal;line-height:18px;margin-bottom:9px}p small{font-size:11px;color:#bfbfbf}h1,h2,h3,h4,h5,h6{font-weight:bold;color:#404040}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{color:#bfbfbf}h1{margin-bottom:18px;font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:14px}h3,h4,h5,h6{line-height:36px}h3{font-size:18px}h3 small{font-size:14px}h4{font-size:16px}h4 small{font-size:12px}h5{font-size:14px}h6{font-size:13px;color:#bfbfbf;text-transform:uppercase}ul,ol{margin:0 0 18px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}ul{list-style:disc}ol{list-style:decimal}li{line-height:18px;color:#808080}ul.unstyled{list-style:none;margin-left:0}dl{margin-bottom:18px}dl dt,dl dd{line-height:18px}dl dt{font-weight:bold}dl dd{margin-left:9px}hr{margin:20px 0 19px;border:0;border-bottom:1px solid #eee}strong{font-style:inherit;font-weight:bold}em{font-style:italic;font-weight:inherit;line-height:inherit}.muted{color:#bfbfbf}blockquote{margin-bottom:18px;border-left:5px solid #eee;padding-left:15px}blockquote p{font-size:14px;font-weight:300;line-height:18px;margin-bottom:0}blockquote small{display:block;font-size:12px;font-weight:300;line-height:18px;color:#bfbfbf}blockquote small:before{content:'\2014 \00A0'}address{display:block;line-height:18px;margin-bottom:18px}code,pre{padding:0 3px 2px;font-family:Monaco,Andale Mono,Courier New,monospace;font-size:12px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{background-color:#fee9cc;color:rgba(0,0,0,0.75);padding:1px 3px}pre{background-color:#f5f5f5;display:block;padding:8.5px;margin:0 0 18px;line-height:18px;font-size:12px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;white-space:pre;white-space:pre-wrap;word-wrap:break-word}form{margin-bottom:18px}fieldset{margin-bottom:18px;padding-top:18px}fieldset legend{display:block;padding-left:150px;font-size:19.5px;line-height:1;color:#404040;*padding:0 0 5px 145px;*line-height:1.5}form .clearfix{margin-bottom:18px;zoom:1}form .clearfix:before,form .clearfix:after{display:table;content:"";zoom:1;*display:inline}form .clearfix:after{clear:both}label,input,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:normal}label{padding-top:6px;font-size:13px;line-height:18px;float:left;width:130px;text-align:right;color:#404040}form .input{margin-left:150px}input[type=checkbox],input[type=radio]{cursor:pointer}input,textarea,select,.uneditable-input{display:inline-block;width:210px;height:18px;padding:4px;font-size:13px;line-height:18px;color:#808080;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}input[type=checkbox],input[type=radio]{width:auto;height:auto;padding:0;margin:3px 0;*margin-top:0;line-height:normal;border:none}input[type=file]{background-color:#fff;padding:initial;border:initial;line-height:initial;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}input[type=button],input[type=reset],input[type=submit]{width:auto;height:auto}select,input[type=file]{height:27px;line-height:27px;*margin-top:4px}select[multiple]{height:inherit}textarea{height:auto}.uneditable-input{background-color:#fff;display:block;border-color:#eee;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);cursor:not-allowed}:-moz-placeholder{color:#bfbfbf}::-webkit-input-placeholder{color:#bfbfbf}input,textarea{-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-ms-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 3px rgba(0,0,0,0.1);box-shadow:inset 0 1px 3px rgba(0,0,0,0.1)}input:focus,textarea:focus{outline:0;border-color:rgba(82,168,236,0.8);-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,0.1),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 3px rgba(0,0,0,0.1),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 3px rgba(0,0,0,0.1),0 0 8px rgba(82,168,236,0.6)}input[type=file]:focus,input[type=checkbox]:focus,select:focus{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;outline:1px dotted #666}form div.clearfix.error{background:#fae5e3;padding:10px 0;margin:-10px 0 10px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}form div.clearfix.error>label,form div.clearfix.error span.help-inline,form div.clearfix.error span.help-block{color:#9d261d}form div.clearfix.error input,form div.clearfix.error textarea{border-color:#c87872;-webkit-box-shadow:0 0 3px rgba(171,41,32,0.25);-moz-box-shadow:0 0 3px rgba(171,41,32,0.25);box-shadow:0 0 3px rgba(171,41,32,0.25)}form div.clearfix.error input:focus,form div.clearfix.error textarea:focus{border-color:#b9554d;-webkit-box-shadow:0 0 6px rgba(171,41,32,0.5);-moz-box-shadow:0 0 6px rgba(171,41,32,0.5);box-shadow:0 0 6px rgba(171,41,32,0.5)}form div.clearfix.error .input-prepend span.add-on,form div.clearfix.error .input-append span.add-on{background:#f4c8c5;border-color:#c87872;color:#b9554d}.input-mini,input.mini,textarea.mini,select.mini{width:60px}.input-small,input.small,textarea.small,select.small{width:90px}.input-medium,input.medium,textarea.medium,select.medium{width:150px}.input-large,input.large,textarea.large,select.large{width:210px}.input-xlarge,input.xlarge,textarea.xlarge,select.xlarge{width:270px}.input-xxlarge,input.xxlarge,textarea.xxlarge,select.xxlarge{width:530px}textarea.xxlarge{overflow-y:auto}input.span1,textarea.span1,select.span1{display:inline-block;float:none;width:30px;margin-left:0}input.span2,textarea.span2,select.span2{display:inline-block;float:none;width:90px;margin-left:0}input.span3,textarea.span3,select.span3{display:inline-block;float:none;width:150px;margin-left:0}input.span4,textarea.span4,select.span4{display:inline-block;float:none;width:210px;margin-left:0}input.span5,textarea.span5,select.span5{display:inline-block;float:none;width:270px;margin-left:0}input.span6,textarea.span6,select.span6{display:inline-block;float:none;width:330px;margin-left:0}input.span7,textarea.span7,select.span7{display:inline-block;float:none;width:390px;margin-left:0}input.span8,textarea.span8,select.span8{display:inline-block;float:none;width:450px;margin-left:0}input.span9,textarea.span9,select.span9{display:inline-block;float:none;width:510px;margin-left:0}input.span10,textarea.span10,select.span10{display:inline-block;float:none;width:570px;margin-left:0}input.span11,textarea.span11,select.span11{display:inline-block;float:none;width:630px;margin-left:0}input.span12,textarea.span12,select.span12{display:inline-block;float:none;width:690px;margin-left:0}input.span13,textarea.span13,select.span13{display:inline-block;float:none;width:750px;margin-left:0}input.span14,textarea.span14,select.span14{display:inline-block;float:none;width:810px;margin-left:0}input.span15,textarea.span15,select.span15{display:inline-block;float:none;width:870px;margin-left:0}input.span16,textarea.span16,select.span16{display:inline-block;float:none;width:930px;margin-left:0}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{background-color:#f5f5f5;border-color:#ddd;cursor:not-allowed}.actions{background:#f5f5f5;margin-top:18px;margin-bottom:18px;padding:17px 20px 18px 150px;border-top:1px solid #ddd;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px}.actions .secondary-action{float:right}.actions .secondary-action a{line-height:30px}.actions .secondary-action a:hover{text-decoration:underline}.help-inline,.help-block{font-size:11px;line-height:18px;color:#bfbfbf}.help-inline{padding-left:5px;*position:relative;*top:-5px}.help-block{display:block;max-width:600px}.inline-inputs{color:#808080}.inline-inputs span,.inline-inputs input{display:inline-block}.inline-inputs input.mini{width:60px}.inline-inputs input.small{width:90px}.inline-inputs span{padding:0 2px 0 1px}.input-prepend input,.input-append input{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0}.input-prepend .add-on,.input-append .add-on{position:relative;background:#f5f5f5;border:1px solid #ccc;z-index:2;float:left;display:block;width:auto;min-width:16px;height:18px;padding:4px 4px 4px 5px;margin-right:-1px;font-weight:normal;line-height:18px;color:#bfbfbf;text-align:center;text-shadow:0 1px 0 #fff;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-prepend .active,.input-append .active{background:#a9dba9;border-color:#46a546}.input-prepend .add-on{*margin-top:1px}.input-append input{float:left;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px}.input-append .add-on{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0;margin-right:0;margin-left:-1px}.inputs-list{margin:0 0 5px;width:100%}.inputs-list li{display:block;padding:0;width:100%}.inputs-list label{display:block;float:none;width:auto;padding:0;line-height:18px;text-align:left;white-space:normal}.inputs-list label strong{color:#808080}.inputs-list label small{font-size:11px;font-weight:normal}.inputs-list .inputs-list{margin-left:25px;margin-bottom:10px;padding-top:0}.inputs-list:first-child{padding-top:6px}.inputs-list li+li{padding-top:2px}.inputs-list input[type=radio],.inputs-list input[type=checkbox]{margin-bottom:0}.form-stacked{padding-left:20px}.form-stacked fieldset{padding-top:9px}.form-stacked legend{padding-left:0}.form-stacked label{display:block;float:none;width:auto;font-weight:bold;text-align:left;line-height:20px;padding-top:0}.form-stacked .clearfix{margin-bottom:9px}.form-stacked .clearfix div.input{margin-left:0}.form-stacked .inputs-list{margin-bottom:0}.form-stacked .inputs-list li{padding-top:0}.form-stacked .inputs-list li label{font-weight:normal;padding-top:0}.form-stacked div.clearfix.error{padding-top:10px;padding-bottom:10px;padding-left:10px;margin-top:0;margin-left:-10px}.form-stacked .actions{margin-left:-20px;padding-left:20px}table{width:100%;margin-bottom:18px;padding:0;border-collapse:separate;*border-collapse:collapse;font-size:13px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}table th,table td{padding:10px 10px 9px;line-height:18px;text-align:left}table th{padding-top:9px;font-weight:bold;vertical-align:middle;border-bottom:1px solid #ddd}table td{vertical-align:top}table th+th,table td+td{border-left:1px solid #ddd}table tr+tr td{border-top:1px solid #ddd}table tbody tr:first-child td:first-child{-webkit-border-radius:4px 0 0 0;-moz-border-radius:4px 0 0 0;border-radius:4px 0 0 0}table tbody tr:first-child td:last-child{-webkit-border-radius:0 4px 0 0;-moz-border-radius:0 4px 0 0;border-radius:0 4px 0 0}table tbody tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px}table tbody tr:last-child td:last-child{-webkit-border-radius:0 0 4px 0;-moz-border-radius:0 0 4px 0;border-radius:0 0 4px 0}.zebra-striped tbody tr:nth-child(odd) td{background-color:#f9f9f9}.zebra-striped tbody tr:hover td{background-color:#f5f5f5}table .header{cursor:pointer}table .header:after{content:"";float:right;margin-top:7px;border-width:0 4px 4px;border-style:solid;border-color:#000 transparent;visibility:hidden}table .headerSortUp,table .headerSortDown{background-color:rgba(141,192,219,0.25);text-shadow:0 1px 1px rgba(255,255,255,0.75)}table .header:hover:after{visibility:visible}table .headerSortDown:after,table .headerSortDown:hover:after{visibility:visible;filter:alpha(opacity=60);-khtml-opacity:.6;-moz-opacity:.6;opacity:.6}table .headerSortUp:after{border-bottom:none;border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid #000;visibility:visible;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;filter:alpha(opacity=60);-khtml-opacity:.6;-moz-opacity:.6;opacity:.6}table .blue{color:#049cdb;border-bottom-color:#049cdb}table .headerSortUp.blue,table .headerSortDown.blue{background-color:#ade6fe}table .green{color:#46a546;border-bottom-color:#46a546}table .headerSortUp.green,table .headerSortDown.green{background-color:#cdeacd}table .red{color:#9d261d;border-bottom-color:#9d261d}table .headerSortUp.red,table .headerSortDown.red{background-color:#f4c8c5}table .yellow{color:#ffc40d;border-bottom-color:#ffc40d}table .headerSortUp.yellow,table .headerSortDown.yellow{background-color:#fff6d9}table .orange{color:#f89406;border-bottom-color:#f89406}table .headerSortUp.orange,table .headerSortDown.orange{background-color:#fee9cc}table .purple{color:#7a43b6;border-bottom-color:#7a43b6}table .headerSortUp.purple,table .headerSortDown.purple{background-color:#e2d5f0}.topbar{height:40px;position:fixed;top:0;left:0;right:0;z-index:10000;overflow:visible}.topbar a{color:#bfbfbf;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.topbar h3 a:hover,.topbar .brand a:hover,.topbar ul .active>a{background-color:#333;background-color:rgba(255,255,255,0.05);color:#fff;text-decoration:none}.topbar h3{position:relative}.topbar h3 a,.topbar .brand{float:left;display:block;padding:8px 20px 12px;margin-left:-20px;color:#fff;font-size:20px;font-weight:200;line-height:1}.topbar p{margin:0;line-height:40px}.topbar p a:hover{background-color:transparent;color:#fff}.topbar form{float:left;margin:5px 0 0 0;position:relative;filter:alpha(opacity=100);-khtml-opacity:1;-moz-opacity:1;opacity:1}.topbar form.pull-right{float:right}.topbar input{background-color:#444;background-color:rgba(255,255,255,0.3);font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:normal;font-weight:13px;line-height:1;padding:4px 9px;color:#fff;color:rgba(255,255,255,0.75);border:1px solid #111;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.25);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.25);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.25);-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none}.topbar input:-moz-placeholder{color:#e6e6e6}.topbar input::-webkit-input-placeholder{color:#e6e6e6}.topbar input:hover{background-color:#bfbfbf;background-color:rgba(255,255,255,0.5);color:#fff}.topbar input:focus,.topbar input.focused{outline:0;background-color:#fff;color:#404040;text-shadow:0 1px 0 #fff;border:0;padding:5px 10px;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.topbar-inner,.topbar .fill{background-color:#222;background-color:#222;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#333),to(#222));background-image:-moz-linear-gradient(top,#333,#222);background-image:-ms-linear-gradient(top,#333,#222);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#333),color-stop(100%,#222));background-image:-webkit-linear-gradient(top,#333,#222);background-image:-o-linear-gradient(top,#333,#222);background-image:linear-gradient(top,#333,#222);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333',endColorstr='#222222',GradientType=0);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.25),inset 0 -1px 0 rgba(0,0,0,0.1)}.topbar div>ul,.nav{display:block;float:left;margin:0 10px 0 0;position:relative;left:0}.topbar div>ul>li,.nav>li{display:block;float:left}.topbar div>ul a,.nav a{display:block;float:none;padding:10px 10px 11px;line-height:19px;text-decoration:none}.topbar div>ul a:hover,.nav a:hover{color:#fff;text-decoration:none}.topbar div>ul .active>a,.nav .active>a{background-color:#222;background-color:rgba(0,0,0,0.5)}.topbar div>ul.secondary-nav,.nav.secondary-nav{float:right;margin-left:10px;margin-right:0}.topbar div>ul.secondary-nav .menu-dropdown,.nav.secondary-nav .menu-dropdown,.topbar div>ul.secondary-nav .dropdown-menu,.nav.secondary-nav .dropdown-menu{right:0;border:0}.topbar div>ul a.menu:hover,.nav a.menu:hover,.topbar div>ul li.open .menu,.nav li.open .menu,.topbar div>ul .dropdown-toggle:hover,.nav .dropdown-toggle:hover,.topbar div>ul .dropdown.open .dropdown-toggle,.nav .dropdown.open .dropdown-toggle{background:#444;background:rgba(255,255,255,0.05)}.topbar div>ul .menu-dropdown,.nav .menu-dropdown,.topbar div>ul .dropdown-menu,.nav .dropdown-menu{background-color:#333}.topbar div>ul .menu-dropdown a.menu,.nav .menu-dropdown a.menu,.topbar div>ul .dropdown-menu a.menu,.nav .dropdown-menu a.menu,.topbar div>ul .menu-dropdown .dropdown-toggle,.nav .menu-dropdown .dropdown-toggle,.topbar div>ul .dropdown-menu .dropdown-toggle,.nav .dropdown-menu .dropdown-toggle{color:#fff}.topbar div>ul .menu-dropdown a.menu.open,.nav .menu-dropdown a.menu.open,.topbar div>ul .dropdown-menu a.menu.open,.nav .dropdown-menu a.menu.open,.topbar div>ul .menu-dropdown .dropdown-toggle.open,.nav .menu-dropdown .dropdown-toggle.open,.topbar div>ul .dropdown-menu .dropdown-toggle.open,.nav .dropdown-menu .dropdown-toggle.open{background:#444;background:rgba(255,255,255,0.05)}.topbar div>ul .menu-dropdown li a,.nav .menu-dropdown li a,.topbar div>ul .dropdown-menu li a,.nav .dropdown-menu li a{color:#999;text-shadow:0 1px 0 rgba(0,0,0,0.5)}.topbar div>ul .menu-dropdown li a:hover,.nav .menu-dropdown li a:hover,.topbar div>ul .dropdown-menu li a:hover,.nav .dropdown-menu li a:hover{background-color:#191919;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#292929),to(#191919));background-image:-moz-linear-gradient(top,#292929,#191919);background-image:-ms-linear-gradient(top,#292929,#191919);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#292929),color-stop(100%,#191919));background-image:-webkit-linear-gradient(top,#292929,#191919);background-image:-o-linear-gradient(top,#292929,#191919);background-image:linear-gradient(top,#292929,#191919);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#292929',endColorstr='#191919',GradientType=0);color:#fff}.topbar div>ul .menu-dropdown .active a,.nav .menu-dropdown .active a,.topbar div>ul .dropdown-menu .active a,.nav .dropdown-menu .active a{color:#fff}.topbar div>ul .menu-dropdown .divider,.nav .menu-dropdown .divider,.topbar div>ul .dropdown-menu .divider,.nav .dropdown-menu .divider{background-color:#222;border-color:#444}.topbar ul .menu-dropdown li a,.topbar ul .dropdown-menu li a{padding:4px 15px}li.menu,.dropdown{position:relative}a.menu:after,.dropdown-toggle:after{width:0;height:0;display:inline-block;content:"↓";text-indent:-99999px;vertical-align:top;margin-top:8px;margin-left:4px;border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid #fff;filter:alpha(opacity=50);-khtml-opacity:.5;-moz-opacity:.5;opacity:.5}.menu-dropdown,.dropdown-menu{background-color:#fff;float:left;display:none;position:absolute;top:40px;z-index:900;min-width:160px;max-width:220px;_width:160px;margin-left:0;margin-right:0;padding:6px 0;zoom:1;border-color:#999;border-color:rgba(0,0,0,0.2);border-style:solid;border-width:0 1px 1px;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:0 2px 4px rgba(0,0,0,0.2);-moz-box-shadow:0 2px 4px rgba(0,0,0,0.2);box-shadow:0 2px 4px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.menu-dropdown li,.dropdown-menu li{float:none;display:block;background-color:none}.menu-dropdown .divider,.dropdown-menu .divider{height:1px;margin:5px 0;overflow:hidden;background-color:#eee;border-bottom:1px solid #fff}.topbar .dropdown-menu a,.dropdown-menu a{display:block;padding:4px 15px;clear:both;font-weight:normal;line-height:18px;color:#808080;text-shadow:0 1px 0 #fff}.topbar .dropdown-menu a:hover,.dropdown-menu a:hover{background-color:#ddd;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#eee),to(#ddd));background-image:-moz-linear-gradient(top,#eee,#ddd);background-image:-ms-linear-gradient(top,#eee,#ddd);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#eee),color-stop(100%,#ddd));background-image:-webkit-linear-gradient(top,#eee,#ddd);background-image:-o-linear-gradient(top,#eee,#ddd);background-image:linear-gradient(top,#eee,#ddd);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee',endColorstr='#dddddd',GradientType=0);color:#404040;text-decoration:none;-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,0.025),inset 0 -1px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 0 rgba(0,0,0,0.025),inset 0 -1px rgba(0,0,0,0.025);box-shadow:inset 0 1px 0 rgba(0,0,0,0.025),inset 0 -1px rgba(0,0,0,0.025)}.open .menu,.dropdown.open .menu,.open .dropdown-toggle,.dropdown.open .dropdown-toggle{color:#fff;background:#ccc;background:rgba(0,0,0,0.3)}.open .menu-dropdown,.dropdown.open .menu-dropdown,.open .dropdown-menu,.dropdown.open .dropdown-menu{display:block}.tabs,.pills{margin:0 0 20px;padding:0;list-style:none;zoom:1}.tabs:before,.pills:before,.tabs:after,.pills:after{display:table;content:"";zoom:1;*display:inline}.tabs:after,.pills:after{clear:both}.tabs>li,.pills>li{float:left}.tabs>li>a,.pills>li>a{display:block}.tabs{float:left;width:100%;border-bottom:1px solid #ddd}.tabs>li{position:relative;top:1px}.tabs>li>a{padding:0 15px;margin-right:2px;line-height:36px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.tabs>li>a:hover{text-decoration:none;background-color:#eee;border-color:#eee #eee #ddd}.tabs>li.active>a{color:#808080;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.tabs .menu-dropdown,.tabs .dropdown-menu{top:35px;border-width:1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px}.tabs a.menu:after,.tabs .dropdown-toggle:after{border-top-color:#999;margin-top:15px;margin-left:5px}.tabs li.open.menu .menu,.tabs .open.dropdown .dropdown-toggle{border-color:#999}.tabs li.open a.menu:after,.tabs .dropdown.open .dropdown-toggle:after{border-top-color:#555}.tab-content{clear:both}.pills a{margin:5px 3px 5px 0;padding:0 15px;text-shadow:0 1px 1px #fff;line-height:30px;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pills a:hover{background:#00438a;color:#fff;text-decoration:none;text-shadow:0 1px 1px rgba(0,0,0,0.25)}.pills .active a{background:#0069d6;color:#fff;text-shadow:0 1px 1px rgba(0,0,0,0.25)}.tab-content>*,.pill-content>*{display:none}.tab-content>.active,.pill-content>.active{display:block}.breadcrumb{margin:0 0 18px;padding:7px 14px;background-color:#f5f5f5;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#fff),to(#f5f5f5));background-image:-moz-linear-gradient(top,#fff,#f5f5f5);background-image:-ms-linear-gradient(top,#fff,#f5f5f5);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#fff),color-stop(100%,#f5f5f5));background-image:-webkit-linear-gradient(top,#fff,#f5f5f5);background-image:-o-linear-gradient(top,#fff,#f5f5f5);background-image:linear-gradient(top,#fff,#f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#f5f5f5',GradientType=0);border:1px solid #ddd;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.breadcrumb li{display:inline;text-shadow:0 1px 0 #fff}.breadcrumb .divider{padding:0 5px;color:#bfbfbf}.breadcrumb .active a{color:#404040}.hero-unit{background-color:#f5f5f5;margin-bottom:30px;padding:60px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px}.hero-unit p{font-size:18px;font-weight:200;line-height:27px}footer{margin-top:17px;padding-top:17px;border-top:1px solid #eee}.page-header{margin-bottom:17px;border-bottom:1px solid #ddd;-webkit-box-shadow:0 1px 0 rgba(255,255,255,0.5);-moz-box-shadow:0 1px 0 rgba(255,255,255,0.5);box-shadow:0 1px 0 rgba(255,255,255,0.5)}.page-header h1{margin-bottom:8px}.btn.danger,.alert-message.danger,.btn.danger:hover,.alert-message.danger:hover,.btn.error,.alert-message.error,.btn.error:hover,.alert-message.error:hover,.btn.success,.alert-message.success,.btn.success:hover,.alert-message.success:hover,.btn.info,.alert-message.info,.btn.info:hover,.alert-message.info:hover{color:#fff}.btn.danger,.alert-message.danger,.btn.error,.alert-message.error{background-color:#c43c35;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#ee5f5b),to(#c43c35));background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-ms-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#ee5f5b),color-stop(100%,#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(top,#ee5f5b,#c43c35);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#c43c35',GradientType=0);text-shadow:0 -1px 0 rgba(0,0,0,0.25);border-color:#c43c35 #c43c35 #882a25;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn.success,.alert-message.success{background-color:#57a957;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#62c462),to(#57a957));background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-ms-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#62c462),color-stop(100%,#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(top,#62c462,#57a957);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462',endColorstr='#57a957',GradientType=0);text-shadow:0 -1px 0 rgba(0,0,0,0.25);border-color:#57a957 #57a957 #3d773d;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn.info,.alert-message.info{background-color:#339bb9;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#5bc0de),to(#339bb9));background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-ms-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#5bc0de),color-stop(100%,#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(top,#5bc0de,#339bb9);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de',endColorstr='#339bb9',GradientType=0);text-shadow:0 -1px 0 rgba(0,0,0,0.25);border-color:#339bb9 #339bb9 #22697d;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn{cursor:pointer;display:inline-block;background-color:#e6e6e6;background-repeat:no-repeat;background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),color-stop(25%,#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(#fff,#fff 25%,#e6e6e6);background-image:-moz-linear-gradient(top,#fff,#fff 25%,#e6e6e6);background-image:-ms-linear-gradient(#fff,#fff 25%,#e6e6e6);background-image:-o-linear-gradient(#fff,#fff 25%,#e6e6e6);background-image:linear-gradient(#fff,#fff 25%,#e6e6e6);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);padding:5px 14px 6px;text-shadow:0 1px 1px rgba(255,255,255,0.75);color:#333;font-size:13px;line-height:normal;border:1px solid #ccc;border-bottom-color:#bbb;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-webkit-transition:.1s linear all;-moz-transition:.1s linear all;-ms-transition:.1s linear all;-o-transition:.1s linear all;transition:.1s linear all}.btn:hover{background-position:0 -15px;color:#333;text-decoration:none}.btn:focus{outline:1px dotted #666}.btn.primary{color:#fff;background-color:#0064cd;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#049cdb),to(#0064cd));background-image:-moz-linear-gradient(top,#049cdb,#0064cd);background-image:-ms-linear-gradient(top,#049cdb,#0064cd);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#049cdb),color-stop(100%,#0064cd));background-image:-webkit-linear-gradient(top,#049cdb,#0064cd);background-image:-o-linear-gradient(top,#049cdb,#0064cd);background-image:linear-gradient(top,#049cdb,#0064cd);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#049cdb',endColorstr='#0064cd',GradientType=0);text-shadow:0 -1px 0 rgba(0,0,0,0.25);border-color:#0064cd #0064cd #003f81;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25)}.btn:active{-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.25),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.25),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.25),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled{cursor:default;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=65);-khtml-opacity:.65;-moz-opacity:.65;opacity:.65;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn[disabled]{cursor:default;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);filter:alpha(opacity=65);-khtml-opacity:.65;-moz-opacity:.65;opacity:.65;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn.large{font-size:15px;line-height:normal;padding:9px 14px 9px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn.small{padding:7px 9px 7px;font-size:11px}:root .alert-message,:root .btn{border-radius:0 \0}button.btn::-moz-focus-inner,input[type=submit].btn::-moz-focus-inner{padding:0;border:0}.close{float:right;color:#000;font-size:20px;font-weight:bold;line-height:13.5px;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);-khtml-opacity:.2;-moz-opacity:.2;opacity:.2}.close:hover{color:#000;text-decoration:none;filter:alpha(opacity=40);-khtml-opacity:.4;-moz-opacity:.4;opacity:.4}.alert-message{position:relative;padding:7px 15px;margin-bottom:18px;color:#404040;background-color:#eedc94;background-repeat:repeat-x;background-image:-khtml-gradient(linear,left top,left bottom,from(#fceec1),to(#eedc94));background-image:-moz-linear-gradient(top,#fceec1,#eedc94);background-image:-ms-linear-gradient(top,#fceec1,#eedc94);background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#fceec1),color-stop(100%,#eedc94));background-image:-webkit-linear-gradient(top,#fceec1,#eedc94);background-image:-o-linear-gradient(top,#fceec1,#eedc94);background-image:linear-gradient(top,#fceec1,#eedc94);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fceec1',endColorstr='#eedc94',GradientType=0);text-shadow:0 -1px 0 rgba(0,0,0,0.25);border-color:#eedc94 #eedc94 #e4c652;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);text-shadow:0 1px 0 rgba(255,255,255,0.5);border-width:1px;border-style:solid;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.25);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.25);box-shadow:inset 0 1px 0 rgba(255,255,255,0.25)}.alert-message .close{*margin-top:3px}.alert-message h5{line-height:18px}.alert-message p{margin-bottom:0}.alert-message div{margin-top:5px;margin-bottom:2px;line-height:28px}.alert-message .btn{-webkit-box-shadow:0 1px 0 rgba(255,255,255,0.25);-moz-box-shadow:0 1px 0 rgba(255,255,255,0.25);box-shadow:0 1px 0 rgba(255,255,255,0.25)}.alert-message.block-message{background-image:none;background-color:#fdf5d9;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);padding:14px;border-color:#fceec1;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.alert-message.block-message ul,.alert-message.block-message p{margin-right:30px}.alert-message.block-message ul{margin-bottom:0}.alert-message.block-message li{color:#404040}.alert-message.block-message .alert-actions{margin-top:5px}.alert-message.block-message.error,.alert-message.block-message.success,.alert-message.block-message.info{color:#404040;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.alert-message.block-message.error{background-color:#fddfde;border-color:#fbc7c6}.alert-message.block-message.success{background-color:#d1eed1;border-color:#bfe7bf}.alert-message.block-message.info{background-color:#ddf4fb;border-color:#c6edf9}.pagination{height:36px;margin:18px 0}.pagination ul{float:left;margin:0;border:1px solid #ddd;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination li{display:inline}.pagination a{float:left;padding:0 14px;line-height:34px;border-right:1px solid;border-right-color:#ddd;border-right-color:rgba(0,0,0,0.15);*border-right-color:#ddd;text-decoration:none}.pagination a:hover,.pagination .active a{background-color:#c7eefe}.pagination .disabled a,.pagination .disabled a:hover{background-color:transparent;color:#bfbfbf}.pagination .next a{border:0}.well{background-color:#f5f5f5;margin-bottom:20px;padding:19px;min-height:20px;border:1px solid #eee;border:1px solid rgba(0,0,0,0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.modal-backdrop{background-color:#000;position:fixed;top:0;left:0;right:0;bottom:0;z-index:10000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{filter:alpha(opacity=80);-khtml-opacity:.8;-moz-opacity:.8;opacity:.8}.modal{position:fixed;top:50%;left:50%;z-index:11000;width:560px;margin:-250px 0 0 -250px;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal .close{margin-top:7px}.modal.fade{-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-ms-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out;top:-25%}.modal.fade.in{top:50%}.modal-header{border-bottom:1px solid #eee;padding:5px 15px}.modal-body{padding:15px}.modal-footer{background-color:#f5f5f5;padding:14px 15px 15px;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff;zoom:1;margin-bottom:0}.modal-footer:before,.modal-footer:after{display:table;content:"";zoom:1;*display:inline}.modal-footer:after{clear:both}.modal-footer .btn{float:right;margin-left:5px}.twipsy{display:block;position:absolute;visibility:visible;padding:5px;font-size:11px;z-index:1000;filter:alpha(opacity=80);-khtml-opacity:.8;-moz-opacity:.8;opacity:.8}.twipsy.fade.in{filter:alpha(opacity=80);-khtml-opacity:.8;-moz-opacity:.8;opacity:.8}.twipsy.above .twipsy-arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000}.twipsy.left .twipsy-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.twipsy.below .twipsy-arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000}.twipsy.right .twipsy-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000}.twipsy-inner{padding:3px 8px;background-color:#000;color:white;text-align:center;max-width:200px;text-decoration:none;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.twipsy-arrow{position:absolute;width:0;height:0}.popover{position:absolute;top:0;left:0;z-index:1000;padding:5px;display:none}.popover.above .arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000}.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000}.popover.below .arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000}.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.popover .arrow{position:absolute;width:0;height:0}.popover .inner{background-color:#000;background-color:rgba(0,0,0,0.8);padding:3px;overflow:hidden;width:280px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.popover .title{background-color:#f5f5f5;padding:9px 15px;line-height:1;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;border-bottom:1px solid #eee}.popover .content{background-color:#fff;padding:14px;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.popover .content p,.popover .content ul,.popover .content ol{margin-bottom:0}.fade{-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-ms-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear;opacity:0}.fade.in{opacity:1}.label{padding:1px 3px 2px;background-color:#bfbfbf;font-size:9.75px;font-weight:bold;color:#fff;text-transform:uppercase;white-space:nowrap;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.label.important{background-color:#c43c35}.label.warning{background-color:#f89406}.label.success{background-color:#46a546}.label.notice{background-color:#62cffc}.media-grid{margin-left:-20px;margin-bottom:0;zoom:1}.media-grid:before,.media-grid:after{display:table;content:"";zoom:1;*display:inline}.media-grid:after{clear:both}.media-grid li{display:inline}.media-grid a{float:left;padding:4px;margin:0 0 20px 20px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.075);box-shadow:0 1px 1px rgba(0,0,0,0.075)}.media-grid a img{display:block}.media-grid a:hover{border-color:#0069d6;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:8px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}</style>
|
16
|
+
<script type="text/javascript" charset="utf-8"> window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"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 p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"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 x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="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,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="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 I=[h,"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 f=[h,"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 H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.ignoreCase){ac=true}else{if(/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){S=true;ac=false;break}}}var Y={b:8,t:9,n:10,v:11,f:12,r:13};function ab(ah){var ag=ah.charCodeAt(0);if(ag!==92){return ag}var af=ah.charAt(1);ag=Y[af];if(ag){return ag}else{if("0"<=af&&af<="7"){return parseInt(ah.substring(1),8)}else{if(af==="u"||af==="x"){return parseInt(ah.substring(2),16)}else{return ah.charCodeAt(1)}}}}function T(af){if(af<32){return(af<16?"\\x0":"\\x")+af.toString(16)}var ag=String.fromCharCode(af);if(ag==="\\"||ag==="-"||ag==="["||ag==="]"){ag="\\"+ag}return ag}function X(am){var aq=am.substring(1,am.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));var ak=[];var af=[];var ao=aq[0]==="^";for(var ar=ao?1:0,aj=aq.length;ar<aj;++ar){var ah=aq[ar];if(/\\[bdsw]/i.test(ah)){ak.push(ah)}else{var ag=ab(ah);var al;if(ar+2<aj&&"-"===aq[ar+1]){al=ab(aq[ar+2]);ar+=2}else{al=ag}af.push([ag,al]);if(!(al<65||ag>122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;ar<af.length;++ar){var at=af[ar];if(at[0]<=ap[1]+1){ap[1]=Math.max(ap[1],at[1])}else{ai.push(ap=at)}}var an=["["];if(ao){an.push("^")}an.push.apply(an,ak);for(var ar=0;ar<ai.length;++ar){var at=ai[ar];an.push(T(at[0]));if(at[1]>at[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.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 ah=aj.length;var an=[];for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){an[af]=-1}}}}for(var ak=1;ak<an.length;++ak){if(-1===an[ak]){an[ak]=++ad}}for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am;if(an[am]===undefined){aj[ak]="(?:"}}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){aj[ak]="\\"+an[am]}}}}for(var ak=0,am=0;ak<ah;++ak){if("^"===aj[ak]&&"^"!==aj[ak+1]){aj[ak]=""}}if(al.ignoreCase&&S){for(var ak=0;ak<ah;++ak){var ag=aj[ak];var ai=ag.charAt(0);if(ag.length>=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.global||ae.multiline){throw new Error(""+ae)}aa.push("(?:"+W(ae)+")")}return new RegExp(aa.join("|"),ac?"gi":"g")}function a(V){var U=/(?:^|\s)nocode(?:\s|$)/;var X=[];var T=0;var Z=[];var W=0;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=document.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Y=S&&"pre"===S.substring(0,3);function aa(ab){switch(ab.nodeType){case 1:if(U.test(ab.className)){return}for(var ae=ab.firstChild;ae;ae=ae.nextSibling){aa(ae)}var ad=ab.nodeName;if("BR"===ad||"LI"===ad){X[W]="\n";Z[W<<1]=T++;Z[(W++<<1)|1]=ab}break;case 3:case 4:var ac=ab.nodeValue;if(ac.length){if(!Y){ac=ac.replace(/[ \t\r\n]+/g," ")}else{ac=ac.replace(/\r\n?/g,"\n")}X[W]=ac;Z[W<<1]=T;T+=ac.length;Z[(W++<<1)|1]=ab}break}}aa(V);return{sourceCode:X.join("").replace(/\n$/,""),spans:Z}}function B(S,U,W,T){if(!U){return}var V={sourceCode:U,basePos:S};W(V);T.push.apply(T,V.decorations)}var v=/\S/;function o(S){var V=undefined;for(var U=S.firstChild;U;U=U.nextSibling){var T=U.nodeType;V=(T===1)?(V?S:U):(T===3)?(v.test(U.nodeValue)?S:V):V}return V===S?undefined:V}function g(U,T){var S={};var V;(function(){var ad=U.concat(T);var ah=[];var ag={};for(var ab=0,Z=ad.length;ab<Z;++ab){var Y=ad[ab];var ac=Y[3];if(ac){for(var ae=ac.length;--ae>=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae<aq;++ae){var ag=an[ae];var ap=aj[ag];var ai=void 0;var am;if(typeof ap==="string"){am=false}else{var aa=S[ag.charAt(0)];if(aa){ai=ag.match(aa[1]);ap=aa[0]}else{for(var ao=0;ao<X;++ao){aa=T[ao];ai=ag.match(aa[1]);if(ai){ap=aa[0];break}}if(!ai){ap=F}}am=ap.length>=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y<W.length;++Y){ae(W[Y])}if(ag===(ag|0)){W[0].setAttribute("value",ag)}var aa=ac.createElement("OL");aa.className="linenums";var X=Math.max(0,((ag-1))|0)||0;for(var Y=0,T=W.length;Y<T;++Y){af=W[Y];af.className="L"+((Y+X)%10);if(!af.firstChild){af.appendChild(ac.createTextNode("\xA0"))}aa.appendChild(af)}V.appendChild(aa)}function D(ac){var aj=/\bMSIE\b/.test(navigator.userAgent);var am=/\n/g;var al=ac.sourceCode;var an=al.length;var V=0;var aa=ac.spans;var T=aa.length;var ah=0;var X=ac.decorations;var Y=X.length;var Z=0;X[Y]=an;var ar,aq;for(aq=ar=0;aq<Y;){if(X[aq]!==X[aq+2]){X[ar++]=X[aq++];X[ar++]=X[aq++]}else{aq+=2}}Y=ar;for(aq=ar=0;aq<Y;){var at=X[aq];var ab=X[aq+1];var W=aq+2;while(W+2<=Y&&X[W+1]===ab){W+=2}X[ar++]=at;X[ar++]=ab;aq=W}Y=X.length=ar;var ae=null;while(ah<T){var af=aa[ah];var S=aa[ah+2]||an;var ag=X[Z];var ap=X[Z+2]||an;var W=Math.min(S,ap);var ak=aa[ah+1];var U;if(ak.nodeType!==1&&(U=al.substring(V,W))){if(aj){U=U.replace(am,"\r")}ak.nodeValue=U;var ai=ak.ownerDocument;var ao=ai.createElement("SPAN");ao.className=X[Z+1];var ad=ak.parentNode;ad.replaceChild(ao,ak);ao.appendChild(ak);if(V<S){aa[ah+1]=ak=ai.createTextNode(al.substring(W,S));ad.insertBefore(ak,ao.nextSibling)}}V=W;if(V>=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*</.test(S)?"default-markup":"default-code"}return t[T]}c(K,["default-code"]);c(g([],[[F,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa<ac.length;++aa){for(var Z=0,V=ac[aa].length;Z<V;++Z){T.push(ac[aa][Z])}}ac=null;var W=Date;if(!W.now){W={now:function(){return +(new Date)}}}var X=0;var S;var ab=/\blang(?:uage)?-([\w.]+)(?!\S)/;var ae=/\bprettyprint\b/;function U(){var ag=(window.PR_SHOULD_USE_CONTINUATION?W.now()+250:Infinity);for(;X<T.length&&W.now()<ag;X++){var aj=T[X];var ai=aj.className;if(ai.indexOf("prettyprint")>=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X<T.length){setTimeout(U,250)}else{if(ad){ad()}}}U()}window.prettyPrintOne=y;window.prettyPrint=b;window.PR={createSimpleLexer:g,registerLangHandler:c,sourceDecorator:i,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:n,PR_COMMENT:j,PR_DECLARATION:E,PR_KEYWORD:z,PR_LITERAL:G,PR_NOCODE:N,PR_PLAIN:F,PR_PUNCTUATION:L,PR_SOURCE:J,PR_STRING:C,PR_TAG:m,PR_TYPE:O}})();</script>
|
17
|
+
</head>
|
18
|
+
<body onload="prettyPrint()">
|
19
|
+
<div class="container">
|
20
|
+
<div class="row">
|
21
|
+
<div id="content" class="span12 offset2"></div>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/* Pretty printing styles. Used with prettify.js. */
|
2
|
+
|
3
|
+
/* SPAN elements with the classes below are added by prettyprint. */
|
4
|
+
.pln { color: #000 } /* plain text */
|
5
|
+
|
6
|
+
@media screen {
|
7
|
+
.str { color: #080 } /* string content */
|
8
|
+
.kwd { color: #008 } /* a keyword */
|
9
|
+
.com { color: #800 } /* a comment */
|
10
|
+
.typ { color: #606 } /* a type name */
|
11
|
+
.lit { color: #066 } /* a literal value */
|
12
|
+
/* punctuation, lisp open bracket, lisp close bracket */
|
13
|
+
.pun, .opn, .clo { color: #660 }
|
14
|
+
.tag { color: #008 } /* a markup tag name */
|
15
|
+
.atn { color: #606 } /* a markup attribute name */
|
16
|
+
.atv { color: #080 } /* a markup attribute value */
|
17
|
+
.dec, .var { color: #606 } /* a declaration; a variable name */
|
18
|
+
.fun { color: red } /* a function name */
|
19
|
+
}
|
20
|
+
|
21
|
+
/* Use higher contrast and text-weight for printable form. */
|
22
|
+
@media print, projection {
|
23
|
+
.str { color: #060 }
|
24
|
+
.kwd { color: #006; font-weight: bold }
|
25
|
+
.com { color: #600; font-style: italic }
|
26
|
+
.typ { color: #404; font-weight: bold }
|
27
|
+
.lit { color: #044 }
|
28
|
+
.pun, .opn, .clo { color: #440 }
|
29
|
+
.tag { color: #006; font-weight: bold }
|
30
|
+
.atn { color: #404 }
|
31
|
+
.atv { color: #060 }
|
32
|
+
}
|
33
|
+
|
34
|
+
/* Put a border around prettyprinted code snippets. */
|
35
|
+
pre.prettyprint { padding: 8px; border: 1px solid #888 }
|
36
|
+
|
37
|
+
/* Specify class=linenums on a pre to get line numbering */
|
38
|
+
ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
|
39
|
+
li.L0,
|
40
|
+
li.L1,
|
41
|
+
li.L2,
|
42
|
+
li.L3,
|
43
|
+
li.L5,
|
44
|
+
li.L6,
|
45
|
+
li.L7,
|
46
|
+
li.L8 { list-style-type: none }
|
47
|
+
/* Alternate shading for lines */
|
48
|
+
li.L1,
|
49
|
+
li.L3,
|
50
|
+
li.L5,
|
51
|
+
li.L7,
|
52
|
+
li.L9 { background: #eee }
|
@@ -0,0 +1,1477 @@
|
|
1
|
+
// Copyright (C) 2006 Google Inc.
|
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
|
+
|
16
|
+
/**
|
17
|
+
* @fileoverview
|
18
|
+
* some functions for browser-side pretty printing of code contained in html.
|
19
|
+
*
|
20
|
+
* <p>
|
21
|
+
* For a fairly comprehensive set of languages see the
|
22
|
+
* <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a>
|
23
|
+
* file that came with this source. At a minimum, the lexer should work on a
|
24
|
+
* number of languages including C and friends, Java, Python, Bash, SQL, HTML,
|
25
|
+
* XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk
|
26
|
+
* and a subset of Perl, but, because of commenting conventions, doesn't work on
|
27
|
+
* Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
|
28
|
+
* <p>
|
29
|
+
* Usage: <ol>
|
30
|
+
* <li> include this source file in an html page via
|
31
|
+
* {@code <script type="text/javascript" src="/path/to/prettify.js"></script>}
|
32
|
+
* <li> define style rules. See the example page for examples.
|
33
|
+
* <li> mark the {@code <pre>} and {@code <code>} tags in your source with
|
34
|
+
* {@code class=prettyprint.}
|
35
|
+
* You can also use the (html deprecated) {@code <xmp>} tag, but the pretty
|
36
|
+
* printer needs to do more substantial DOM manipulations to support that, so
|
37
|
+
* some css styles may not be preserved.
|
38
|
+
* </ol>
|
39
|
+
* That's it. I wanted to keep the API as simple as possible, so there's no
|
40
|
+
* need to specify which language the code is in, but if you wish, you can add
|
41
|
+
* another class to the {@code <pre>} or {@code <code>} element to specify the
|
42
|
+
* language, as in {@code <pre class="prettyprint lang-java">}. Any class that
|
43
|
+
* starts with "lang-" followed by a file extension, specifies the file type.
|
44
|
+
* See the "lang-*.js" files in this directory for code that implements
|
45
|
+
* per-language file handlers.
|
46
|
+
* <p>
|
47
|
+
* Change log:<br>
|
48
|
+
* cbeust, 2006/08/22
|
49
|
+
* <blockquote>
|
50
|
+
* Java annotations (start with "@") are now captured as literals ("lit")
|
51
|
+
* </blockquote>
|
52
|
+
* @requires console
|
53
|
+
*/
|
54
|
+
|
55
|
+
// JSLint declarations
|
56
|
+
/*global console, document, navigator, setTimeout, window */
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Split {@code prettyPrint} into multiple timeouts so as not to interfere with
|
60
|
+
* UI events.
|
61
|
+
* If set to {@code false}, {@code prettyPrint()} is synchronous.
|
62
|
+
*/
|
63
|
+
window['PR_SHOULD_USE_CONTINUATION'] = true;
|
64
|
+
|
65
|
+
(function () {
|
66
|
+
// Keyword lists for various languages.
|
67
|
+
// We use things that coerce to strings to make them compact when minified
|
68
|
+
// and to defeat aggressive optimizers that fold large string constants.
|
69
|
+
var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"];
|
70
|
+
var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," +
|
71
|
+
"double,enum,extern,float,goto,int,long,register,short,signed,sizeof," +
|
72
|
+
"static,struct,switch,typedef,union,unsigned,void,volatile"];
|
73
|
+
var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," +
|
74
|
+
"new,operator,private,protected,public,this,throw,true,try,typeof"];
|
75
|
+
var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," +
|
76
|
+
"concept,concept_map,const_cast,constexpr,decltype," +
|
77
|
+
"dynamic_cast,explicit,export,friend,inline,late_check," +
|
78
|
+
"mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast," +
|
79
|
+
"template,typeid,typename,using,virtual,where"];
|
80
|
+
var JAVA_KEYWORDS = [COMMON_KEYWORDS,
|
81
|
+
"abstract,boolean,byte,extends,final,finally,implements,import," +
|
82
|
+
"instanceof,null,native,package,strictfp,super,synchronized,throws," +
|
83
|
+
"transient"];
|
84
|
+
var CSHARP_KEYWORDS = [JAVA_KEYWORDS,
|
85
|
+
"as,base,by,checked,decimal,delegate,descending,dynamic,event," +
|
86
|
+
"fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock," +
|
87
|
+
"object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed," +
|
88
|
+
"stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];
|
89
|
+
var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," +
|
90
|
+
"for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," +
|
91
|
+
"true,try,unless,until,when,while,yes";
|
92
|
+
var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS,
|
93
|
+
"debugger,eval,export,function,get,null,set,undefined,var,with," +
|
94
|
+
"Infinity,NaN"];
|
95
|
+
var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," +
|
96
|
+
"goto,if,import,last,local,my,next,no,our,print,package,redo,require," +
|
97
|
+
"sub,undef,unless,until,use,wantarray,while,BEGIN,END";
|
98
|
+
var PYTHON_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "and,as,assert,class,def,del," +
|
99
|
+
"elif,except,exec,finally,from,global,import,in,is,lambda," +
|
100
|
+
"nonlocal,not,or,pass,print,raise,try,with,yield," +
|
101
|
+
"False,True,None"];
|
102
|
+
var RUBY_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "alias,and,begin,case,class," +
|
103
|
+
"def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo," +
|
104
|
+
"rescue,retry,self,super,then,true,undef,unless,until,when,yield," +
|
105
|
+
"BEGIN,END"];
|
106
|
+
var SH_KEYWORDS = [FLOW_CONTROL_KEYWORDS, "case,done,elif,esac,eval,fi," +
|
107
|
+
"function,in,local,set,then,until"];
|
108
|
+
var ALL_KEYWORDS = [
|
109
|
+
CPP_KEYWORDS, CSHARP_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS +
|
110
|
+
PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS];
|
111
|
+
var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;
|
112
|
+
|
113
|
+
// token style names. correspond to css classes
|
114
|
+
/**
|
115
|
+
* token style for a string literal
|
116
|
+
* @const
|
117
|
+
*/
|
118
|
+
var PR_STRING = 'str';
|
119
|
+
/**
|
120
|
+
* token style for a keyword
|
121
|
+
* @const
|
122
|
+
*/
|
123
|
+
var PR_KEYWORD = 'kwd';
|
124
|
+
/**
|
125
|
+
* token style for a comment
|
126
|
+
* @const
|
127
|
+
*/
|
128
|
+
var PR_COMMENT = 'com';
|
129
|
+
/**
|
130
|
+
* token style for a type
|
131
|
+
* @const
|
132
|
+
*/
|
133
|
+
var PR_TYPE = 'typ';
|
134
|
+
/**
|
135
|
+
* token style for a literal value. e.g. 1, null, true.
|
136
|
+
* @const
|
137
|
+
*/
|
138
|
+
var PR_LITERAL = 'lit';
|
139
|
+
/**
|
140
|
+
* token style for a punctuation string.
|
141
|
+
* @const
|
142
|
+
*/
|
143
|
+
var PR_PUNCTUATION = 'pun';
|
144
|
+
/**
|
145
|
+
* token style for a punctuation string.
|
146
|
+
* @const
|
147
|
+
*/
|
148
|
+
var PR_PLAIN = 'pln';
|
149
|
+
|
150
|
+
/**
|
151
|
+
* token style for an sgml tag.
|
152
|
+
* @const
|
153
|
+
*/
|
154
|
+
var PR_TAG = 'tag';
|
155
|
+
/**
|
156
|
+
* token style for a markup declaration such as a DOCTYPE.
|
157
|
+
* @const
|
158
|
+
*/
|
159
|
+
var PR_DECLARATION = 'dec';
|
160
|
+
/**
|
161
|
+
* token style for embedded source.
|
162
|
+
* @const
|
163
|
+
*/
|
164
|
+
var PR_SOURCE = 'src';
|
165
|
+
/**
|
166
|
+
* token style for an sgml attribute name.
|
167
|
+
* @const
|
168
|
+
*/
|
169
|
+
var PR_ATTRIB_NAME = 'atn';
|
170
|
+
/**
|
171
|
+
* token style for an sgml attribute value.
|
172
|
+
* @const
|
173
|
+
*/
|
174
|
+
var PR_ATTRIB_VALUE = 'atv';
|
175
|
+
|
176
|
+
/**
|
177
|
+
* A class that indicates a section of markup that is not code, e.g. to allow
|
178
|
+
* embedding of line numbers within code listings.
|
179
|
+
* @const
|
180
|
+
*/
|
181
|
+
var PR_NOCODE = 'nocode';
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
/**
|
186
|
+
* A set of tokens that can precede a regular expression literal in
|
187
|
+
* javascript
|
188
|
+
* http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html
|
189
|
+
* has the full list, but I've removed ones that might be problematic when
|
190
|
+
* seen in languages that don't support regular expression literals.
|
191
|
+
*
|
192
|
+
* <p>Specifically, I've removed any keywords that can't precede a regexp
|
193
|
+
* literal in a syntactically legal javascript program, and I've removed the
|
194
|
+
* "in" keyword since it's not a keyword in many languages, and might be used
|
195
|
+
* as a count of inches.
|
196
|
+
*
|
197
|
+
* <p>The link a above does not accurately describe EcmaScript rules since
|
198
|
+
* it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
|
199
|
+
* very well in practice.
|
200
|
+
*
|
201
|
+
* @private
|
202
|
+
* @const
|
203
|
+
*/
|
204
|
+
var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*';
|
205
|
+
|
206
|
+
// CAVEAT: this does not properly handle the case where a regular
|
207
|
+
// expression immediately follows another since a regular expression may
|
208
|
+
// have flags for case-sensitivity and the like. Having regexp tokens
|
209
|
+
// adjacent is not valid in any language I'm aware of, so I'm punting.
|
210
|
+
// TODO: maybe style special characters inside a regexp as punctuation.
|
211
|
+
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
|
215
|
+
* matches the union of the sets of strings matched by the input RegExp.
|
216
|
+
* Since it matches globally, if the input strings have a start-of-input
|
217
|
+
* anchor (/^.../), it is ignored for the purposes of unioning.
|
218
|
+
* @param {Array.<RegExp>} regexs non multiline, non-global regexs.
|
219
|
+
* @return {RegExp} a global regex.
|
220
|
+
*/
|
221
|
+
function combinePrefixPatterns(regexs) {
|
222
|
+
var capturedGroupIndex = 0;
|
223
|
+
|
224
|
+
var needToFoldCase = false;
|
225
|
+
var ignoreCase = false;
|
226
|
+
for (var i = 0, n = regexs.length; i < n; ++i) {
|
227
|
+
var regex = regexs[i];
|
228
|
+
if (regex.ignoreCase) {
|
229
|
+
ignoreCase = true;
|
230
|
+
} else if (/[a-z]/i.test(regex.source.replace(
|
231
|
+
/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
|
232
|
+
needToFoldCase = true;
|
233
|
+
ignoreCase = false;
|
234
|
+
break;
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
var escapeCharToCodeUnit = {
|
239
|
+
'b': 8,
|
240
|
+
't': 9,
|
241
|
+
'n': 0xa,
|
242
|
+
'v': 0xb,
|
243
|
+
'f': 0xc,
|
244
|
+
'r': 0xd
|
245
|
+
};
|
246
|
+
|
247
|
+
function decodeEscape(charsetPart) {
|
248
|
+
var cc0 = charsetPart.charCodeAt(0);
|
249
|
+
if (cc0 !== 92 /* \\ */) {
|
250
|
+
return cc0;
|
251
|
+
}
|
252
|
+
var c1 = charsetPart.charAt(1);
|
253
|
+
cc0 = escapeCharToCodeUnit[c1];
|
254
|
+
if (cc0) {
|
255
|
+
return cc0;
|
256
|
+
} else if ('0' <= c1 && c1 <= '7') {
|
257
|
+
return parseInt(charsetPart.substring(1), 8);
|
258
|
+
} else if (c1 === 'u' || c1 === 'x') {
|
259
|
+
return parseInt(charsetPart.substring(2), 16);
|
260
|
+
} else {
|
261
|
+
return charsetPart.charCodeAt(1);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
function encodeEscape(charCode) {
|
266
|
+
if (charCode < 0x20) {
|
267
|
+
return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
|
268
|
+
}
|
269
|
+
var ch = String.fromCharCode(charCode);
|
270
|
+
if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
|
271
|
+
ch = '\\' + ch;
|
272
|
+
}
|
273
|
+
return ch;
|
274
|
+
}
|
275
|
+
|
276
|
+
function caseFoldCharset(charSet) {
|
277
|
+
var charsetParts = charSet.substring(1, charSet.length - 1).match(
|
278
|
+
new RegExp(
|
279
|
+
'\\\\u[0-9A-Fa-f]{4}'
|
280
|
+
+ '|\\\\x[0-9A-Fa-f]{2}'
|
281
|
+
+ '|\\\\[0-3][0-7]{0,2}'
|
282
|
+
+ '|\\\\[0-7]{1,2}'
|
283
|
+
+ '|\\\\[\\s\\S]'
|
284
|
+
+ '|-'
|
285
|
+
+ '|[^-\\\\]',
|
286
|
+
'g'));
|
287
|
+
var groups = [];
|
288
|
+
var ranges = [];
|
289
|
+
var inverse = charsetParts[0] === '^';
|
290
|
+
for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
|
291
|
+
var p = charsetParts[i];
|
292
|
+
if (/\\[bdsw]/i.test(p)) { // Don't muck with named groups.
|
293
|
+
groups.push(p);
|
294
|
+
} else {
|
295
|
+
var start = decodeEscape(p);
|
296
|
+
var end;
|
297
|
+
if (i + 2 < n && '-' === charsetParts[i + 1]) {
|
298
|
+
end = decodeEscape(charsetParts[i + 2]);
|
299
|
+
i += 2;
|
300
|
+
} else {
|
301
|
+
end = start;
|
302
|
+
}
|
303
|
+
ranges.push([start, end]);
|
304
|
+
// If the range might intersect letters, then expand it.
|
305
|
+
// This case handling is too simplistic.
|
306
|
+
// It does not deal with non-latin case folding.
|
307
|
+
// It works for latin source code identifiers though.
|
308
|
+
if (!(end < 65 || start > 122)) {
|
309
|
+
if (!(end < 65 || start > 90)) {
|
310
|
+
ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
|
311
|
+
}
|
312
|
+
if (!(end < 97 || start > 122)) {
|
313
|
+
ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
|
314
|
+
}
|
315
|
+
}
|
316
|
+
}
|
317
|
+
}
|
318
|
+
|
319
|
+
// [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
|
320
|
+
// -> [[1, 12], [14, 14], [16, 17]]
|
321
|
+
ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
|
322
|
+
var consolidatedRanges = [];
|
323
|
+
var lastRange = [NaN, NaN];
|
324
|
+
for (var i = 0; i < ranges.length; ++i) {
|
325
|
+
var range = ranges[i];
|
326
|
+
if (range[0] <= lastRange[1] + 1) {
|
327
|
+
lastRange[1] = Math.max(lastRange[1], range[1]);
|
328
|
+
} else {
|
329
|
+
consolidatedRanges.push(lastRange = range);
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
var out = ['['];
|
334
|
+
if (inverse) { out.push('^'); }
|
335
|
+
out.push.apply(out, groups);
|
336
|
+
for (var i = 0; i < consolidatedRanges.length; ++i) {
|
337
|
+
var range = consolidatedRanges[i];
|
338
|
+
out.push(encodeEscape(range[0]));
|
339
|
+
if (range[1] > range[0]) {
|
340
|
+
if (range[1] + 1 > range[0]) { out.push('-'); }
|
341
|
+
out.push(encodeEscape(range[1]));
|
342
|
+
}
|
343
|
+
}
|
344
|
+
out.push(']');
|
345
|
+
return out.join('');
|
346
|
+
}
|
347
|
+
|
348
|
+
function allowAnywhereFoldCaseAndRenumberGroups(regex) {
|
349
|
+
// Split into character sets, escape sequences, punctuation strings
|
350
|
+
// like ('(', '(?:', ')', '^'), and runs of characters that do not
|
351
|
+
// include any of the above.
|
352
|
+
var parts = regex.source.match(
|
353
|
+
new RegExp(
|
354
|
+
'(?:'
|
355
|
+
+ '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
|
356
|
+
+ '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
|
357
|
+
+ '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
|
358
|
+
+ '|\\\\[0-9]+' // a back-reference or octal escape
|
359
|
+
+ '|\\\\[^ux0-9]' // other escape sequence
|
360
|
+
+ '|\\(\\?[:!=]' // start of a non-capturing group
|
361
|
+
+ '|[\\(\\)\\^]' // start/emd of a group, or line start
|
362
|
+
+ '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
|
363
|
+
+ ')',
|
364
|
+
'g'));
|
365
|
+
var n = parts.length;
|
366
|
+
|
367
|
+
// Maps captured group numbers to the number they will occupy in
|
368
|
+
// the output or to -1 if that has not been determined, or to
|
369
|
+
// undefined if they need not be capturing in the output.
|
370
|
+
var capturedGroups = [];
|
371
|
+
|
372
|
+
// Walk over and identify back references to build the capturedGroups
|
373
|
+
// mapping.
|
374
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
375
|
+
var p = parts[i];
|
376
|
+
if (p === '(') {
|
377
|
+
// groups are 1-indexed, so max group index is count of '('
|
378
|
+
++groupIndex;
|
379
|
+
} else if ('\\' === p.charAt(0)) {
|
380
|
+
var decimalValue = +p.substring(1);
|
381
|
+
if (decimalValue && decimalValue <= groupIndex) {
|
382
|
+
capturedGroups[decimalValue] = -1;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
// Renumber groups and reduce capturing groups to non-capturing groups
|
388
|
+
// where possible.
|
389
|
+
for (var i = 1; i < capturedGroups.length; ++i) {
|
390
|
+
if (-1 === capturedGroups[i]) {
|
391
|
+
capturedGroups[i] = ++capturedGroupIndex;
|
392
|
+
}
|
393
|
+
}
|
394
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
395
|
+
var p = parts[i];
|
396
|
+
if (p === '(') {
|
397
|
+
++groupIndex;
|
398
|
+
if (capturedGroups[groupIndex] === undefined) {
|
399
|
+
parts[i] = '(?:';
|
400
|
+
}
|
401
|
+
} else if ('\\' === p.charAt(0)) {
|
402
|
+
var decimalValue = +p.substring(1);
|
403
|
+
if (decimalValue && decimalValue <= groupIndex) {
|
404
|
+
parts[i] = '\\' + capturedGroups[groupIndex];
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
// Remove any prefix anchors so that the output will match anywhere.
|
410
|
+
// ^^ really does mean an anchored match though.
|
411
|
+
for (var i = 0, groupIndex = 0; i < n; ++i) {
|
412
|
+
if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
|
413
|
+
}
|
414
|
+
|
415
|
+
// Expand letters to groups to handle mixing of case-sensitive and
|
416
|
+
// case-insensitive patterns if necessary.
|
417
|
+
if (regex.ignoreCase && needToFoldCase) {
|
418
|
+
for (var i = 0; i < n; ++i) {
|
419
|
+
var p = parts[i];
|
420
|
+
var ch0 = p.charAt(0);
|
421
|
+
if (p.length >= 2 && ch0 === '[') {
|
422
|
+
parts[i] = caseFoldCharset(p);
|
423
|
+
} else if (ch0 !== '\\') {
|
424
|
+
// TODO: handle letters in numeric escapes.
|
425
|
+
parts[i] = p.replace(
|
426
|
+
/[a-zA-Z]/g,
|
427
|
+
function (ch) {
|
428
|
+
var cc = ch.charCodeAt(0);
|
429
|
+
return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
|
430
|
+
});
|
431
|
+
}
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
return parts.join('');
|
436
|
+
}
|
437
|
+
|
438
|
+
var rewritten = [];
|
439
|
+
for (var i = 0, n = regexs.length; i < n; ++i) {
|
440
|
+
var regex = regexs[i];
|
441
|
+
if (regex.global || regex.multiline) { throw new Error('' + regex); }
|
442
|
+
rewritten.push(
|
443
|
+
'(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
|
444
|
+
}
|
445
|
+
|
446
|
+
return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
|
447
|
+
}
|
448
|
+
|
449
|
+
|
450
|
+
/**
|
451
|
+
* Split markup into a string of source code and an array mapping ranges in
|
452
|
+
* that string to the text nodes in which they appear.
|
453
|
+
*
|
454
|
+
* <p>
|
455
|
+
* The HTML DOM structure:</p>
|
456
|
+
* <pre>
|
457
|
+
* (Element "p"
|
458
|
+
* (Element "b"
|
459
|
+
* (Text "print ")) ; #1
|
460
|
+
* (Text "'Hello '") ; #2
|
461
|
+
* (Element "br") ; #3
|
462
|
+
* (Text " + 'World';")) ; #4
|
463
|
+
* </pre>
|
464
|
+
* <p>
|
465
|
+
* corresponds to the HTML
|
466
|
+
* {@code <p><b>print </b>'Hello '<br> + 'World';</p>}.</p>
|
467
|
+
*
|
468
|
+
* <p>
|
469
|
+
* It will produce the output:</p>
|
470
|
+
* <pre>
|
471
|
+
* {
|
472
|
+
* sourceCode: "print 'Hello '\n + 'World';",
|
473
|
+
* // 1 2
|
474
|
+
* // 012345678901234 5678901234567
|
475
|
+
* spans: [0, #1, 6, #2, 14, #3, 15, #4]
|
476
|
+
* }
|
477
|
+
* </pre>
|
478
|
+
* <p>
|
479
|
+
* where #1 is a reference to the {@code "print "} text node above, and so
|
480
|
+
* on for the other text nodes.
|
481
|
+
* </p>
|
482
|
+
*
|
483
|
+
* <p>
|
484
|
+
* The {@code} spans array is an array of pairs. Even elements are the start
|
485
|
+
* indices of substrings, and odd elements are the text nodes (or BR elements)
|
486
|
+
* that contain the text for those substrings.
|
487
|
+
* Substrings continue until the next index or the end of the source.
|
488
|
+
* </p>
|
489
|
+
*
|
490
|
+
* @param {Node} node an HTML DOM subtree containing source-code.
|
491
|
+
* @return {Object} source code and the text nodes in which they occur.
|
492
|
+
*/
|
493
|
+
function extractSourceSpans(node) {
|
494
|
+
var nocode = /(?:^|\s)nocode(?:\s|$)/;
|
495
|
+
|
496
|
+
var chunks = [];
|
497
|
+
var length = 0;
|
498
|
+
var spans = [];
|
499
|
+
var k = 0;
|
500
|
+
|
501
|
+
var whitespace;
|
502
|
+
if (node.currentStyle) {
|
503
|
+
whitespace = node.currentStyle.whiteSpace;
|
504
|
+
} else if (window.getComputedStyle) {
|
505
|
+
whitespace = document.defaultView.getComputedStyle(node, null)
|
506
|
+
.getPropertyValue('white-space');
|
507
|
+
}
|
508
|
+
var isPreformatted = whitespace && 'pre' === whitespace.substring(0, 3);
|
509
|
+
|
510
|
+
function walk(node) {
|
511
|
+
switch (node.nodeType) {
|
512
|
+
case 1: // Element
|
513
|
+
if (nocode.test(node.className)) { return; }
|
514
|
+
for (var child = node.firstChild; child; child = child.nextSibling) {
|
515
|
+
walk(child);
|
516
|
+
}
|
517
|
+
var nodeName = node.nodeName;
|
518
|
+
if ('BR' === nodeName || 'LI' === nodeName) {
|
519
|
+
chunks[k] = '\n';
|
520
|
+
spans[k << 1] = length++;
|
521
|
+
spans[(k++ << 1) | 1] = node;
|
522
|
+
}
|
523
|
+
break;
|
524
|
+
case 3: case 4: // Text
|
525
|
+
var text = node.nodeValue;
|
526
|
+
if (text.length) {
|
527
|
+
if (!isPreformatted) {
|
528
|
+
text = text.replace(/[ \t\r\n]+/g, ' ');
|
529
|
+
} else {
|
530
|
+
text = text.replace(/\r\n?/g, '\n'); // Normalize newlines.
|
531
|
+
}
|
532
|
+
// TODO: handle tabs here?
|
533
|
+
chunks[k] = text;
|
534
|
+
spans[k << 1] = length;
|
535
|
+
length += text.length;
|
536
|
+
spans[(k++ << 1) | 1] = node;
|
537
|
+
}
|
538
|
+
break;
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
walk(node);
|
543
|
+
|
544
|
+
return {
|
545
|
+
sourceCode: chunks.join('').replace(/\n$/, ''),
|
546
|
+
spans: spans
|
547
|
+
};
|
548
|
+
}
|
549
|
+
|
550
|
+
|
551
|
+
/**
|
552
|
+
* Apply the given language handler to sourceCode and add the resulting
|
553
|
+
* decorations to out.
|
554
|
+
* @param {number} basePos the index of sourceCode within the chunk of source
|
555
|
+
* whose decorations are already present on out.
|
556
|
+
*/
|
557
|
+
function appendDecorations(basePos, sourceCode, langHandler, out) {
|
558
|
+
if (!sourceCode) { return; }
|
559
|
+
var job = {
|
560
|
+
sourceCode: sourceCode,
|
561
|
+
basePos: basePos
|
562
|
+
};
|
563
|
+
langHandler(job);
|
564
|
+
out.push.apply(out, job.decorations);
|
565
|
+
}
|
566
|
+
|
567
|
+
var notWs = /\S/;
|
568
|
+
|
569
|
+
/**
|
570
|
+
* Given an element, if it contains only one child element and any text nodes
|
571
|
+
* it contains contain only space characters, return the sole child element.
|
572
|
+
* Otherwise returns undefined.
|
573
|
+
* <p>
|
574
|
+
* This is meant to return the CODE element in {@code <pre><code ...>} when
|
575
|
+
* there is a single child element that contains all the non-space textual
|
576
|
+
* content, but not to return anything where there are multiple child elements
|
577
|
+
* as in {@code <pre><code>...</code><code>...</code></pre>} or when there
|
578
|
+
* is textual content.
|
579
|
+
*/
|
580
|
+
function childContentWrapper(element) {
|
581
|
+
var wrapper = undefined;
|
582
|
+
for (var c = element.firstChild; c; c = c.nextSibling) {
|
583
|
+
var type = c.nodeType;
|
584
|
+
wrapper = (type === 1) // Element Node
|
585
|
+
? (wrapper ? element : c)
|
586
|
+
: (type === 3) // Text Node
|
587
|
+
? (notWs.test(c.nodeValue) ? element : wrapper)
|
588
|
+
: wrapper;
|
589
|
+
}
|
590
|
+
return wrapper === element ? undefined : wrapper;
|
591
|
+
}
|
592
|
+
|
593
|
+
/** Given triples of [style, pattern, context] returns a lexing function,
|
594
|
+
* The lexing function interprets the patterns to find token boundaries and
|
595
|
+
* returns a decoration list of the form
|
596
|
+
* [index_0, style_0, index_1, style_1, ..., index_n, style_n]
|
597
|
+
* where index_n is an index into the sourceCode, and style_n is a style
|
598
|
+
* constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
|
599
|
+
* all characters in sourceCode[index_n-1:index_n].
|
600
|
+
*
|
601
|
+
* The stylePatterns is a list whose elements have the form
|
602
|
+
* [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
|
603
|
+
*
|
604
|
+
* Style is a style constant like PR_PLAIN, or can be a string of the
|
605
|
+
* form 'lang-FOO', where FOO is a language extension describing the
|
606
|
+
* language of the portion of the token in $1 after pattern executes.
|
607
|
+
* E.g., if style is 'lang-lisp', and group 1 contains the text
|
608
|
+
* '(hello (world))', then that portion of the token will be passed to the
|
609
|
+
* registered lisp handler for formatting.
|
610
|
+
* The text before and after group 1 will be restyled using this decorator
|
611
|
+
* so decorators should take care that this doesn't result in infinite
|
612
|
+
* recursion. For example, the HTML lexer rule for SCRIPT elements looks
|
613
|
+
* something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
|
614
|
+
* '<script>foo()<\/script>', which would cause the current decorator to
|
615
|
+
* be called with '<script>' which would not match the same rule since
|
616
|
+
* group 1 must not be empty, so it would be instead styled as PR_TAG by
|
617
|
+
* the generic tag rule. The handler registered for the 'js' extension would
|
618
|
+
* then be called with 'foo()', and finally, the current decorator would
|
619
|
+
* be called with '<\/script>' which would not match the original rule and
|
620
|
+
* so the generic tag rule would identify it as a tag.
|
621
|
+
*
|
622
|
+
* Pattern must only match prefixes, and if it matches a prefix, then that
|
623
|
+
* match is considered a token with the same style.
|
624
|
+
*
|
625
|
+
* Context is applied to the last non-whitespace, non-comment token
|
626
|
+
* recognized.
|
627
|
+
*
|
628
|
+
* Shortcut is an optional string of characters, any of which, if the first
|
629
|
+
* character, gurantee that this pattern and only this pattern matches.
|
630
|
+
*
|
631
|
+
* @param {Array} shortcutStylePatterns patterns that always start with
|
632
|
+
* a known character. Must have a shortcut string.
|
633
|
+
* @param {Array} fallthroughStylePatterns patterns that will be tried in
|
634
|
+
* order if the shortcut ones fail. May have shortcuts.
|
635
|
+
*
|
636
|
+
* @return {function (Object)} a
|
637
|
+
* function that takes source code and returns a list of decorations.
|
638
|
+
*/
|
639
|
+
function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
|
640
|
+
var shortcuts = {};
|
641
|
+
var tokenizer;
|
642
|
+
(function () {
|
643
|
+
var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
|
644
|
+
var allRegexs = [];
|
645
|
+
var regexKeys = {};
|
646
|
+
for (var i = 0, n = allPatterns.length; i < n; ++i) {
|
647
|
+
var patternParts = allPatterns[i];
|
648
|
+
var shortcutChars = patternParts[3];
|
649
|
+
if (shortcutChars) {
|
650
|
+
for (var c = shortcutChars.length; --c >= 0;) {
|
651
|
+
shortcuts[shortcutChars.charAt(c)] = patternParts;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
var regex = patternParts[1];
|
655
|
+
var k = '' + regex;
|
656
|
+
if (!regexKeys.hasOwnProperty(k)) {
|
657
|
+
allRegexs.push(regex);
|
658
|
+
regexKeys[k] = null;
|
659
|
+
}
|
660
|
+
}
|
661
|
+
allRegexs.push(/[\0-\uffff]/);
|
662
|
+
tokenizer = combinePrefixPatterns(allRegexs);
|
663
|
+
})();
|
664
|
+
|
665
|
+
var nPatterns = fallthroughStylePatterns.length;
|
666
|
+
|
667
|
+
/**
|
668
|
+
* Lexes job.sourceCode and produces an output array job.decorations of
|
669
|
+
* style classes preceded by the position at which they start in
|
670
|
+
* job.sourceCode in order.
|
671
|
+
*
|
672
|
+
* @param {Object} job an object like <pre>{
|
673
|
+
* sourceCode: {string} sourceText plain text,
|
674
|
+
* basePos: {int} position of job.sourceCode in the larger chunk of
|
675
|
+
* sourceCode.
|
676
|
+
* }</pre>
|
677
|
+
*/
|
678
|
+
var decorate = function (job) {
|
679
|
+
var sourceCode = job.sourceCode, basePos = job.basePos;
|
680
|
+
/** Even entries are positions in source in ascending order. Odd enties
|
681
|
+
* are style markers (e.g., PR_COMMENT) that run from that position until
|
682
|
+
* the end.
|
683
|
+
* @type {Array.<number|string>}
|
684
|
+
*/
|
685
|
+
var decorations = [basePos, PR_PLAIN];
|
686
|
+
var pos = 0; // index into sourceCode
|
687
|
+
var tokens = sourceCode.match(tokenizer) || [];
|
688
|
+
var styleCache = {};
|
689
|
+
|
690
|
+
for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
|
691
|
+
var token = tokens[ti];
|
692
|
+
var style = styleCache[token];
|
693
|
+
var match = void 0;
|
694
|
+
|
695
|
+
var isEmbedded;
|
696
|
+
if (typeof style === 'string') {
|
697
|
+
isEmbedded = false;
|
698
|
+
} else {
|
699
|
+
var patternParts = shortcuts[token.charAt(0)];
|
700
|
+
if (patternParts) {
|
701
|
+
match = token.match(patternParts[1]);
|
702
|
+
style = patternParts[0];
|
703
|
+
} else {
|
704
|
+
for (var i = 0; i < nPatterns; ++i) {
|
705
|
+
patternParts = fallthroughStylePatterns[i];
|
706
|
+
match = token.match(patternParts[1]);
|
707
|
+
if (match) {
|
708
|
+
style = patternParts[0];
|
709
|
+
break;
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
if (!match) { // make sure that we make progress
|
714
|
+
style = PR_PLAIN;
|
715
|
+
}
|
716
|
+
}
|
717
|
+
|
718
|
+
isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
|
719
|
+
if (isEmbedded && !(match && typeof match[1] === 'string')) {
|
720
|
+
isEmbedded = false;
|
721
|
+
style = PR_SOURCE;
|
722
|
+
}
|
723
|
+
|
724
|
+
if (!isEmbedded) { styleCache[token] = style; }
|
725
|
+
}
|
726
|
+
|
727
|
+
var tokenStart = pos;
|
728
|
+
pos += token.length;
|
729
|
+
|
730
|
+
if (!isEmbedded) {
|
731
|
+
decorations.push(basePos + tokenStart, style);
|
732
|
+
} else { // Treat group 1 as an embedded block of source code.
|
733
|
+
var embeddedSource = match[1];
|
734
|
+
var embeddedSourceStart = token.indexOf(embeddedSource);
|
735
|
+
var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
|
736
|
+
if (match[2]) {
|
737
|
+
// If embeddedSource can be blank, then it would match at the
|
738
|
+
// beginning which would cause us to infinitely recurse on the
|
739
|
+
// entire token, so we catch the right context in match[2].
|
740
|
+
embeddedSourceEnd = token.length - match[2].length;
|
741
|
+
embeddedSourceStart = embeddedSourceEnd - embeddedSource.length;
|
742
|
+
}
|
743
|
+
var lang = style.substring(5);
|
744
|
+
// Decorate the left of the embedded source
|
745
|
+
appendDecorations(
|
746
|
+
basePos + tokenStart,
|
747
|
+
token.substring(0, embeddedSourceStart),
|
748
|
+
decorate, decorations);
|
749
|
+
// Decorate the embedded source
|
750
|
+
appendDecorations(
|
751
|
+
basePos + tokenStart + embeddedSourceStart,
|
752
|
+
embeddedSource,
|
753
|
+
langHandlerForExtension(lang, embeddedSource),
|
754
|
+
decorations);
|
755
|
+
// Decorate the right of the embedded section
|
756
|
+
appendDecorations(
|
757
|
+
basePos + tokenStart + embeddedSourceEnd,
|
758
|
+
token.substring(embeddedSourceEnd),
|
759
|
+
decorate, decorations);
|
760
|
+
}
|
761
|
+
}
|
762
|
+
job.decorations = decorations;
|
763
|
+
};
|
764
|
+
return decorate;
|
765
|
+
}
|
766
|
+
|
767
|
+
/** returns a function that produces a list of decorations from source text.
|
768
|
+
*
|
769
|
+
* This code treats ", ', and ` as string delimiters, and \ as a string
|
770
|
+
* escape. It does not recognize perl's qq() style strings.
|
771
|
+
* It has no special handling for double delimiter escapes as in basic, or
|
772
|
+
* the tripled delimiters used in python, but should work on those regardless
|
773
|
+
* although in those cases a single string literal may be broken up into
|
774
|
+
* multiple adjacent string literals.
|
775
|
+
*
|
776
|
+
* It recognizes C, C++, and shell style comments.
|
777
|
+
*
|
778
|
+
* @param {Object} options a set of optional parameters.
|
779
|
+
* @return {function (Object)} a function that examines the source code
|
780
|
+
* in the input job and builds the decoration list.
|
781
|
+
*/
|
782
|
+
function sourceDecorator(options) {
|
783
|
+
var shortcutStylePatterns = [], fallthroughStylePatterns = [];
|
784
|
+
if (options['tripleQuotedStrings']) {
|
785
|
+
// '''multi-line-string''', 'single-line-string', and double-quoted
|
786
|
+
shortcutStylePatterns.push(
|
787
|
+
[PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
|
788
|
+
null, '\'"']);
|
789
|
+
} else if (options['multiLineStrings']) {
|
790
|
+
// 'multi-line-string', "multi-line-string"
|
791
|
+
shortcutStylePatterns.push(
|
792
|
+
[PR_STRING, /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
|
793
|
+
null, '\'"`']);
|
794
|
+
} else {
|
795
|
+
// 'single-line-string', "single-line-string"
|
796
|
+
shortcutStylePatterns.push(
|
797
|
+
[PR_STRING,
|
798
|
+
/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
|
799
|
+
null, '"\'']);
|
800
|
+
}
|
801
|
+
if (options['verbatimStrings']) {
|
802
|
+
// verbatim-string-literal production from the C# grammar. See issue 93.
|
803
|
+
fallthroughStylePatterns.push(
|
804
|
+
[PR_STRING, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
|
805
|
+
}
|
806
|
+
var hc = options['hashComments'];
|
807
|
+
if (hc) {
|
808
|
+
if (options['cStyleComments']) {
|
809
|
+
if (hc > 1) { // multiline hash comments
|
810
|
+
shortcutStylePatterns.push(
|
811
|
+
[PR_COMMENT, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, '#']);
|
812
|
+
} else {
|
813
|
+
// Stop C preprocessor declarations at an unclosed open comment
|
814
|
+
shortcutStylePatterns.push(
|
815
|
+
[PR_COMMENT, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,
|
816
|
+
null, '#']);
|
817
|
+
}
|
818
|
+
fallthroughStylePatterns.push(
|
819
|
+
[PR_STRING,
|
820
|
+
/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
|
821
|
+
null]);
|
822
|
+
} else {
|
823
|
+
shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
|
824
|
+
}
|
825
|
+
}
|
826
|
+
if (options['cStyleComments']) {
|
827
|
+
fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
|
828
|
+
fallthroughStylePatterns.push(
|
829
|
+
[PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
|
830
|
+
}
|
831
|
+
if (options['regexLiterals']) {
|
832
|
+
/**
|
833
|
+
* @const
|
834
|
+
*/
|
835
|
+
var REGEX_LITERAL = (
|
836
|
+
// A regular expression literal starts with a slash that is
|
837
|
+
// not followed by * or / so that it is not confused with
|
838
|
+
// comments.
|
839
|
+
'/(?=[^/*])'
|
840
|
+
// and then contains any number of raw characters,
|
841
|
+
+ '(?:[^/\\x5B\\x5C]'
|
842
|
+
// escape sequences (\x5C),
|
843
|
+
+ '|\\x5C[\\s\\S]'
|
844
|
+
// or non-nesting character sets (\x5B\x5D);
|
845
|
+
+ '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
|
846
|
+
// finally closed by a /.
|
847
|
+
+ '/');
|
848
|
+
fallthroughStylePatterns.push(
|
849
|
+
['lang-regex',
|
850
|
+
new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
|
851
|
+
]);
|
852
|
+
}
|
853
|
+
|
854
|
+
var types = options['types'];
|
855
|
+
if (types) {
|
856
|
+
fallthroughStylePatterns.push([PR_TYPE, types]);
|
857
|
+
}
|
858
|
+
|
859
|
+
var keywords = ("" + options['keywords']).replace(/^ | $/g, '');
|
860
|
+
if (keywords.length) {
|
861
|
+
fallthroughStylePatterns.push(
|
862
|
+
[PR_KEYWORD,
|
863
|
+
new RegExp('^(?:' + keywords.replace(/[\s,]+/g, '|') + ')\\b'),
|
864
|
+
null]);
|
865
|
+
}
|
866
|
+
|
867
|
+
shortcutStylePatterns.push([PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0']);
|
868
|
+
fallthroughStylePatterns.push(
|
869
|
+
// TODO(mikesamuel): recognize non-latin letters and numerals in idents
|
870
|
+
[PR_LITERAL, /^@[a-z_$][a-z_$@0-9]*/i, null],
|
871
|
+
[PR_TYPE, /^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null],
|
872
|
+
[PR_PLAIN, /^[a-z_$][a-z_$@0-9]*/i, null],
|
873
|
+
[PR_LITERAL,
|
874
|
+
new RegExp(
|
875
|
+
'^(?:'
|
876
|
+
// A hex number
|
877
|
+
+ '0x[a-f0-9]+'
|
878
|
+
// or an octal or decimal number,
|
879
|
+
+ '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
|
880
|
+
// possibly in scientific notation
|
881
|
+
+ '(?:e[+\\-]?\\d+)?'
|
882
|
+
+ ')'
|
883
|
+
// with an optional modifier like UL for unsigned long
|
884
|
+
+ '[a-z]*', 'i'),
|
885
|
+
null, '0123456789'],
|
886
|
+
// Don't treat escaped quotes in bash as starting strings. See issue 144.
|
887
|
+
[PR_PLAIN, /^\\[\s\S]?/, null],
|
888
|
+
[PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#\\]*/, null]);
|
889
|
+
|
890
|
+
return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
|
891
|
+
}
|
892
|
+
|
893
|
+
var decorateSource = sourceDecorator({
|
894
|
+
'keywords': ALL_KEYWORDS,
|
895
|
+
'hashComments': true,
|
896
|
+
'cStyleComments': true,
|
897
|
+
'multiLineStrings': true,
|
898
|
+
'regexLiterals': true
|
899
|
+
});
|
900
|
+
|
901
|
+
/**
|
902
|
+
* Given a DOM subtree, wraps it in a list, and puts each line into its own
|
903
|
+
* list item.
|
904
|
+
*
|
905
|
+
* @param {Node} node modified in place. Its content is pulled into an
|
906
|
+
* HTMLOListElement, and each line is moved into a separate list item.
|
907
|
+
* This requires cloning elements, so the input might not have unique
|
908
|
+
* IDs after numbering.
|
909
|
+
*/
|
910
|
+
function numberLines(node, opt_startLineNum) {
|
911
|
+
var nocode = /(?:^|\s)nocode(?:\s|$)/;
|
912
|
+
var lineBreak = /\r\n?|\n/;
|
913
|
+
|
914
|
+
var document = node.ownerDocument;
|
915
|
+
|
916
|
+
var whitespace;
|
917
|
+
if (node.currentStyle) {
|
918
|
+
whitespace = node.currentStyle.whiteSpace;
|
919
|
+
} else if (window.getComputedStyle) {
|
920
|
+
whitespace = document.defaultView.getComputedStyle(node, null)
|
921
|
+
.getPropertyValue('white-space');
|
922
|
+
}
|
923
|
+
// If it's preformatted, then we need to split lines on line breaks
|
924
|
+
// in addition to <BR>s.
|
925
|
+
var isPreformatted = whitespace && 'pre' === whitespace.substring(0, 3);
|
926
|
+
|
927
|
+
var li = document.createElement('LI');
|
928
|
+
while (node.firstChild) {
|
929
|
+
li.appendChild(node.firstChild);
|
930
|
+
}
|
931
|
+
// An array of lines. We split below, so this is initialized to one
|
932
|
+
// un-split line.
|
933
|
+
var listItems = [li];
|
934
|
+
|
935
|
+
function walk(node) {
|
936
|
+
switch (node.nodeType) {
|
937
|
+
case 1: // Element
|
938
|
+
if (nocode.test(node.className)) { break; }
|
939
|
+
if ('BR' === node.nodeName) {
|
940
|
+
breakAfter(node);
|
941
|
+
// Discard the <BR> since it is now flush against a </LI>.
|
942
|
+
if (node.parentNode) {
|
943
|
+
node.parentNode.removeChild(node);
|
944
|
+
}
|
945
|
+
} else {
|
946
|
+
for (var child = node.firstChild; child; child = child.nextSibling) {
|
947
|
+
walk(child);
|
948
|
+
}
|
949
|
+
}
|
950
|
+
break;
|
951
|
+
case 3: case 4: // Text
|
952
|
+
if (isPreformatted) {
|
953
|
+
var text = node.nodeValue;
|
954
|
+
var match = text.match(lineBreak);
|
955
|
+
if (match) {
|
956
|
+
var firstLine = text.substring(0, match.index);
|
957
|
+
node.nodeValue = firstLine;
|
958
|
+
var tail = text.substring(match.index + match[0].length);
|
959
|
+
if (tail) {
|
960
|
+
var parent = node.parentNode;
|
961
|
+
parent.insertBefore(
|
962
|
+
document.createTextNode(tail), node.nextSibling);
|
963
|
+
}
|
964
|
+
breakAfter(node);
|
965
|
+
if (!firstLine) {
|
966
|
+
// Don't leave blank text nodes in the DOM.
|
967
|
+
node.parentNode.removeChild(node);
|
968
|
+
}
|
969
|
+
}
|
970
|
+
}
|
971
|
+
break;
|
972
|
+
}
|
973
|
+
}
|
974
|
+
|
975
|
+
// Split a line after the given node.
|
976
|
+
function breakAfter(lineEndNode) {
|
977
|
+
// If there's nothing to the right, then we can skip ending the line
|
978
|
+
// here, and move root-wards since splitting just before an end-tag
|
979
|
+
// would require us to create a bunch of empty copies.
|
980
|
+
while (!lineEndNode.nextSibling) {
|
981
|
+
lineEndNode = lineEndNode.parentNode;
|
982
|
+
if (!lineEndNode) { return; }
|
983
|
+
}
|
984
|
+
|
985
|
+
function breakLeftOf(limit, copy) {
|
986
|
+
// Clone shallowly if this node needs to be on both sides of the break.
|
987
|
+
var rightSide = copy ? limit.cloneNode(false) : limit;
|
988
|
+
var parent = limit.parentNode;
|
989
|
+
if (parent) {
|
990
|
+
// We clone the parent chain.
|
991
|
+
// This helps us resurrect important styling elements that cross lines.
|
992
|
+
// E.g. in <i>Foo<br>Bar</i>
|
993
|
+
// should be rewritten to <li><i>Foo</i></li><li><i>Bar</i></li>.
|
994
|
+
var parentClone = breakLeftOf(parent, 1);
|
995
|
+
// Move the clone and everything to the right of the original
|
996
|
+
// onto the cloned parent.
|
997
|
+
var next = limit.nextSibling;
|
998
|
+
parentClone.appendChild(rightSide);
|
999
|
+
for (var sibling = next; sibling; sibling = next) {
|
1000
|
+
next = sibling.nextSibling;
|
1001
|
+
parentClone.appendChild(sibling);
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
return rightSide;
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
var copiedListItem = breakLeftOf(lineEndNode.nextSibling, 0);
|
1008
|
+
|
1009
|
+
// Walk the parent chain until we reach an unattached LI.
|
1010
|
+
for (var parent;
|
1011
|
+
// Check nodeType since IE invents document fragments.
|
1012
|
+
(parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
|
1013
|
+
copiedListItem = parent;
|
1014
|
+
}
|
1015
|
+
// Put it on the list of lines for later processing.
|
1016
|
+
listItems.push(copiedListItem);
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
// Split lines while there are lines left to split.
|
1020
|
+
for (var i = 0; // Number of lines that have been split so far.
|
1021
|
+
i < listItems.length; // length updated by breakAfter calls.
|
1022
|
+
++i) {
|
1023
|
+
walk(listItems[i]);
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
// Make sure numeric indices show correctly.
|
1027
|
+
if (opt_startLineNum === (opt_startLineNum|0)) {
|
1028
|
+
listItems[0].setAttribute('value', opt_startLineNum);
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
var ol = document.createElement('OL');
|
1032
|
+
ol.className = 'linenums';
|
1033
|
+
var offset = Math.max(0, ((opt_startLineNum - 1 /* zero index */)) | 0) || 0;
|
1034
|
+
for (var i = 0, n = listItems.length; i < n; ++i) {
|
1035
|
+
li = listItems[i];
|
1036
|
+
// Stick a class on the LIs so that stylesheets can
|
1037
|
+
// color odd/even rows, or any other row pattern that
|
1038
|
+
// is co-prime with 10.
|
1039
|
+
li.className = 'L' + ((i + offset) % 10);
|
1040
|
+
if (!li.firstChild) {
|
1041
|
+
li.appendChild(document.createTextNode('\xA0'));
|
1042
|
+
}
|
1043
|
+
ol.appendChild(li);
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
node.appendChild(ol);
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
/**
|
1050
|
+
* Breaks {@code job.sourceCode} around style boundaries in
|
1051
|
+
* {@code job.decorations} and modifies {@code job.sourceNode} in place.
|
1052
|
+
* @param {Object} job like <pre>{
|
1053
|
+
* sourceCode: {string} source as plain text,
|
1054
|
+
* spans: {Array.<number|Node>} alternating span start indices into source
|
1055
|
+
* and the text node or element (e.g. {@code <BR>}) corresponding to that
|
1056
|
+
* span.
|
1057
|
+
* decorations: {Array.<number|string} an array of style classes preceded
|
1058
|
+
* by the position at which they start in job.sourceCode in order
|
1059
|
+
* }</pre>
|
1060
|
+
* @private
|
1061
|
+
*/
|
1062
|
+
function recombineTagsAndDecorations(job) {
|
1063
|
+
var isIE = /\bMSIE\b/.test(navigator.userAgent);
|
1064
|
+
var newlineRe = /\n/g;
|
1065
|
+
|
1066
|
+
var source = job.sourceCode;
|
1067
|
+
var sourceLength = source.length;
|
1068
|
+
// Index into source after the last code-unit recombined.
|
1069
|
+
var sourceIndex = 0;
|
1070
|
+
|
1071
|
+
var spans = job.spans;
|
1072
|
+
var nSpans = spans.length;
|
1073
|
+
// Index into spans after the last span which ends at or before sourceIndex.
|
1074
|
+
var spanIndex = 0;
|
1075
|
+
|
1076
|
+
var decorations = job.decorations;
|
1077
|
+
var nDecorations = decorations.length;
|
1078
|
+
// Index into decorations after the last decoration which ends at or before
|
1079
|
+
// sourceIndex.
|
1080
|
+
var decorationIndex = 0;
|
1081
|
+
|
1082
|
+
// Remove all zero-length decorations.
|
1083
|
+
decorations[nDecorations] = sourceLength;
|
1084
|
+
var decPos, i;
|
1085
|
+
for (i = decPos = 0; i < nDecorations;) {
|
1086
|
+
if (decorations[i] !== decorations[i + 2]) {
|
1087
|
+
decorations[decPos++] = decorations[i++];
|
1088
|
+
decorations[decPos++] = decorations[i++];
|
1089
|
+
} else {
|
1090
|
+
i += 2;
|
1091
|
+
}
|
1092
|
+
}
|
1093
|
+
nDecorations = decPos;
|
1094
|
+
|
1095
|
+
// Simplify decorations.
|
1096
|
+
for (i = decPos = 0; i < nDecorations;) {
|
1097
|
+
var startPos = decorations[i];
|
1098
|
+
// Conflate all adjacent decorations that use the same style.
|
1099
|
+
var startDec = decorations[i + 1];
|
1100
|
+
var end = i + 2;
|
1101
|
+
while (end + 2 <= nDecorations && decorations[end + 1] === startDec) {
|
1102
|
+
end += 2;
|
1103
|
+
}
|
1104
|
+
decorations[decPos++] = startPos;
|
1105
|
+
decorations[decPos++] = startDec;
|
1106
|
+
i = end;
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
nDecorations = decorations.length = decPos;
|
1110
|
+
|
1111
|
+
var decoration = null;
|
1112
|
+
while (spanIndex < nSpans) {
|
1113
|
+
var spanStart = spans[spanIndex];
|
1114
|
+
var spanEnd = spans[spanIndex + 2] || sourceLength;
|
1115
|
+
|
1116
|
+
var decStart = decorations[decorationIndex];
|
1117
|
+
var decEnd = decorations[decorationIndex + 2] || sourceLength;
|
1118
|
+
|
1119
|
+
var end = Math.min(spanEnd, decEnd);
|
1120
|
+
|
1121
|
+
var textNode = spans[spanIndex + 1];
|
1122
|
+
var styledText;
|
1123
|
+
if (textNode.nodeType !== 1 // Don't muck with <BR>s or <LI>s
|
1124
|
+
// Don't introduce spans around empty text nodes.
|
1125
|
+
&& (styledText = source.substring(sourceIndex, end))) {
|
1126
|
+
// This may seem bizarre, and it is. Emitting LF on IE causes the
|
1127
|
+
// code to display with spaces instead of line breaks.
|
1128
|
+
// Emitting Windows standard issue linebreaks (CRLF) causes a blank
|
1129
|
+
// space to appear at the beginning of every line but the first.
|
1130
|
+
// Emitting an old Mac OS 9 line separator makes everything spiffy.
|
1131
|
+
if (isIE) { styledText = styledText.replace(newlineRe, '\r'); }
|
1132
|
+
textNode.nodeValue = styledText;
|
1133
|
+
var document = textNode.ownerDocument;
|
1134
|
+
var span = document.createElement('SPAN');
|
1135
|
+
span.className = decorations[decorationIndex + 1];
|
1136
|
+
var parentNode = textNode.parentNode;
|
1137
|
+
parentNode.replaceChild(span, textNode);
|
1138
|
+
span.appendChild(textNode);
|
1139
|
+
if (sourceIndex < spanEnd) { // Split off a text node.
|
1140
|
+
spans[spanIndex + 1] = textNode
|
1141
|
+
// TODO: Possibly optimize by using '' if there's no flicker.
|
1142
|
+
= document.createTextNode(source.substring(end, spanEnd));
|
1143
|
+
parentNode.insertBefore(textNode, span.nextSibling);
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
sourceIndex = end;
|
1148
|
+
|
1149
|
+
if (sourceIndex >= spanEnd) {
|
1150
|
+
spanIndex += 2;
|
1151
|
+
}
|
1152
|
+
if (sourceIndex >= decEnd) {
|
1153
|
+
decorationIndex += 2;
|
1154
|
+
}
|
1155
|
+
}
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
|
1159
|
+
/** Maps language-specific file extensions to handlers. */
|
1160
|
+
var langHandlerRegistry = {};
|
1161
|
+
/** Register a language handler for the given file extensions.
|
1162
|
+
* @param {function (Object)} handler a function from source code to a list
|
1163
|
+
* of decorations. Takes a single argument job which describes the
|
1164
|
+
* state of the computation. The single parameter has the form
|
1165
|
+
* {@code {
|
1166
|
+
* sourceCode: {string} as plain text.
|
1167
|
+
* decorations: {Array.<number|string>} an array of style classes
|
1168
|
+
* preceded by the position at which they start in
|
1169
|
+
* job.sourceCode in order.
|
1170
|
+
* The language handler should assigned this field.
|
1171
|
+
* basePos: {int} the position of source in the larger source chunk.
|
1172
|
+
* All positions in the output decorations array are relative
|
1173
|
+
* to the larger source chunk.
|
1174
|
+
* } }
|
1175
|
+
* @param {Array.<string>} fileExtensions
|
1176
|
+
*/
|
1177
|
+
function registerLangHandler(handler, fileExtensions) {
|
1178
|
+
for (var i = fileExtensions.length; --i >= 0;) {
|
1179
|
+
var ext = fileExtensions[i];
|
1180
|
+
if (!langHandlerRegistry.hasOwnProperty(ext)) {
|
1181
|
+
langHandlerRegistry[ext] = handler;
|
1182
|
+
} else if (window['console']) {
|
1183
|
+
console['warn']('cannot override language handler %s', ext);
|
1184
|
+
}
|
1185
|
+
}
|
1186
|
+
}
|
1187
|
+
function langHandlerForExtension(extension, source) {
|
1188
|
+
if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
|
1189
|
+
// Treat it as markup if the first non whitespace character is a < and
|
1190
|
+
// the last non-whitespace character is a >.
|
1191
|
+
extension = /^\s*</.test(source)
|
1192
|
+
? 'default-markup'
|
1193
|
+
: 'default-code';
|
1194
|
+
}
|
1195
|
+
return langHandlerRegistry[extension];
|
1196
|
+
}
|
1197
|
+
registerLangHandler(decorateSource, ['default-code']);
|
1198
|
+
registerLangHandler(
|
1199
|
+
createSimpleLexer(
|
1200
|
+
[],
|
1201
|
+
[
|
1202
|
+
[PR_PLAIN, /^[^<?]+/],
|
1203
|
+
[PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
|
1204
|
+
[PR_COMMENT, /^<\!--[\s\S]*?(?:-\->|$)/],
|
1205
|
+
// Unescaped content in an unknown language
|
1206
|
+
['lang-', /^<\?([\s\S]+?)(?:\?>|$)/],
|
1207
|
+
['lang-', /^<%([\s\S]+?)(?:%>|$)/],
|
1208
|
+
[PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
|
1209
|
+
['lang-', /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
|
1210
|
+
// Unescaped content in javascript. (Or possibly vbscript).
|
1211
|
+
['lang-js', /^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
|
1212
|
+
// Contains unescaped stylesheet content
|
1213
|
+
['lang-css', /^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],
|
1214
|
+
['lang-in.tag', /^(<\/?[a-z][^<>]*>)/i]
|
1215
|
+
]),
|
1216
|
+
['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
|
1217
|
+
registerLangHandler(
|
1218
|
+
createSimpleLexer(
|
1219
|
+
[
|
1220
|
+
[PR_PLAIN, /^[\s]+/, null, ' \t\r\n'],
|
1221
|
+
[PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
|
1222
|
+
],
|
1223
|
+
[
|
1224
|
+
[PR_TAG, /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],
|
1225
|
+
[PR_ATTRIB_NAME, /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],
|
1226
|
+
['lang-uq.val', /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
|
1227
|
+
[PR_PUNCTUATION, /^[=<>\/]+/],
|
1228
|
+
['lang-js', /^on\w+\s*=\s*\"([^\"]+)\"/i],
|
1229
|
+
['lang-js', /^on\w+\s*=\s*\'([^\']+)\'/i],
|
1230
|
+
['lang-js', /^on\w+\s*=\s*([^\"\'>\s]+)/i],
|
1231
|
+
['lang-css', /^style\s*=\s*\"([^\"]+)\"/i],
|
1232
|
+
['lang-css', /^style\s*=\s*\'([^\']+)\'/i],
|
1233
|
+
['lang-css', /^style\s*=\s*([^\"\'>\s]+)/i]
|
1234
|
+
]),
|
1235
|
+
['in.tag']);
|
1236
|
+
registerLangHandler(
|
1237
|
+
createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
|
1238
|
+
registerLangHandler(sourceDecorator({
|
1239
|
+
'keywords': CPP_KEYWORDS,
|
1240
|
+
'hashComments': true,
|
1241
|
+
'cStyleComments': true,
|
1242
|
+
'types': C_TYPES
|
1243
|
+
}), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
|
1244
|
+
registerLangHandler(sourceDecorator({
|
1245
|
+
'keywords': 'null,true,false'
|
1246
|
+
}), ['json']);
|
1247
|
+
registerLangHandler(sourceDecorator({
|
1248
|
+
'keywords': CSHARP_KEYWORDS,
|
1249
|
+
'hashComments': true,
|
1250
|
+
'cStyleComments': true,
|
1251
|
+
'verbatimStrings': true,
|
1252
|
+
'types': C_TYPES
|
1253
|
+
}), ['cs']);
|
1254
|
+
registerLangHandler(sourceDecorator({
|
1255
|
+
'keywords': JAVA_KEYWORDS,
|
1256
|
+
'cStyleComments': true
|
1257
|
+
}), ['java']);
|
1258
|
+
registerLangHandler(sourceDecorator({
|
1259
|
+
'keywords': SH_KEYWORDS,
|
1260
|
+
'hashComments': true,
|
1261
|
+
'multiLineStrings': true
|
1262
|
+
}), ['bsh', 'csh', 'sh']);
|
1263
|
+
registerLangHandler(sourceDecorator({
|
1264
|
+
'keywords': PYTHON_KEYWORDS,
|
1265
|
+
'hashComments': true,
|
1266
|
+
'multiLineStrings': true,
|
1267
|
+
'tripleQuotedStrings': true
|
1268
|
+
}), ['cv', 'py']);
|
1269
|
+
registerLangHandler(sourceDecorator({
|
1270
|
+
'keywords': PERL_KEYWORDS,
|
1271
|
+
'hashComments': true,
|
1272
|
+
'multiLineStrings': true,
|
1273
|
+
'regexLiterals': true
|
1274
|
+
}), ['perl', 'pl', 'pm']);
|
1275
|
+
registerLangHandler(sourceDecorator({
|
1276
|
+
'keywords': RUBY_KEYWORDS,
|
1277
|
+
'hashComments': true,
|
1278
|
+
'multiLineStrings': true,
|
1279
|
+
'regexLiterals': true
|
1280
|
+
}), ['rb']);
|
1281
|
+
registerLangHandler(sourceDecorator({
|
1282
|
+
'keywords': JSCRIPT_KEYWORDS,
|
1283
|
+
'cStyleComments': true,
|
1284
|
+
'regexLiterals': true
|
1285
|
+
}), ['js']);
|
1286
|
+
registerLangHandler(sourceDecorator({
|
1287
|
+
'keywords': COFFEE_KEYWORDS,
|
1288
|
+
'hashComments': 3, // ### style block comments
|
1289
|
+
'cStyleComments': true,
|
1290
|
+
'multilineStrings': true,
|
1291
|
+
'tripleQuotedStrings': true,
|
1292
|
+
'regexLiterals': true
|
1293
|
+
}), ['coffee']);
|
1294
|
+
registerLangHandler(createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
|
1295
|
+
|
1296
|
+
function applyDecorator(job) {
|
1297
|
+
var opt_langExtension = job.langExtension;
|
1298
|
+
|
1299
|
+
try {
|
1300
|
+
// Extract tags, and convert the source code to plain text.
|
1301
|
+
var sourceAndSpans = extractSourceSpans(job.sourceNode);
|
1302
|
+
/** Plain text. @type {string} */
|
1303
|
+
var source = sourceAndSpans.sourceCode;
|
1304
|
+
job.sourceCode = source;
|
1305
|
+
job.spans = sourceAndSpans.spans;
|
1306
|
+
job.basePos = 0;
|
1307
|
+
|
1308
|
+
// Apply the appropriate language handler
|
1309
|
+
langHandlerForExtension(opt_langExtension, source)(job);
|
1310
|
+
|
1311
|
+
// Integrate the decorations and tags back into the source code,
|
1312
|
+
// modifying the sourceNode in place.
|
1313
|
+
recombineTagsAndDecorations(job);
|
1314
|
+
} catch (e) {
|
1315
|
+
if ('console' in window) {
|
1316
|
+
console['log'](e && e['stack'] ? e['stack'] : e);
|
1317
|
+
}
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
/**
|
1322
|
+
* @param sourceCodeHtml {string} The HTML to pretty print.
|
1323
|
+
* @param opt_langExtension {string} The language name to use.
|
1324
|
+
* Typically, a filename extension like 'cpp' or 'java'.
|
1325
|
+
* @param opt_numberLines {number|boolean} True to number lines,
|
1326
|
+
* or the 1-indexed number of the first line in sourceCodeHtml.
|
1327
|
+
*/
|
1328
|
+
function prettyPrintOne(sourceCodeHtml, opt_langExtension, opt_numberLines) {
|
1329
|
+
var container = document.createElement('PRE');
|
1330
|
+
// This could cause images to load and onload listeners to fire.
|
1331
|
+
// E.g. <img onerror="alert(1337)" src="nosuchimage.png">.
|
1332
|
+
// We assume that the inner HTML is from a trusted source.
|
1333
|
+
container.innerHTML = sourceCodeHtml;
|
1334
|
+
if (opt_numberLines) {
|
1335
|
+
numberLines(container, opt_numberLines);
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
var job = {
|
1339
|
+
langExtension: opt_langExtension,
|
1340
|
+
numberLines: opt_numberLines,
|
1341
|
+
sourceNode: container
|
1342
|
+
};
|
1343
|
+
applyDecorator(job);
|
1344
|
+
return container.innerHTML;
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
function prettyPrint(opt_whenDone) {
|
1348
|
+
function byTagName(tn) { return document.getElementsByTagName(tn); }
|
1349
|
+
// fetch a list of nodes to rewrite
|
1350
|
+
var codeSegments = [byTagName('pre'), byTagName('code'), byTagName('xmp')];
|
1351
|
+
var elements = [];
|
1352
|
+
for (var i = 0; i < codeSegments.length; ++i) {
|
1353
|
+
for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
|
1354
|
+
elements.push(codeSegments[i][j]);
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
codeSegments = null;
|
1358
|
+
|
1359
|
+
var clock = Date;
|
1360
|
+
if (!clock['now']) {
|
1361
|
+
clock = { 'now': function () { return +(new Date); } };
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
// The loop is broken into a series of continuations to make sure that we
|
1365
|
+
// don't make the browser unresponsive when rewriting a large page.
|
1366
|
+
var k = 0;
|
1367
|
+
var prettyPrintingJob;
|
1368
|
+
|
1369
|
+
var langExtensionRe = /\blang(?:uage)?-([\w.]+)(?!\S)/;
|
1370
|
+
var prettyPrintRe = /\bprettyprint\b/;
|
1371
|
+
|
1372
|
+
function doWork() {
|
1373
|
+
var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
|
1374
|
+
clock['now']() + 250 /* ms */ :
|
1375
|
+
Infinity);
|
1376
|
+
for (; k < elements.length && clock['now']() < endTime; k++) {
|
1377
|
+
var cs = elements[k];
|
1378
|
+
var className = cs.className;
|
1379
|
+
if (className.indexOf('prettyprint') >= 0) {
|
1380
|
+
// If the classes includes a language extensions, use it.
|
1381
|
+
// Language extensions can be specified like
|
1382
|
+
// <pre class="prettyprint lang-cpp">
|
1383
|
+
// the language extension "cpp" is used to find a language handler as
|
1384
|
+
// passed to PR.registerLangHandler.
|
1385
|
+
// HTML5 recommends that a language be specified using "language-"
|
1386
|
+
// as the prefix instead. Google Code Prettify supports both.
|
1387
|
+
// http://dev.w3.org/html5/spec-author-view/the-code-element.html
|
1388
|
+
var langExtension = className.match(langExtensionRe);
|
1389
|
+
// Support <pre class="prettyprint"><code class="language-c">
|
1390
|
+
var wrapper;
|
1391
|
+
if (!langExtension && (wrapper = childContentWrapper(cs))
|
1392
|
+
&& "CODE" === wrapper.tagName) {
|
1393
|
+
langExtension = wrapper.className.match(langExtensionRe);
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
if (langExtension) {
|
1397
|
+
langExtension = langExtension[1];
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
// make sure this is not nested in an already prettified element
|
1401
|
+
var nested = false;
|
1402
|
+
for (var p = cs.parentNode; p; p = p.parentNode) {
|
1403
|
+
if ((p.tagName === 'pre' || p.tagName === 'code' ||
|
1404
|
+
p.tagName === 'xmp') &&
|
1405
|
+
p.className && p.className.indexOf('prettyprint') >= 0) {
|
1406
|
+
nested = true;
|
1407
|
+
break;
|
1408
|
+
}
|
1409
|
+
}
|
1410
|
+
if (!nested) {
|
1411
|
+
// Look for a class like linenums or linenums:<n> where <n> is the
|
1412
|
+
// 1-indexed number of the first line.
|
1413
|
+
var lineNums = cs.className.match(/\blinenums\b(?::(\d+))?/);
|
1414
|
+
lineNums = lineNums
|
1415
|
+
? lineNums[1] && lineNums[1].length ? +lineNums[1] : true
|
1416
|
+
: false;
|
1417
|
+
if (lineNums) { numberLines(cs, lineNums); }
|
1418
|
+
|
1419
|
+
// do the pretty printing
|
1420
|
+
prettyPrintingJob = {
|
1421
|
+
langExtension: langExtension,
|
1422
|
+
sourceNode: cs,
|
1423
|
+
numberLines: lineNums
|
1424
|
+
};
|
1425
|
+
applyDecorator(prettyPrintingJob);
|
1426
|
+
}
|
1427
|
+
}
|
1428
|
+
}
|
1429
|
+
if (k < elements.length) {
|
1430
|
+
// finish up in a continuation
|
1431
|
+
setTimeout(doWork, 250);
|
1432
|
+
} else if (opt_whenDone) {
|
1433
|
+
opt_whenDone();
|
1434
|
+
}
|
1435
|
+
}
|
1436
|
+
|
1437
|
+
doWork();
|
1438
|
+
}
|
1439
|
+
|
1440
|
+
/**
|
1441
|
+
* Find all the {@code <pre>} and {@code <code>} tags in the DOM with
|
1442
|
+
* {@code class=prettyprint} and prettify them.
|
1443
|
+
*
|
1444
|
+
* @param {Function?} opt_whenDone if specified, called when the last entry
|
1445
|
+
* has been finished.
|
1446
|
+
*/
|
1447
|
+
window['prettyPrintOne'] = prettyPrintOne;
|
1448
|
+
/**
|
1449
|
+
* Pretty print a chunk of code.
|
1450
|
+
*
|
1451
|
+
* @param {string} sourceCodeHtml code as html
|
1452
|
+
* @return {string} code as html, but prettier
|
1453
|
+
*/
|
1454
|
+
window['prettyPrint'] = prettyPrint;
|
1455
|
+
/**
|
1456
|
+
* Contains functions for creating and registering new language handlers.
|
1457
|
+
* @type {Object}
|
1458
|
+
*/
|
1459
|
+
window['PR'] = {
|
1460
|
+
'createSimpleLexer': createSimpleLexer,
|
1461
|
+
'registerLangHandler': registerLangHandler,
|
1462
|
+
'sourceDecorator': sourceDecorator,
|
1463
|
+
'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
|
1464
|
+
'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
|
1465
|
+
'PR_COMMENT': PR_COMMENT,
|
1466
|
+
'PR_DECLARATION': PR_DECLARATION,
|
1467
|
+
'PR_KEYWORD': PR_KEYWORD,
|
1468
|
+
'PR_LITERAL': PR_LITERAL,
|
1469
|
+
'PR_NOCODE': PR_NOCODE,
|
1470
|
+
'PR_PLAIN': PR_PLAIN,
|
1471
|
+
'PR_PUNCTUATION': PR_PUNCTUATION,
|
1472
|
+
'PR_SOURCE': PR_SOURCE,
|
1473
|
+
'PR_STRING': PR_STRING,
|
1474
|
+
'PR_TAG': PR_TAG,
|
1475
|
+
'PR_TYPE': PR_TYPE
|
1476
|
+
};
|
1477
|
+
})();
|