Skip to content

Match line-number font-size to the pre element - #30

Open
bluzername wants to merge 1 commit into
davatron5000:mainfrom
bluzername:fix-line-numbers-font-size
Open

Match line-number font-size to the pre element#30
bluzername wants to merge 1 commit into
davatron5000:mainfrom
bluzername:fix-line-numbers-font-size

Conversation

@bluzername

Copy link
Copy Markdown

Fixes #14.

The gutter always use a fixed 0.875rem font-size, and #alignLineNumbers only copy lineHeight and paddingBlockStart from the pre element, not fontSize. So when a page set its own font-size on the pre (like the codepen in the issue), the line numbers stop lining up with the code, because font-size also change the line box height, not only line-height.

Fix is one line: also copy fontSize from the pre computed style, same as the other two properties already do.

Added a Playwright test that set font-size: 20px on the pre (a size that do not match the gutter default) and check the gutter font-size now match. It fail on main and pass with the fix.

npm test is green (33/33).

The gutter had a fixed 0.875rem font-size but only copy lineHeight
and paddingBlockStart from the pre. When a page set a different
font-size on the pre (like the codepen in the issue), the numbers
stop lining up with the code because font-size affect the line box
too, not just line-height.

Fixes davatron5000#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Font-size issue with line-numbers in micro-lighter element

1 participant