rust-lang / rust-lang/mdBook

How to use custom color schemes

Open
#2,340 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-Theme C-question
Dominant language
Rust
Stars
22.2k
Forks
1.9k
PR merge metrics
PR metrics pending

Description

Question

In the past i used to add two new items for "themes" to the index.hbs

...
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
    <li role="none"><button role="menuitem" class="theme" id="my-new-style">{{ theme_option "My Light Theme" }}</button></li>
...

Then i added custom css via book.toml to create the "style":

.my-new-style {
  --bg: hsl(210, 1.9%, 78.8%);
  ...
}

This seemed to work, but with newer versions it breaks like this issue: #2131
Is there an easy way to add custom styles? I still can use those changes, but they make it impossible to set new "styles" as default styles. Thanks for your help!

Version
Used to work:
mdbook v0.4.34

Current:
mdbook v0.4.36

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the custom theme markup in index.hbs and the CSS supplied through book.toml between mdBook v0.4.34 and v0.4.36, then read issue #2131 for the related breakage. Define how custom styles should be added and selected as defaults; the issue is done when that workflow works without the existing theme changes breaking.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, handlebars
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.