X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/aa4a9fd115357f8d8781220e1f1345df774d6893..a09479494778e395ffe2dc75eb858ab3537ef14a:/article.inc.php diff --git a/article.inc.php b/article.inc.php index dd3d5b2..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) @@ -128,19 +131,10 @@ class ArchiveArticle return $override; } + # paragraph contents following the page header if any if (preg_match('{ - (?: \s+ | | ]*> )*

\s* (.*?)

- }sx', $this->raw, $bodyp, PREG_OFFSET_CAPTURE)) { - # fallback paragraph contents following the page header - if ($bodyp[1][1] < 512) { - return $bodyp[1][0]; - } - } - - # starting paragraph for documents without title (assumed simple/partial) - if (strpos($this->raw, ']*> \s* )*

\s* (.*?)

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

\s* (.*?)

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