Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (#152): remove last new line from rich text blocks #195

Conversation

c0nst4ntin
Copy link
Collaborator

@c0nst4ntin c0nst4ntin commented Nov 21, 2022

This PR aims to solve Issue #152

As mentioned by @cloakedninjas it does not make sense to have a trailing \n on the last block in RichText::asText().

I implemented a solution like the one mentioned in the issue and updated and extended the Tests for the asText function.

@c0nst4ntin c0nst4ntin self-assigned this Nov 21, 2022
@c0nst4ntin
Copy link
Collaborator Author

Do you see any problem with the change or the updated tests @gsteel?

src/Prismic/Dom/RichText.php Outdated Show resolved Hide resolved
tests/Prismic/Dom/RichTextTest.php Show resolved Hide resolved
@c0nst4ntin
Copy link
Collaborator Author

I'd say this is good to be merged and released in v5.2.1
@gsteel Anything else to add?

@gsteel
Copy link
Contributor

gsteel commented Nov 22, 2022

The patch is fine now, but I struggle to see why the trailing \n is a problem in the first place. One of the problems of mixing formatting and output with these value objects is that you'll always have to be tweaking them to satisfy someones preference as to what the output should be. Standalone serializers are much easier to reason about and test and of course much more easily replaced.

@c0nst4ntin c0nst4ntin merged commit 94709c5 into prismicio-community:master Nov 22, 2022
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.

RichText::asText() only include newline when there are multiple blocks?
2 participants