Fix H1 header alignment: change from center to left justification #3830
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.