public function renderPage($path) { if (preg_match('#(^|/)\\.\\.?(/|$)#', $path)) { throw new \Exception('Invalid path'); } $path = $this->wikiPath . '/' . $path . '.md'; if (!file_exists($path)) { throw new \Exception('File not found'); } $html = $this->parsedown->parse(file_get_contents($path)); return $html; }
protected function blockHeader($Line) { $header = parent::blockHeader($Line); if (preg_match('/^###(?!#)/', $Line['text'])) { $hash = trim($Line['text'], '# '); $hash = preg_replace('/[^a-z\\s]+/', '', strtolower($hash)); $hash = trim(preg_replace('/\\s+/', '-', $hash), '-'); $header['element']['attributes']['id'] = $hash; } return $header; }