From: Mischa POSLAWSKY Date: Sun, 29 Nov 2020 03:07:33 +0000 (+0100) Subject: page: ignore asides in article body (cq title, teaser) X-Git-Tag: v4.5~15 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/a5cbc9ddb6ad65b17f83d2931e3318d94e498a0e?hp=3b7350299c92ff6de3b7980791657de1f5269e48 page: ignore asides in article body (cq title, teaser) Prepare significant page contents in body attribute, regardless of raw. Assume it will be used for summary text, without stripped parts in preface. Fixes preceding aside becoming page metadata on lijtweg.nl/doc/regels. --- diff --git a/article.inc.php b/article.inc.php index 98cd475..6c3ca93 100644 --- a/article.inc.php +++ b/article.inc.php @@ -16,7 +16,7 @@ function showdate($parts) class ArchiveArticle { - public $raw, $preface, $title, $body; + public $raw, $title, $body; # file contents public $meta = []; function __construct($path) @@ -41,8 +41,11 @@ class ArchiveArticle $this->meta = array_combine($meta[1], $meta[2]); # [property => content] } - @list ($this->preface, $this->title, $this->body) = - preg_split('{

(.*?)

\s*}s', $this->raw, 2, PREG_SPLIT_DELIM_CAPTURE); + // find significant contents + $this->body = preg_replace('{}s', '', $this->raw); + if (preg_match('{

(.*?)

\s*(.*)}s', $this->body, $titlematch)) { + list (, $this->title, $this->body) = $titlematch; + } } function __get($col) @@ -129,11 +132,9 @@ class ArchiveArticle } # paragraph contents following the page header if any - $offset = strpos($this->raw, ''); - $offset = $offset ? $offset + 5 : 0; if (preg_match('{ - \G (?> \s+ | |
]*> | \[\[[^]]*\]\] )*

\s* (.*?)

- }sx', $this->raw, $bodyp, 0, $offset)) { + \G (?> \s+ |
]*> | \[\[[^]]*\]\] )*

\s* (.*?)

+ }sx', $this->body, $bodyp, 0)) { return $bodyp[1]; } }