]> _ Git - psq.git/commitdiff
html2text
authorLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 14:34:01 +0000 (16:34 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 14:34:01 +0000 (16:34 +0200)
.idea/lettre-pharma.iml
.idea/php.xml
app/Models/HasMetaTags.php
app/Models/LaboArticle.php
composer.json
composer.lock

index a117e04d36b5f250b457e55674724569c17454fe..0937141b974ada1c0e143ec288b71add962d9dc9 100644 (file)
@@ -17,6 +17,7 @@
       <excludeFolder url="file://$MODULE_DIR$/vendor/clue/stream-filter" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/coderello/laravel-nova-lang" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/dompdf/dompdf" />
+      <excludeFolder url="file://$MODULE_DIR$/vendor/html2text/html2text" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/http-interop/http-factory-guzzle" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/itsgoingd/clockwork" />
       <excludeFolder url="file://$MODULE_DIR$/vendor/jean85/pretty-package-versions" />
index fdcbde49807dd4f32f68547619adc11537dec384..b0b2f0fef8f4d07a880d626a1e9594c9d1d42911 100644 (file)
       <path value="$PROJECT_DIR$/vendor/maennchen/zipstream-php" />
       <path value="$PROJECT_DIR$/vendor/masterminds/html5" />
       <path value="$PROJECT_DIR$/vendor/judev/php-htmltruncator" />
+      <path value="$PROJECT_DIR$/vendor/html2text/html2text" />
     </include_path>
   </component>
   <component name="PhpInterpreters">
index 0572f59f019be4a4d9a303a06e1a273ff1d0de9d..a0e23319b204eadce631574a2d407b38a4d06b08 100644 (file)
@@ -10,7 +10,7 @@ trait HasMetaTags
     {
         return [
             'title' => $this->getMetaTitle(),
-            'description' => strip_tags($this->getMetaDescription()),
+            'description' => $this->getCleanMetaDescription(),
             'image' => $this->getMetaImage(),
             'url' => $this->getMetaUrl(),
         ];
@@ -22,6 +22,15 @@ trait HasMetaTags
         return $this->title;
     }
 
+    /**
+     * @return string
+     */
+    final protected function getCleanMetaDescription(): string
+    {
+        $str = (new \Html2Text\Html2Text($this->getMetaDescription()))->getText();
+        return preg_replace("/\r\n|\r|\n/", ' ', $str);
+    }
+
     protected function getMetaDescription(): string
     {
         return $this->chapo;
index 10d01764eaaeae2bddfa3d51035876aa56c2f49a..2b9784fec7ff085bbe2d79868ff9cf196a471783 100644 (file)
@@ -56,9 +56,10 @@ class LaboArticle extends Model implements Sortable, PillBoxContract
     ];
 
 
+
     public function getPreviewAttribute(): string
     {
-        $line = strip_tags($this->content);
+        $line = (new \Html2Text\Html2Text($this->content))->getText();
 
         if (preg_match('/^.{1,200}\b/s', $line, $match)) {
             $line = trim($match[0]) . "…";
index 23b53f1814d642ed2c7031053ed6f34ac24f8a03..b29e909805cec61e4a772c867c8d5a8ce367db68 100644 (file)
@@ -20,6 +20,7 @@
         "fideloper/proxy": "^4.2",
         "fruitcake/laravel-cors": "^1.0",
         "guzzlehttp/guzzle": "^6.3",
+        "html2text/html2text": "^4.3",
         "itsgoingd/clockwork": "^4.1",
         "judev/php-htmltruncator": "^1.2",
         "kriswallsmith/buzz": "^1.1",
index 238f80c09b607b8fadc04cbd9f13d4ea9136318c..e3b5740d82566cd86f0788002dfe6ef2d90a4c9a 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "70d746984d1fe596d469cdd574622e82",
+    "content-hash": "3a16aca0cab60a6ab491bc8a8516253e",
     "packages": [
         {
             "name": "algolia/algoliasearch-client-php",
             ],
             "time": "2019-07-01T23:21:34+00:00"
         },
+        {
+            "name": "html2text/html2text",
+            "version": "4.3.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/mtibben/html2text.git",
+                "reference": "61ad68e934066a6f8df29a3d23a6460536d0855c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/mtibben/html2text/zipball/61ad68e934066a6f8df29a3d23a6460536d0855c",
+                "reference": "61ad68e934066a6f8df29a3d23a6460536d0855c",
+                "shasum": ""
+            },
+            "require-dev": {
+                "phpunit/phpunit": "~4"
+            },
+            "suggest": {
+                "ext-mbstring": "For best performance",
+                "symfony/polyfill-mbstring": "If you can't install ext-mbstring"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Html2Text\\": [
+                        "src/",
+                        "test/"
+                    ]
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "GPL-2.0-or-later"
+            ],
+            "description": "Converts HTML to formatted plain text",
+            "time": "2020-04-16T23:44:31+00:00"
+        },
         {
             "name": "http-interop/http-factory-guzzle",
             "version": "1.0.0",