automatically configure git paths (dir + public clone url)
[phorkie.git] / src / phorkie / Renderer / Markdown.php
1 <?php
2 namespace phorkie;
3
4 class Renderer_Markdown
5 {
6     /**
7      * Converts the code to HTML
8      *
9      * @param File        $file File to render
10      * @param Tool_Result $res  Tool result to integrate
11      *
12      * @return string HTML
13      */
14     public function toHtml(File $file, Tool_Result $res = null)
15     {
16         if (class_exists('\\Michelf\\Markdown', true)) {
17             //composer-installed version 1.4+
18             $markdown = \Michelf\Markdown::defaultTransform(
19                 $file->getContent()
20             );
21         } else {
22             //PEAR-installed version 1.0.2 has a different API
23             require_once 'markdown.php';
24             $markdown = \markdown($file->getContent());
25         }
26
27         return '<div class="markdown">'
28             . $markdown
29             . '</div>';
30     }
31 }
32
33 ?>