Page MenuHomePhabricator

Add highlighting to targeted code snippet
Closed, ResolvedPublic

Description

In the nature theme, the `.viewcode-block:target` - representing a code snippet targeted by an anchor or link - is highlighted with a different background color. This is not the case in Furo at the moment.

My initial attempt at adding highlighting used the following CSS code:

@media screen and (prefers-color-scheme: dark) {
  .viewcode-block:target {
    background-color: #131313;
    border: 1px solid #666;
  }

  .viewcode-block .viewcode-back {
    color: #3facad;
  }
}

@media screen and (prefers-color-scheme: light) {
  .viewcode-block:target {
    background-color: #e3e3e3;
    border: 1px solid #a0a0a0;
  }
}

However, this code seems to add incorrect highlighting as indicated in this comment by @Xqt

This task is about finding a better way to do this.

Event Timeline

KBach triaged this task as Medium priority.Nov 25 2022, 9:52 AM
KBach changed the task status from Open to In Progress.Dec 7 2022, 1:56 PM

Change 865647 had a related patch set uploaded (by KBach; author: KBach):

[pywikibot/core@tests] [doc] Add highlighting to targeted code snippet

https://gerrit.wikimedia.org/r/865647

Change 865647 merged by jenkins-bot:

[pywikibot/core@tests] [doc] Add highlighting to targeted code snippet

https://gerrit.wikimedia.org/r/865647