Description
Problem
I want to be able to include a code snippet
- either by lines or anchors
that is:
- runnable (with Playground)
- editable by the user
By default, only the selected range (either by lines or anchors) should be displayed, but the user should be able to run the whole file with Playground, expand all content, and edit the content.
As I've seen that's currently not possible as only the shown part of the file will be sent to the playground.
The closest I got is:
```rust,editable
{{#include ../code/hello.rs:printl}}
````
This displays the selected anchor of the file, keep the content editable, and displays the play button.
However, when the reader taps on play, only the selected content between the anchors will be sent to the Rust playground, so it won't compile, as the the main function and some of the .rs file's content is not in the snippet.
Another approach I tried is this
```rust
{{#rustdoc_include ../code/hello.rs:printl}}
```
This will show only the selected part of the file, it will run the whole file, BUT it won't be editable.
```rust,editable
{{#rustdoc_include ../code/hello.rs:printl}}
```
If I add the editable
tag, it becomes editable, it runs the examples with Playgorund BUT the whole file is rendered, not only the selected region.
Proposed Solution
I should be able to
- include only part of the file by lines or anchor, and display only that region of the code in the book
- have the code run the whole file with Playground
- keep the content editable
- keep the content expandable and show the whole file with the eyes icon
All four should be true.
Notes
It would be great if this could work:
```rust,editable
{{#rustdoc_include ../code/hello.rs:printl}}
```
Or alternatively, a global "editable-by-default" flag in the book.toml
:
```rust
{{#rustdoc_include ../code/hello.rs:printl}}
```
[output-html-playground]
editable-by-default = true