Debian Codegraph @

guide/src/format/theme/editor.md

raw
1 # Editor
2
3 In addition to providing runnable code playgrounds, mdBook optionally allows them
4 to be editable. In order to enable editable code blocks, the following needs to
5 be added to the ***book.toml***:
6
7 ```toml
8 [output.html.playground]
9 editable = true
10 ```
11
12 After enabling editable code blocks, the `editable` attribute must be added to a
13 code block to make it editable:
14
15 ~~~markdown
16 ```rust,editable
17 fn main() {
18 let number = 5;
19 print!("{}", number);
20 }
21 ```
22 ~~~
23
24 The above will result in this editable playground:
25
26 ```rust,editable
27 fn main() {
28 let number = 5;
29 print!("{}", number);
30 }
31 ```
32
33 Note the new `Undo Changes` button in the editable playgrounds.
34
35 ## Customizing the editor
36
37 By default, the editor is the [Ace](https://ace.c9.io/) editor, but, if desired,
38 the functionality may be overridden by providing a different folder:
39
40 ```toml
41 [output.html.playground]
42 editable = true
43 editor = "/path/to/editor"
44 ```
45
46 Note that for the editor changes to function correctly, the `book.js` inside of
47 the `theme` folder will need to be overridden as it has some couplings with the
48 default Ace editor.