improved syntax highlighting

This commit is contained in:
Brandon Mathis 2010-12-15 18:15:19 -06:00
parent 34f8763b22
commit 2da5502040
18 changed files with 198 additions and 91 deletions

View File

@ -14,7 +14,7 @@ GIT
PATH PATH
remote: .. remote: ..
specs: specs:
compass (0.11.alpha.4.e616fa1) compass (0.11.alpha.4.34f8763)
chunky_png (~> 0.10.3) chunky_png (~> 0.10.3)
sass (>= 3.1.0.alpha.50) sass (>= 3.1.0.alpha.50)

View File

@ -0,0 +1,33 @@
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (July 02 2010)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
;(function()
{
// CommonJS
typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
function Brush()
{
};
Brush.prototype = new SyntaxHighlighter.Highlighter();
Brush.aliases = ['text', 'plain', 'haml'];
SyntaxHighlighter.brushes.Plain = Brush;
// CommonJS
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
})();

View File

@ -1,9 +1,5 @@
#opacity-10.opacity-example #opacity-10.opacity-example
#opacity-20.opacity-example #opacity-20.opacity-example
#opacity-50.opacity-example #opacity-50.opacity-example
#opaque.opacity-example #opaque.opacity-example
#transparent.opacity-example #transparent.opacity-example

View File

