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.
- public $raw, $preface, $title, $body;
+ public $raw, $title, $body; # file contents
public $meta = [];
function __construct($path)
public $meta = [];
function __construct($path)
$this->meta = array_combine($meta[1], $meta[2]); # [property => content]
}
$this->meta = array_combine($meta[1], $meta[2]); # [property => content]
}
- @list ($this->preface, $this->title, $this->body) =
- preg_split('{<h2>(.*?)</h2>\s*}s', $this->raw, 2, PREG_SPLIT_DELIM_CAPTURE);
+ // find significant contents
+ $this->body = preg_replace('{<aside\b.*?</aside>}s', '', $this->raw);
+ if (preg_match('{<h2>(.*?)</h2>\s*(.*)}s', $this->body, $titlematch)) {
+ list (, $this->title, $this->body) = $titlematch;
+ }
}
# paragraph contents following the page header if any
}
# paragraph contents following the page header if any
- $offset = strpos($this->raw, '</h2>');
- $offset = $offset ? $offset + 5 : 0;
- \G (?> \s+ | <aside\b.*?</aside> | <div [^>]*> | \[\[[^]]*\]\] )* <p> \s* (.*?) </p>
- }sx', $this->raw, $bodyp, 0, $offset)) {
+ \G (?> \s+ | <div [^>]*> | \[\[[^]]*\]\] )* <p> \s* (.*?) </p>
+ }sx', $this->body, $bodyp, 0)) {