예제 #1
0
파일: Wiki.php 프로젝트: nittro/nittro-web
 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;
 }
예제 #2
0
 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;
 }