Skip to content

Commit d44b67b

Browse files
Merge pull request #552 from projektir/editor-docs
Documenting the editor #521
2 parents 7b4b70a + 57f960a commit d44b67b

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

book-example/book.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ author = "Mathieu David"
55

66
[output.html]
77
mathjax-support = true
8+
9+
[output.html.playpen]
10+
editable = true

book-example/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Theme](format/theme/theme.md)
1414
- [index.hbs](format/theme/index-hbs.md)
1515
- [Syntax highlighting](format/theme/syntax-highlighting.md)
16+
- [Editor](format/theme/editor.md)
1617
- [MathJax Support](format/mathjax.md)
1718
- [Rust code specific features](format/rust.md)
1819
- [For Developers](lib/index.md)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Editor
2+
3+
In addition to providing runnable code playpens, mdBook optionally allows them to be editable. In order to enable editable code blocks, the following needs to be added to the ***book.toml***:
4+
5+
```toml
6+
[output.html.playpen]
7+
editable = true
8+
```
9+
10+
To make a specific block available for editing, the attribute `editable` needs to be added to it:
11+
12+
<pre><code class="language-markdown">```rust,editable
13+
fn main() {
14+
let number = 5;
15+
print!("{}", number);
16+
}
17+
```</code></pre>
18+
19+
The above will result in this editable playpen:
20+
21+
```rust,editable
22+
fn main() {
23+
let number = 5;
24+
print!("{}", number);
25+
}
26+
```
27+
28+
Note the new `Undo Changes` button in the editable playpens.
29+
30+
## Customizing the Editor
31+
32+
By default, the editor is the [Ace](https://ace.c9.io/) editor, but, if desired, the functionality may be overriden by providing a different folder:
33+
34+
```toml
35+
[output.html.playpen]
36+
editable = true
37+
editor = "/path/to/editor"
38+
```
39+
40+
Note that for the editor changes to function correctly, the `book.js` inside of the `theme` folder will need to be overriden as it has some couplings with the default Ace editor.

book-example/src/misc/contributors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ If you have contributed to mdBook and I forgot to add you, don't hesitate to add
1313
- Fu Gangqiang ([FuGangqiang](https://github.com/FuGangqiang))
1414
- [Michael-F-Bryan](https://github.com/Michael-F-Bryan)
1515
- [Chris Spiegel](https://github.com/cspiegel)
16+
- [projektir](https://github.com/projektir)

0 commit comments

Comments
 (0)