Skip to content

Fix hard wrapping of long headings - #448

Open
ryanchou1994 wants to merge 1 commit into
Alir3z4:masterfrom
ryanchou1994:fix/preserve-heading-lines
Open

ryanchou1994 wants to merge 1 commit into
Alir3z4:masterfrom
ryanchou1994:fix/preserve-heading-lines

Conversation

@ryanchou1994

Copy link
Copy Markdown

Long headings are passed through the paragraph wrapper, so everything after the first wrapped line becomes ordinary text in the generated Markdown. For example, <h1>A long heading with several words</h1> should keep its whole title after #, even when body_width is small.

Skip wrapping ATX heading lines, including headings inside blockquotes. The matcher uses ASCII spaces and tabs so ordinary text containing non-breaking spaces keeps its existing wrapping behavior. Paragraphs, hashtags, and lines with seven # characters still wrap normally.

The regression fixture exercises the class, convenience function, and actual CLI, including emphasis and inline links in headings. Additional tests cover h1–h6, quoted headings, wrapping disabled, and three Unicode-whitespace controls. This change addresses wrapping added by body_width; it does not change explicit line breaks already present inside a heading or implement a full Markdown parser.

Validation: 241 tests each on macOS (Python 3.13.13) and Linux (Python 3.13.15), plus Black, Flake8, isort, strict mypy 1.19.1 (Python 3.9 target), wheel/sdist builds and Twine checks. The installed Linux wheel passed 12 API/CLI checks outside the checkout. The existing generator-parametrization warnings from pytest remain. One existing expression in the touched config file was reformatted by Black 26.5.1.

Fixes #424

Copilot AI lite review requested due to automatic review settings September 9, 2026 05:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

Hard wraps break headers

2 participants