Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
html_to_text
is currently represented as .inc
file.
Proposed resolution
Convert it to a class similarly to what core did.
Comments
Comment #1
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedComment #2
BerdirThere's also the option of bringing the fixes back into core, which was always the idea. See #299138: Improve \Drupal\Core\Utility\Mail::htmlToText(). But it's going to require a very painful reroll and has been postponed to 8.1.x, apparently.
Comment #3
MatroskeenActually, I'm not sure what is the purpose to use this converter in Mail System module. (I thought that plugins should take care of this)
But maybe there is a reason to use some external library? Just an example - https://github.com/mtibben/html2text
Comment #4
BerdirThe point of this was to be a better version of what is in core because the issue to try and improve that has been stale for years. And it was made a static class, not a service, so we can't switch it out.
This has nothing to do with plugins, it's just an API that plugins can use if they want.
And yes, I actually opened a core issue about replacing our custom implementation with that, the problem is that it is completely different from the current implementation, so it's not really possible to just switch it out. See #2830384: Deprecate MailFormatHelper in favor of html2text/html2text library. But swiftmailer already uses it, so the logic thing would be to simply move forward with that and offer it as a new API.