You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-12-22 06:47:49 +02:00
Add support for speaker notes
This implements a system for speaker notes via `details` elements and some JavaScript. The general idea is 1. You add speaker notes to each page by wrapping some Markdown code in `<details> … </details>`. This is a standard HTML element for, well extra details. Browsers will render the element with a toggle control for showing/hiding the content. 2. We inject JavaScript on every page which finds these speaker note elements. They’re styled slightly and we keep their open/closed state in a browser local storage. This ensures that you can keep them open/closed across page loads. 3. We add a link to the speaker notes which will open in a new tab. The URL is amended with `#speaker-notes-open`, which we detect in the new tab: we hide the other content in this case. Simultaneously, we hide the speaker notes in the original window. 4. When navigating to a new page, we signal this to the other window. We then navigate to the same page. The logic above kicks in and hides the right part of the content. This lets the users page through the course using either the regular window or the speaker notes — the result is the same and both windows stay in sync. Tested in both Chrome and Firefox. When using a popup speaker note window, the content loads more smoothly in Chrome, but it still works fine in Firefox. Fixes #53.
This commit is contained in:
@@ -18,3 +18,27 @@ fn main() { // Program entry point
|
||||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
The code implements the Collatz conjecture: it is believed that the loop will
|
||||
always end, but this is not yet proved. Edit the code and play with different
|
||||
inputs.
|
||||
|
||||
Key points:
|
||||
|
||||
* Explain that all variables are statically typed. Try removing `i32` to trigger
|
||||
type inference. Try with `i8` instead and trigger a runtime integer overflow.
|
||||
|
||||
* Change `let mut x` to `let x`, discuss the compiler error.
|
||||
|
||||
* Show how `print!` gives a compilation error if the arguments don't match the
|
||||
format string.
|
||||
|
||||
* Show how you need to use `{}` as a placeholder if you want to print an
|
||||
expression which is more complex than just a single variable.
|
||||
|
||||
* Show the students the standard library, show them how to search for `std::fmt`
|
||||
which has the rules of the formatting mini-language. It's important that the
|
||||
students become familiar with searching in the standard library.
|
||||
|
||||
</details>
|
||||
|
||||
Reference in New Issue
Block a user