- commit
- cd2b38387d4b4bc5196c0e386fae3410d8afbf68
- parent
- fee2db24dca58d605652ea2c0bcd860f8f342461
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2018-10-14 11:33
shift headings
Diffstat
| M | index.php | 16 | ++++++++++++++-- |
1 files changed, 14 insertions, 2 deletions
diff --git a/index.php b/index.php
@@ -26,6 +26,14 @@ function mkdirp($path) 26 26 } 27 27 } 28 28 -1 29 function shiftHeadings($html, $offset) -1 30 { -1 31 return preg_replace_callback('|(</?h)([1-6])([ >])|', function ($match) use ($offset) { -1 32 $target = max(1, min(6, (intval($match[2]) + $offset))); -1 33 return $match[1] . $target . $match[3]; -1 34 }, $html); -1 35 } -1 36 29 37 function validatePath($path) 30 38 { 31 39 if ( @@ -161,11 +169,15 @@ class Pupupu 161 169 } 162 170 163 171 $page = $this->getPage($path); -1 172 $site = $this->getSite(); -1 173 $body = $this->getBody($path); -1 174 $body = shiftHeadings($body, $site['shiftHeadings'] ?? 0); -1 175 164 176 $template = $page['template'] ?? 'base.html'; 165 177 $html = $this->twig->render($template, array( 166 178 'page' => $page,167 -1 'site' => $this->getSite(),168 -1 'body' => $this->getBody($path),-1 179 'site' => $site, -1 180 'body' => $body, 169 181 'date' => time(), 170 182 'pupupu' => $this, 171 183 ));