Reader: Add support for <br> tags in excerpt generator#25392
Conversation
|
| App Name | WordPress | |
| Configuration | Release-Alpha | |
| Build Number | 31992 | |
| Version | PR #25392 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 5775715 | |
| Installation URL | 6didf0dgvpq7g |
|
| App Name | Jetpack | |
| Configuration | Release-Alpha | |
| Build Number | 31992 | |
| Version | PR #25392 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 5775715 | |
| Installation URL | 6kg0midr7ut70 |
|
In order to use |
b390713 to
c7c2052
Compare
218eb41 to
0e16c02
Compare
|
FYI, the unit tests job failed. |
|
Version |
0e16c02 to
736443e
Compare
|
jkmassel
left a comment
There was a problem hiding this comment.
Some edge cases:
- What if there is more than one
<br />tag in a row? It should probably collapse into a single space, right? - What if the tags aren't all lowercase (
<BR />is common from HTML processing tools)
| let content = #"<p class="wp-block-paragraph">Yes,<br>look behind<br>in remembrance and with gratitude.</p><p class="wp-block-paragraph">Then,<br>stay present,<br>or miss memories in the making.</p>"# | ||
|
|
||
| let summary = GutenbergExcerptGenerator.firstParagraph(from: content, maxLength: 150) | ||
| print(summary) |
736443e to
dc660f3
Compare
dc660f3 to
5775715
Compare
|
I covered the additional scenarios. Ideally, it should be refactored in the future to use SwiftSoup, but this should cove the vast majority of scenarios. Turned out, the issue was on the backend anyway. Reader always returns an excerpt, even if the post doesn't provide one. |
|
Version |





Fixes CMM-82: Reader incorrectly renders newlines in excerpts.
Prerequisite: #25400.
This PR is for excerpts generated on the client. In the case of the post from the issue, the lack of whitespaces is backed in on the server. I opened a separate issue for the Loop team. The client-side one should be considered fixed, which you can see in the unit tests.