From 57f960a03bddf450792f9051591f30c40a1142f7 Mon Sep 17 00:00:00 2001 From: projektir Date: Tue, 16 Jan 2018 21:26:13 -0800 Subject: [PATCH] Documenting the editor #521 --- book-example/book.toml | 3 ++ book-example/src/SUMMARY.md | 1 + book-example/src/format/theme/editor.md | 40 +++++++++++++++++++++++++ book-example/src/misc/contributors.md | 1 + 4 files changed, 45 insertions(+) create mode 100644 book-example/src/format/theme/editor.md diff --git a/book-example/book.toml b/book-example/book.toml index e730b43e..1c2e9699 100644 --- a/book-example/book.toml +++ b/book-example/book.toml @@ -5,3 +5,6 @@ author = "Mathieu David" [output.html] mathjax-support = true + +[output.html.playpen] +editable = true diff --git a/book-example/src/SUMMARY.md b/book-example/src/SUMMARY.md index dd703380..078eef90 100644 --- a/book-example/src/SUMMARY.md +++ b/book-example/src/SUMMARY.md @@ -13,6 +13,7 @@ - [Theme](format/theme/theme.md) - [index.hbs](format/theme/index-hbs.md) - [Syntax highlighting](format/theme/syntax-highlighting.md) + - [Editor](format/theme/editor.md) - [MathJax Support](format/mathjax.md) - [Rust code specific features](format/rust.md) - [For Developers](lib/index.md) diff --git a/book-example/src/format/theme/editor.md b/book-example/src/format/theme/editor.md new file mode 100644 index 00000000..4af22e49 --- /dev/null +++ b/book-example/src/format/theme/editor.md @@ -0,0 +1,40 @@ +# Editor + +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***: + +```toml +[output.html.playpen] +editable = true +``` + +To make a specific block available for editing, the attribute `editable` needs to be added to it: + +
```rust,editable
+fn main() {
+    let number = 5;
+    print!("{}", number);
+}
+```
+ +The above will result in this editable playpen: + +```rust,editable +fn main() { + let number = 5; + print!("{}", number); +} +``` + +Note the new `Undo Changes` button in the editable playpens. + +## Customizing the Editor + +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: + +```toml +[output.html.playpen] +editable = true +editor = "/path/to/editor" +``` + +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. diff --git a/book-example/src/misc/contributors.md b/book-example/src/misc/contributors.md index f0184c15..94191db4 100644 --- a/book-example/src/misc/contributors.md +++ b/book-example/src/misc/contributors.md @@ -13,3 +13,4 @@ If you have contributed to mdBook and I forgot to add you, don't hesitate to add - Fu Gangqiang ([FuGangqiang](https://github.com/FuGangqiang)) - [Michael-F-Bryan](https://github.com/Michael-F-Bryan) - [Chris Spiegel](https://github.com/cspiegel) +- [projektir](https://github.com/projektir)