From 58d18d467cc015a06cbc4e6b59a5abcdafc3a523 Mon Sep 17 00:00:00 2001
From: Mathieu David
Date: Wed, 5 Aug 2015 19:14:03 +0200
Subject: [PATCH] Fixed a bug where custom theme was appended to default theme
+ Changed syntax highlighting theme to something lighter, the dark theme did
not fit the light style of the page
---
book-example/book/format/theme.html | 2 +-
book-example/book/highlight.css | 200 +++++++++-----------------
book-example/src/format/theme.md | 2 +-
src/renderer/html_handlebars/theme.rs | 5 +
src/theme/highlight.css | 200 +++++++++-----------------
5 files changed, 147 insertions(+), 262 deletions(-)
diff --git a/book-example/book/format/theme.html b/book-example/book/format/theme.html
index cba996a9..5e08d08f 100644
--- a/book-example/book/format/theme.html
+++ b/book-example/book/format/theme.html
@@ -42,7 +42,7 @@ and now that file will be used instead of the default file.
Note:
When you overwrite a file, it is possible that you break some functionality. Therefore I recommend to use the file from the default theme as template and only add / modify what you need. In the future you will be able to copy the default theme into your source directory automatically by using mdbook init --theme
.
Syntax Highlighting
-For syntax highlighting I use Highlight.js with the Monokai Sublime theme as default.
+
For syntax highlighting I use Highlight.js with modified theme.
But if you want a different theme, just put a highlight.css
file in your theme folder and your theme will be used.
- highlight.js normally you shouldn't have to overwrite this file. But if you need to, you can.
diff --git a/book-example/book/highlight.css b/book-example/book/highlight.css
index 12f55b1b..0b9578c3 100644
--- a/book-example/book/highlight.css
+++ b/book-example/book/highlight.css
@@ -1,15 +1,12 @@
-/*
-
-Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
-
-*/
+/* Modified Base16 Atelier Dune Light - Theme
+/* Original by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */
.hljs {
display: block;
overflow-x: auto;
+ background: #f1f1f1;
+ color: #6e6b5e;
padding: 0.5em;
- background: #23241f;
- border-radius: 4px;
-webkit-text-size-adjust: none;
}
@@ -20,133 +17,78 @@ Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-lic
border-radius: 3px;
}
-.hljs,
-.hljs-tag,
-.css .hljs-rule,
-.css .hljs-value,
-.aspectj .hljs-function,
-.css .hljs-function
-.hljs-preprocessor,
-.hljs-pragma {
- color: #f8f8f2;
-}
-
-.hljs-strongemphasis,
-.hljs-strong,
-.hljs-emphasis {
- color: #a8a8a2;
-}
-
-.hljs-bullet,
-.hljs-blockquote,
-.hljs-horizontal_rule,
-.hljs-number,
-.hljs-regexp,
-.alias .hljs-keyword,
-.hljs-literal,
-.hljs-hexcolor {
- color: #ae81ff;
-}
-
-.hljs-tag .hljs-value,
-.hljs-code,
-.hljs-title,
-.css .hljs-class,
-.hljs-class .hljs-title:last-child {
- color: #a6e22e;
-}
-
-.hljs-link_url {
- font-size: 80%;
-}
-
-.hljs-strong,
-.hljs-strongemphasis {
- font-weight: bold;
-}
-
-.hljs-emphasis,
-.hljs-strongemphasis,
-.hljs-class .hljs-title:last-child,
-.hljs-typename {
- font-style: italic;
-}
-
-.hljs-keyword,
-.ruby .hljs-class .hljs-keyword:first-child,
-.ruby .hljs-function .hljs-keyword,
-.hljs-function,
-.hljs-change,
-.hljs-winutils,
-.hljs-flow,
-.nginx .hljs-title,
-.tex .hljs-special,
-.hljs-header,
-.hljs-attribute,
-.hljs-symbol,
-.hljs-symbol .hljs-string,
-.hljs-tag .hljs-title,
-.hljs-value,
-.alias .hljs-keyword:first-child,
-.css .hljs-tag,
-.css .unit,
-.css .hljs-important {
- color: #f92672;
-}
-
-.hljs-function .hljs-keyword,
-.hljs-class .hljs-keyword:first-child,
-.hljs-aspect .hljs-keyword:first-child,
-.hljs-constant,
-.hljs-typename,
-.hljs-name,
-.css .hljs-attribute {
- color: #66d9ef;
+
+/* Atelier-Dune Comment */
+.hljs-comment {
+ color: #AAA;
}
+/* Atelier-Dune Red */
.hljs-variable,
-.hljs-params,
-.hljs-class .hljs-title,
-.hljs-aspect .hljs-title {
- color: #f8f8f2;
-}
-.hljs-string,
+.hljs-tag,
+.hljs-regexp,
+.hljs-name,
+.ruby .hljs-constant,
+.xml .hljs-tag .hljs-title,
+.xml .hljs-pi,
+.xml .hljs-doctype,
+.html .hljs-doctype,
.css .hljs-id,
-.hljs-subst,
-.hljs-type,
-.ruby .hljs-class .hljs-parent,
-.hljs-built_in,
-.django .hljs-template_tag,
-.django .hljs-variable,
-.smalltalk .hljs-class,
-.django .hljs-filter .hljs-argument,
-.smalltalk .hljs-localvars,
-.smalltalk .hljs-array,
-.hljs-attr_selector,
-.hljs-pseudo,
-.hljs-addition,
-.hljs-stream,
-.hljs-envvar,
-.apache .hljs-tag,
-.apache .hljs-cbracket,
-.tex .hljs-command,
-.hljs-prompt,
-.hljs-link_label,
-.hljs-link_url {
- color: #e6db74;
+.css .hljs-class,
+.css .hljs-pseudo {
+ color: #d73737;
}
-.hljs-comment,
-.hljs-annotation,
-.hljs-decorator,
-.hljs-pi,
-.hljs-doctype,
-.hljs-deletion,
-.hljs-shebang,
-.apache .hljs-sqbracket,
-.tex .hljs-formula {
- color: #75715e;
+/* Atelier-Dune Orange */
+.hljs-number,
+.hljs-preprocessor,
+.hljs-built_in,
+.hljs-literal,
+.hljs-params,
+.hljs-attribute,
+.hljs-constant {
+ color: #b65611;
+}
+
+/* Atelier-Dune Yellow */
+.ruby .hljs-class .hljs-title,
+.css .hljs-rule .hljs-attribute {
+ color: #ae9513;
+}
+
+/* Atelier-Dune Green */
+.hljs-string,
+.hljs-value,
+.hljs-inheritance,
+.hljs-header,
+.ruby .hljs-symbol,
+.xml .hljs-cdata {
+ color: #2a9292;
+}
+
+/* Atelier-Dune Aqua */
+.hljs-title,
+.css .hljs-hexcolor {
+ color: #1fad83;
+}
+
+/* Atelier-Dune 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: #6684e1;
+}
+
+/* Atelier-Dune Purple */
+.hljs-keyword,
+.javascript .hljs-function {
+ color: #b854d4;
}
.coffeescript .javascript,
@@ -155,8 +97,6 @@ Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-lic
.xml .javascript,
.xml .vbscript,
.xml .css,
-.xml .hljs-cdata,
-.xml .php,
-.php .xml {
+.xml .hljs-cdata {
opacity: 0.5;
}
diff --git a/book-example/src/format/theme.md b/book-example/src/format/theme.md
index cc5a2a5b..8cdff1b7 100644
--- a/book-example/src/format/theme.md
+++ b/book-example/src/format/theme.md
@@ -19,7 +19,7 @@ When you overwrite a file, it is possible that you break some functionality. The
### Syntax Highlighting
-For syntax highlighting I use [Highlight.js](https://highlightjs.org) with the **Monokai Sublime** theme as default.
+For syntax highlighting I use [Highlight.js](https://highlightjs.org) with modified theme.
But if you want a different theme, just put a `highlight.css` file in your theme folder and your theme will be used.
- ***highlight.js*** normally you shouldn't have to overwrite this file. But if you need to, you can.
diff --git a/src/renderer/html_handlebars/theme.rs b/src/renderer/html_handlebars/theme.rs
index 99279b37..b773930e 100644
--- a/src/renderer/html_handlebars/theme.rs
+++ b/src/renderer/html_handlebars/theme.rs
@@ -51,6 +51,7 @@ impl Theme {
// index.hbs
match File::open(&src.join("index.hbs")) {
Ok(mut f) => {
+ theme.index = String::new(); // Reset the value, because read_to_string appends...
f.read_to_string(&mut theme.index).unwrap();
},
_ => {},
@@ -59,6 +60,7 @@ impl Theme {
// book.js
match File::open(&src.join("book.js")) {
Ok(mut f) => {
+ theme.js.clear();
f.read_to_end(&mut theme.js).unwrap();
},
_ => {},
@@ -67,6 +69,7 @@ impl Theme {
// book.css
match File::open(&src.join("book.css")) {
Ok(mut f) => {
+ theme.css.clear();
f.read_to_end(&mut theme.css).unwrap();
},
_ => {},
@@ -75,6 +78,7 @@ impl Theme {
// highlight.js
match File::open(&src.join("highlight.js")) {
Ok(mut f) => {
+ theme.highlight_js.clear();
f.read_to_end(&mut theme.highlight_js).unwrap();
},
_ => {},
@@ -83,6 +87,7 @@ impl Theme {
// highlight.css
match File::open(&src.join("highlight.css")) {
Ok(mut f) => {
+ theme.highlight_css.clear();
f.read_to_end(&mut theme.highlight_css).unwrap();
},
_ => {},
diff --git a/src/theme/highlight.css b/src/theme/highlight.css
index 12f55b1b..0b9578c3 100644
--- a/src/theme/highlight.css
+++ b/src/theme/highlight.css
@@ -1,15 +1,12 @@
-/*
-
-Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
-
-*/
+/* Modified Base16 Atelier Dune Light - Theme
+/* Original by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */
.hljs {
display: block;
overflow-x: auto;
+ background: #f1f1f1;
+ color: #6e6b5e;
padding: 0.5em;
- background: #23241f;
- border-radius: 4px;
-webkit-text-size-adjust: none;
}
@@ -20,133 +17,78 @@ Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-lic
border-radius: 3px;
}
-.hljs,
-.hljs-tag,
-.css .hljs-rule,
-.css .hljs-value,
-.aspectj .hljs-function,
-.css .hljs-function
-.hljs-preprocessor,
-.hljs-pragma {
- color: #f8f8f2;
-}
-
-.hljs-strongemphasis,
-.hljs-strong,
-.hljs-emphasis {
- color: #a8a8a2;
-}
-
-.hljs-bullet,
-.hljs-blockquote,
-.hljs-horizontal_rule,
-.hljs-number,
-.hljs-regexp,
-.alias .hljs-keyword,
-.hljs-literal,
-.hljs-hexcolor {
- color: #ae81ff;
-}
-
-.hljs-tag .hljs-value,
-.hljs-code,
-.hljs-title,
-.css .hljs-class,
-.hljs-class .hljs-title:last-child {
- color: #a6e22e;
-}
-
-.hljs-link_url {
- font-size: 80%;
-}
-
-.hljs-strong,
-.hljs-strongemphasis {
- font-weight: bold;
-}
-
-.hljs-emphasis,
-.hljs-strongemphasis,
-.hljs-class .hljs-title:last-child,
-.hljs-typename {
- font-style: italic;
-}
-
-.hljs-keyword,
-.ruby .hljs-class .hljs-keyword:first-child,
-.ruby .hljs-function .hljs-keyword,
-.hljs-function,
-.hljs-change,
-.hljs-winutils,
-.hljs-flow,
-.nginx .hljs-title,
-.tex .hljs-special,
-.hljs-header,
-.hljs-attribute,
-.hljs-symbol,
-.hljs-symbol .hljs-string,
-.hljs-tag .hljs-title,
-.hljs-value,
-.alias .hljs-keyword:first-child,
-.css .hljs-tag,
-.css .unit,
-.css .hljs-important {
- color: #f92672;
-}
-
-.hljs-function .hljs-keyword,
-.hljs-class .hljs-keyword:first-child,
-.hljs-aspect .hljs-keyword:first-child,
-.hljs-constant,
-.hljs-typename,
-.hljs-name,
-.css .hljs-attribute {
- color: #66d9ef;
+
+/* Atelier-Dune Comment */
+.hljs-comment {
+ color: #AAA;
}
+/* Atelier-Dune Red */
.hljs-variable,
-.hljs-params,
-.hljs-class .hljs-title,
-.hljs-aspect .hljs-title {
- color: #f8f8f2;
-}
-.hljs-string,
+.hljs-tag,
+.hljs-regexp,
+.hljs-name,
+.ruby .hljs-constant,
+.xml .hljs-tag .hljs-title,
+.xml .hljs-pi,
+.xml .hljs-doctype,
+.html .hljs-doctype,
.css .hljs-id,
-.hljs-subst,
-.hljs-type,
-.ruby .hljs-class .hljs-parent,
-.hljs-built_in,
-.django .hljs-template_tag,
-.django .hljs-variable,
-.smalltalk .hljs-class,
-.django .hljs-filter .hljs-argument,
-.smalltalk .hljs-localvars,
-.smalltalk .hljs-array,
-.hljs-attr_selector,
-.hljs-pseudo,
-.hljs-addition,
-.hljs-stream,
-.hljs-envvar,
-.apache .hljs-tag,
-.apache .hljs-cbracket,
-.tex .hljs-command,
-.hljs-prompt,
-.hljs-link_label,
-.hljs-link_url {
- color: #e6db74;
+.css .hljs-class,
+.css .hljs-pseudo {
+ color: #d73737;
}
-.hljs-comment,
-.hljs-annotation,
-.hljs-decorator,
-.hljs-pi,
-.hljs-doctype,
-.hljs-deletion,
-.hljs-shebang,
-.apache .hljs-sqbracket,
-.tex .hljs-formula {
- color: #75715e;
+/* Atelier-Dune Orange */
+.hljs-number,
+.hljs-preprocessor,
+.hljs-built_in,
+.hljs-literal,
+.hljs-params,
+.hljs-attribute,
+.hljs-constant {
+ color: #b65611;
+}
+
+/* Atelier-Dune Yellow */
+.ruby .hljs-class .hljs-title,
+.css .hljs-rule .hljs-attribute {
+ color: #ae9513;
+}
+
+/* Atelier-Dune Green */
+.hljs-string,
+.hljs-value,
+.hljs-inheritance,
+.hljs-header,
+.ruby .hljs-symbol,
+.xml .hljs-cdata {
+ color: #2a9292;
+}
+
+/* Atelier-Dune Aqua */
+.hljs-title,
+.css .hljs-hexcolor {
+ color: #1fad83;
+}
+
+/* Atelier-Dune 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: #6684e1;
+}
+
+/* Atelier-Dune Purple */
+.hljs-keyword,
+.javascript .hljs-function {
+ color: #b854d4;
}
.coffeescript .javascript,
@@ -155,8 +97,6 @@ Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-lic
.xml .javascript,
.xml .vbscript,
.xml .css,
-.xml .hljs-cdata,
-.xml .php,
-.php .xml {
+.xml .hljs-cdata {
opacity: 0.5;
}