HighlightJS support for code inside Markdown posts.

master
Nick Sergeant 2013-02-09 22:08:30 -05:00
parent 5b8887c2b7
commit ca227b7b49
13 changed files with 80 additions and 6 deletions

View File

@ -2,9 +2,12 @@
cat media/css/bootstrap.css \
media/css/blog-themes/pro-adams/style.css \
media/css/highlightjs-themes/tomorrow.css \
media/css/themes.css \
> media/css/pro.css
scss -t compressed media/css/highlightjs-themes/tomorrow.scss > media/css/highlightjs-themes/tomorrow.css
cat media/css/bootstrap.css \
media/css/style.css \
media/css/themes.css \
@ -25,5 +28,6 @@ cat media/css/bootstrap.css \
media/css/codemirror-themes/twilight.css \
media/css/codemirror-themes/vibrant-ink.css \
media/css/codemirror-themes/xq-dark.css \
media/css/highlightjs-themes/tomorrow.css \
media/css/blog-themes/default/style.css \
> media/css/snipt.css

View File

@ -0,0 +1 @@
div.markdown .tomorrow-comment,div.markdown pre .comment,div.markdown pre .title{color:#8e908c}div.markdown .tomorrow-red,div.markdown pre .variable,div.markdown pre .attribute,div.markdown pre .tag,div.markdown pre .regexp,div.markdown pre .ruby .constant,div.markdown pre .xml .tag .title,div.markdown pre .xml .pi,div.markdown pre .xml .doctype,div.markdown pre .html .doctype,div.markdown pre .css .id,div.markdown pre .css .class,div.markdown pre .css .pseudo{color:#c82829}div.markdown .tomorrow-orange,div.markdown pre .number,div.markdown pre .preprocessor,div.markdown pre .built_in,div.markdown pre .literal,div.markdown pre .params,div.markdown pre .constant{color:#f5871f}div.markdown .tomorrow-yellow,div.markdown pre .class,div.markdown pre .ruby .class .title,div.markdown pre .css .rules .attribute{color:#eab700}div.markdown .tomorrow-green,div.markdown pre .string,div.markdown pre .value,div.markdown pre .inheritance,div.markdown pre .header,div.markdown pre .ruby .symbol,div.markdown pre .xml .cdata{color:#718c00}div.markdown .tomorrow-aqua,div.markdown pre .css .hexcolor{color:#3e999f}div.markdown .tomorrow-blue,div.markdown pre .function,div.markdown pre .python .decorator,div.markdown pre .python .title,div.markdown pre .ruby .function .title,div.markdown pre .ruby .title .keyword,div.markdown pre .perl .sub,div.markdown pre .javascript .title,div.markdown pre .coffeescript .title{color:#4271ae}div.markdown .tomorrow-purple,div.markdown pre .keyword,div.markdown pre .javascript .function{color:#8959a8}div.markdown pre code{color:#4d4d4c}div.markdown pre .coffeescript .javascript,div.markdown pre .javascript .xml,div.markdown pre .tex .formula,div.markdown pre .xml .javascript,div.markdown pre .xml .vbscript,div.markdown pre .xml .css,div.markdown pre .xml .cdata{opacity:0.5}

View File

@ -0,0 +1,48 @@
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
div.markdown {
.tomorrow-comment, pre .comment, pre .title {
color: #8e908c;
}
.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo {
color: #c82829;
}
.tomorrow-orange, pre .number, pre .preprocessor, pre .built_in, pre .literal, pre .params, pre .constant {
color: #f5871f;
}
.tomorrow-yellow, pre .class, pre .ruby .class .title, pre .css .rules .attribute {
color: #eab700;
}
.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata {
color: #718c00;
}
.tomorrow-aqua, pre .css .hexcolor {
color: #3e999f;
}
.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title {
color: #4271ae;
}
.tomorrow-purple, pre .keyword, pre .javascript .function {
color: #8959a8;
}
pre code {
color: #4d4d4c;
}
pre .coffeescript .javascript,
pre .javascript .xml,
pre .tex .formula,
pre .xml .javascript,
pre .xml .vbscript,
pre .xml .css,
pre .xml .cdata {
opacity: 0.5;
}
}

File diff suppressed because one or more lines are too long

View File

@ -2257,4 +2257,5 @@ THE SOFTWARE.
.cm-s-xq-dark span.cm-bracket {color: #cc7;}
.cm-s-xq-dark span.cm-tag {color: #FFBD40;}
.cm-s-xq-dark span.cm-attribute {color: #FFF700;}
div.markdown .tomorrow-comment,div.markdown pre .comment,div.markdown pre .title{color:#8e908c}div.markdown .tomorrow-red,div.markdown pre .variable,div.markdown pre .attribute,div.markdown pre .tag,div.markdown pre .regexp,div.markdown pre .ruby .constant,div.markdown pre .xml .tag .title,div.markdown pre .xml .pi,div.markdown pre .xml .doctype,div.markdown pre .html .doctype,div.markdown pre .css .id,div.markdown pre .css .class,div.markdown pre .css .pseudo{color:#c82829}div.markdown .tomorrow-orange,div.markdown pre .number,div.markdown pre .preprocessor,div.markdown pre .built_in,div.markdown pre .literal,div.markdown pre .params,div.markdown pre .constant{color:#f5871f}div.markdown .tomorrow-yellow,div.markdown pre .class,div.markdown pre .ruby .class .title,div.markdown pre .css .rules .attribute{color:#eab700}div.markdown .tomorrow-green,div.markdown pre .string,div.markdown pre .value,div.markdown pre .inheritance,div.markdown pre .header,div.markdown pre .ruby .symbol,div.markdown pre .xml .cdata{color:#718c00}div.markdown .tomorrow-aqua,div.markdown pre .css .hexcolor{color:#3e999f}div.markdown .tomorrow-blue,div.markdown pre .function,div.markdown pre .python .decorator,div.markdown pre .python .title,div.markdown pre .ruby .function .title,div.markdown pre .ruby .title .keyword,div.markdown pre .perl .sub,div.markdown pre .javascript .title,div.markdown pre .coffeescript .title{color:#4271ae}div.markdown .tomorrow-purple,div.markdown pre .keyword,div.markdown pre .javascript .function{color:#8959a8}div.markdown pre code{color:#4d4d4c}div.markdown pre .coffeescript .javascript,div.markdown pre .javascript .xml,div.markdown pre .tex .formula,div.markdown pre .xml .javascript,div.markdown pre .xml .vbscript,div.markdown pre .xml .css,div.markdown pre .xml .cdata{opacity:0.5}
body.blog-site article.snipt div.group div.container{width:718px}body.blog-site article.snipt div.group div.container header{min-height:0}body.blog-site article.snipt div.group div.container header h1{margin:11px 15px}body.blog-site article.snipt footer ul.attrs li.tweet{margin-right:30px}body.blog-site section.main div.ruler{z-index:50}body.blog-site section.main aside.main nav.footer{margin-right:0}body.blog-site section.main aside.main nav.footer ul.powered{border-top:1px solid #DDDDDD;padding-top:30px}body.blog-site section.main aside.main nav.footer ul.powered li{background:transparent url("/static/images/favicon.png") top left no-repeat}body.blog-site section.main aside.main nav.footer ul.powered li a{border:none;color:#3E6B73;display:inline-block;font-style:italic}body.blog-site section.main aside.main nav.footer ul.powered li a:hover{border-bottom:1px solid #333;color:#333}body.blog-site section.main aside.main nav.footer.with-sidebar{margin-top:30px}body.blog-site section.main aside.main section.sidebar{margin-bottom:30px;margin-left:15px}body.blog-site section.main aside.main section.sidebar p{line-height:16px;margin-bottom:15px}body.blog-site section.main aside.main section.sidebar a:hover{text-decoration:none}body.blog-site header.main{background:transparent url("/static/images/blog-header-bg.png") top left repeat;height:auto}body.blog-site header.main div.inner{height:auto}body.blog-site header.main div.inner h1{float:none;position:static}body.blog-site header.main div.inner h1 a{background:none;border-bottom:2px solid transparent;color:#2A535C;font:normal 30px "Helvetica Neue",Helvetica,Arial,"Liberation Sans",FreeSans,sans-serif;height:auto;letter-spacing:-1px;line-height:30px;margin:17px 0 17px 16px;text-decoration:none;text-indent:0;text-shadow:none;width:auto;-webkit-transition:border .08s linear;-moz-transition:border .08s linear;-o-transition:border .08s linear;transition:border .08s linear}body.blog-site header.main div.inner h1 a:hover{border-bottom:2px solid #3A5E67}body.blog-site header.sub div.inner{z-index:51}body.blog-detail section.main div.inner{width:718px}body.blog-detail section.main div.inner section.snipts article.snipt{margin-bottom:0}body.blog-detail section.main div.inner section.snipts article.snipt div.container{width:100%}body.blog-detail section.main div.inner section.snipts article.snipt div.container h1 a{white-space:normal}body.blog-detail section.main div.inner section.snipts article.snipt div.container section.code{height:auto}body.blog-detail section.main div.inner section.snipts article.snipt div.container section.code td.code div.highlight pre{width:683px}body.blog-detail section.main div.inner section.snipts article.snipt footer ul.attrs li.tweet{margin-right:116px}body.blog-detail div#disqus_thread{width:704px}body.blog-detail div#disqus_thread #dsq-content{margin-top:-38px}body.blog-list article.snipt div.container section.code td.code div.highlight pre{width:683px}

View File

@ -17,7 +17,9 @@ cat media/js/libs/underscore.js \
media/js/src/modules/site.min.js \
media/js/src/modules/snipt.min.js \
media/js/libs/codemirror.js \
media/js/libs/highlight.js \
> media/js/snipt.js
cat media/js/src/pro.js \
cat media/js/libs/highlight.js \
media/js/src/pro.js \
> media/js/pro.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -164,6 +164,11 @@
$('iframe', this.$aside_main).parent('p').prev('p').css('margin-bottom', '10px');
}
// Highlight any Markdown code.
$('div.markdown pre code').each(function(i, e) {
hljs.highlightBlock(e);
});
window.ui_halted = false;
},
events: {

View File

@ -10,4 +10,4 @@ if(!errors){$('.payment-errors').hide();$('.payment-loading').show();Stripe.crea
return false;});}
if(this.$body.hasClass('login')){$('input#id_username').focus();}
if(window.gittip_username){this.$aside_main.html(this.$aside_main.html().replace(/\[\[.*gittip.*\]\]/,'<iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/'+window.gittip_username+'/widget.html" width="48pt" height="22pt"></iframe>'));$('iframe',this.$aside_main).parent('p').prev('p').css('margin-bottom','10px');}
window.ui_halted=false;},events:{'showKeyboardShortcuts':'showKeyboardShortcuts','click a.mini-profile':'toggleMiniProfile'},keyboardShortcuts:function(){var $body=this.$body;var that=this;$search_queries=this.$search_queries;$search_page_query=this.$search_page_query;$search_query=this.$search_query;$document=$(document);$document.bind('keydown','/',function(e){if(!window.ui_halted){e.preventDefault();if($body.hasClass('search')){$search_page_query.focus();}else{$search_query.focus();}}});$document.bind('keydown','h',function(e){if(!window.ui_halted){window.ui_halted=true;$body.trigger('showKeyboardShortcuts');}else{if(that.$keyboard_shortcuts.is(':visible')){that.$keyboard_shortcuts.modal('hide');}}});$document.bind('keydown','t',function(e){if(!window.ui_halted){window.open('','_blank');}});$document.bind('keydown','r',function(e){if(!window.ui_halted){location.reload(true);}});$document.bind('keydown','Ctrl+h',function(e){if(!window.ui_halted){history.go(-1);}});$document.bind('keydown','Ctrl+l',function(e){if(!window.ui_halted){history.go(1);}});this.$search_queries.bind('keydown','esc',function(e){if(!window.ui_halted){e.preventDefault();this.blur();}});},showKeyboardShortcuts:function(){this.$keyboard_shortcuts.modal('toggle');},toggleMiniProfile:function(e){this.$aside_nav.toggleClass('open');return false;},inFieldLabels:function(){$('div.infield label',this.$body).inFieldLabels({fadeDuration:200});},stripeResponseHandler:function(status,response){var $form=$('form#pro-signup');if(response.error){$('button[type="submit"]',$form).removeAttr('disabled');$('.payment-loading').hide();$('.payment-errors').text(response.error.message).show();}else{var token=response.id;$('input#name').val('');$('input#number').val('');$('select#exp-month').val('');$('select#exp-year').val('');$('input#cvc').val('');$form.append("<input type='hidden' name='token' value='"+token+"'/>");$form.get(0).submit();}}});})(snipt.module('site'));
$('div.markdown pre code').each(function(i,e){hljs.highlightBlock(e);});window.ui_halted=false;},events:{'showKeyboardShortcuts':'showKeyboardShortcuts','click a.mini-profile':'toggleMiniProfile'},keyboardShortcuts:function(){var $body=this.$body;var that=this;$search_queries=this.$search_queries;$search_page_query=this.$search_page_query;$search_query=this.$search_query;$document=$(document);$document.bind('keydown','/',function(e){if(!window.ui_halted){e.preventDefault();if($body.hasClass('search')){$search_page_query.focus();}else{$search_query.focus();}}});$document.bind('keydown','h',function(e){if(!window.ui_halted){window.ui_halted=true;$body.trigger('showKeyboardShortcuts');}else{if(that.$keyboard_shortcuts.is(':visible')){that.$keyboard_shortcuts.modal('hide');}}});$document.bind('keydown','t',function(e){if(!window.ui_halted){window.open('','_blank');}});$document.bind('keydown','r',function(e){if(!window.ui_halted){location.reload(true);}});$document.bind('keydown','Ctrl+h',function(e){if(!window.ui_halted){history.go(-1);}});$document.bind('keydown','Ctrl+l',function(e){if(!window.ui_halted){history.go(1);}});this.$search_queries.bind('keydown','esc',function(e){if(!window.ui_halted){e.preventDefault();this.blur();}});},showKeyboardShortcuts:function(){this.$keyboard_shortcuts.modal('toggle');},toggleMiniProfile:function(e){this.$aside_nav.toggleClass('open');return false;},inFieldLabels:function(){$('div.infield label',this.$body).inFieldLabels({fadeDuration:200});},stripeResponseHandler:function(status,response){var $form=$('form#pro-signup');if(response.error){$('button[type="submit"]',$form).removeAttr('disabled');$('.payment-loading').hide();$('.payment-errors').text(response.error.message).show();}else{var token=response.id;$('input#name').val('');$('input#number').val('');$('select#exp-month').val('');$('select#exp-year').val('');$('input#cvc').val('');$form.append("<input type='hidden' name='token' value='"+token+"'/>");$form.get(0).submit();}}});})(snipt.module('site'));

View File

@ -14,4 +14,9 @@ $(function() {
$('iframe', $aside).parent('p').prev('p').css('margin-bottom', '10px');
}
// Highlight any Markdown code.
$('div.markdown pre code').each(function(i, e) {
hljs.highlightBlock(e);
});
});

View File

@ -1,2 +1,3 @@
$(function(){var $aside=$('aside');$('a:contains("View more")',$aside).addClass('more');if(window.gittip_username){$aside.html($aside.html().replace(/\[\[.*gittip.*\]\]/,'<iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/'+window.gittip_username+'/widget.html" width="48pt" height="22pt"></iframe>'));$('iframe',$aside).parent('p').prev('p').css('margin-bottom','10px');}});
$(function(){var $aside=$('aside');$('a:contains("View more")',$aside).addClass('more');if(window.gittip_username){$aside.html($aside.html().replace(/\[\[.*gittip.*\]\]/,'<iframe style="border: 0; margin: 0; padding: 0;" src="https://www.gittip.com/'+window.gittip_username+'/widget.html" width="48pt" height="22pt"></iframe>'));$('iframe',$aside).parent('p').prev('p').css('margin-bottom','10px');}
$('div.markdown pre code').each(function(i,e){hljs.highlightBlock(e);});});