PlainTextOutput::renderFromHtml() could better handle spaces

Created on 5 July 2023, over 1 year ago
Updated 11 July 2023, over 1 year ago

Problem/Motivation

Many HTML tags add horizontal space or a line break between them when rendered.
PlainTextOutput::renderFromHtml() simply removes HTML tags but does not add spaces, which can lead to a result that is surprising for users.

Steps to reproduce

Call PlainTextOutput::renderFromHtml('<p>Foo</p><p>Bar</p>'); .
The result will be FooBar but it would make more sense to have Foo Bar.

We noticed this when using HTML fields as metatag tokens. Some sentences are joined together without a space between them.

Proposed resolution

The method could add a space between each tag before stripping the tags.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Render 

Last updated 3 days ago

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024