mdBook icon indicating copy to clipboard operation
mdBook copied to clipboard

Theme-dependent image variants

Open mlange-42 opened this issue 2 years ago • 1 comments

Problem

MdBook themes do currently not work well together with images.

Images with light background look weird in the dark and Rust themes, while images with transparent background can become invisible e.g. on the dark themes.

Proposed Solution

Allow for different image versions for different themes. There are several ways to implement it, as well as to realize a syntax for it.

My ideas so far:

  • Implement it in mdBook (using a custom syntax)
  • Write a preprocessor for it (using a custom syntax)
  • Use HTML classes and CSS and/or JS to hide specific classes (e.g., each theme could hide HTML tags that have a certain class, like no-rust or no-light)

For the first two options, a syntax would be required. could be something like an HTML comment on the line before the image.

Probably, the last option would be the most consistent one.

Notes

No response

mlange-42 avatar Jan 18 '23 10:01 mlange-42

Working on this, PR coming soon.

mlange-42 avatar Jan 18 '23 12:01 mlange-42