Skip to content

[2.x] Fix Markdown heading conversion - #2590

Open
emmadesilva wants to merge 1 commit into
2.xfrom
agent/fix-markdown-heading-conversion
Open

[2.x] Fix Markdown heading conversion#2590
emmadesilva wants to merge 1 commit into
2.xfrom
agent/fix-markdown-heading-conversion

Conversation

@emmadesilva

Copy link
Copy Markdown
Member

What changed

  • Narrow the ATX heading regex so it removes Markdown heading markers without consuming unrelated content across lines.
  • Add regression coverage for long Markdown documents containing headings followed by wide tables.
  • Update the empty-line expectation to reflect preservation of the remaining line breaks.

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

@emmadesilvaemmadesilva changed the title Fix Markdown heading conversion[2.x] Fix Markdown heading conversionAug 17, 2026
@emmadesilva
emmadesilva marked this pull request as ready for review August 17, 2026 19:12
@emmadesilva
emmadesilva requested a balanced review from CopilotAugust 17, 2026 19:12
@codecov

codecovBot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (44b4b56) to head (b69b3af).
⚠️ Report is 3 commits behind head on 2.x.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

FileDescription
ConvertsMarkdownToPlainText.phpRefines ATX heading conversion.
ConvertsMarkdownToPlainTextTest.phpAdds 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' => ''];
Sign up for freeto 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.

2 participants

@emmadesilva