markup: improve code block readability and copy button positioning #34008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the rendering and structure of code blocks in markdown files to enhance readability and layout stability across various screen sizes.
Before
white-space: pre-wrap, making long code hard to read on mobile and narrow displays.After
white-space: preandoverflow-x: autoto support horizontal scrolling without line wrapping.code-blockclass is applied to both<pre>and<code>elements for consistent targeting..copy-button-container) positioned absolutely, preventing it from being affected by scrolling.Affected Files
modules/highlight/highlight.go: modifies rendered HTML for code blocksmodules/markup/markdown/markdown.go: ensures correct formatter options passedweb_src/css/markup/codecopy.css: handles absolute positioning for the copy buttonweb_src/css/markup/content.css: applies horizontal scroll and no-wrap for.code-blockweb_src/js/markup/codecopy.ts: adapts JS logic to target the updated structureMotivation
This change improves UX for reading markdown code on mobile and prevents UI overlap between scrolling code and fixed-position buttons. It also brings the structure closer to best practices for developer tools and documentation interfaces.
Tested on modern Chromium and WebKit browsers.