diff options
author | Vincent Peugnet <33429034+vincent-peugnet@users.noreply.github.com> | 2020-04-08 17:42:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 17:42:26 +0200 |
commit | f718dc515b3d617e24578dfa875ae786e93f8295 (patch) | |
tree | 1f19a1c27a0eaa4f5908d0d8090f504eaad5cb11 /app/class/Modelrender.php | |
parent | c3e62c500b38104acaecc987621cfc03058729c0 (diff) | |
parent | bfa7d5b2b22b2286faba00884925ff7ecb9392cb (diff) | |
download | wcms-f718dc515b3d617e24578dfa875ae786e93f8295.tar.gz wcms-f718dc515b3d617e24578dfa875ae786e93f8295.zip |
Merge pull request #86 from n-peugnet/fix-summary-rendering
Fix summary rendering
Diffstat (limited to 'app/class/Modelrender.php')
-rw-r--r-- | app/class/Modelrender.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 29a3fa7..091179d 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -437,17 +437,23 @@ class Modelrender extends Modelpage $max = 6; } - $sum = []; $text = preg_replace_callback( - '/<h([' . $min . '-' . $max . '])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[' . $min . '-' . $max . ']>/mU', - function ($matches) use (&$sum) { - $cleanid = idclean($matches[4]); - $sum[$cleanid][$matches[1]] = $matches[4]; - return '<h' . $matches[1] . $matches[2] . ' id="' . $cleanid . '">' . $matches[4] . '</h' . $matches[1] . '>'; + "/<h([$min-$max])((.*)id=\"([^\"]*)\"(.*)|.*)>(.+)<\/h[$min-$max]>/mU", + function ($matches) { + $level = $matches[1]; + $beforeid = $matches[3]; + $id = $matches[4]; + $afterid = $matches[5]; + $content = $matches[6]; + // if no custom id is defined, use idclean of the content as id + if (empty($id)) { + $id = idclean($content); + } + $this->sum[] = new Header($id, intval($level), $content); + return "<h$level $beforeid id=\"$id\" $afterid>$content</h$level>"; }, $text ); - $this->sum[$element] = $sum; return $text; } |