Skip to content

Post list preview: trim trailing newline in generated excerpt#25349

Merged
jkmassel merged 3 commits intowordpress-mobile:testing-25349from
YuF-9468:fix-12673-trim-preview-newlines
Apr 8, 2026
Merged

Post list preview: trim trailing newline in generated excerpt#25349
jkmassel merged 3 commits intowordpress-mobile:testing-25349from
YuF-9468:fix-12673-trim-preview-newlines

Conversation

@YuF-9468
Copy link
Copy Markdown
Contributor

@YuF-9468 YuF-9468 commented Mar 5, 2026

Description

Fixes #12673.

This updates post preview generation to trim leading/trailing whitespace and newlines after extracting/collapsing preview text. It prevents preview labels from rendering a trailing blank line in the post list when content contains paragraph separators.

Testing instructions

  1. Create or edit a post with multiple paragraph blocks.
  2. Return to the post list.
  3. Verify the preview no longer shows an extra blank trailing line/empty space under the first visible line.

Automated verification

  • Added testThatContentPreviewForDisplayTrimsLeadingAndTrailingNewlines in PostTests.
  • CI should run the updated test suite for this PR.

@jkmassel jkmassel self-assigned this Mar 6, 2026
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

Thanks for taking a look at this! The implementation looks good, I just left a note about improving one test.

I appreciate the contribution, and I'm excited to get it merged!

Comment thread Tests/KeystoneTests/Tests/Models/PostTests.swift Outdated
@YuF-9468
Copy link
Copy Markdown
Contributor Author

YuF-9468 commented Mar 7, 2026

Great call — updated ✅

I changed the test to assert the explicit expected output instead of mirroring implementation details:

  • XCTAssertEqual("Paragraph 1\nParagraph 2", preview)

Commit: 9f5831e

Copy link
Copy Markdown
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@jkmassel jkmassel force-pushed the fix-12673-trim-preview-newlines branch from ead6a8e to 1398920 Compare March 18, 2026 16:51
@sonarqubecloud
Copy link
Copy Markdown

@jkmassel jkmassel changed the base branch from trunk to testing-25349 April 8, 2026 01:44
jkmassel added a commit that referenced this pull request Apr 8, 2026
The test exercises the excerpt path where leading/trailing newlines
survive after collapsing. It will fail until the trimmedForPreview()
change from #25349 lands.
@jkmassel jkmassel force-pushed the testing-25349 branch 2 times, most recently from e5fa570 to 53f0ea7 Compare April 8, 2026 03:13
@jkmassel jkmassel merged commit c6f27d0 into wordpress-mobile:testing-25349 Apr 8, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Apr 8, 2026
* Add failing test and release note for post list preview newline fix

* Post list preview: trim trailing newline in generated excerpt (#25349)

* Fix post preview to trim leading/trailing newlines

* test: assert explicit preview content for newline trim case

---------

Co-authored-by: YuF-9468 <150006551+YuF-9468@users.noreply.github.com>
Co-authored-by: YuF-9468 <2060563720+YuF-9468@users.noreply.github.com>
Co-authored-by: Jeremy Massel <1123407+jkmassel@users.noreply.github.com>

---------

Co-authored-by: YuF-9468 <corgiking@163.com>
Co-authored-by: YuF-9468 <150006551+YuF-9468@users.noreply.github.com>
Co-authored-by: YuF-9468 <2060563720+YuF-9468@users.noreply.github.com>
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.

Gutenberg paragraph shows up as an empty space in Post List

3 participants