43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace WMarkDown\Modules;
|
||
|
|
||
|
class Includes extends \WMarkDown\Abstracts\Modules{
|
||
|
|
||
|
private $menu = '';
|
||
|
private $title = '';
|
||
|
|
||
|
public function get_next_position($string){
|
||
|
|
||
|
if(
|
||
|
$this->more &&
|
||
|
$this->from < 0 &&
|
||
|
$this->more = preg_match('/\[\[include ([^\[\]]+)\]\]/', $string, $this->matches, PREG_OFFSET_CAPTURE)
|
||
|
)
|
||
|
$this->from = $this->matches[0][1];
|
||
|
|
||
|
}
|
||
|
|
||
|
public function process($string, $modules, $level){
|
||
|
|
||
|
$formatted = \WMarkDown\Modules::format($this->wmarkdown, $data = $this->wmarkdown->load_file($this->matches[1][0]), [], $modules, $modules->menu_level);
|
||
|
|
||
|
$this->html = (
|
||
|
'<article class="included" data-file="' . $this->matches[1][0] . '">' .
|
||
|
'<a name="' . preg_replace('/[^a-z\d]+/', "-", strtolower(substr($this->matches[1][0], 1))) . '"></a>' .
|
||
|
$formatted["content"] .
|
||
|
'</article>'
|
||
|
);
|
||
|
$this->menu = $formatted["menu"];
|
||
|
$this->title = $formatted["title"];
|
||
|
$this->length = strlen($this->matches[0][0]);
|
||
|
$this->to = $this->from + $this->length;
|
||
|
$this->content = $this->matches[1][0];
|
||
|
|
||
|
}
|
||
|
|
||
|
public function get_menu(){return "" . $this->menu;}
|
||
|
public function get_title(){return "" . $this->title;}
|
||
|
|
||
|
};
|