]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
better entry txt export using html2text 3332/head
authorNicolas Hart <contact@nclshart.net>
Sat, 26 Aug 2017 22:04:21 +0000 (00:04 +0200)
committerNicolas Hart <contact@nclshart.net>
Sat, 26 Aug 2017 22:04:21 +0000 (00:04 +0200)
composer.json
src/Wallabag/CoreBundle/Helper/EntriesExport.php

index e609af40a711fd922b7d7af60d6f0975691c5610..fa0a4a39d7309145058f80221557fe4c169dab56 100644 (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",
index de259e7ffc25246acbab2299078b63afd38778cd..838b97342eb171ed8ee671f75b70549720e7ee32 100644 (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(