-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
markup: improve code block readability and isolate copy button #34009
base: main
Are you sure you want to change the base?
Conversation
Previously, code blocks did not support horizontal scrolling, leading to poor readability on mobile or narrow displays due to forced line wrapping. This patch updates the HTML structure and CSS so that: - Code blocks now scroll horizontally instead of wrapping lines - The copy button is placed in a separate wrapper to avoid layout interference These changes improve overall accessibility and usability for markdown-rendered content in the Gitea interface.
This reverts commit 95f7abb.
Awesome |
There are people who prefer to always wrap code (me), and ones who don't. I think instead of this, we need a per-user preference that controls whether we wrap code everywhere or not. Singling out these inline blocks to not wrap seems a bad solution to me, we should either wrap everything or nothing. PS: Reason I prefer to always wrap is because I think vertical scrollbars are bad UX. |
To be clear, are you saying we should apply code wrapping consistently—either everywhere or nowhere—based on a user preference? |
Summary
This PR improves the rendering of code blocks in markdown content (e.g., README.md) for better readability and UI stability across screen sizes.
Problem
pre-wrap
), which caused line breaks on narrow or mobile displays.Changes
overflow-x: auto
) for code blockswhite-space: pre
Result
Affected Files
modules/highlight/highlight.go
— changed rendered HTML structuremodules/markup/markdown/markdown.go
— passed format optionsweb_src/css/markup/codecopy.css
— copy button isolationweb_src/css/markup/content.css
— horizontal scroll and white-space handlingweb_src/js/markup/codecopy.ts
— adjusted to handle isolated copy areaNotes
This is a UI/UX refinement that improves the usability of code blocks, especially for developers reading source code on mobile devices or narrow displays.