page: teaser fallback to untitled paragraph
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 27 Jun 2019 22:32:11 +0000 (00:32 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 12 Jul 2019 02:18:16 +0000 (04:18 +0200)
article.inc.php

index e3a3ee824d1949a7dea0292c86c25a3e143c33be..a6a4ef800e9504f7440a5d34b42d774606c2fe96 100644 (file)
@@ -89,14 +89,22 @@ class ArchiveArticle
                        #TODO: strip from body contents
                        return $meta[1];
                }
+
                if (preg_match('{
-                       </h2> (?: \s+ | <p\sclass="nav\b.*?</p> | <div[^>]*> )* <p> (.*?) </p>
+                       </h2> (?: \s+ | <p\sclass="nav\b.*?</p> | <div[^>]*> )* <p> \s* (.*?) </p>
                }sx', $this->raw, $bodyp, PREG_OFFSET_CAPTURE)) {
                        # fallback paragraph contents following the page header
                        if ($bodyp[1][1] < 256) {
                                return $bodyp[1][0];
                        }
                }
+
+               # starting paragraph for documents without title (assumed simple/partial)
+               if (strpos($this->raw, '<h2') === FALSE and preg_match('{
+                       \A <p> \s* (.*?) </p>
+               }sx', $this->raw, $bodyp)) {
+                       return $bodyp[1];
+               }
        }
 
        function img()