From bfa7d5b2b22b2286faba00884925ff7ecb9392cb Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Wed, 8 Apr 2020 17:22:41 +0200 Subject: fix: SUMMARY does not work with custom header Ids Fixes #80 --- app/class/Modelrender.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'app/class/Modelrender.php') diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 1721e4e..091179d 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -438,11 +438,19 @@ class Modelrender extends Modelpage } $text = preg_replace_callback( - '/(.+)<\/h[' . $min . '-' . $max . ']>/mU', + "/(.+)<\/h[$min-$max]>/mU", function ($matches) { - $cleanid = idclean($matches[4]); - $this->sum[] = new Header($cleanid, intval($matches[1]), $matches[4]); - return '' . $matches[4] . ''; + $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 "$content"; }, $text ); -- cgit v1.2.3