prismicio-community / php-kit

Community maintained development kit for Prismic and the PHP language
https://prismic.io
Other
109 stars 83 forks source link

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

Closed c0nst4ntin closed 1 year ago

c0nst4ntin commented 1 year ago

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 commented 1 year ago

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

c0nst4ntin commented 1 year ago

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

gsteel commented 1 year ago

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.