X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/ed38c6a76767a893a319f7bfd9229b0dad6b08db..621fc2f9638a1a92aa8535310e7852de5542f11e:/article.inc.php diff --git a/article.inc.php b/article.inc.php index d8ddf77..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); } @@ -110,7 +110,7 @@ class ArchiveArticle function story() { if ( preg_match('{ - \n (?: < (?: p | figure [^>]* ) >\s* )+ (]*>) | \n + (?: < (?: p | figure [^>]* ) >\s* )+ (]*>) | \n }x', $this->body, $img, PREG_OFFSET_CAPTURE) ) { # strip part after matching divider (image) if (isset($img[1])) { @@ -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]; } }