Skip to content

Commit 04e80c0

Browse files
Merge #213
213: Feat: add custom formatting for images r=adamgreig a=tomasz-rozanski Some images with alpha channel, are unreadable when a dark theme is applied. This commit adds a custom image style, named `white_bg`, that can be used to fix this issue. The style is very simple, and adds two features: - white background, - a small padding around the image Co-authored-by: Tomasz Różański <[email protected]>
2 parents f1c96f9 + 038f8a2 commit 04e80c0

File tree

8 files changed

+16
-7
lines changed

8 files changed

+16
-7
lines changed

book.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ title = "Discovery"
33
description = "Discover the world of microcontrollers through Rust"
44
author = "Rust Embedded Resources Team"
55
language = "en"
6+
7+
[output.html]
8+
additional-css = ["custom.css"]

custom.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* Add this style to the image if it's unreadable
2+
when the dark theme is applied */
3+
img.white_bg {
4+
background-color: white;
5+
padding: 1em;
6+
}

src/05-led-roulette/the-challenge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Here's the GIF again:
1212
Also, this may help:
1313

1414
<p align="center">
15-
<img src="../assets/timing-diagram.png">
15+
<img class="white_bg" src="../assets/timing-diagram.png">
1616
</p>
1717

1818
This is a timing diagram. It indicates which LED is on at any given instant of time and for how long

src/07-registers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ connected to LEDs. An LED, a Light Emitting Diode, will only emit light when vol
2828
it with a certain polarity.
2929

3030
<p align="center">
31-
<img height=180 title="LED circuit" src="https://upload.wikimedia.org/wikipedia/commons/c/c9/LED_circuit.svg">
31+
<img class="white_bg" height=180 title="LED circuit" src="https://upload.wikimedia.org/wikipedia/commons/c/c9/LED_circuit.svg">
3232
</p>
3333

3434
Luckily for us, the microcontroller's pins are connected to the LEDs with the right polarity. All

src/14-i2c/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ uses two lines to exchange data: a data line (SDA) and a clock line (SCL). Becau
1919
used to synchronize the communication, this is a *synchronous* protocol.
2020

2121
<p align="center">
22-
<img height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
22+
<img class="white_bg" height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
2323
</p>
2424

2525
This protocol uses a *master* *slave* model where the master is the device that *starts* and

src/14-i2c/the-general-protocol.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ communication between several devices. Let's see how it works using examples:
88
If the master wants to send data to the slave:
99

1010
<p align="center">
11-
<img height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
11+
<img class="white_bg" height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
1212
</p>
1313

1414
1. Master: Broadcast START
@@ -27,7 +27,7 @@ If the master wants to send data to the slave:
2727
If the master wants to read data from the slave:
2828

2929
<p align="center">
30-
<img height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
30+
<img class="white_bg" height=180 title="I2C bus" src="https://upload.wikimedia.org/wikipedia/commons/3/3e/I2C.svg">
3131
</p>
3232

3333
1. M: Broadcast START

src/15-led-compass/take-1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If we only looked at the signs of the X and Y components we could determine to w
2121
magnetic field belongs to.
2222
2323
<p align="center">
24-
<img title="Quadrants" src="../assets/quadrants.png">
24+
<img class="white_bg" title="Quadrants" src="../assets/quadrants.png">
2525
</p>
2626

2727
In the previous example, the magnetic field was in the first quadrant (x and y were positive) and it

src/15-led-compass/take-2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ We'll use the `atan2` function. This function returns an angle in the `-PI` to `
77
graphic below shows how this angle is measured:
88

99
<p align="center">
10-
<img title="atan2" src="https://upload.wikimedia.org/wikipedia/commons/0/03/Atan2_60.svg">
10+
<img class="white_bg" title="atan2" src="https://upload.wikimedia.org/wikipedia/commons/0/03/Atan2_60.svg">
1111
</p>
1212

1313
Although not explicitly shown in this graph the X axis points to the right and the Y axis points up.

0 commit comments

Comments
 (0)