Skip to content

Commit 213ed82

Browse files
committed
document the new feature
1 parent 83f190b commit 213ed82

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 1 addition & 0 deletions
Loading

guide/src/format/markdown.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ Which, of course displays the image like so:
117117

118118
![The Rust Logo](images/rust-logo-blk.svg)
119119

120+
## Theme-dependent images
121+
122+
Image variants for different themes can be used via CSS classes.
123+
124+
Here is an example for different images for light vs. dark themes:
125+
126+
```markdown
127+
<img src="images/rust-logo-blk.svg" class="no-dark-themes" />
128+
<img src="images/rust-logo-blk-dark.svg" class="no-light-themes" />
129+
```
130+
131+
Try switching the theme to see the effect below (brush icon at the top left of the page):
132+
133+
<img src="images/rust-logo-blk.svg" class="no-dark-themes" />
134+
<img src="images/rust-logo-blk-dark.svg" class="no-light-themes" />
135+
136+
To exclude an image (or any HTML element) for all dark or all light themes
137+
(incl. the Rust theme), use the classes `no-dark-themes` and `no-light-themes`.
138+
139+
For even more control, elements can be hidden on an individual theme basis using the classes
140+
`no-light`, `no-rust`, `no-coal`, `no-navy` and `no-ayu`.
141+
120142
## Extensions
121143

122144
mdBook has several extensions beyond the standard CommonMark specification.

guide/src/format/theme/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Here are the files you can override:
1818
- **_css/chrome.css_** is for UI elements.
1919
- **_css/general.css_** is the base styles.
2020
- **_css/print.css_** is the style for printer output.
21+
- **_css/exclude.css_** is for [theme-dependent images](../markdown.md#theme-dependent-images).
2122
- **_css/variables.css_** contains variables used in other CSS files.
2223
- **_book.js_** is mostly used to add client side functionality, like hiding /
2324
un-hiding the sidebar, changing the theme, ...

0 commit comments

Comments
 (0)