Automattic / Automattic/syntaxhighlighter

CSS for Line Number, displays too wide

Open
#287 0 comments 0 reactions 0 assignees View on GitHub
[Type] Bug
Dominant language
CSS
Stars
251
Forks
81
PR merge metrics
No merged PRs in 30d

Description

![Image](https://github.com/user-attachments/assets/b9f5d295-0683-48b6-a42d-b1e596696e1f)

Two issues:
1. The line number td displays half-screen width, unless the code is wider than half-screen (if wide, the code pushes the line number td to the left)
2. On narrow screens, the line numbers display on their own lines, followed by the code lines

This is the CSS needed:

```
.syntaxhighlighter table td.gutter {
max-width: fit-content; /* prevent wide line number table cells */
}

.wp-block-syntaxhighlighter-code tr {
display: inline-table; /* prevent line numbers on their own lines, followed by code lines */
/* or display: block, or inline-flex also work */
}

```

### Steps to Reproduce
1. Insert a code block
2. Leave the Align to none
3. Line number shows so line number is in center of window, unless width of the code pushes it to the left
4. On narrow screens, get several lines with only line numbers, followed by several lines with only code. Line numbers aren't "attached" to the code lines.

### PHP / WordPress / SyntaxHighlighter Evolved version
WP version: 6.7.2
Twenty Twenty-Four (twentytwentyfour) version: 1.3
SyntaxHighlighter Evolved Version 3.7.2
php_version: 8.2.26 64bit

### Browser / OS version
Brave (Chrome based) [Version 1.77.97 Chromium: 135.0.7049.84 (Official Build) (64-bit)](https://brave.com/latest/)
Linux Mint 21.2 Cinnamon

Contributor guide

No contributing guide indexed for this repository

Research direction

No file or test is named. Reproduce the issue by inserting a code block with Align set to none, using the reported WordPress and SyntaxHighlighter Evolved versions, then inspect the CSS rules for the listed selectors. Done means the gutter stays only as wide as its line numbers and line numbers remain attached to their code lines on narrow screens.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, wordpress
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.