aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-09-06 15:08:12 +0200
committerGitHub <noreply@github.com>2017-09-06 15:08:12 +0200
commit78b36d4dbeedd60c5aa25dbd30a2a2d41a658f94 (patch)
treef1f5da8dd28739cc3fa4dae0fb0bb7dcc2217040
parentb9c26b6330f688ce18af65a05a821f70dd73259c (diff)
parentc66087838886d5921ffd8b5b1e57e0a09528e4b8 (diff)
downloadwallabag-78b36d4dbeedd60c5aa25dbd30a2a2d41a658f94.tar.gz
wallabag-78b36d4dbeedd60c5aa25dbd30a2a2d41a658f94.tar.zst
wallabag-78b36d4dbeedd60c5aa25dbd30a2a2d41a658f94.zip
Merge pull request #3332 from nclsHart/better-txt-export
Better entry txt export using html2text
-rw-r--r--composer.json3
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php4
2 files changed, 5 insertions, 2 deletions
diff --git a/composer.json b/composer.json
index e609af40..fa0a4a39 100644
--- a/composer.json
+++ b/composer.json
@@ -84,7 +84,8 @@
84 "symfony/dom-crawler": "^3.1", 84 "symfony/dom-crawler": "^3.1",
85 "friendsofsymfony/jsrouting-bundle": "^1.6", 85 "friendsofsymfony/jsrouting-bundle": "^1.6",
86 "bdunogier/guzzle-site-authenticator": "^1.0.0@dev", 86 "bdunogier/guzzle-site-authenticator": "^1.0.0@dev",
87 "defuse/php-encryption": "^2.1" 87 "defuse/php-encryption": "^2.1",
88 "html2text/html2text": "^4.1"
88 }, 89 },
89 "require-dev": { 90 "require-dev": {
90 "doctrine/doctrine-fixtures-bundle": "~2.2", 91 "doctrine/doctrine-fixtures-bundle": "~2.2",
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index de259e7f..838b9734 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -2,6 +2,7 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Html2Text\Html2Text;
5use JMS\Serializer\SerializationContext; 6use JMS\Serializer\SerializationContext;
6use JMS\Serializer\SerializerBuilder; 7use JMS\Serializer\SerializerBuilder;
7use PHPePub\Core\EPub; 8use PHPePub\Core\EPub;
@@ -408,7 +409,8 @@ class EntriesExport
408 $bar = str_repeat('=', 100); 409 $bar = str_repeat('=', 100);
409 foreach ($this->entries as $entry) { 410 foreach ($this->entries as $entry) {
410 $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n"; 411 $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
411 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n"; 412 $html = new Html2Text($entry->getContent(), ['do_links' => 'none', 'width' => 100]);
413 $content .= $html->getText();
412 } 414 }
413 415
414 return Response::create( 416 return Response::create(