@ -29,5 +29,5 @@ layout: default
## Give Financially ## Give Financially
Compass is charityware. We ask users to [donate to United Mitochondrial Disease Foundation](http://umdf.org/compass) Compass is charityware. You can use it as much as you like, but we encourage you to make a donation to help the [UMDF](http://umdf.org/)
to support their efforts to find a cure for this disease. find a cure for mitochondrial disease. If you can, please [donate here](http://umdf.org/compass/). Thanks!

View File

@ -7,8 +7,8 @@
html.sass { .mixin-source .syntaxhighlighter.sass, .example-source .syntaxhighlighter.sass { display: block; } } html.sass { .mixin-source .syntaxhighlighter.sass, .example-source .syntaxhighlighter.sass { display: block; } }
html.scss { .mixin-source .syntaxhighlighter.scss, .example-source .syntaxhighlighter.scss { display: block; } } html.scss { .mixin-source .syntaxhighlighter.scss, .example-source .syntaxhighlighter.scss { display: block; } }
html.css .example-source .syntaxhighlighter.css { display: block; } html.css .example-source .syntaxhighlighter.css { display: block; }
html.html .example-source .html { display: block; } html.html .example-source .syntaxhighlighter.html { display: block; }
html.haml .example-source .haml { display: block; } html.haml .example-source .syntaxhighlighter.haml { display: block; }
@ -20,7 +20,6 @@ html.light .syntaxhighlighter, html.dark .syntaxhighlighter {
//font-size: 1.1em; //font-size: 1.1em;
text-shadow: none; text-shadow: none;
.code-block { background: none; @extend .clear-box-shadow; } .code-block { background: none; @extend .clear-box-shadow; }
&, table td.code .container { position: static !important; }
table td.gutter { .line { &:first-child { padding-top: 10px !important; } &:last-child { padding-bottom: 10px !important; } } } table td.gutter { .line { &:first-child { padding-top: 10px !important; } &:last-child { padding-bottom: 10px !important; } } }
.toolbar { display: none; } .toolbar { display: none; }
//a.help { font-size: 1.5em; @extend .pictos; color: #aaa; position: relative; right: 6px; top: 2px; } //a.help { font-size: 1.5em; @extend .pictos; color: #aaa; position: relative; right: 6px; top: 2px; }
@ -104,6 +103,8 @@ h2 + a[rel="view source"]{ margin-top: 6px;}
.toolbar { position: absolute; right: 1px; top: 1px; width: 11px; height: 11px; font-size: 10px; z-index: 10; .toolbar { position: absolute; right: 1px; top: 1px; width: 11px; height: 11px; font-size: 10px; z-index: 10;
span.title { display: inline; } span.title { display: inline; }
a { display: block; text-align: center; text-decoration: none; padding-top: 1px; } } a { display: block; text-align: center; text-decoration: none; padding-top: 1px; } }
.container { position: relative; }
textarea { @include stretch(0, .65em, 0, .65em); @extend .fixed-font; font-size: .95em; line-height: 1.3em !important;}
} }
.syntaxhighlighter, pre .code-block:first-child, pre { .syntaxhighlighter, pre .code-block:first-child, pre {
&::-webkit-scrollbar { height: 12px; } &::-webkit-scrollbar { height: 12px; }

View File

@ -70,7 +70,9 @@
&.sass a[rel=sass], &.scss a[rel=scss], &.css a[rel=css], &.html a[rel=html], &.haml a[rel=haml] { color: $heading; color: rgba($heading, .7); @extend .round-corners-em; @extend .inset-panel-#{$theme}; } &.sass a[rel=sass], &.scss a[rel=scss], &.css a[rel=css], &.html a[rel=html], &.haml a[rel=haml] { color: $heading; color: rgba($heading, .7); @extend .round-corners-em; @extend .inset-panel-#{$theme}; }
#version { color: rgba($heading, .3); a { color: rgba($nav-link, .7); } } #version { color: rgba($heading, .3); a { color: rgba($nav-link, .7); } }
.mixin-source, .example-source { @extend .mixin-panel-#{$theme}; } .mixin-source, .example-source { @extend .mixin-panel-#{$theme};
.container textarea { color: $code; }
}
h2 a.help { color: $heading;} h2 a.help { color: $heading;}
.source-documentation { @extend .doc-panel-#{$theme}; } .source-documentation { @extend .doc-panel-#{$theme}; }
@ -86,7 +88,7 @@
// Dark theme // Dark theme
.inset-panel-dark { .inset-panel-dark {
@include box-shadow(rgba(#fff, .1) 0 1px 0, rgba(#000, .8) 0 1px 7px 0px inset); @include box-shadow(rgba(#fff, .1) 0 1px 0, rgba(#000, .8) 0 1px 7px 0px inset);
background: darken(#2f2f2f, 4); background-color: rgba(#000, .3); } background: darken(#2f2f2f, 6); background-color: rgba(#000, .3); }
.horizontal-rule-dark { .horizontal-rule-dark {
@include box-shadow(rgba(#fff, .07) 0 1px 0); @include box-shadow(rgba(#fff, .07) 0 1px 0);
@ -105,7 +107,6 @@
.demo-dark { .demo-dark {
@include box-shadow(rgba(#000, .5) 0 2px 10px inset, rgba(#fff, .3) 0 1px 2px 0px, rgba(#000, .8) 0 0 0 1px inset); } @include box-shadow(rgba(#000, .5) 0 2px 10px inset, rgba(#fff, .3) 0 1px 2px 0px, rgba(#000, .8) 0 0 0 1px inset); }
.heading-panel-dark { .heading-panel-dark {
background: darken(#2f2f2f, 6); background: darken(#2f2f2f, 6);
background: rgba(#000, .2); background: rgba(#000, .2);
@ -137,6 +138,7 @@
.mixin-panel-dark { .mixin-panel-dark {
@extend .inset-panel-dark; @extend .inset-panel-dark;
td.gutter { background: rgba(#fff, .05); .line { border-right: 2px solid rgba(#fff, .15); color: rgba(#fff, .5); }} td.gutter { background: rgba(#fff, .05); .line { border-right: 2px solid rgba(#fff, .15); color: rgba(#fff, .5); }}
.container textarea { background: darken(#2f2f2f, 6); }
} }
@mixin dark-theme($docs: false) { @mixin dark-theme($docs: false) {
@ -157,8 +159,8 @@
$docs-nav-selected: $strong-text; $docs-nav-selected: $strong-text;
$module-nav-selected: $link; $module-nav-selected: $link;
$option-panel-border: rgba(#000, .3); $option-panel-border: rgba(#000, .5);
$option-panel-bg: rgba(#fff, .03); $option-panel-bg: rgba(#fff, .06);
@include site-theme(dark, $page-bg, $text, $strong-text, $heading, $link, $code, $search, $nav-link, $main-nav, $main-nav-selected, $option-panel-border, $option-panel-bg); @include site-theme(dark, $page-bg, $text, $strong-text, $heading, $link, $code, $search, $nav-link, $main-nav, $main-nav-selected, $option-panel-border, $option-panel-bg);
@ -177,7 +179,7 @@
.inset-panel-light { .inset-panel-light {
@include box-shadow(rgba(#fff, 1) 0 1px 0, rgba(#000, .5) 0 1px 3px 0px inset); @include box-shadow(rgba(#fff, 1) 0 1px 0, rgba(#000, .5) 0 1px 3px 0px inset);
text-shadow: 0 1px 1px #fff; text-shadow: 0 1px 1px #fff;
background-color: rgba(#000, .04); } background: darken(#fff, .04); background-color: rgba(#000, .04); }
.horizontal-rule-light { .horizontal-rule-light {
@include box-shadow(#fff 0 1px 0); @include box-shadow(#fff 0 1px 0);
@ -227,6 +229,7 @@
@extend .inset-panel-light; @extend .inset-panel-light;
background: rgba(#fff, .8); background: rgba(#fff, .8);
td.gutter { background: rgba(#000, .08); .line { border-right: 2px solid rgba(#000, .2); color: rgba(#000, .4); } } td.gutter { background: rgba(#000, .08); .line { border-right: 2px solid rgba(#000, .2); color: rgba(#000, .4); } }
.container textarea { background: darken(#fff, .04); }
} }
@mixin light-theme($docs: false) { @mixin light-theme($docs: false) {

View File

@ -1,4 +1,5 @@
@import "compass"; @import "compass";
@import "compass/layout";
@import "core/extensions"; @import "core/extensions";
@include global-reset; @include global-reset;
@ -16,7 +17,7 @@
@import "partials/code"; @import "partials/code";
@import "partials/example"; @import "partials/example";
//@import "syntax/syntax-theme"; @import "syntax/syntax-theme";
@import "core/clearing-classes"; @import "core/clearing-classes";

View File

@ -1,32 +1,113 @@
// RDark SyntaxHighlighter theme based on theme by Radu Dineiu
// http://www.vim.org/scripts/script.php?script_id=1732
$background: #1b2426 !default; // Dark Theme
$line_highlighted_background: #323E41 !default; $background: none;
$line_highlighted_number: #b9bdb6 !default;
$gutter_text: #afafaf !default; $line_highlighted_background: #323E41;
$gutter_border_color: #435a5f !default; $line_highlighted_number: #b9bdb6;
$toolbar_collapsed_a: #5ba1cf !default; $gutter_text: #afafaf;
$toolbar_collapsed_a_hover: #5ce638 !default; $gutter_border_color: rgba(#fff, .15);
$toolbar_collapsed_background: #000 !default;
$toolbar_a: #fff !default; $toolbar_collapsed_a: #5ba1cf;
$toolbar_a_hover: #e0e8ff !default; $toolbar_collapsed_a_hover: #5ce638;
$toolbar_collapsed_background: #000;
$code_plain: #b9bdb6 !default; $toolbar_a: #fff;
$code_comments: #878a85 !default; $toolbar_a_hover: #e0e8ff;
$code_string: #5ce638 !default;
$code_keyword: #5ba1cf !default; $code_plain: #dadbb1;
$code_preprocessor: #435a5f !default; $code_comments: #878a85;
$code_variable: #ffaa3e !default; $code_string: #64b041;
$code_value: #009900 !default; $code_keyword: #6cc7eb;
$code_functions: #ffaa3e !default; $code_preprocessor: #cd5c57;
$code_constants: #e0e8ff !default; $code_variable: $code_keyword;
$code_color1: #e0e8ff !default; $code_value: #ffa0a0;
$code_color2: white !default; $code_functions: #3d95e6;
$code_color3: #ffaa3e !default; $code_constants: #e0e8ff;
$code_script: $code_keyword;
$code_script_background: none;
$code_color1: #b0b76b;
$code_color2: #98f77a;
$code_color3: #ffaa3e;
$code_color4: $code_plain;
//@import "theme_template.scss";
// Interface elements.
html.dark .syntaxhighlighter {
// Actual syntax highlighter colors.
.plain, .plain a { color: $code_plain; }
.comments, .comments a { color: $code_comments; }
.string, .string a { color: $code_string; }
.keyword { color: $code_keyword; }
.preprocessor { color: $code_preprocessor; }
.variable { color: $code_variable; }
.value { color: $code_value; }
.functions { color: $code_functions; }
.constants { color: $code_constants; }
.script {
font-weight: bold;
color: $code_script;
background-color: $code_script_background;
}
.color1, .color1 a { color: $code_color1; }
.color2, .color2 a { color: $code_color2; }
.color3, .color3 a { color: $code_color3; }
.color4, .color4 a { color: $code_color4; }
}
// Light Theme
$background: none;
$line_highlighted_background: #c3defe;
$line_highlighted_number: #fff;
$gutter_text: #787878;
$gutter_border_color: #d4d0c8;
$toolbar_collapsed_a: #3f5fbf;
$toolbar_collapsed_a_hover: #aa7700;
$toolbar_collapsed_background: #fff;
$toolbar_a: #a0a0a0;
$toolbar_a_hover: red;
$code_plain: black;
$code_comments: #3f5fbf;
$code_string: #4fa33f;
$code_keyword: #7f0055;
$code_preprocessor: #006699;
$code_variable: #aa7700;
$code_value: #4fa33f;
$code_functions: #b553ba;
$code_constants: #0066cc;
$code_color1: gray;
$code_color2: #ca6436;
$code_color3: red;
$code_color4: $code_plain;
// Interface elements.
html.light .syntaxhighlighter {
// Actual syntax highlighter colors.
.plain, .plain a { color: $code_plain; }
.comments, .comments a { color: $code_comments; }
.string, .string a { color: $code_string; }
.keyword { color: $code_keyword; }
.preprocessor { color: $code_preprocessor; }
.variable { color: $code_variable; }
.value { color: $code_value; }
.functions { color: $code_functions; }
.constants { color: $code_constants; }
.script {
font-weight: bold;
color: $code_script;
background-color: $code_script_background;
}
.color1, .color1 a { color: $code_color1; }
.color2, .color2 a { color: $code_color2; }
.color3, .color3 a { color: $code_color3; }
.color4, .color4 a { color: $code_color4; }
}
@import "theme_template.scss";

View File

@ -1,6 +1,7 @@
// Default Syntax Highlighter theme. // Default Syntax Highlighter theme.
//@import "shCore.scss"; //@import "shCore.scss";
//@import "shThemeRDark.scss";
@import "shThemeRDark.scss";
/*.syntaxhighlighter { /*.syntaxhighlighter {
.keyword { font-weight: bold !important; } .keyword { font-weight: bold !important; }

View File

@ -9,15 +9,8 @@
%title %title
#{@item[:title]} | Compass Documentation #{@item[:title]} | Compass Documentation
%link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"}
%script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript") = render "partials/js-core"
%script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript") = render "partials/js-highlighter"
%script(src="/javascripts/jquery.cookie.js" type="text/javascript")
%script(src="/javascripts/site.js" type="text/javascript")
%script(src="/javascripts/shCore.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushSass.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushCss.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushXml.js" type="text/javascript" deferred)
%script(src="/javascripts/fixups.js" type="text/javascript" deferred)
/[if lte IE 8] /[if lte IE 8]
%link{:charset => "utf-8", :href => "/stylesheets/ie.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/ie.css", :rel => "stylesheet", :type => "text/css"}
- if @item[:content_for_additional_css] - if @item[:content_for_additional_css]

View File

@ -1,5 +1,4 @@
!!!5 !!!5
- # This template is just the stuff until the body tag.
%html.no-js{:dir => "ltr", :lang => "en"} %html.no-js{:dir => "ltr", :lang => "en"}
%head %head
%meta{:charset => "utf-8"}/ %meta{:charset => "utf-8"}/
@ -9,10 +8,7 @@
%title %title
#{@item[:title]} | Compass Documentation #{@item[:title]} | Compass Documentation
%link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"}
%script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript") = render "partials/js-core"
%script(src="/javascripts/jquery.cookie.js" type="text/javascript")
%script(src="/javascripts/site.js" type="text/javascript")
%script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript")
%body.default{body_attributes(@item)} %body.default{body_attributes(@item)}
#wrap #wrap
= render "partials/main-navigation" = render "partials/main-navigation"

View File

@ -1,5 +1,4 @@
!!!5 !!!5
- # This template is just the stuff until the body tag.
%html.no-js{:dir => "ltr", :lang => "en"} %html.no-js{:dir => "ltr", :lang => "en"}
%head %head
%meta{:charset => "utf-8"}/ %meta{:charset => "utf-8"}/
@ -9,10 +8,7 @@
%title %title
#{@item[:title]} | Compass Documentation #{@item[:title]} | Compass Documentation
%link{:charset => "utf-8", :href => "/stylesheets/home.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/home.css", :rel => "stylesheet", :type => "text/css"}
%script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript") = render "partials/js-core"
%script(src="/javascripts/jquery.cookie.js" type="text/javascript")
%script(src="/javascripts/site.js" type="text/javascript")
%script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript")
/[if lte IE 8] /[if lte IE 8]
%link{:charset => "utf-8", :href => "/stylesheets/ie.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/ie.css", :rel => "stylesheet", :type => "text/css"}
- if @item[:content_for_additional_css] - if @item[:content_for_additional_css]

View File

@ -0,0 +1,5 @@
%script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript")
%script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript")
%script(src="/javascripts/jquery.cookie.js" type="text/javascript")
%script(src="/javascripts/site.js" type="text/javascript")
%script(src="/javascripts/fixups.js" type="text/javascript" deferred)

View File

@ -0,0 +1,5 @@
%script(src="/javascripts/shCore.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushSass.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushCss.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushXml.js" type="text/javascript" deferred)
%script(src="/javascripts/shBrushPlain.js" type="text/javascript" deferred)

View File

@ -1,5 +1,4 @@
!!!5 !!!5
- # This template is just the stuff until the body tag.
%html.no-js{:dir => "ltr", :lang => "en"} %html.no-js{:dir => "ltr", :lang => "en"}
%head %head
%meta{:charset => "utf-8"}/ %meta{:charset => "utf-8"}/
@ -9,10 +8,7 @@
%title %title
#{@item[:title]} | Compass Documentation #{@item[:title]} | Compass Documentation
%link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"} %link{:charset => "utf-8", :href => "/stylesheets/screen.css", :rel => "stylesheet", :type => "text/css"}
%script(src="/javascripts/jquery-1.3.2.min.js" type="text/javascript") = render "partials/js-core"
%script(src="/javascripts/jquery.cookie.js" type="text/javascript")
%script(src="/javascripts/site.js" type="text/javascript")
%script(src="/javascripts/modernizr-1.6.min.js" type="text/javascript")
%body.site{body_attributes(@item)} %body.site{body_attributes(@item)}
#wrap #wrap
= render "partials/main-navigation" = render "partials/main-navigation"

View File

@ -26,7 +26,7 @@ class SyntaxHighlighterFilter < Nanoc3::Filter
def run(content, params={}) def run(content, params={})
doc = Nokogiri::HTML.fragment(content) doc = Nokogiri::HTML.fragment(content)
[:css, :sass, :scss].each do |format| [:css, :sass, :scss, :html, :haml].each do |format|
doc.css("pre.source-code.#{format}, code.#{format}").each do |el| doc.css("pre.source-code.#{format}, code.#{format}").each do |el|
el.set_attribute("class", "brush: #{format} "+el.attribute("class").value) el.set_attribute("class", "brush: #{format} "+el.attribute("class").value)
end end