mdBook

https://rust-lang.github.io/mdBook/format/markdown.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# install
cargo install mdbook

# tools
## init --theme --title --ignore --force
mdbook init
mdbook init path/to/book

## The build command is used to render your book --open --dest-dir
mdbook build
mdbook build path/to/book

## The watch command is useful when you want your book to be rendered on every file change.
mdbook watch path/to/book

## The serve command is used to preview a book by serving it via HTTP at localhost:3000 by default:
mdbook serve
mdbook serve path/to/book

## mdBook supports a test command that will run all available tests in a book
mdbook test path/to/book

## The clean command is used to delete the generated book and any other build artifacts.
mdbook clean
mdbook clean path/to/book
mdbook clean --dest-dir=path/to/book 

Hiding code lines

```rust
# fn main() {
let x = 5;
let y = 6;

println!("{}", x + y);
# }
```

```java,hidelines=//
public int getId(){
//this line will hide
return this.id;
}
```

```python,hidelines=~
~hidden()
nothidden():
~ hidden()
~hidden()
nothidden()
```

```python,hidelines=!!!
!!!hidden()
nothidden():
!!! hidden()
!!!hidden()
nothidden()
```

Rust Playground

```rust,playground
#![allow(unused)]
fn main() {
println!(“Hello, World!”);
}
```

```rust,noplayground
let mut name = String::new();
std::io::stdin().read_line(&mut name).expect(“failed to read line”);
println!(“Hello {}!”, name);
```

Rust code block attributes

```rust,ignore
# This example won’t be tested.
panic!(“oops!”);
```

Including files

```rust
{{#include file.rs}}
```

```java
{{#include ../../../hello.java}}
```

Including portions of a file

```rust
{{#include file.rs:2}}
{{#include file.rs::10}}
{{#include file.rs:2:}}
{{#include file.rs:2:10}}
```

book.toml

1
2
3
4
5
[output.html.code.hidelines]
java = "//"
python = "~"
[output.html.playground]
runnable = false