Skip to content

Commit

Permalink
Fixed a bug where custom theme was appended to default theme + Change…
Browse files Browse the repository at this point in the history
…d syntax highlighting theme to something lighter, the dark theme did not fit the light style of the page
  • Loading branch information
azerupi committed Aug 5, 2015
1 parent 90719f7 commit 58d18d4
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 240 deletions.
2 changes: 1 addition & 1 deletion book-example/book/format/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1>Theme</h1>
<p><strong>Note:</strong></p>
<p>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 <code>mdbook init --theme</code>.</p>
<h3>Syntax Highlighting</h3>
<p>For syntax highlighting I use <a href="https://highlightjs.org">Highlight.js</a> with the <strong>Monokai Sublime</strong> theme as default.
<p>For syntax highlighting I use <a href="https://highlightjs.org">Highlight.js</a> with modified theme.
But if you want a different theme, just put a <code>highlight.css</code> file in your theme folder and your theme will be used.</p>
<ul>
<li><strong><em>highlight.js</em></strong> normally you shouldn't have to overwrite this file. But if you need to, you can.</li>
Expand Down
178 changes: 59 additions & 119 deletions book-example/book/highlight.css
Original file line number Diff line number Diff line change
@@ -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;
}

Expand All @@ -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;
/* Atelier-Dune Comment */
.hljs-comment {
color: #AAA;
}

.hljs-bullet,
.hljs-blockquote,
.hljs-horizontal_rule,
.hljs-number,
.hljs-regexp,
.alias .hljs-keyword,
.hljs-literal,
.hljs-hexcolor {
color: #ae81ff;
}
/* Atelier-Dune Red */
.hljs-variable,

.hljs-tag .hljs-value,
.hljs-code,
.hljs-title,
.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,
.css .hljs-class,
.hljs-class .hljs-title:last-child {
color: #a6e22e;
.css .hljs-pseudo {
color: #d73737;
}

.hljs-link_url {
font-size: 80%;
}

.hljs-strong,
.hljs-strongemphasis {
font-weight: bold;
/* Atelier-Dune Orange */
.hljs-number,
.hljs-preprocessor,
.hljs-built_in,
.hljs-literal,
.hljs-params,
.hljs-attribute,
.hljs-constant {
color: #b65611;
}

.hljs-emphasis,
.hljs-strongemphasis,
.hljs-class .hljs-title:last-child,
.hljs-typename {
font-style: italic;
/* Atelier-Dune Yellow */
.ruby .hljs-class .hljs-title,
.css .hljs-rule .hljs-attribute {
color: #ae9513;
}

.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,
/* Atelier-Dune Green */
.hljs-string,
.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;
.hljs-inheritance,
.hljs-header,
.ruby .hljs-symbol,
.xml .hljs-cdata {
color: #2a9292;
}

.hljs-variable,
.hljs-params,
.hljs-class .hljs-title,
.hljs-aspect .hljs-title {
color: #f8f8f2;
/* Atelier-Dune Aqua */
.hljs-title,
.css .hljs-hexcolor {
color: #1fad83;
}

.hljs-string,
.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;
/* 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;
}

.hljs-comment,
.hljs-annotation,
.hljs-decorator,
.hljs-pi,
.hljs-doctype,
.hljs-deletion,
.hljs-shebang,
.apache .hljs-sqbracket,
.tex .hljs-formula {
color: #75715e;
/* Atelier-Dune Purple */
.hljs-keyword,
.javascript .hljs-function {
color: #b854d4;
}

.coffeescript .javascript,
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion book-example/src/format/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/html_handlebars/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
_ => {},
Expand All @@ -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();
},
_ => {},
Expand All @@ -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();
},
_ => {},
Expand All @@ -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();
},
_ => {},
Expand All @@ -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();
},
_ => {},
Expand Down
Loading

0 comments on commit 58d18d4

Please sign in to comment.