-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix H1 header alignment: change from center to left justification #3830
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
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Changes markdown H1 headers to be left-justified instead of center-justified for better readability in terminal contexts. This addresses user feedback about centered headers being harder to read. Fixes Textualize#2137
- Update CHANGELOG.md with entry for H1 alignment change - Add contributor to CONTRIBUTORS.md - Update test expectations for left-aligned H1 headers - Both test_markdown.py and test_markdown_no_hyperlinks.py updated Related to Textualize#2137
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of changes
Checklist
Description
This PR fixes the alignment of H1 headers in markdown rendering by changing them from center-justified to left-justified. This improves readability, especially in terminal contexts where left-aligned text is generally easier to scan and read.
Changes Made
rich/markdown.py
line 147: Changedtext.justify = "center"
totext.justify = "left"
in theHeading
class's__rich_console__
method[Unreleased]
sectiontest_markdown.py
andtest_markdown_no_hyperlinks.py
to expect left-aligned H1 headersBefore/After Comparison
Before (center-justified):
After (left-justified):
Impact
Testing
python -m rich.markdown
test_markdown.py
andtest_markdown_no_hyperlinks.py
Motivation
This addresses the community feedback about centered headers being less readable in terminal environments. Left-aligned headers are more consistent with typical markdown rendering and improve the overall user experience when reading documentation in the terminal.
Fixes #2137
Additional Context
The original issue highlighted that centered headers can be harder to read, especially when scanning through documentation. This small change brings Rich's markdown rendering more in line with common expectations while maintaining the distinctive panel styling for H1 headers.