Problem/Motivation

html_to_text is currently represented as .inc file.

Proposed resolution

Convert it to a class similarly to what core did.

Remaining tasks

User interface changes

API changes

Comments

mbovan’s picture

Version: 8.x-2.x-dev » 8.x-4.x-dev
Berdir’s picture

There'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.

Matroskeen’s picture

Actually, 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

Berdir’s picture

The 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.