convert to autocracy
[mdref/mdref] / mdref / Markdown.php
1 <?php
2
3 namespace mdref;
4
5 class Markdown
6 {
7 /**
8 * @var \mdref\Path
9 */
10 protected $path;
11
12 /**
13 * @param \mdref\Path $path
14 */
15 function __construct(Path $path) {
16 $this->path = $path;
17 }
18
19 /**
20 * @return string
21 */
22 function __toString() {
23 try {
24 $r = fopen($this->path->getFullPath(".md"), "r");
25 $md = \MarkdownDocument::createFromStream($r);
26 $md->compile(\MarkdownDocument::AUTOLINK | \MarkdownDocument::TOC);
27 $html = $md->getHtml();
28 fclose($r);
29 } catch (\Exception $e) {
30 $html = ExceptionHandler::html($e);
31 }
32 return $html;
33 }
34 }