1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-22 18:30:33 +02:00

Create solution attribute for details

This commit is contained in:
Alexandre Senges 2023-08-15 10:26:34 +00:00
parent 27f763ad56
commit 6ade0b002d
2 changed files with 14 additions and 7 deletions

View File

@ -128,11 +128,18 @@
// Create headers on the print page. // Create headers on the print page.
function setupPrintPage() { function setupPrintPage() {
for (const notes of document.querySelectorAll("details")) { for (const notes of document.querySelectorAll("details")) {
notes.open = true; let summaryContent;
let summary = document.createElement("summary"); if (notes.getAttribute("solution") !== null) {
notes.open = false;
summaryContent = "Solution";
} else {
notes.open = true;
summaryContent = "Speaker Notes";
}
const summary = document.createElement("summary");
notes.insertBefore(summary, notes.firstChild); notes.insertBefore(summary, notes.firstChild);
let h4 = document.createElement("h4"); const h4 = document.createElement("h4");
h4.append("Speaker Notes"); h4.append(summaryContent);
summary.append(h4); summary.append(h4);
} }
} }

View File

@ -15,7 +15,7 @@ enum Side {
Using the data structures in the standard library, how can we represent such a Binary Tree in Rust? Using the data structures in the standard library, how can we represent such a Binary Tree in Rust?
<details open=false> <details solution>
```rust ```rust
#[derive(Debug)] #[derive(Debug)]
@ -30,7 +30,7 @@ struct BinaryTree {
Let's now write a method to to create a BinaryTree with arbitrary depth: Let's now write a method to to create a BinaryTree with arbitrary depth:
<details open=false> <details solution>
```rust ```rust
use Side::*; use Side::*;
@ -57,7 +57,7 @@ Let's now write a method to invert the tree. To make sure that the tree is inver
left nodes values should now be `Right` and right nodes values should now be `Left`. left nodes values should now be `Right` and right nodes values should now be `Left`.
<details open=false> <details solution>
```rust ```rust
use Side::*; use Side::*;