X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/dcf14e6ed4093fd464367806e2211bb4bec3c8ba..3b7350299c92ff6de3b7980791657de1f5269e48:/article.inc.php diff --git a/article.inc.php b/article.inc.php index 503c5a1..98cd475 100644 --- a/article.inc.php +++ b/article.inc.php @@ -22,7 +22,7 @@ class ArchiveArticle function __construct($path) { $this->page = preg_replace('{^\.(?:/|$)}', '', $path); - $this->link = preg_replace('{(?:/index)?\.html$}', '', $this->page); + $this->link = preg_replace('{(?:(?:/|^)index)?\.html$}', '', $this->page); $this->raw($this->page); } @@ -128,19 +128,12 @@ class ArchiveArticle return $override; } + # paragraph contents following the page header if any + $offset = strpos($this->raw, ''); + $offset = $offset ? $offset + 5 : 0; if (preg_match('{ - (?: \s+ | | ]*> )*

\s* (.*?)

- }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, ']*> \s* )*

\s* (.*?)

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

\s* (.*?)

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