From b4c5790ef82a4cc248d40c8403e795089d06ab08 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 14 Nov 2018 10:04:58 +0100 Subject: article-render --- app/class/modelrender.php | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'app/class/modelrender.php') diff --git a/app/class/modelrender.php b/app/class/modelrender.php index 2d56f6b..64a07fa 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -51,7 +51,9 @@ class Modelrender extends Modelart } else { $text = $art->$element(); } - $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $this->markdown($text) . PHP_EOL . '' . PHP_EOL; + $text = $this->article($text); + $text = $this->markdown($text); + $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $text . PHP_EOL . '' . PHP_EOL; } @@ -158,8 +160,6 @@ class Modelrender extends Modelart $text = $this->wurl($text); $text = $this->wikiurl($text); - $text = $this->tooltip($art->linkfrom('array'), $text); - $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text); $text = str_replace('getlisterid($linkfrom); - foreach ($artlist as $art) { - $descriptions[$art->id()] = $art->description(); - } - - foreach ($linkfrom as $id) { - if (isset($descriptions[$id])) { - $linkfrom = 'href="?id=' . $id . '"'; - $titlelinkfrom = ' title="' . $descriptions[$id] . '" ' . $linkfrom; - $text = str_replace($linkfrom, $titlelinkfrom, $text); + $pattern = '/(\R\R|^\R|^)[=]{3,}([\w-]*)\R\R(.*)(?=\R\R[=]{3,}[\w-]*\R)/sUm'; + $text = preg_replace_callback($pattern, function($matches) { + if(!empty($matches[2])) { + $id = ' id="'.$matches[2].'" '; + } else { + $id = ' '; } - } + return '
' . PHP_EOL . PHP_EOL . $matches[3] . PHP_EOL . PHP_EOL . '
' . PHP_EOL . PHP_EOL; + } , $text); + $text = preg_replace('/\R\R[=]{3,}([\w-]*)\R/', '', $text); return $text; } -- cgit v1.2.3