Skip to content

Introduce an html to text facility #4077

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

Closed
wants to merge 8 commits into from
Closed

Introduce an html to text facility #4077

wants to merge 8 commits into from

Conversation

mondrake
Copy link
Contributor

@mondrake mondrake commented Jun 4, 2019

Drupal outputs HTML text in some cases, which is not fit to present in a CLI environment (example, in site:status and site:install). In Drupal console there are places where strip_tags and html_entity_decode are used to clean up a bit, but any formatting and links are lost.

I suggest to add a dependency to html2text/html2text and build a facility service to help converting HTML strings to a prettier text.

Example 1: site:install error message

before

2019_06_03_19_06_40_raspberrypi_Dataplicity

after

2019_06_04_09_03_21_raspberrypi_Dataplicity

Example 2: site:status (verbose)

before

2019_06_04_10_48_47_raspberrypi_Dataplicity

after

2019_06_04_10_49_51_raspberrypi_Dataplicity

@hjuarez20
Copy link
Contributor

hjuarez20 commented Jun 5, 2019

Hi @mondrake thanks for the PR.
I am trying to review this PR but I have trouble with html2text/html2text

When I execute drupal site:install I have the following error

Error: Class 'Html2Text\Html2Text' not found in /Users/path-to-console/drupal-console/src/Utils/HtmlConverter.php 
on line 27 #0 /Users/path-to-console/drupal-console/src/Command/Site/InstallCommand.php(587): Drupal\Console\Utils\HtmlConverter::html2text('Resolve all iss...', Array)

I have the library installed.

drupal-console git:(4077-introduce-html) ✗ composer show | grep html2text/html2text
html2text/html2text                   4.2.1    Converts HTML to formatted plain text

Do you know what it can be?

@mondrake
Copy link
Contributor Author

mondrake commented Jun 6, 2019

The class is missing from the autoloader map, maybe you git cloned it instead of indtalling via composer?

Try

composer require html2text/html2text

@hjuarez20
Copy link
Contributor

I can't solve the issue, I installed the dependency on my drupal and now it work, but it is no the right way.

@enzolutions
Copy link
Contributor

@mondrake could you help us with this, to see if we could include in next week release 1.9.1? Thanks in advance

@mondrake
Copy link
Contributor Author

@enzolutions @harold20 sure! What is exactly the problem here? Sorry but I can not understand.

@mondrake
Copy link
Contributor Author

@enzolutions @harold20 I have rebased and pushed my branch, now all checks on TravisCI are passing. What else you need?

@mondrake
Copy link
Contributor Author

@enzolutions @harold20 now, after #4136 and #4137, you can see in the TravisCI logs the effect of this PR on the site:status command

@mondrake mondrake closed this Oct 25, 2020
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.

3 participants