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.
function setupPrintPage() {
for (const notes of document.querySelectorAll("details")) {
let summaryContent;
if (notes.getAttribute("solution") !== null) {
notes.open = false;
summaryContent = "Solution";
} else {
notes.open = true;
let summary = document.createElement("summary");
summaryContent = "Speaker Notes";
}
const summary = document.createElement("summary");
notes.insertBefore(summary, notes.firstChild);
let h4 = document.createElement("h4");
h4.append("Speaker Notes");
const h4 = document.createElement("h4");
h4.append(summaryContent);
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?
<details open=false>
<details solution>
```rust
#[derive(Debug)]
@ -30,7 +30,7 @@ struct BinaryTree {
Let's now write a method to to create a BinaryTree with arbitrary depth:
<details open=false>
<details solution>
```rust
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`.
<details open=false>
<details solution>
```rust
use Side::*;