update prettify style and add clojure highlighting support

This commit is contained in:
Gered 2014-03-29 11:13:37 -04:00
parent 8d9047946f
commit b56b43533d
4 changed files with 113 additions and 27 deletions

View file

@ -1,30 +1,84 @@
.com { color: #93a1a1; }
.lit { color: #195f91; }
.pun, .opn, .clo { color: #93a1a1; }
.fun { color: #dc322f; }
.str, .atv { color: #D14; }
.kwd, .prettyprint .tag { color: #1e347b; }
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }
/* ========================
//#google-prettify-monokai-theme
//#Version: 0.2
//#Author: RaphaelDDL
//#Github: https://github.com/RaphaelDDL/google-prettify-monokai-theme/
//#MIT LICENSE
//#https://github.com/RaphaelDDL/compass-generic-config/blob/master/LICENSE
//For use with Google Code Prettify, HTML Syntax only
//======================== */
.prettyprint {
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.prettyprint.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
pre .str, code .str { color: #e6db5a; } /* string */
pre .kwd, code .kwd { color: #66d9ef; } /* keyword */
pre .com, code .com { color: #75715e; font-style: italic; } /* comment */
pre .typ, code .typ { color: #66d9ef; } /* type */
pre .lit, code .lit { color: #ae81ff; } /* literal */
pre .pun, code .pun { color: #fff; } /* punctuation */
pre .pln, code .pln { color: #fff; } /* plaintext */
pre .tag, code .tag { color: #f92672; } /* html/xml tag */
pre .atn, code .atn { color: #a6e22a; } /* html/xml attribute name */
pre .atv, code .atv { color: #e6db74; } /* html/xml attribute value */
pre .dec, code .dec { color: #ae81ff; } /* decimal */
pre .opn, code .opn { color: #aaa; }
pre .clo, code .clo { color: #aaa; }
pre.prettyprint, code.prettyprint {
background-color: #272822;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
-o-border-radius: 8px;
-ms-border-radius: 8px;
-khtml-border-radius: 8px;
border-radius: 8px;
}
/* Specify class=linenums on a pre to get line numbering */
pre.prettyprint {
/*width: 100%;*/
margin: 1em auto;
padding: 1em;
white-space: pre-wrap;
}
pre.prettyprinted {
box-shadow:inset 0 0 1px 2px #3c3d39, 0 0 15px rgba(0,0,0,0.5);
border:1px solid #0b0c0a;
}
/* ------------------------
//Section: class 'linenums' for line numbering
//------------------------ */
ol.linenums {
margin: 0 0 0 33px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 20px;
text-shadow: 0 1px 0 #fff;
margin-top: 0;
margin-bottom: 0;
color: #75715e;
list-style: decimal inside !important;
} /* IE indents via margin-left */
/* =============================================
//Section: Print Styles (partially from Sunburn Theme)
//================================================ */
@media print {
pre.prettyprinted, pre.prettyprint, code.prettyprint {
background-color:#fff;
color:#000;
-moz-border-radius:0;
-webkit-border-radius:0;
-o-border-radius:0;
-ms-border-radius:0;
-khtml-border-radius:0;
border-radius:0;
}
pre .str, code .str { color: #060; }
pre .kwd, code .kwd { color: #006; font-weight: bold; }
pre .com, code .com { color: #600; font-style: italic; }
pre .typ, code .typ { color: #404; font-weight: bold; }
pre .lit, code .lit { color: #044; }
pre .pun, code .pun { color: #440; }
pre .pln, code .pln { color: #000; }
pre .tag, code .tag { color: #006; font-weight: bold; }
pre .atn, code .atn { color: #404; }
pre .atv, code .atv { color: #060; }
}

View file

@ -0,0 +1,18 @@
/*
Copyright (C) 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var a=null;
PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn|re-find|number?|string?|coll?|int)\b/,a],
["typ",/^:[\dA-Za-z-]+/]]),["clj"]);

View file

@ -1,6 +1,19 @@
$(document).ready(function() {
var code = $('div.content[role="main"]').find('pre');
code.addClass('prettyprint');
code.each(function() {
var pre = $(this);
// markdown-clj sets up <pre> tags for use with another syntax highlighting lib that we're
// not using. so we need to convert some css classes to work with Prettify
pre.removeClass('brush:');
var languageHint = pre.attr('class'); // should be the only class left at this point
var classAttr = 'prettyprint';
if (languageHint && languageHint.length > 0)
classAttr += ' lang-' + languageHint;
pre.attr('class', classAttr);
});
prettyPrint();
});

View file

@ -25,6 +25,7 @@
{{ javascript('/js/to-markdown.js') }}
{{ javascript('/js/bootstrap-markdown.js') }}
{{ javascript('/js/prettify.js') }}
{{ javascript('/js/lang-clj.js') }}
{% if userId %}
{{ javascript('/js/select2.min.js') }}
{{ javascript('/js/bootstrap-combobox.js') }}