From 872f9ea5e6f3a3d28f8b757cee7360a7452e3866 Mon Sep 17 00:00:00 2001 From: mdinger Date: Mon, 14 Sep 2015 05:08:48 -0400 Subject: [PATCH] Add tomorrow night as dark code highlighting theme --- src/renderer/html_handlebars/hbs_renderer.rs | 2 + src/theme/index.hbs | 1 + src/theme/mod.rs | 9 ++ src/theme/tomorrow-night.css | 96 ++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 src/theme/tomorrow-night.css diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index deb4c556..886b6730 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -179,6 +179,8 @@ impl Renderer for HtmlHandlebars { // syntax highlighting let mut highlight_css = try!(File::create(book.get_dest().join("highlight.css"))); try!(highlight_css.write_all(&theme.highlight_css)); + let mut tomorrow_night_css = try!(File::create(book.get_dest().join("tomorrow-night.css"))); + try!(tomorrow_night_css.write_all(&theme.tomorrow_night_css)); let mut highlight_js = try!(File::create(book.get_dest().join("highlight.js"))); try!(highlight_js.write_all(&theme.highlight_js)); diff --git a/src/theme/index.hbs b/src/theme/index.hbs index cdbccbc4..32c90a0b 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -16,6 +16,7 @@ + diff --git a/src/theme/mod.rs b/src/theme/mod.rs index e8f21570..703a994c 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -8,6 +8,7 @@ pub static INDEX: &'static [u8] = include_bytes!("index.hbs"); pub static CSS: &'static [u8] = include_bytes!("book.css"); pub static JS: &'static [u8] = include_bytes!("book.js"); pub static HIGHLIGHT_JS: &'static [u8] = include_bytes!("highlight.js"); +pub static TOMORROW_NIGHT_CSS: &'static [u8] = include_bytes!("tomorrow-night.css"); pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css"); pub static JQUERY: &'static [u8] = include_bytes!("jquery-2.1.4.min.js"); pub static FONT_AWESOME: &'static [u8] = include_bytes!("_FontAwesome/css/font-awesome.min.css"); @@ -29,6 +30,7 @@ pub struct Theme { pub css: Vec, pub js: Vec, pub highlight_css: Vec, + pub tomorrow_night_css: Vec, pub highlight_js: Vec, pub jquery: Vec, } @@ -42,6 +44,7 @@ impl Theme { css: CSS.to_owned(), js: JS.to_owned(), highlight_css: HIGHLIGHT_CSS.to_owned(), + tomorrow_night_css: TOMORROW_NIGHT_CSS.to_owned(), highlight_js: HIGHLIGHT_JS.to_owned(), jquery: JQUERY.to_owned(), }; @@ -89,6 +92,12 @@ impl Theme { let _ = f.read_to_end(&mut theme.highlight_css); } + // tomorrow-night.css + if let Ok(mut f) = File::open(&src.join("tomorrow-night.css")) { + theme.tomorrow_night_css.clear(); + let _ = f.read_to_end(&mut theme.tomorrow_night_css); + } + theme } } diff --git a/src/theme/tomorrow-night.css b/src/theme/tomorrow-night.css new file mode 100644 index 00000000..9788e084 --- /dev/null +++ b/src/theme/tomorrow-night.css @@ -0,0 +1,96 @@ +/* Tomorrow Night Theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ + +/* Tomorrow Comment */ +.hljs-comment { + color: #969896; +} + +/* Tomorrow Red */ +.hljs-variable, +.hljs-attribute, +.hljs-tag, +.hljs-regexp, +.ruby .hljs-constant, +.xml .hljs-tag .hljs-title, +.xml .hljs-pi, +.xml .hljs-doctype, +.html .hljs-doctype, +.css .hljs-id, +.css .hljs-class, +.css .hljs-pseudo { + color: #cc6666; +} + +/* Tomorrow Orange */ +.hljs-number, +.hljs-preprocessor, +.hljs-pragma, +.hljs-built_in, +.hljs-literal, +.hljs-params, +.hljs-constant { + color: #de935f; +} + +/* Tomorrow Yellow */ +.ruby .hljs-class .hljs-title, +.css .hljs-rule .hljs-attribute { + color: #f0c674; +} + +/* Tomorrow Green */ +.hljs-string, +.hljs-value, +.hljs-inheritance, +.hljs-header, +.hljs-name, +.ruby .hljs-symbol, +.xml .hljs-cdata { + color: #b5bd68; +} + +/* Tomorrow Aqua */ +.hljs-title, +.css .hljs-hexcolor { + color: #8abeb7; +} + +/* Tomorrow Blue */ +.hljs-function, +.python .hljs-decorator, +.python .hljs-title, +.ruby .hljs-function .hljs-title, +.ruby .hljs-title .hljs-keyword, +.perl .hljs-sub, +.javascript .hljs-title, +.coffeescript .hljs-title { + color: #81a2be; +} + +/* Tomorrow Purple */ +.hljs-keyword, +.javascript .hljs-function { + color: #b294bb; +} + +.hljs { + display: block; + overflow-x: auto; + background: #1d1f21; + color: #c5c8c6; + padding: 0.5em; + -webkit-text-size-adjust: none; +} + +.coffeescript .javascript, +.javascript .xml, +.tex .hljs-formula, +.xml .javascript, +.xml .vbscript, +.xml .css, +.xml .hljs-cdata { + opacity: 0.5; +}