Merge pull request #3332 from nclsHart/better-txt-export

Better entry txt export using html2text
This commit is contained in:
Nicolas Lœuillet 2017-09-06 15:08:12 +02:00 committed by GitHub
commit 78b36d4dbe
2 changed files with 5 additions and 2 deletions

View file

@ -84,7 +84,8 @@
"symfony/dom-crawler": "^3.1",
"friendsofsymfony/jsrouting-bundle": "^1.6",
"bdunogier/guzzle-site-authenticator": "^1.0.0@dev",
"defuse/php-encryption": "^2.1"
"defuse/php-encryption": "^2.1",
"html2text/html2text": "^4.1"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2",

View file

@ -2,6 +2,7 @@
namespace Wallabag\CoreBundle\Helper;
use Html2Text\Html2Text;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use PHPePub\Core\EPub;
@ -408,7 +409,8 @@ class EntriesExport
$bar = str_repeat('=', 100);
foreach ($this->entries as $entry) {
$content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
$content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n";
$html = new Html2Text($entry->getContent(), ['do_links' => 'none', 'width' => 100]);
$content .= $html->getText();
}
return Response::create(