Skip to content

Commit 7446743

Browse files
committed
Merge branch 'css-to-stylus'
2 parents 2b905aa + a177a9e commit 7446743

File tree

19 files changed

+904
-509
lines changed

19 files changed

+904
-509
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,12 @@ matrix:
99
env:
1010
global:
1111
secure: l3/qEC4krRerllLQzni8j5AjngFi6pluWvBWj//1mJLoIEYwxlQ9mYxEdd9BqccWWFn3K0bVYCVC/64+tP6sRfLkZCe2gPUtwe7ITwCDbapUxmkiRObVJCs5yMQZt6idyhHUDKAXKgNCrusfI2BM3tKGBfRK7Cnn/R/7p/U9+q7D1sgJtUKp6ypVzK6A3jLNp3dFLFI19a5KmbZMVsaa7tOhtdDJjjr7ebsc9z7HMW5/OItiWU3FSauVQQlUMaCiEgFuIG7H7OnBAYWB/gNEtLuwfLqU9UjtWk/njNNRnmJ7m3y5HbQhv5H5F5mJUOq9XFlPLwPwyTeVztSGdQm6k8Pp2pgKBUjY27afBl9BWU+msmN6k0oXfhvIebiBPe/x2udiKeFik1xqOOEU1q9dF0sZiuPxCSM1n7tgWklJ8epgaRQaMPPQw9pO/2H5/ynHCJqBlw6WcdiqWtwAyyr/GEx62u/cg5IVkqb7KLmYsWzjS8wYG4CYs1eIxCw2xPZxP0FGuUXvxTBUPipFze6Z7FqxVauXtVe2D7c1P4738HZP660rmR0GYtHtKLny1QxCCK9sxd9JmcezFCSz4YeQ1od9xc0OzGJ2ullKNGizmGfYmgL6X8faNylLIEdaiHAcY16xV3L0g3fXL1Qg360UHQyj7GIv+0nqQnf+H9xRTTU=
12+
addons:
13+
apt:
14+
packages:
15+
- nodejs
16+
- npm
17+
install:
18+
- npm install stylus nib
1219
after_success:
1320
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && bash deploy.sh

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ repository = "https://github.com/azerupi/mdBook"
88
keywords = ["book", "gitbook", "rustbook", "markdown"]
99
license = "MPL-2.0"
1010
readme = "README.md"
11+
build = "build.rs"
1112
exclude = [
1213
"book-example/*",
1314
]
@@ -25,6 +26,7 @@ tempdir = "*"
2526
default = ["output"]
2627
debug = []
2728
output = []
29+
regenerate-css = []
2830

2931
[[bin]]
3032
doc = false

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ To have an idea of what a rendered book looks like,take a look at the [**Documen
1212

1313
## Installation
1414

15+
Before building mdBook, make sure that you installed `stylus` and `nib` from `npm` because it is used to compile the stylesheets
16+
17+
Install [node.js](https://nodejs.org/en/)
18+
19+
```
20+
npm install -g stylus nib
21+
```
22+
1523
```
1624
git clone --depth=1 https://github.com/azerupi/mdBook.git
1725
cd mdBook

build.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// build.rs
2+
3+
use std::process::Command;
4+
use std::env;
5+
use std::path::Path;
6+
7+
fn main() {
8+
9+
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
10+
11+
// Compile stylus stylesheet to css
12+
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
13+
14+
let theme_dir = Path::new(&manifest_dir).join("src/theme/");
15+
let stylus_dir = theme_dir.join("stylus/book.styl");
16+
17+
if !Command::new("stylus")
18+
.arg(format!("{}", stylus_dir.to_str().unwrap()))
19+
.arg("--out")
20+
.arg(format!("{}", theme_dir.to_str().unwrap()))
21+
.arg("--use")
22+
.arg("nib")
23+
.status().unwrap()
24+
.success() {
25+
panic!("Stylus encoutered an error");
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)