Page MenuHomePhabricator

Black text should not inherit colour in page syntax highlighting
Closed, ResolvedPublic0 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?: At the least, semicolons, colons, curly brackets, and full stops match the background color which means they are hiding. I suspect there are others.

image.png (377×622 px, 36 KB)

What should have happened instead?: Probably wants for dark characters instead.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

It is amazing how much noise we have in CSS. :) I find this version surprisingly more readable in some ways.

Requirement

Ensure that black text does not inherit color in page syntax highlighting for dark mode.

BDD

gherkin
Feature: Black Text Color in Syntax Highlighting

  Scenario: Ensure black text remains visible in dark mode
    Given the user has enabled dark mode
    When the user views a page with syntax highlighting
    Then black text should not inherit color and should remain visible

Test Steps

Test Case 1: Ensure Black Text Remains Visible in Dark Mode

  1. Visit this page or this page in dark mode.
  2. Verify that black text, including semicolons, colons, curly brackets, and full stops, remains visible.
  3. AC1: Confirm that black text does not inherit the background color and remains visible.

QA Results - Beta

ACStatusDetails
1T365774#9851729

QA Results - PROD

ACStatusDetails
1T365774#9881292

Event Timeline

Jdlrobson renamed this task from TemplateStyles page syntax highlighting punctuation is hiding to Parentheses do not show in page syntax highlighting.May 24 2024, 3:53 PM
Jdlrobson added a project: SyntaxHighlight.

This happens with all black characters and not only in CSS files.

Izno renamed this task from Parentheses do not show in page syntax highlighting to Punctuation does not show in page syntax highlighting.May 24 2024, 5:33 PM

I think that black text (with class="p") should remain black (if it doesn't change all the color scheme).

zdev renamed this task from Punctuation does not show in page syntax highlighting to Black text should not inherit colour in page syntax highlighting.May 24 2024, 5:47 PM
Jdlrobson subscribed.

Looks like .mw-highlight pre defines a hardcoded background of #f8f8f8 but doesn't define color so that needs updating.

I actually don't know what the appropriate thing to do here is. Right now it kind of looks like a fix was tried here and it didn't select the right element because of CSS elsewhere. SyntaxHighlight has this block of LESS:

/* pygments.wrapper.less */
.mw-highlight {
	...
	pre {
		...
		background-color: #f8f8f8;
	}

	code&,
	div& {
		background-color: #f8f8f8;
		color: #333;
	}
	...
}

And this separate block of CSS from elsewhere.

/* from pygments.generated.css */
.mw-highlight { background: #f8f8f8; }

pygments.generated.css is generated by updateCSS.php according to the documentation...? (What a pain.)

The skin (loading from common CSS folder) has:

@media screen {
  pre, code, .mw-code {
    background-color: var(--background-color-neutral-subtle, #f8f9fa); /* overridden by SH; in dark mode, --background-color-neutral-subtle is #202122 */
    color: var(--color-emphasized, #000); /* in dark mode, --color-emphasized is #fff */
    ...
  }
}

It's the skin color that's causing the color issue in SyntaxHighlight. I think the skin is probably doing fine. So I guess we can add the same color that was added for T356956 (the .mw-highlight pre's background-color), but either way it feels like way too many colors are running around all trying to do the same thing. (I actually think that div& may be wrong and causing the background to be displayed incorrectly next to floating content, something I don't recall occurring before recently. OK it was happening before recently but it is a visual bug, the pygments.generated.css is also to blame on that one.) I think there's also a question of whether this extension needs a fuller treatment to give it a real dark mode, which maybe can be a different task?

pygments.generated.css is generated by updateCSS.php according to the documentation...? (What a pain.)

Yes, it is essentially the default CSS style we use as provided by the pygments binary for the syntax highlighting. The pygments.wrapper.less is for the MW specific things which we then add on top of those defaults. This, some degree, is needed because the default <code> and <pre> elements ALSO provide styling and this needs more specificity for that reason as well as to color the parent of those nested code and pre elements.

I think there's also a question of whether this extension needs a fuller treatment to give it a real dark mode, which maybe can be a different task?

That definitely would be a separate task yes. I think there already is one, but not sure where... Hmm. maybe it was CodeMirror that already had a separate task for that.

Anyway, the pygments default shipped styles are listed at https://pygments.org/styles/, or we can completely write our own of course.

Change #1035658 had a related patch set uploaded (by Steven Rawson; author: Steven Rawson):

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] SyntaxHighlight: Add color to override skin

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

Jdlrobson triaged this task as Low priority.
Jdlrobson updated the task description. (Show Details)
Jdlrobson set the point value for this task to 0.

Change #1035658 merged by jenkins-bot:

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] SyntaxHighlight: Add color to override skin

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

Edtadros subscribed.

Test Result - Beta

Status: ✅ PASS
Environment: Beta
OS: macOS Sonoma
Browser: Chrome
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Ensure Black Text Remains Visible in Dark Mode

  1. Visit this page or this page in dark mode.
  2. Verify that black text, including semicolons, colons, curly brackets, and full stops, remains visible.
  3. AC1: Confirm that black text does not inherit the background color and remains visible.

screenshot 98.mov.gif (1×1 px, 943 KB)

Jdlrobson claimed this task.

Test Result - PROD

Status: ✅ PASS
Environment: PROD
OS: macOS Sonoma 14.5
Browser: Chrome 125
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Ensure Black Text Remains Visible in Dark Mode

  1. Visit this page or this page in dark mode.
  2. Verify that black text, including semicolons, colons, curly brackets, and full stops, remains visible.
  3. AC1: Confirm that black text does not inherit the background color and remains visible.

2024-06-11_10-44-54 (1).gif (844×1 px, 2 MB)