add code execution examples to code.md presentation

This commit is contained in:
dmackdev 2024-05-22 19:21:32 +01:00
parent 3ce1133c35
commit e950a12c84

View File

@ -13,6 +13,7 @@ This presentation shows how to:
* Left-align code blocks.
* Have code blocks without background.
* Execute code snippets.
```rust
pub struct Greeter {
@ -74,3 +75,32 @@ fn main() {
println!("{greeting}");
}
```
<!-- end_slide -->
Code execution
===
Run commands from the presentation and display their output dynamically.
```bash +exec
for i in $(seq 1 5)
do
echo "hi $i"
sleep 0.5
done
```
<!-- end_slide -->
Code execution - `stderr`
===
Output from `stderr` will also be shown as output.
```bash +exec
echo "This is a successful command"
echo "This message redirects to stderr" >&2
echo "This is a successful command again"
man # Missing argument
```