[2.x] Fix Markdown heading conversion - #2590
Open
emmadesilva wants to merge 1 commit into
Open
Conversation
emmadesilva
marked this pull request as ready for review
August 17, 2026 19:12
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #2590 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 1615 1615
===========================================
Files 169 169
Lines 4074 4074
===========================================
Hits 4074 4074 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Narrows ATX heading matching to avoid consuming content across lines during Markdown-to-text conversion.
Changes:
- Restricts heading whitespace matching to spaces and tabs.
- Adds regression coverage for headings followed by wide tables.
- Updates empty-line preservation expectations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
ConvertsMarkdownToPlainText.php |
Refines ATX heading conversion. |
ConvertsMarkdownToPlainTextTest.php |
Adds regression coverage and updates newline expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| class ConvertsMarkdownToPlainText | ||
| { | ||
| protected const ATX_HEADERS = ['/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/m' => '$1$2$3']; | ||
| protected const ATX_HEADERS = ['/^[ \t]*#{1,6}[ \t]+|[ \t]+#{1,6}[ \t]*$/m' => '']; |
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
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.
What changed
Why
The previous regex used optional newline and unbounded whitespace matching. On long documents, it could consume content beyond the heading markers and corrupt the plain-text result. Restricting whitespace to spaces and tabs keeps matching local to each heading line.
Impact
Markdown-to-plain-text conversion now preserves content following ATX headings, including wide tables, while continuing to remove opening and closing heading markers.
Validation
vendor/bin/phpunit packages/framework/tests/Feature/Actions/ConvertsMarkdownToPlainTextTest.php(29 tests, 31 assertions)git diff --check